babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. /**
  431. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  432. */
  433. export class WebRequest implements IWebRequest {
  434. private _xhr;
  435. /**
  436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  437. * i.e. when loading files, where the server/service expects an Authorization header
  438. */
  439. static CustomRequestHeaders: {
  440. [key: string]: string;
  441. };
  442. /**
  443. * Add callback functions in this array to update all the requests before they get sent to the network
  444. */
  445. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  446. private _injectCustomRequestHeaders;
  447. /**
  448. * Gets or sets a function to be called when loading progress changes
  449. */
  450. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  451. /**
  452. * Returns client's state
  453. */
  454. readonly readyState: number;
  455. /**
  456. * Returns client's status
  457. */
  458. readonly status: number;
  459. /**
  460. * Returns client's status as a text
  461. */
  462. readonly statusText: string;
  463. /**
  464. * Returns client's response
  465. */
  466. readonly response: any;
  467. /**
  468. * Returns client's response url
  469. */
  470. readonly responseURL: string;
  471. /**
  472. * Returns client's response as text
  473. */
  474. readonly responseText: string;
  475. /**
  476. * Gets or sets the expected response type
  477. */
  478. responseType: XMLHttpRequestResponseType;
  479. /** @hidden */
  480. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  481. /** @hidden */
  482. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  483. /**
  484. * Cancels any network activity
  485. */
  486. abort(): void;
  487. /**
  488. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  489. * @param body defines an optional request body
  490. */
  491. send(body?: Document | BodyInit | null): void;
  492. /**
  493. * Sets the request method, request URL
  494. * @param method defines the method to use (GET, POST, etc..)
  495. * @param url defines the url to connect with
  496. */
  497. open(method: string, url: string): void;
  498. }
  499. }
  500. declare module "babylonjs/Misc/fileRequest" {
  501. import { Observable } from "babylonjs/Misc/observable";
  502. /**
  503. * File request interface
  504. */
  505. export interface IFileRequest {
  506. /**
  507. * Raised when the request is complete (success or error).
  508. */
  509. onCompleteObservable: Observable<IFileRequest>;
  510. /**
  511. * Aborts the request for a file.
  512. */
  513. abort: () => void;
  514. }
  515. }
  516. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  517. /**
  518. * Define options used to create a render target texture
  519. */
  520. export class RenderTargetCreationOptions {
  521. /**
  522. * Specifies is mipmaps must be generated
  523. */
  524. generateMipMaps?: boolean;
  525. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  526. generateDepthBuffer?: boolean;
  527. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  528. generateStencilBuffer?: boolean;
  529. /** Defines texture type (int by default) */
  530. type?: number;
  531. /** Defines sampling mode (trilinear by default) */
  532. samplingMode?: number;
  533. /** Defines format (RGBA by default) */
  534. format?: number;
  535. }
  536. }
  537. declare module "babylonjs/Instrumentation/timeToken" {
  538. import { Nullable } from "babylonjs/types";
  539. /**
  540. * @hidden
  541. **/
  542. export class _TimeToken {
  543. _startTimeQuery: Nullable<WebGLQuery>;
  544. _endTimeQuery: Nullable<WebGLQuery>;
  545. _timeElapsedQuery: Nullable<WebGLQuery>;
  546. _timeElapsedQueryEnded: boolean;
  547. }
  548. }
  549. declare module "babylonjs/Engines/constants" {
  550. /** Defines the cross module used constants to avoid circular dependncies */
  551. export class Constants {
  552. /** Defines that alpha blending is disabled */
  553. static readonly ALPHA_DISABLE: number;
  554. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  555. static readonly ALPHA_ADD: number;
  556. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  557. static readonly ALPHA_COMBINE: number;
  558. /** Defines that alpha blending to DEST - SRC * DEST */
  559. static readonly ALPHA_SUBTRACT: number;
  560. /** Defines that alpha blending to SRC * DEST */
  561. static readonly ALPHA_MULTIPLY: number;
  562. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  563. static readonly ALPHA_MAXIMIZED: number;
  564. /** Defines that alpha blending to SRC + DEST */
  565. static readonly ALPHA_ONEONE: number;
  566. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  567. static readonly ALPHA_PREMULTIPLIED: number;
  568. /**
  569. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  570. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  571. */
  572. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  573. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  574. static readonly ALPHA_INTERPOLATE: number;
  575. /**
  576. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  577. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  578. */
  579. static readonly ALPHA_SCREENMODE: number;
  580. /**
  581. * Defines that alpha blending to SRC + DST
  582. * Alpha will be set to SRC ALPHA + DST ALPHA
  583. */
  584. static readonly ALPHA_ONEONE_ONEONE: number;
  585. /**
  586. * Defines that alpha blending to SRC * DST ALPHA + DST
  587. * Alpha will be set to 0
  588. */
  589. static readonly ALPHA_ALPHATOCOLOR: number;
  590. /**
  591. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  592. */
  593. static readonly ALPHA_REVERSEONEMINUS: number;
  594. /**
  595. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  596. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  597. */
  598. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  599. /**
  600. * Defines that alpha blending to SRC + DST
  601. * Alpha will be set to SRC ALPHA
  602. */
  603. static readonly ALPHA_ONEONE_ONEZERO: number;
  604. /** Defines that alpha blending equation a SUM */
  605. static readonly ALPHA_EQUATION_ADD: number;
  606. /** Defines that alpha blending equation a SUBSTRACTION */
  607. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  608. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  609. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  610. /** Defines that alpha blending equation a MAX operation */
  611. static readonly ALPHA_EQUATION_MAX: number;
  612. /** Defines that alpha blending equation a MIN operation */
  613. static readonly ALPHA_EQUATION_MIN: number;
  614. /**
  615. * Defines that alpha blending equation a DARKEN operation:
  616. * It takes the min of the src and sums the alpha channels.
  617. */
  618. static readonly ALPHA_EQUATION_DARKEN: number;
  619. /** Defines that the ressource is not delayed*/
  620. static readonly DELAYLOADSTATE_NONE: number;
  621. /** Defines that the ressource was successfully delay loaded */
  622. static readonly DELAYLOADSTATE_LOADED: number;
  623. /** Defines that the ressource is currently delay loading */
  624. static readonly DELAYLOADSTATE_LOADING: number;
  625. /** Defines that the ressource is delayed and has not started loading */
  626. static readonly DELAYLOADSTATE_NOTLOADED: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  628. static readonly NEVER: number;
  629. /** 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 */
  630. static readonly ALWAYS: number;
  631. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  632. static readonly LESS: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  634. static readonly EQUAL: number;
  635. /** 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 */
  636. static readonly LEQUAL: number;
  637. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  638. static readonly GREATER: number;
  639. /** 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 */
  640. static readonly GEQUAL: number;
  641. /** 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 */
  642. static readonly NOTEQUAL: number;
  643. /** Passed to stencilOperation to specify that stencil value must be kept */
  644. static readonly KEEP: number;
  645. /** Passed to stencilOperation to specify that stencil value must be replaced */
  646. static readonly REPLACE: number;
  647. /** Passed to stencilOperation to specify that stencil value must be incremented */
  648. static readonly INCR: number;
  649. /** Passed to stencilOperation to specify that stencil value must be decremented */
  650. static readonly DECR: number;
  651. /** Passed to stencilOperation to specify that stencil value must be inverted */
  652. static readonly INVERT: number;
  653. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  654. static readonly INCR_WRAP: number;
  655. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  656. static readonly DECR_WRAP: number;
  657. /** Texture is not repeating outside of 0..1 UVs */
  658. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  659. /** Texture is repeating outside of 0..1 UVs */
  660. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  661. /** Texture is repeating and mirrored */
  662. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  663. /** ALPHA */
  664. static readonly TEXTUREFORMAT_ALPHA: number;
  665. /** LUMINANCE */
  666. static readonly TEXTUREFORMAT_LUMINANCE: number;
  667. /** LUMINANCE_ALPHA */
  668. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  669. /** RGB */
  670. static readonly TEXTUREFORMAT_RGB: number;
  671. /** RGBA */
  672. static readonly TEXTUREFORMAT_RGBA: number;
  673. /** RED */
  674. static readonly TEXTUREFORMAT_RED: number;
  675. /** RED (2nd reference) */
  676. static readonly TEXTUREFORMAT_R: number;
  677. /** RG */
  678. static readonly TEXTUREFORMAT_RG: number;
  679. /** RED_INTEGER */
  680. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  681. /** RED_INTEGER (2nd reference) */
  682. static readonly TEXTUREFORMAT_R_INTEGER: number;
  683. /** RG_INTEGER */
  684. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  685. /** RGB_INTEGER */
  686. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  687. /** RGBA_INTEGER */
  688. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  689. /** UNSIGNED_BYTE */
  690. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  691. /** UNSIGNED_BYTE (2nd reference) */
  692. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  693. /** FLOAT */
  694. static readonly TEXTURETYPE_FLOAT: number;
  695. /** HALF_FLOAT */
  696. static readonly TEXTURETYPE_HALF_FLOAT: number;
  697. /** BYTE */
  698. static readonly TEXTURETYPE_BYTE: number;
  699. /** SHORT */
  700. static readonly TEXTURETYPE_SHORT: number;
  701. /** UNSIGNED_SHORT */
  702. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  703. /** INT */
  704. static readonly TEXTURETYPE_INT: number;
  705. /** UNSIGNED_INT */
  706. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  707. /** UNSIGNED_SHORT_4_4_4_4 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  709. /** UNSIGNED_SHORT_5_5_5_1 */
  710. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  711. /** UNSIGNED_SHORT_5_6_5 */
  712. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  713. /** UNSIGNED_INT_2_10_10_10_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  715. /** UNSIGNED_INT_24_8 */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  717. /** UNSIGNED_INT_10F_11F_11F_REV */
  718. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  719. /** UNSIGNED_INT_5_9_9_9_REV */
  720. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  721. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  722. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  723. /** nearest is mag = nearest and min = nearest and mip = linear */
  724. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  726. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  727. /** Trilinear is mag = linear and min = linear and mip = linear */
  728. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  729. /** nearest is mag = nearest and min = nearest and mip = linear */
  730. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  732. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  733. /** Trilinear is mag = linear and min = linear and mip = linear */
  734. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  735. /** mag = nearest and min = nearest and mip = nearest */
  736. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  737. /** mag = nearest and min = linear and mip = nearest */
  738. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  739. /** mag = nearest and min = linear and mip = linear */
  740. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  741. /** mag = nearest and min = linear and mip = none */
  742. static readonly TEXTURE_NEAREST_LINEAR: number;
  743. /** mag = nearest and min = nearest and mip = none */
  744. static readonly TEXTURE_NEAREST_NEAREST: number;
  745. /** mag = linear and min = nearest and mip = nearest */
  746. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  747. /** mag = linear and min = nearest and mip = linear */
  748. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  749. /** mag = linear and min = linear and mip = none */
  750. static readonly TEXTURE_LINEAR_LINEAR: number;
  751. /** mag = linear and min = nearest and mip = none */
  752. static readonly TEXTURE_LINEAR_NEAREST: number;
  753. /** Explicit coordinates mode */
  754. static readonly TEXTURE_EXPLICIT_MODE: number;
  755. /** Spherical coordinates mode */
  756. static readonly TEXTURE_SPHERICAL_MODE: number;
  757. /** Planar coordinates mode */
  758. static readonly TEXTURE_PLANAR_MODE: number;
  759. /** Cubic coordinates mode */
  760. static readonly TEXTURE_CUBIC_MODE: number;
  761. /** Projection coordinates mode */
  762. static readonly TEXTURE_PROJECTION_MODE: number;
  763. /** Skybox coordinates mode */
  764. static readonly TEXTURE_SKYBOX_MODE: number;
  765. /** Inverse Cubic coordinates mode */
  766. static readonly TEXTURE_INVCUBIC_MODE: number;
  767. /** Equirectangular coordinates mode */
  768. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  769. /** Equirectangular Fixed coordinates mode */
  770. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  771. /** Equirectangular Fixed Mirrored coordinates mode */
  772. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  773. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  774. static readonly SCALEMODE_FLOOR: number;
  775. /** Defines that texture rescaling will look for the nearest power of 2 size */
  776. static readonly SCALEMODE_NEAREST: number;
  777. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  778. static readonly SCALEMODE_CEILING: number;
  779. /**
  780. * The dirty texture flag value
  781. */
  782. static readonly MATERIAL_TextureDirtyFlag: number;
  783. /**
  784. * The dirty light flag value
  785. */
  786. static readonly MATERIAL_LightDirtyFlag: number;
  787. /**
  788. * The dirty fresnel flag value
  789. */
  790. static readonly MATERIAL_FresnelDirtyFlag: number;
  791. /**
  792. * The dirty attribute flag value
  793. */
  794. static readonly MATERIAL_AttributesDirtyFlag: number;
  795. /**
  796. * The dirty misc flag value
  797. */
  798. static readonly MATERIAL_MiscDirtyFlag: number;
  799. /**
  800. * The all dirty flag value
  801. */
  802. static readonly MATERIAL_AllDirtyFlag: number;
  803. /**
  804. * Returns the triangle fill mode
  805. */
  806. static readonly MATERIAL_TriangleFillMode: number;
  807. /**
  808. * Returns the wireframe mode
  809. */
  810. static readonly MATERIAL_WireFrameFillMode: number;
  811. /**
  812. * Returns the point fill mode
  813. */
  814. static readonly MATERIAL_PointFillMode: number;
  815. /**
  816. * Returns the point list draw mode
  817. */
  818. static readonly MATERIAL_PointListDrawMode: number;
  819. /**
  820. * Returns the line list draw mode
  821. */
  822. static readonly MATERIAL_LineListDrawMode: number;
  823. /**
  824. * Returns the line loop draw mode
  825. */
  826. static readonly MATERIAL_LineLoopDrawMode: number;
  827. /**
  828. * Returns the line strip draw mode
  829. */
  830. static readonly MATERIAL_LineStripDrawMode: number;
  831. /**
  832. * Returns the triangle strip draw mode
  833. */
  834. static readonly MATERIAL_TriangleStripDrawMode: number;
  835. /**
  836. * Returns the triangle fan draw mode
  837. */
  838. static readonly MATERIAL_TriangleFanDrawMode: number;
  839. /**
  840. * Stores the clock-wise side orientation
  841. */
  842. static readonly MATERIAL_ClockWiseSideOrientation: number;
  843. /**
  844. * Stores the counter clock-wise side orientation
  845. */
  846. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  847. /**
  848. * Nothing
  849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  850. */
  851. static readonly ACTION_NothingTrigger: number;
  852. /**
  853. * On pick
  854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  855. */
  856. static readonly ACTION_OnPickTrigger: number;
  857. /**
  858. * On left pick
  859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  860. */
  861. static readonly ACTION_OnLeftPickTrigger: number;
  862. /**
  863. * On right pick
  864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  865. */
  866. static readonly ACTION_OnRightPickTrigger: number;
  867. /**
  868. * On center pick
  869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  870. */
  871. static readonly ACTION_OnCenterPickTrigger: number;
  872. /**
  873. * On pick down
  874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  875. */
  876. static readonly ACTION_OnPickDownTrigger: number;
  877. /**
  878. * On double pick
  879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  880. */
  881. static readonly ACTION_OnDoublePickTrigger: number;
  882. /**
  883. * On pick up
  884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  885. */
  886. static readonly ACTION_OnPickUpTrigger: number;
  887. /**
  888. * On pick out.
  889. * This trigger will only be raised if you also declared a OnPickDown
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_OnPickOutTrigger: number;
  893. /**
  894. * On long press
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnLongPressTrigger: number;
  898. /**
  899. * On pointer over
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPointerOverTrigger: number;
  903. /**
  904. * On pointer out
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPointerOutTrigger: number;
  908. /**
  909. * On every frame
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnEveryFrameTrigger: number;
  913. /**
  914. * On intersection enter
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnIntersectionEnterTrigger: number;
  918. /**
  919. * On intersection exit
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnIntersectionExitTrigger: number;
  923. /**
  924. * On key down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnKeyDownTrigger: number;
  928. /**
  929. * On key up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnKeyUpTrigger: number;
  933. /**
  934. * Billboard mode will only apply to Y axis
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  937. /**
  938. * Billboard mode will apply to all axes
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  941. /**
  942. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  943. */
  944. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  945. /**
  946. * Gets or sets base Assets URL
  947. */
  948. static PARTICLES_BaseAssetsUrl: string;
  949. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  950. * Test order :
  951. * Is the bounding sphere outside the frustum ?
  952. * If not, are the bounding box vertices outside the frustum ?
  953. * It not, then the cullable object is in the frustum.
  954. */
  955. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  956. /** Culling strategy : Bounding Sphere Only.
  957. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  958. * It's also less accurate than the standard because some not visible objects can still be selected.
  959. * Test : is the bounding sphere outside the frustum ?
  960. * If not, then the cullable object is in the frustum.
  961. */
  962. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  963. /** Culling strategy : Optimistic Inclusion.
  964. * This in an inclusion test first, then the standard exclusion test.
  965. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  966. * 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.
  967. * Anyway, it's as accurate as the standard strategy.
  968. * Test :
  969. * Is the cullable object bounding sphere center in the frustum ?
  970. * If not, apply the default culling strategy.
  971. */
  972. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  973. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  974. * This in an inclusion test first, then the bounding sphere only exclusion test.
  975. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  976. * 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.
  977. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  978. * Test :
  979. * Is the cullable object bounding sphere center in the frustum ?
  980. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  981. */
  982. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  983. /**
  984. * No logging while loading
  985. */
  986. static readonly SCENELOADER_NO_LOGGING: number;
  987. /**
  988. * Minimal logging while loading
  989. */
  990. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  991. /**
  992. * Summary logging while loading
  993. */
  994. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  995. /**
  996. * Detailled logging while loading
  997. */
  998. static readonly SCENELOADER_DETAILED_LOGGING: number;
  999. }
  1000. }
  1001. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1002. import { Nullable } from "babylonjs/types";
  1003. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1004. /**
  1005. * This represents the required contract to create a new type of texture loader.
  1006. */
  1007. export interface IInternalTextureLoader {
  1008. /**
  1009. * Defines wether the loader supports cascade loading the different faces.
  1010. */
  1011. supportCascades: boolean;
  1012. /**
  1013. * This returns if the loader support the current file information.
  1014. * @param extension defines the file extension of the file being loaded
  1015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1016. * @param fallback defines the fallback internal texture if any
  1017. * @param isBase64 defines whether the texture is encoded as a base64
  1018. * @param isBuffer defines whether the texture data are stored as a buffer
  1019. * @returns true if the loader can load the specified file
  1020. */
  1021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1022. /**
  1023. * Transform the url before loading if required.
  1024. * @param rootUrl the url of the texture
  1025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1026. * @returns the transformed texture
  1027. */
  1028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1029. /**
  1030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1031. * @param rootUrl the url of the texture
  1032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1033. * @returns the fallback texture
  1034. */
  1035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1036. /**
  1037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1038. * @param data contains the texture data
  1039. * @param texture defines the BabylonJS internal texture
  1040. * @param createPolynomials will be true if polynomials have been requested
  1041. * @param onLoad defines the callback to trigger once the texture is ready
  1042. * @param onError defines the callback to trigger in case of error
  1043. */
  1044. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1045. /**
  1046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param callback defines the method to call once ready to upload
  1050. */
  1051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1052. }
  1053. }
  1054. declare module "babylonjs/Engines/IPipelineContext" {
  1055. /**
  1056. * Class used to store and describe the pipeline context associated with an effect
  1057. */
  1058. export interface IPipelineContext {
  1059. /**
  1060. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1061. */
  1062. isAsync: boolean;
  1063. /**
  1064. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1065. */
  1066. isReady: boolean;
  1067. /** @hidden */
  1068. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1069. }
  1070. }
  1071. declare module "babylonjs/Meshes/dataBuffer" {
  1072. /**
  1073. * Class used to store gfx data (like WebGLBuffer)
  1074. */
  1075. export class DataBuffer {
  1076. /**
  1077. * Gets or sets the number of objects referencing this buffer
  1078. */
  1079. references: number;
  1080. /** Gets or sets the size of the underlying buffer */
  1081. capacity: number;
  1082. /**
  1083. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1084. */
  1085. is32Bits: boolean;
  1086. /**
  1087. * Gets the underlying buffer
  1088. */
  1089. readonly underlyingResource: any;
  1090. }
  1091. }
  1092. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1093. /** @hidden */
  1094. export interface IShaderProcessor {
  1095. attributeProcessor?: (attribute: string) => string;
  1096. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1097. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1098. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1099. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1100. lineProcessor?: (line: string, isFragment: boolean) => string;
  1101. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1102. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1103. }
  1104. }
  1105. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1106. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1107. /** @hidden */
  1108. export interface ProcessingOptions {
  1109. defines: string[];
  1110. indexParameters: any;
  1111. isFragment: boolean;
  1112. shouldUseHighPrecisionShader: boolean;
  1113. supportsUniformBuffers: boolean;
  1114. shadersRepository: string;
  1115. includesShadersStore: {
  1116. [key: string]: string;
  1117. };
  1118. processor?: IShaderProcessor;
  1119. version: string;
  1120. platformName: string;
  1121. lookForClosingBracketForUniformBuffer?: boolean;
  1122. }
  1123. }
  1124. declare module "babylonjs/Misc/stringTools" {
  1125. /**
  1126. * Helper to manipulate strings
  1127. */
  1128. export class StringTools {
  1129. /**
  1130. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1131. * @param str Source string
  1132. * @param suffix Suffix to search for in the source string
  1133. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1134. */
  1135. static EndsWith(str: string, suffix: string): boolean;
  1136. /**
  1137. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1138. * @param str Source string
  1139. * @param suffix Suffix to search for in the source string
  1140. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1141. */
  1142. static StartsWith(str: string, suffix: string): boolean;
  1143. }
  1144. }
  1145. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1146. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1147. /** @hidden */
  1148. export class ShaderCodeNode {
  1149. line: string;
  1150. children: ShaderCodeNode[];
  1151. additionalDefineKey?: string;
  1152. additionalDefineValue?: string;
  1153. isValid(preprocessors: {
  1154. [key: string]: string;
  1155. }): boolean;
  1156. process(preprocessors: {
  1157. [key: string]: string;
  1158. }, options: ProcessingOptions): string;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1162. /** @hidden */
  1163. export class ShaderCodeCursor {
  1164. private _lines;
  1165. lineIndex: number;
  1166. readonly currentLine: string;
  1167. readonly canRead: boolean;
  1168. lines: string[];
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1172. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1173. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1174. /** @hidden */
  1175. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1176. process(preprocessors: {
  1177. [key: string]: string;
  1178. }, options: ProcessingOptions): string;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1182. /** @hidden */
  1183. export class ShaderDefineExpression {
  1184. isTrue(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1190. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1191. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1192. /** @hidden */
  1193. export class ShaderCodeTestNode extends ShaderCodeNode {
  1194. testExpression: ShaderDefineExpression;
  1195. isValid(preprocessors: {
  1196. [key: string]: string;
  1197. }): boolean;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1201. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1202. /** @hidden */
  1203. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1204. define: string;
  1205. not: boolean;
  1206. constructor(define: string, not?: boolean);
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. }
  1211. }
  1212. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1213. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1214. /** @hidden */
  1215. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1216. leftOperand: ShaderDefineExpression;
  1217. rightOperand: ShaderDefineExpression;
  1218. isTrue(preprocessors: {
  1219. [key: string]: string;
  1220. }): boolean;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1224. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1225. /** @hidden */
  1226. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1227. leftOperand: ShaderDefineExpression;
  1228. rightOperand: ShaderDefineExpression;
  1229. isTrue(preprocessors: {
  1230. [key: string]: string;
  1231. }): boolean;
  1232. }
  1233. }
  1234. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1235. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module "babylonjs/Misc/loadFileError" {
  1248. import { WebRequest } from "babylonjs/Misc/webRequest";
  1249. /**
  1250. * @ignore
  1251. * Application error to support additional information when loading a file
  1252. */
  1253. export class LoadFileError extends Error {
  1254. /** defines the optional web request */
  1255. request?: WebRequest | undefined;
  1256. private static _setPrototypeOf;
  1257. /**
  1258. * Creates a new LoadFileError
  1259. * @param message defines the message of the error
  1260. * @param request defines the optional web request
  1261. */
  1262. constructor(message: string,
  1263. /** defines the optional web request */
  1264. request?: WebRequest | undefined);
  1265. }
  1266. }
  1267. declare module "babylonjs/Offline/IOfflineProvider" {
  1268. /**
  1269. * Class used to enable access to offline support
  1270. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1271. */
  1272. export interface IOfflineProvider {
  1273. /**
  1274. * Gets a boolean indicating if scene must be saved in the database
  1275. */
  1276. enableSceneOffline: boolean;
  1277. /**
  1278. * Gets a boolean indicating if textures must be saved in the database
  1279. */
  1280. enableTexturesOffline: boolean;
  1281. /**
  1282. * Open the offline support and make it available
  1283. * @param successCallback defines the callback to call on success
  1284. * @param errorCallback defines the callback to call on error
  1285. */
  1286. open(successCallback: () => void, errorCallback: () => void): void;
  1287. /**
  1288. * Loads an image from the offline support
  1289. * @param url defines the url to load from
  1290. * @param image defines the target DOM image
  1291. */
  1292. loadImage(url: string, image: HTMLImageElement): void;
  1293. /**
  1294. * Loads a file from offline support
  1295. * @param url defines the URL to load from
  1296. * @param sceneLoaded defines a callback to call on success
  1297. * @param progressCallBack defines a callback to call when progress changed
  1298. * @param errorCallback defines a callback to call on error
  1299. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1300. */
  1301. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1302. }
  1303. }
  1304. declare module "babylonjs/Misc/filesInputStore" {
  1305. /**
  1306. * Class used to help managing file picking and drag'n'drop
  1307. * File Storage
  1308. */
  1309. export class FilesInputStore {
  1310. /**
  1311. * List of files ready to be loaded
  1312. */
  1313. static FilesToLoad: {
  1314. [key: string]: File;
  1315. };
  1316. }
  1317. }
  1318. declare module "babylonjs/Misc/retryStrategy" {
  1319. import { WebRequest } from "babylonjs/Misc/webRequest";
  1320. /**
  1321. * Class used to define a retry strategy when error happens while loading assets
  1322. */
  1323. export class RetryStrategy {
  1324. /**
  1325. * Function used to defines an exponential back off strategy
  1326. * @param maxRetries defines the maximum number of retries (3 by default)
  1327. * @param baseInterval defines the interval between retries
  1328. * @returns the strategy function to use
  1329. */
  1330. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1331. }
  1332. }
  1333. declare module "babylonjs/Misc/fileTools" {
  1334. import { WebRequest } from "babylonjs/Misc/webRequest";
  1335. import { Nullable } from "babylonjs/types";
  1336. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1337. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1338. /**
  1339. * @hidden
  1340. */
  1341. export class FileTools {
  1342. /**
  1343. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1344. */
  1345. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1346. /**
  1347. * Gets or sets the base URL to use to load assets
  1348. */
  1349. static BaseUrl: string;
  1350. /**
  1351. * Default behaviour for cors in the application.
  1352. * It can be a string if the expected behavior is identical in the entire app.
  1353. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1354. */
  1355. static CorsBehavior: string | ((url: string | string[]) => string);
  1356. /**
  1357. * Gets or sets a function used to pre-process url before using them to load assets
  1358. */
  1359. static PreprocessUrl: (url: string) => string;
  1360. /**
  1361. * Removes unwanted characters from an url
  1362. * @param url defines the url to clean
  1363. * @returns the cleaned url
  1364. */
  1365. private static _CleanUrl;
  1366. /**
  1367. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1368. * @param url define the url we are trying
  1369. * @param element define the dom element where to configure the cors policy
  1370. */
  1371. static SetCorsBehavior(url: string | string[], element: {
  1372. crossOrigin: string | null;
  1373. }): void;
  1374. /**
  1375. * Loads an image as an HTMLImageElement.
  1376. * @param input url string, ArrayBuffer, or Blob to load
  1377. * @param onLoad callback called when the image successfully loads
  1378. * @param onError callback called when the image fails to load
  1379. * @param offlineProvider offline provider for caching
  1380. * @returns the HTMLImageElement of the loaded image
  1381. */
  1382. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  1383. /**
  1384. * Loads a file
  1385. * @param fileToLoad defines the file to load
  1386. * @param callback defines the callback to call when data is loaded
  1387. * @param progressCallBack defines the callback to call during loading process
  1388. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1389. * @returns a file request object
  1390. */
  1391. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1392. /**
  1393. * Loads a file
  1394. * @param url url string, ArrayBuffer, or Blob to load
  1395. * @param onSuccess callback called when the file successfully loads
  1396. * @param onProgress callback called while file is loading (if the server supports this mode)
  1397. * @param offlineProvider defines the offline provider for caching
  1398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1399. * @param onError callback called when the file fails to load
  1400. * @returns a file request object
  1401. */
  1402. 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;
  1403. /**
  1404. * Checks if the loaded document was accessed via `file:`-Protocol.
  1405. * @returns boolean
  1406. */
  1407. static IsFileURL(): boolean;
  1408. }
  1409. }
  1410. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1411. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1412. /** @hidden */
  1413. export class ShaderProcessor {
  1414. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1415. private static _ProcessPrecision;
  1416. private static _ExtractOperation;
  1417. private static _BuildSubExpression;
  1418. private static _BuildExpression;
  1419. private static _MoveCursorWithinIf;
  1420. private static _MoveCursor;
  1421. private static _EvaluatePreProcessors;
  1422. private static _PreparePreProcessors;
  1423. private static _ProcessShaderConversion;
  1424. private static _ProcessIncludes;
  1425. }
  1426. }
  1427. declare module "babylonjs/Maths/math.like" {
  1428. import { float, int, DeepImmutable } from "babylonjs/types";
  1429. /**
  1430. * @hidden
  1431. */
  1432. export interface IColor4Like {
  1433. r: float;
  1434. g: float;
  1435. b: float;
  1436. a: float;
  1437. }
  1438. /**
  1439. * @hidden
  1440. */
  1441. export interface IColor3Like {
  1442. r: float;
  1443. g: float;
  1444. b: float;
  1445. }
  1446. /**
  1447. * @hidden
  1448. */
  1449. export interface IVector4Like {
  1450. x: float;
  1451. y: float;
  1452. z: float;
  1453. w: float;
  1454. }
  1455. /**
  1456. * @hidden
  1457. */
  1458. export interface IVector3Like {
  1459. x: float;
  1460. y: float;
  1461. z: float;
  1462. }
  1463. /**
  1464. * @hidden
  1465. */
  1466. export interface IVector2Like {
  1467. x: float;
  1468. y: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IMatrixLike {
  1474. toArray(): DeepImmutable<Float32Array>;
  1475. updateFlag: int;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IViewportLike {
  1481. x: float;
  1482. y: float;
  1483. width: float;
  1484. height: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IPlaneLike {
  1490. normal: IVector3Like;
  1491. d: float;
  1492. normalize(): void;
  1493. }
  1494. }
  1495. declare module "babylonjs/Materials/iEffectFallbacks" {
  1496. import { Effect } from "babylonjs/Materials/effect";
  1497. /**
  1498. * Interface used to define common properties for effect fallbacks
  1499. */
  1500. export interface IEffectFallbacks {
  1501. /**
  1502. * Removes the defines that should be removed when falling back.
  1503. * @param currentDefines defines the current define statements for the shader.
  1504. * @param effect defines the current effect we try to compile
  1505. * @returns The resulting defines with defines of the current rank removed.
  1506. */
  1507. reduce(currentDefines: string, effect: Effect): string;
  1508. /**
  1509. * Removes the fallback from the bound mesh.
  1510. */
  1511. unBindMesh(): void;
  1512. /**
  1513. * Checks to see if more fallbacks are still availible.
  1514. */
  1515. hasMoreFallbacks: boolean;
  1516. }
  1517. }
  1518. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1519. /**
  1520. * Class used to evalaute queries containing `and` and `or` operators
  1521. */
  1522. export class AndOrNotEvaluator {
  1523. /**
  1524. * Evaluate a query
  1525. * @param query defines the query to evaluate
  1526. * @param evaluateCallback defines the callback used to filter result
  1527. * @returns true if the query matches
  1528. */
  1529. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1530. private static _HandleParenthesisContent;
  1531. private static _SimplifyNegation;
  1532. }
  1533. }
  1534. declare module "babylonjs/Misc/tags" {
  1535. /**
  1536. * Class used to store custom tags
  1537. */
  1538. export class Tags {
  1539. /**
  1540. * Adds support for tags on the given object
  1541. * @param obj defines the object to use
  1542. */
  1543. static EnableFor(obj: any): void;
  1544. /**
  1545. * Removes tags support
  1546. * @param obj defines the object to use
  1547. */
  1548. static DisableFor(obj: any): void;
  1549. /**
  1550. * Gets a boolean indicating if the given object has tags
  1551. * @param obj defines the object to use
  1552. * @returns a boolean
  1553. */
  1554. static HasTags(obj: any): boolean;
  1555. /**
  1556. * Gets the tags available on a given object
  1557. * @param obj defines the object to use
  1558. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1559. * @returns the tags
  1560. */
  1561. static GetTags(obj: any, asString?: boolean): any;
  1562. /**
  1563. * Adds tags to an object
  1564. * @param obj defines the object to use
  1565. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1566. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1567. */
  1568. static AddTagsTo(obj: any, tagsString: string): void;
  1569. /**
  1570. * @hidden
  1571. */
  1572. static _AddTagTo(obj: any, tag: string): void;
  1573. /**
  1574. * Removes specific tags from a specific object
  1575. * @param obj defines the object to use
  1576. * @param tagsString defines the tags to remove
  1577. */
  1578. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1579. /**
  1580. * @hidden
  1581. */
  1582. static _RemoveTagFrom(obj: any, tag: string): void;
  1583. /**
  1584. * Defines if tags hosted on an object match a given query
  1585. * @param obj defines the object to use
  1586. * @param tagsQuery defines the tag query
  1587. * @returns a boolean
  1588. */
  1589. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1590. }
  1591. }
  1592. declare module "babylonjs/Maths/math.scalar" {
  1593. /**
  1594. * Scalar computation library
  1595. */
  1596. export class Scalar {
  1597. /**
  1598. * Two pi constants convenient for computation.
  1599. */
  1600. static TwoPi: number;
  1601. /**
  1602. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1603. * @param a number
  1604. * @param b number
  1605. * @param epsilon (default = 1.401298E-45)
  1606. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1607. */
  1608. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1609. /**
  1610. * Returns a string : the upper case translation of the number i to hexadecimal.
  1611. * @param i number
  1612. * @returns the upper case translation of the number i to hexadecimal.
  1613. */
  1614. static ToHex(i: number): string;
  1615. /**
  1616. * Returns -1 if value is negative and +1 is value is positive.
  1617. * @param value the value
  1618. * @returns the value itself if it's equal to zero.
  1619. */
  1620. static Sign(value: number): number;
  1621. /**
  1622. * Returns the value itself if it's between min and max.
  1623. * Returns min if the value is lower than min.
  1624. * Returns max if the value is greater than max.
  1625. * @param value the value to clmap
  1626. * @param min the min value to clamp to (default: 0)
  1627. * @param max the max value to clamp to (default: 1)
  1628. * @returns the clamped value
  1629. */
  1630. static Clamp(value: number, min?: number, max?: number): number;
  1631. /**
  1632. * the log2 of value.
  1633. * @param value the value to compute log2 of
  1634. * @returns the log2 of value.
  1635. */
  1636. static Log2(value: number): number;
  1637. /**
  1638. * Loops the value, so that it is never larger than length and never smaller than 0.
  1639. *
  1640. * This is similar to the modulo operator but it works with floating point numbers.
  1641. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1642. * With t = 5 and length = 2.5, the result would be 0.0.
  1643. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1644. * @param value the value
  1645. * @param length the length
  1646. * @returns the looped value
  1647. */
  1648. static Repeat(value: number, length: number): number;
  1649. /**
  1650. * Normalize the value between 0.0 and 1.0 using min and max values
  1651. * @param value value to normalize
  1652. * @param min max to normalize between
  1653. * @param max min to normalize between
  1654. * @returns the normalized value
  1655. */
  1656. static Normalize(value: number, min: number, max: number): number;
  1657. /**
  1658. * Denormalize the value from 0.0 and 1.0 using min and max values
  1659. * @param normalized value to denormalize
  1660. * @param min max to denormalize between
  1661. * @param max min to denormalize between
  1662. * @returns the denormalized value
  1663. */
  1664. static Denormalize(normalized: number, min: number, max: number): number;
  1665. /**
  1666. * Calculates the shortest difference between two given angles given in degrees.
  1667. * @param current current angle in degrees
  1668. * @param target target angle in degrees
  1669. * @returns the delta
  1670. */
  1671. static DeltaAngle(current: number, target: number): number;
  1672. /**
  1673. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1674. * @param tx value
  1675. * @param length length
  1676. * @returns The returned value will move back and forth between 0 and length
  1677. */
  1678. static PingPong(tx: number, length: number): number;
  1679. /**
  1680. * Interpolates between min and max with smoothing at the limits.
  1681. *
  1682. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1683. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1684. * @param from from
  1685. * @param to to
  1686. * @param tx value
  1687. * @returns the smooth stepped value
  1688. */
  1689. static SmoothStep(from: number, to: number, tx: number): number;
  1690. /**
  1691. * Moves a value current towards target.
  1692. *
  1693. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1694. * Negative values of maxDelta pushes the value away from target.
  1695. * @param current current value
  1696. * @param target target value
  1697. * @param maxDelta max distance to move
  1698. * @returns resulting value
  1699. */
  1700. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1701. /**
  1702. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1703. *
  1704. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1705. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1706. * @param current current value
  1707. * @param target target value
  1708. * @param maxDelta max distance to move
  1709. * @returns resulting angle
  1710. */
  1711. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1712. /**
  1713. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1714. * @param start start value
  1715. * @param end target value
  1716. * @param amount amount to lerp between
  1717. * @returns the lerped value
  1718. */
  1719. static Lerp(start: number, end: number, amount: number): number;
  1720. /**
  1721. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1722. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1723. * @param start start value
  1724. * @param end target value
  1725. * @param amount amount to lerp between
  1726. * @returns the lerped value
  1727. */
  1728. static LerpAngle(start: number, end: number, amount: number): number;
  1729. /**
  1730. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1731. * @param a start value
  1732. * @param b target value
  1733. * @param value value between a and b
  1734. * @returns the inverseLerp value
  1735. */
  1736. static InverseLerp(a: number, b: number, value: number): number;
  1737. /**
  1738. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1739. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1740. * @param value1 spline value
  1741. * @param tangent1 spline value
  1742. * @param value2 spline value
  1743. * @param tangent2 spline value
  1744. * @param amount input value
  1745. * @returns hermite result
  1746. */
  1747. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1748. /**
  1749. * Returns a random float number between and min and max values
  1750. * @param min min value of random
  1751. * @param max max value of random
  1752. * @returns random value
  1753. */
  1754. static RandomRange(min: number, max: number): number;
  1755. /**
  1756. * This function returns percentage of a number in a given range.
  1757. *
  1758. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1759. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1760. * @param number to convert to percentage
  1761. * @param min min range
  1762. * @param max max range
  1763. * @returns the percentage
  1764. */
  1765. static RangeToPercent(number: number, min: number, max: number): number;
  1766. /**
  1767. * This function returns number that corresponds to the percentage in a given range.
  1768. *
  1769. * PercentToRange(0.34,0,100) will return 34.
  1770. * @param percent to convert to number
  1771. * @param min min range
  1772. * @param max max range
  1773. * @returns the number
  1774. */
  1775. static PercentToRange(percent: number, min: number, max: number): number;
  1776. /**
  1777. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1778. * @param angle The angle to normalize in radian.
  1779. * @return The converted angle.
  1780. */
  1781. static NormalizeRadians(angle: number): number;
  1782. }
  1783. }
  1784. declare module "babylonjs/Maths/math.constants" {
  1785. /**
  1786. * Constant used to convert a value to gamma space
  1787. * @ignorenaming
  1788. */
  1789. export const ToGammaSpace: number;
  1790. /**
  1791. * Constant used to convert a value to linear space
  1792. * @ignorenaming
  1793. */
  1794. export const ToLinearSpace = 2.2;
  1795. /**
  1796. * Constant used to define the minimal number value in Babylon.js
  1797. * @ignorenaming
  1798. */
  1799. let Epsilon: number;
  1800. export { Epsilon };
  1801. }
  1802. declare module "babylonjs/Maths/math.viewport" {
  1803. /**
  1804. * Class used to represent a viewport on screen
  1805. */
  1806. export class Viewport {
  1807. /** viewport left coordinate */
  1808. x: number;
  1809. /** viewport top coordinate */
  1810. y: number;
  1811. /**viewport width */
  1812. width: number;
  1813. /** viewport height */
  1814. height: number;
  1815. /**
  1816. * Creates a Viewport object located at (x, y) and sized (width, height)
  1817. * @param x defines viewport left coordinate
  1818. * @param y defines viewport top coordinate
  1819. * @param width defines the viewport width
  1820. * @param height defines the viewport height
  1821. */
  1822. constructor(
  1823. /** viewport left coordinate */
  1824. x: number,
  1825. /** viewport top coordinate */
  1826. y: number,
  1827. /**viewport width */
  1828. width: number,
  1829. /** viewport height */
  1830. height: number);
  1831. /**
  1832. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1833. * @param renderWidth defines the rendering width
  1834. * @param renderHeight defines the rendering height
  1835. * @returns a new Viewport
  1836. */
  1837. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1838. /**
  1839. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1840. * @param renderWidth defines the rendering width
  1841. * @param renderHeight defines the rendering height
  1842. * @param ref defines the target viewport
  1843. * @returns the current viewport
  1844. */
  1845. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1846. /**
  1847. * Returns a new Viewport copied from the current one
  1848. * @returns a new Viewport
  1849. */
  1850. clone(): Viewport;
  1851. }
  1852. }
  1853. declare module "babylonjs/Misc/arrayTools" {
  1854. /**
  1855. * Class containing a set of static utilities functions for arrays.
  1856. */
  1857. export class ArrayTools {
  1858. /**
  1859. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1860. * @param size the number of element to construct and put in the array
  1861. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1862. * @returns a new array filled with new objects
  1863. */
  1864. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1865. }
  1866. }
  1867. declare module "babylonjs/Maths/math.vector" {
  1868. import { Viewport } from "babylonjs/Maths/math.viewport";
  1869. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1870. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1871. /**
  1872. * Class representing a vector containing 2 coordinates
  1873. */
  1874. export class Vector2 {
  1875. /** defines the first coordinate */
  1876. x: number;
  1877. /** defines the second coordinate */
  1878. y: number;
  1879. /**
  1880. * Creates a new Vector2 from the given x and y coordinates
  1881. * @param x defines the first coordinate
  1882. * @param y defines the second coordinate
  1883. */
  1884. constructor(
  1885. /** defines the first coordinate */
  1886. x?: number,
  1887. /** defines the second coordinate */
  1888. y?: number);
  1889. /**
  1890. * Gets a string with the Vector2 coordinates
  1891. * @returns a string with the Vector2 coordinates
  1892. */
  1893. toString(): string;
  1894. /**
  1895. * Gets class name
  1896. * @returns the string "Vector2"
  1897. */
  1898. getClassName(): string;
  1899. /**
  1900. * Gets current vector hash code
  1901. * @returns the Vector2 hash code as a number
  1902. */
  1903. getHashCode(): number;
  1904. /**
  1905. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1906. * @param array defines the source array
  1907. * @param index defines the offset in source array
  1908. * @returns the current Vector2
  1909. */
  1910. toArray(array: FloatArray, index?: number): Vector2;
  1911. /**
  1912. * Copy the current vector to an array
  1913. * @returns a new array with 2 elements: the Vector2 coordinates.
  1914. */
  1915. asArray(): number[];
  1916. /**
  1917. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1918. * @param source defines the source Vector2
  1919. * @returns the current updated Vector2
  1920. */
  1921. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1922. /**
  1923. * Sets the Vector2 coordinates with the given floats
  1924. * @param x defines the first coordinate
  1925. * @param y defines the second coordinate
  1926. * @returns the current updated Vector2
  1927. */
  1928. copyFromFloats(x: number, y: number): Vector2;
  1929. /**
  1930. * Sets the Vector2 coordinates with the given floats
  1931. * @param x defines the first coordinate
  1932. * @param y defines the second coordinate
  1933. * @returns the current updated Vector2
  1934. */
  1935. set(x: number, y: number): Vector2;
  1936. /**
  1937. * Add another vector with the current one
  1938. * @param otherVector defines the other vector
  1939. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1940. */
  1941. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1942. /**
  1943. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1944. * @param otherVector defines the other vector
  1945. * @param result defines the target vector
  1946. * @returns the unmodified current Vector2
  1947. */
  1948. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1949. /**
  1950. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1951. * @param otherVector defines the other vector
  1952. * @returns the current updated Vector2
  1953. */
  1954. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1955. /**
  1956. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1957. * @param otherVector defines the other vector
  1958. * @returns a new Vector2
  1959. */
  1960. addVector3(otherVector: Vector3): Vector2;
  1961. /**
  1962. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1963. * @param otherVector defines the other vector
  1964. * @returns a new Vector2
  1965. */
  1966. subtract(otherVector: Vector2): Vector2;
  1967. /**
  1968. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1969. * @param otherVector defines the other vector
  1970. * @param result defines the target vector
  1971. * @returns the unmodified current Vector2
  1972. */
  1973. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1974. /**
  1975. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1976. * @param otherVector defines the other vector
  1977. * @returns the current updated Vector2
  1978. */
  1979. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1980. /**
  1981. * Multiplies in place the current Vector2 coordinates by the given ones
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1992. /**
  1993. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1994. * @param otherVector defines the other vector
  1995. * @param result defines the target vector
  1996. * @returns the unmodified current Vector2
  1997. */
  1998. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1999. /**
  2000. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2001. * @param x defines the first coordinate
  2002. * @param y defines the second coordinate
  2003. * @returns a new Vector2
  2004. */
  2005. multiplyByFloats(x: number, y: number): Vector2;
  2006. /**
  2007. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. divide(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Divides the current Vector2 coordinates by the given ones
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Gets a new Vector2 with current Vector2 negated coordinates
  2027. * @returns a new Vector2
  2028. */
  2029. negate(): Vector2;
  2030. /**
  2031. * Multiply the Vector2 coordinates by scale
  2032. * @param scale defines the scaling factor
  2033. * @returns the current updated Vector2
  2034. */
  2035. scaleInPlace(scale: number): Vector2;
  2036. /**
  2037. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2038. * @param scale defines the scaling factor
  2039. * @returns a new Vector2
  2040. */
  2041. scale(scale: number): Vector2;
  2042. /**
  2043. * Scale the current Vector2 values by a factor to a given Vector2
  2044. * @param scale defines the scale factor
  2045. * @param result defines the Vector2 object where to store the result
  2046. * @returns the unmodified current Vector2
  2047. */
  2048. scaleToRef(scale: number, result: Vector2): Vector2;
  2049. /**
  2050. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2051. * @param scale defines the scale factor
  2052. * @param result defines the Vector2 object where to store the result
  2053. * @returns the unmodified current Vector2
  2054. */
  2055. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2056. /**
  2057. * Gets a boolean if two vectors are equals
  2058. * @param otherVector defines the other vector
  2059. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2060. */
  2061. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2062. /**
  2063. * Gets a boolean if two vectors are equals (using an epsilon value)
  2064. * @param otherVector defines the other vector
  2065. * @param epsilon defines the minimal distance to consider equality
  2066. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2067. */
  2068. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2069. /**
  2070. * Gets a new Vector2 from current Vector2 floored values
  2071. * @returns a new Vector2
  2072. */
  2073. floor(): Vector2;
  2074. /**
  2075. * Gets a new Vector2 from current Vector2 floored values
  2076. * @returns a new Vector2
  2077. */
  2078. fract(): Vector2;
  2079. /**
  2080. * Gets the length of the vector
  2081. * @returns the vector length (float)
  2082. */
  2083. length(): number;
  2084. /**
  2085. * Gets the vector squared length
  2086. * @returns the vector squared length (float)
  2087. */
  2088. lengthSquared(): number;
  2089. /**
  2090. * Normalize the vector
  2091. * @returns the current updated Vector2
  2092. */
  2093. normalize(): Vector2;
  2094. /**
  2095. * Gets a new Vector2 copied from the Vector2
  2096. * @returns a new Vector2
  2097. */
  2098. clone(): Vector2;
  2099. /**
  2100. * Gets a new Vector2(0, 0)
  2101. * @returns a new Vector2
  2102. */
  2103. static Zero(): Vector2;
  2104. /**
  2105. * Gets a new Vector2(1, 1)
  2106. * @returns a new Vector2
  2107. */
  2108. static One(): Vector2;
  2109. /**
  2110. * Gets a new Vector2 set from the given index element of the given array
  2111. * @param array defines the data source
  2112. * @param offset defines the offset in the data source
  2113. * @returns a new Vector2
  2114. */
  2115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2116. /**
  2117. * Sets "result" from the given index element of the given array
  2118. * @param array defines the data source
  2119. * @param offset defines the offset in the data source
  2120. * @param result defines the target vector
  2121. */
  2122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2123. /**
  2124. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2125. * @param value1 defines 1st point of control
  2126. * @param value2 defines 2nd point of control
  2127. * @param value3 defines 3rd point of control
  2128. * @param value4 defines 4th point of control
  2129. * @param amount defines the interpolation factor
  2130. * @returns a new Vector2
  2131. */
  2132. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2133. /**
  2134. * 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".
  2135. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2136. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2137. * @param value defines the value to clamp
  2138. * @param min defines the lower limit
  2139. * @param max defines the upper limit
  2140. * @returns a new Vector2
  2141. */
  2142. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2145. * @param value1 defines the 1st control point
  2146. * @param tangent1 defines the outgoing tangent
  2147. * @param value2 defines the 2nd control point
  2148. * @param tangent2 defines the incoming tangent
  2149. * @param amount defines the interpolation factor
  2150. * @returns a new Vector2
  2151. */
  2152. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2153. /**
  2154. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2155. * @param start defines the start vector
  2156. * @param end defines the end vector
  2157. * @param amount defines the interpolation factor
  2158. * @returns a new Vector2
  2159. */
  2160. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2161. /**
  2162. * Gets the dot product of the vector "left" and the vector "right"
  2163. * @param left defines first vector
  2164. * @param right defines second vector
  2165. * @returns the dot product (float)
  2166. */
  2167. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2168. /**
  2169. * Returns a new Vector2 equal to the normalized given vector
  2170. * @param vector defines the vector to normalize
  2171. * @returns a new Vector2
  2172. */
  2173. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2176. * @param left defines 1st vector
  2177. * @param right defines 2nd vector
  2178. * @returns a new Vector2
  2179. */
  2180. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2183. * @param left defines 1st vector
  2184. * @param right defines 2nd vector
  2185. * @returns a new Vector2
  2186. */
  2187. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2190. * @param vector defines the vector to transform
  2191. * @param transformation defines the matrix to apply
  2192. * @returns a new Vector2
  2193. */
  2194. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2195. /**
  2196. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2197. * @param vector defines the vector to transform
  2198. * @param transformation defines the matrix to apply
  2199. * @param result defines the target vector
  2200. */
  2201. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2202. /**
  2203. * Determines if a given vector is included in a triangle
  2204. * @param p defines the vector to test
  2205. * @param p0 defines 1st triangle point
  2206. * @param p1 defines 2nd triangle point
  2207. * @param p2 defines 3rd triangle point
  2208. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2209. */
  2210. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2211. /**
  2212. * Gets the distance between the vectors "value1" and "value2"
  2213. * @param value1 defines first vector
  2214. * @param value2 defines second vector
  2215. * @returns the distance between vectors
  2216. */
  2217. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2218. /**
  2219. * Returns the squared distance between the vectors "value1" and "value2"
  2220. * @param value1 defines first vector
  2221. * @param value2 defines second vector
  2222. * @returns the squared distance between vectors
  2223. */
  2224. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2225. /**
  2226. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2227. * @param value1 defines first vector
  2228. * @param value2 defines second vector
  2229. * @returns a new Vector2
  2230. */
  2231. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2234. * @param p defines the middle point
  2235. * @param segA defines one point of the segment
  2236. * @param segB defines the other point of the segment
  2237. * @returns the shortest distance
  2238. */
  2239. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2240. }
  2241. /**
  2242. * Classed used to store (x,y,z) vector representation
  2243. * A Vector3 is the main object used in 3D geometry
  2244. * It can represent etiher the coordinates of a point the space, either a direction
  2245. * Reminder: js uses a left handed forward facing system
  2246. */
  2247. export class Vector3 {
  2248. /**
  2249. * Defines the first coordinates (on X axis)
  2250. */
  2251. x: number;
  2252. /**
  2253. * Defines the second coordinates (on Y axis)
  2254. */
  2255. y: number;
  2256. /**
  2257. * Defines the third coordinates (on Z axis)
  2258. */
  2259. z: number;
  2260. private static _UpReadOnly;
  2261. private static _ZeroReadOnly;
  2262. /**
  2263. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2264. * @param x defines the first coordinates (on X axis)
  2265. * @param y defines the second coordinates (on Y axis)
  2266. * @param z defines the third coordinates (on Z axis)
  2267. */
  2268. constructor(
  2269. /**
  2270. * Defines the first coordinates (on X axis)
  2271. */
  2272. x?: number,
  2273. /**
  2274. * Defines the second coordinates (on Y axis)
  2275. */
  2276. y?: number,
  2277. /**
  2278. * Defines the third coordinates (on Z axis)
  2279. */
  2280. z?: number);
  2281. /**
  2282. * Creates a string representation of the Vector3
  2283. * @returns a string with the Vector3 coordinates.
  2284. */
  2285. toString(): string;
  2286. /**
  2287. * Gets the class name
  2288. * @returns the string "Vector3"
  2289. */
  2290. getClassName(): string;
  2291. /**
  2292. * Creates the Vector3 hash code
  2293. * @returns a number which tends to be unique between Vector3 instances
  2294. */
  2295. getHashCode(): number;
  2296. /**
  2297. * Creates an array containing three elements : the coordinates of the Vector3
  2298. * @returns a new array of numbers
  2299. */
  2300. asArray(): number[];
  2301. /**
  2302. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2303. * @param array defines the destination array
  2304. * @param index defines the offset in the destination array
  2305. * @returns the current Vector3
  2306. */
  2307. toArray(array: FloatArray, index?: number): Vector3;
  2308. /**
  2309. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2310. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2311. */
  2312. toQuaternion(): Quaternion;
  2313. /**
  2314. * Adds the given vector to the current Vector3
  2315. * @param otherVector defines the second operand
  2316. * @returns the current updated Vector3
  2317. */
  2318. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2319. /**
  2320. * Adds the given coordinates to the current Vector3
  2321. * @param x defines the x coordinate of the operand
  2322. * @param y defines the y coordinate of the operand
  2323. * @param z defines the z coordinate of the operand
  2324. * @returns the current updated Vector3
  2325. */
  2326. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2327. /**
  2328. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2329. * @param otherVector defines the second operand
  2330. * @returns the resulting Vector3
  2331. */
  2332. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2333. /**
  2334. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2335. * @param otherVector defines the second operand
  2336. * @param result defines the Vector3 object where to store the result
  2337. * @returns the current Vector3
  2338. */
  2339. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2340. /**
  2341. * Subtract the given vector from the current Vector3
  2342. * @param otherVector defines the second operand
  2343. * @returns the current updated Vector3
  2344. */
  2345. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2346. /**
  2347. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2348. * @param otherVector defines the second operand
  2349. * @returns the resulting Vector3
  2350. */
  2351. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2352. /**
  2353. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2354. * @param otherVector defines the second operand
  2355. * @param result defines the Vector3 object where to store the result
  2356. * @returns the current Vector3
  2357. */
  2358. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2359. /**
  2360. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2361. * @param x defines the x coordinate of the operand
  2362. * @param y defines the y coordinate of the operand
  2363. * @param z defines the z coordinate of the operand
  2364. * @returns the resulting Vector3
  2365. */
  2366. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2367. /**
  2368. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2369. * @param x defines the x coordinate of the operand
  2370. * @param y defines the y coordinate of the operand
  2371. * @param z defines the z coordinate of the operand
  2372. * @param result defines the Vector3 object where to store the result
  2373. * @returns the current Vector3
  2374. */
  2375. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2376. /**
  2377. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2378. * @returns a new Vector3
  2379. */
  2380. negate(): Vector3;
  2381. /**
  2382. * Multiplies the Vector3 coordinates by the float "scale"
  2383. * @param scale defines the multiplier factor
  2384. * @returns the current updated Vector3
  2385. */
  2386. scaleInPlace(scale: number): Vector3;
  2387. /**
  2388. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2389. * @param scale defines the multiplier factor
  2390. * @returns a new Vector3
  2391. */
  2392. scale(scale: number): Vector3;
  2393. /**
  2394. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2395. * @param scale defines the multiplier factor
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. scaleToRef(scale: number, result: Vector3): Vector3;
  2400. /**
  2401. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2402. * @param scale defines the scale factor
  2403. * @param result defines the Vector3 object where to store the result
  2404. * @returns the unmodified current Vector3
  2405. */
  2406. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2407. /**
  2408. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2409. * @param otherVector defines the second operand
  2410. * @returns true if both vectors are equals
  2411. */
  2412. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2413. /**
  2414. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2415. * @param otherVector defines the second operand
  2416. * @param epsilon defines the minimal distance to define values as equals
  2417. * @returns true if both vectors are distant less than epsilon
  2418. */
  2419. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2420. /**
  2421. * Returns true if the current Vector3 coordinates equals the given floats
  2422. * @param x defines the x coordinate of the operand
  2423. * @param y defines the y coordinate of the operand
  2424. * @param z defines the z coordinate of the operand
  2425. * @returns true if both vectors are equals
  2426. */
  2427. equalsToFloats(x: number, y: number, z: number): boolean;
  2428. /**
  2429. * Multiplies the current Vector3 coordinates by the given ones
  2430. * @param otherVector defines the second operand
  2431. * @returns the current updated Vector3
  2432. */
  2433. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2434. /**
  2435. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2436. * @param otherVector defines the second operand
  2437. * @returns the new Vector3
  2438. */
  2439. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2440. /**
  2441. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2442. * @param otherVector defines the second operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2447. /**
  2448. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2449. * @param x defines the x coordinate of the operand
  2450. * @param y defines the y coordinate of the operand
  2451. * @param z defines the z coordinate of the operand
  2452. * @returns the new Vector3
  2453. */
  2454. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2455. /**
  2456. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2457. * @param otherVector defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2463. * @param otherVector defines the second operand
  2464. * @param result defines the Vector3 object where to store the result
  2465. * @returns the current Vector3
  2466. */
  2467. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2468. /**
  2469. * Divides the current Vector3 coordinates by the given ones.
  2470. * @param otherVector defines the second operand
  2471. * @returns the current updated Vector3
  2472. */
  2473. divideInPlace(otherVector: Vector3): Vector3;
  2474. /**
  2475. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2476. * @param other defines the second operand
  2477. * @returns the current updated Vector3
  2478. */
  2479. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2480. /**
  2481. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2482. * @param other defines the second operand
  2483. * @returns the current updated Vector3
  2484. */
  2485. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2486. /**
  2487. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2488. * @param x defines the x coordinate of the operand
  2489. * @param y defines the y coordinate of the operand
  2490. * @param z defines the z coordinate of the operand
  2491. * @returns the current updated Vector3
  2492. */
  2493. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2494. /**
  2495. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2496. * @param x defines the x coordinate of the operand
  2497. * @param y defines the y coordinate of the operand
  2498. * @param z defines the z coordinate of the operand
  2499. * @returns the current updated Vector3
  2500. */
  2501. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2502. /**
  2503. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2504. * Check if is non uniform within a certain amount of decimal places to account for this
  2505. * @param epsilon the amount the values can differ
  2506. * @returns if the the vector is non uniform to a certain number of decimal places
  2507. */
  2508. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2509. /**
  2510. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2511. */
  2512. readonly isNonUniform: boolean;
  2513. /**
  2514. * Gets a new Vector3 from current Vector3 floored values
  2515. * @returns a new Vector3
  2516. */
  2517. floor(): Vector3;
  2518. /**
  2519. * Gets a new Vector3 from current Vector3 floored values
  2520. * @returns a new Vector3
  2521. */
  2522. fract(): Vector3;
  2523. /**
  2524. * Gets the length of the Vector3
  2525. * @returns the length of the Vector3
  2526. */
  2527. length(): number;
  2528. /**
  2529. * Gets the squared length of the Vector3
  2530. * @returns squared length of the Vector3
  2531. */
  2532. lengthSquared(): number;
  2533. /**
  2534. * Normalize the current Vector3.
  2535. * Please note that this is an in place operation.
  2536. * @returns the current updated Vector3
  2537. */
  2538. normalize(): Vector3;
  2539. /**
  2540. * Reorders the x y z properties of the vector in place
  2541. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2542. * @returns the current updated vector
  2543. */
  2544. reorderInPlace(order: string): this;
  2545. /**
  2546. * Rotates the vector around 0,0,0 by a quaternion
  2547. * @param quaternion the rotation quaternion
  2548. * @param result vector to store the result
  2549. * @returns the resulting vector
  2550. */
  2551. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2552. /**
  2553. * Rotates a vector around a given point
  2554. * @param quaternion the rotation quaternion
  2555. * @param point the point to rotate around
  2556. * @param result vector to store the result
  2557. * @returns the resulting vector
  2558. */
  2559. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2560. /**
  2561. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2562. * The cross product is then orthogonal to both current and "other"
  2563. * @param other defines the right operand
  2564. * @returns the cross product
  2565. */
  2566. cross(other: Vector3): Vector3;
  2567. /**
  2568. * Normalize the current Vector3 with the given input length.
  2569. * Please note that this is an in place operation.
  2570. * @param len the length of the vector
  2571. * @returns the current updated Vector3
  2572. */
  2573. normalizeFromLength(len: number): Vector3;
  2574. /**
  2575. * Normalize the current Vector3 to a new vector
  2576. * @returns the new Vector3
  2577. */
  2578. normalizeToNew(): Vector3;
  2579. /**
  2580. * Normalize the current Vector3 to the reference
  2581. * @param reference define the Vector3 to update
  2582. * @returns the updated Vector3
  2583. */
  2584. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Creates a new Vector3 copied from the current Vector3
  2587. * @returns the new Vector3
  2588. */
  2589. clone(): Vector3;
  2590. /**
  2591. * Copies the given vector coordinates to the current Vector3 ones
  2592. * @param source defines the source Vector3
  2593. * @returns the current updated Vector3
  2594. */
  2595. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2596. /**
  2597. * Copies the given floats to the current Vector3 coordinates
  2598. * @param x defines the x coordinate of the operand
  2599. * @param y defines the y coordinate of the operand
  2600. * @param z defines the z coordinate of the operand
  2601. * @returns the current updated Vector3
  2602. */
  2603. copyFromFloats(x: number, y: number, z: number): Vector3;
  2604. /**
  2605. * Copies the given floats to the current Vector3 coordinates
  2606. * @param x defines the x coordinate of the operand
  2607. * @param y defines the y coordinate of the operand
  2608. * @param z defines the z coordinate of the operand
  2609. * @returns the current updated Vector3
  2610. */
  2611. set(x: number, y: number, z: number): Vector3;
  2612. /**
  2613. * Copies the given float to the current Vector3 coordinates
  2614. * @param v defines the x, y and z coordinates of the operand
  2615. * @returns the current updated Vector3
  2616. */
  2617. setAll(v: number): Vector3;
  2618. /**
  2619. * Get the clip factor between two vectors
  2620. * @param vector0 defines the first operand
  2621. * @param vector1 defines the second operand
  2622. * @param axis defines the axis to use
  2623. * @param size defines the size along the axis
  2624. * @returns the clip factor
  2625. */
  2626. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2627. /**
  2628. * Get angle between two vectors
  2629. * @param vector0 angle between vector0 and vector1
  2630. * @param vector1 angle between vector0 and vector1
  2631. * @param normal direction of the normal
  2632. * @return the angle between vector0 and vector1
  2633. */
  2634. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2635. /**
  2636. * Returns a new Vector3 set from the index "offset" of the given array
  2637. * @param array defines the source array
  2638. * @param offset defines the offset in the source array
  2639. * @returns the new Vector3
  2640. */
  2641. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2642. /**
  2643. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2644. * This function is deprecated. Use FromArray instead
  2645. * @param array defines the source array
  2646. * @param offset defines the offset in the source array
  2647. * @returns the new Vector3
  2648. */
  2649. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2650. /**
  2651. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2652. * @param array defines the source array
  2653. * @param offset defines the offset in the source array
  2654. * @param result defines the Vector3 where to store the result
  2655. */
  2656. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2657. /**
  2658. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2659. * This function is deprecated. Use FromArrayToRef instead.
  2660. * @param array defines the source array
  2661. * @param offset defines the offset in the source array
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2665. /**
  2666. * Sets the given vector "result" with the given floats.
  2667. * @param x defines the x coordinate of the source
  2668. * @param y defines the y coordinate of the source
  2669. * @param z defines the z coordinate of the source
  2670. * @param result defines the Vector3 where to store the result
  2671. */
  2672. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2673. /**
  2674. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2675. * @returns a new empty Vector3
  2676. */
  2677. static Zero(): Vector3;
  2678. /**
  2679. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2680. * @returns a new unit Vector3
  2681. */
  2682. static One(): Vector3;
  2683. /**
  2684. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2685. * @returns a new up Vector3
  2686. */
  2687. static Up(): Vector3;
  2688. /**
  2689. * Gets a up Vector3 that must not be updated
  2690. */
  2691. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2692. /**
  2693. * Gets a zero Vector3 that must not be updated
  2694. */
  2695. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2696. /**
  2697. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2698. * @returns a new down Vector3
  2699. */
  2700. static Down(): Vector3;
  2701. /**
  2702. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2703. * @returns a new forward Vector3
  2704. */
  2705. static Forward(): Vector3;
  2706. /**
  2707. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2708. * @returns a new forward Vector3
  2709. */
  2710. static Backward(): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2713. * @returns a new right Vector3
  2714. */
  2715. static Right(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2718. * @returns a new left Vector3
  2719. */
  2720. static Left(): Vector3;
  2721. /**
  2722. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2723. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2724. * @param vector defines the Vector3 to transform
  2725. * @param transformation defines the transformation matrix
  2726. * @returns the transformed Vector3
  2727. */
  2728. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2729. /**
  2730. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2731. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2732. * @param vector defines the Vector3 to transform
  2733. * @param transformation defines the transformation matrix
  2734. * @param result defines the Vector3 where to store the result
  2735. */
  2736. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2737. /**
  2738. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2739. * This method computes tranformed coordinates only, not transformed direction vectors
  2740. * @param x define the x coordinate of the source vector
  2741. * @param y define the y coordinate of the source vector
  2742. * @param z define the z coordinate of the source vector
  2743. * @param transformation defines the transformation matrix
  2744. * @param result defines the Vector3 where to store the result
  2745. */
  2746. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2749. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the new Vector3
  2753. */
  2754. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2757. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2765. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2775. * @param value1 defines the first control point
  2776. * @param value2 defines the second control point
  2777. * @param value3 defines the third control point
  2778. * @param value4 defines the fourth control point
  2779. * @param amount defines the amount on the spline to use
  2780. * @returns the new Vector3
  2781. */
  2782. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2783. /**
  2784. * 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"
  2785. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2786. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2787. * @param value defines the current value
  2788. * @param min defines the lower range value
  2789. * @param max defines the upper range value
  2790. * @returns the new Vector3
  2791. */
  2792. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2793. /**
  2794. * 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"
  2795. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2796. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2797. * @param value defines the current value
  2798. * @param min defines the lower range value
  2799. * @param max defines the upper range value
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2803. /**
  2804. * Checks if a given vector is inside a specific range
  2805. * @param v defines the vector to test
  2806. * @param min defines the minimum range
  2807. * @param max defines the maximum range
  2808. */
  2809. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2810. /**
  2811. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2812. * @param value1 defines the first control point
  2813. * @param tangent1 defines the first tangent vector
  2814. * @param value2 defines the second control point
  2815. * @param tangent2 defines the second tangent vector
  2816. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2817. * @returns the new Vector3
  2818. */
  2819. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2820. /**
  2821. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2822. * @param start defines the start value
  2823. * @param end defines the end value
  2824. * @param amount max defines amount between both (between 0 and 1)
  2825. * @returns the new Vector3
  2826. */
  2827. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2828. /**
  2829. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2830. * @param start defines the start value
  2831. * @param end defines the end value
  2832. * @param amount max defines amount between both (between 0 and 1)
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2836. /**
  2837. * Returns the dot product (float) between the vectors "left" and "right"
  2838. * @param left defines the left operand
  2839. * @param right defines the right operand
  2840. * @returns the dot product
  2841. */
  2842. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2843. /**
  2844. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2845. * The cross product is then orthogonal to both "left" and "right"
  2846. * @param left defines the left operand
  2847. * @param right defines the right operand
  2848. * @returns the cross product
  2849. */
  2850. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * Sets the given vector "result" with the cross product of "left" and "right"
  2853. * The cross product is then orthogonal to both "left" and "right"
  2854. * @param left defines the left operand
  2855. * @param right defines the right operand
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 as the normalization of the given vector
  2861. * @param vector defines the Vector3 to normalize
  2862. * @returns the new Vector3
  2863. */
  2864. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2865. /**
  2866. * Sets the given vector "result" with the normalization of the given first vector
  2867. * @param vector defines the Vector3 to normalize
  2868. * @param result defines the Vector3 where to store the result
  2869. */
  2870. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2871. /**
  2872. * Project a Vector3 onto screen space
  2873. * @param vector defines the Vector3 to project
  2874. * @param world defines the world matrix to use
  2875. * @param transform defines the transform (view x projection) matrix to use
  2876. * @param viewport defines the screen viewport to use
  2877. * @returns the new Vector3
  2878. */
  2879. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2880. /** @hidden */
  2881. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2882. /**
  2883. * Unproject from screen space to object space
  2884. * @param source defines the screen space Vector3 to use
  2885. * @param viewportWidth defines the current width of the viewport
  2886. * @param viewportHeight defines the current height of the viewport
  2887. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2888. * @param transform defines the transform (view x projection) matrix to use
  2889. * @returns the new Vector3
  2890. */
  2891. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2892. /**
  2893. * Unproject from screen space to object space
  2894. * @param source defines the screen space Vector3 to use
  2895. * @param viewportWidth defines the current width of the viewport
  2896. * @param viewportHeight defines the current height of the viewport
  2897. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2898. * @param view defines the view matrix to use
  2899. * @param projection defines the projection matrix to use
  2900. * @returns the new Vector3
  2901. */
  2902. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2903. /**
  2904. * Unproject from screen space to object space
  2905. * @param source defines the screen space Vector3 to use
  2906. * @param viewportWidth defines the current width of the viewport
  2907. * @param viewportHeight defines the current height of the viewport
  2908. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2909. * @param view defines the view matrix to use
  2910. * @param projection defines the projection matrix to use
  2911. * @param result defines the Vector3 where to store the result
  2912. */
  2913. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2914. /**
  2915. * Unproject from screen space to object space
  2916. * @param sourceX defines the screen space x coordinate to use
  2917. * @param sourceY defines the screen space y coordinate to use
  2918. * @param sourceZ defines the screen space z coordinate to use
  2919. * @param viewportWidth defines the current width of the viewport
  2920. * @param viewportHeight defines the current height of the viewport
  2921. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2922. * @param view defines the view matrix to use
  2923. * @param projection defines the projection matrix to use
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Gets the minimal coordinate values between two Vector3
  2929. * @param left defines the first operand
  2930. * @param right defines the second operand
  2931. * @returns the new Vector3
  2932. */
  2933. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2934. /**
  2935. * Gets the maximal coordinate values between two Vector3
  2936. * @param left defines the first operand
  2937. * @param right defines the second operand
  2938. * @returns the new Vector3
  2939. */
  2940. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2941. /**
  2942. * Returns the distance between the vectors "value1" and "value2"
  2943. * @param value1 defines the first operand
  2944. * @param value2 defines the second operand
  2945. * @returns the distance
  2946. */
  2947. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2948. /**
  2949. * Returns the squared distance between the vectors "value1" and "value2"
  2950. * @param value1 defines the first operand
  2951. * @param value2 defines the second operand
  2952. * @returns the squared distance
  2953. */
  2954. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2955. /**
  2956. * Returns a new Vector3 located at the center between "value1" and "value2"
  2957. * @param value1 defines the first operand
  2958. * @param value2 defines the second operand
  2959. * @returns the new Vector3
  2960. */
  2961. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2962. /**
  2963. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2964. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2965. * to something in order to rotate it from its local system to the given target system
  2966. * Note: axis1, axis2 and axis3 are normalized during this operation
  2967. * @param axis1 defines the first axis
  2968. * @param axis2 defines the second axis
  2969. * @param axis3 defines the third axis
  2970. * @returns a new Vector3
  2971. */
  2972. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2973. /**
  2974. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2975. * @param axis1 defines the first axis
  2976. * @param axis2 defines the second axis
  2977. * @param axis3 defines the third axis
  2978. * @param ref defines the Vector3 where to store the result
  2979. */
  2980. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2981. }
  2982. /**
  2983. * Vector4 class created for EulerAngle class conversion to Quaternion
  2984. */
  2985. export class Vector4 {
  2986. /** x value of the vector */
  2987. x: number;
  2988. /** y value of the vector */
  2989. y: number;
  2990. /** z value of the vector */
  2991. z: number;
  2992. /** w value of the vector */
  2993. w: number;
  2994. /**
  2995. * Creates a Vector4 object from the given floats.
  2996. * @param x x value of the vector
  2997. * @param y y value of the vector
  2998. * @param z z value of the vector
  2999. * @param w w value of the vector
  3000. */
  3001. constructor(
  3002. /** x value of the vector */
  3003. x: number,
  3004. /** y value of the vector */
  3005. y: number,
  3006. /** z value of the vector */
  3007. z: number,
  3008. /** w value of the vector */
  3009. w: number);
  3010. /**
  3011. * Returns the string with the Vector4 coordinates.
  3012. * @returns a string containing all the vector values
  3013. */
  3014. toString(): string;
  3015. /**
  3016. * Returns the string "Vector4".
  3017. * @returns "Vector4"
  3018. */
  3019. getClassName(): string;
  3020. /**
  3021. * Returns the Vector4 hash code.
  3022. * @returns a unique hash code
  3023. */
  3024. getHashCode(): number;
  3025. /**
  3026. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3027. * @returns the resulting array
  3028. */
  3029. asArray(): number[];
  3030. /**
  3031. * Populates the given array from the given index with the Vector4 coordinates.
  3032. * @param array array to populate
  3033. * @param index index of the array to start at (default: 0)
  3034. * @returns the Vector4.
  3035. */
  3036. toArray(array: FloatArray, index?: number): Vector4;
  3037. /**
  3038. * Adds the given vector to the current Vector4.
  3039. * @param otherVector the vector to add
  3040. * @returns the updated Vector4.
  3041. */
  3042. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3043. /**
  3044. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3045. * @param otherVector the vector to add
  3046. * @returns the resulting vector
  3047. */
  3048. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3049. /**
  3050. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3051. * @param otherVector the vector to add
  3052. * @param result the vector to store the result
  3053. * @returns the current Vector4.
  3054. */
  3055. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3056. /**
  3057. * Subtract in place the given vector from the current Vector4.
  3058. * @param otherVector the vector to subtract
  3059. * @returns the updated Vector4.
  3060. */
  3061. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3062. /**
  3063. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3064. * @param otherVector the vector to add
  3065. * @returns the new vector with the result
  3066. */
  3067. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3068. /**
  3069. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3070. * @param otherVector the vector to subtract
  3071. * @param result the vector to store the result
  3072. * @returns the current Vector4.
  3073. */
  3074. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3075. /**
  3076. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3077. */
  3078. /**
  3079. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3080. * @param x value to subtract
  3081. * @param y value to subtract
  3082. * @param z value to subtract
  3083. * @param w value to subtract
  3084. * @returns new vector containing the result
  3085. */
  3086. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3087. /**
  3088. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3089. * @param x value to subtract
  3090. * @param y value to subtract
  3091. * @param z value to subtract
  3092. * @param w value to subtract
  3093. * @param result the vector to store the result in
  3094. * @returns the current Vector4.
  3095. */
  3096. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3097. /**
  3098. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3099. * @returns a new vector with the negated values
  3100. */
  3101. negate(): Vector4;
  3102. /**
  3103. * Multiplies the current Vector4 coordinates by scale (float).
  3104. * @param scale the number to scale with
  3105. * @returns the updated Vector4.
  3106. */
  3107. scaleInPlace(scale: number): Vector4;
  3108. /**
  3109. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3110. * @param scale the number to scale with
  3111. * @returns a new vector with the result
  3112. */
  3113. scale(scale: number): Vector4;
  3114. /**
  3115. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3116. * @param scale the number to scale with
  3117. * @param result a vector to store the result in
  3118. * @returns the current Vector4.
  3119. */
  3120. scaleToRef(scale: number, result: Vector4): Vector4;
  3121. /**
  3122. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3123. * @param scale defines the scale factor
  3124. * @param result defines the Vector4 object where to store the result
  3125. * @returns the unmodified current Vector4
  3126. */
  3127. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3128. /**
  3129. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3130. * @param otherVector the vector to compare against
  3131. * @returns true if they are equal
  3132. */
  3133. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3134. /**
  3135. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3136. * @param otherVector vector to compare against
  3137. * @param epsilon (Default: very small number)
  3138. * @returns true if they are equal
  3139. */
  3140. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3141. /**
  3142. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3143. * @param x x value to compare against
  3144. * @param y y value to compare against
  3145. * @param z z value to compare against
  3146. * @param w w value to compare against
  3147. * @returns true if equal
  3148. */
  3149. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3150. /**
  3151. * Multiplies in place the current Vector4 by the given one.
  3152. * @param otherVector vector to multiple with
  3153. * @returns the updated Vector4.
  3154. */
  3155. multiplyInPlace(otherVector: Vector4): Vector4;
  3156. /**
  3157. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3158. * @param otherVector vector to multiple with
  3159. * @returns resulting new vector
  3160. */
  3161. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3162. /**
  3163. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3164. * @param otherVector vector to multiple with
  3165. * @param result vector to store the result
  3166. * @returns the current Vector4.
  3167. */
  3168. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3169. /**
  3170. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3171. * @param x x value multiply with
  3172. * @param y y value multiply with
  3173. * @param z z value multiply with
  3174. * @param w w value multiply with
  3175. * @returns resulting new vector
  3176. */
  3177. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3178. /**
  3179. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3180. * @param otherVector vector to devide with
  3181. * @returns resulting new vector
  3182. */
  3183. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3184. /**
  3185. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3186. * @param otherVector vector to devide with
  3187. * @param result vector to store the result
  3188. * @returns the current Vector4.
  3189. */
  3190. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3191. /**
  3192. * Divides the current Vector3 coordinates by the given ones.
  3193. * @param otherVector vector to devide with
  3194. * @returns the updated Vector3.
  3195. */
  3196. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3197. /**
  3198. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3199. * @param other defines the second operand
  3200. * @returns the current updated Vector4
  3201. */
  3202. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3203. /**
  3204. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3205. * @param other defines the second operand
  3206. * @returns the current updated Vector4
  3207. */
  3208. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3209. /**
  3210. * Gets a new Vector4 from current Vector4 floored values
  3211. * @returns a new Vector4
  3212. */
  3213. floor(): Vector4;
  3214. /**
  3215. * Gets a new Vector4 from current Vector3 floored values
  3216. * @returns a new Vector4
  3217. */
  3218. fract(): Vector4;
  3219. /**
  3220. * Returns the Vector4 length (float).
  3221. * @returns the length
  3222. */
  3223. length(): number;
  3224. /**
  3225. * Returns the Vector4 squared length (float).
  3226. * @returns the length squared
  3227. */
  3228. lengthSquared(): number;
  3229. /**
  3230. * Normalizes in place the Vector4.
  3231. * @returns the updated Vector4.
  3232. */
  3233. normalize(): Vector4;
  3234. /**
  3235. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3236. * @returns this converted to a new vector3
  3237. */
  3238. toVector3(): Vector3;
  3239. /**
  3240. * Returns a new Vector4 copied from the current one.
  3241. * @returns the new cloned vector
  3242. */
  3243. clone(): Vector4;
  3244. /**
  3245. * Updates the current Vector4 with the given one coordinates.
  3246. * @param source the source vector to copy from
  3247. * @returns the updated Vector4.
  3248. */
  3249. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Updates the current Vector4 coordinates with the given floats.
  3252. * @param x float to copy from
  3253. * @param y float to copy from
  3254. * @param z float to copy from
  3255. * @param w float to copy from
  3256. * @returns the updated Vector4.
  3257. */
  3258. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3259. /**
  3260. * Updates the current Vector4 coordinates with the given floats.
  3261. * @param x float to set from
  3262. * @param y float to set from
  3263. * @param z float to set from
  3264. * @param w float to set from
  3265. * @returns the updated Vector4.
  3266. */
  3267. set(x: number, y: number, z: number, w: number): Vector4;
  3268. /**
  3269. * Copies the given float to the current Vector3 coordinates
  3270. * @param v defines the x, y, z and w coordinates of the operand
  3271. * @returns the current updated Vector3
  3272. */
  3273. setAll(v: number): Vector4;
  3274. /**
  3275. * Returns a new Vector4 set from the starting index of the given array.
  3276. * @param array the array to pull values from
  3277. * @param offset the offset into the array to start at
  3278. * @returns the new vector
  3279. */
  3280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3281. /**
  3282. * Updates the given vector "result" from the starting index of the given array.
  3283. * @param array the array to pull values from
  3284. * @param offset the offset into the array to start at
  3285. * @param result the vector to store the result in
  3286. */
  3287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3288. /**
  3289. * Updates the given vector "result" from the starting index of the given Float32Array.
  3290. * @param array the array to pull values from
  3291. * @param offset the offset into the array to start at
  3292. * @param result the vector to store the result in
  3293. */
  3294. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3295. /**
  3296. * Updates the given vector "result" coordinates from the given floats.
  3297. * @param x float to set from
  3298. * @param y float to set from
  3299. * @param z float to set from
  3300. * @param w float to set from
  3301. * @param result the vector to the floats in
  3302. */
  3303. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3304. /**
  3305. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3306. * @returns the new vector
  3307. */
  3308. static Zero(): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3311. * @returns the new vector
  3312. */
  3313. static One(): Vector4;
  3314. /**
  3315. * Returns a new normalized Vector4 from the given one.
  3316. * @param vector the vector to normalize
  3317. * @returns the vector
  3318. */
  3319. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Updates the given vector "result" from the normalization of the given one.
  3322. * @param vector the vector to normalize
  3323. * @param result the vector to store the result in
  3324. */
  3325. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3326. /**
  3327. * Returns a vector with the minimum values from the left and right vectors
  3328. * @param left left vector to minimize
  3329. * @param right right vector to minimize
  3330. * @returns a new vector with the minimum of the left and right vector values
  3331. */
  3332. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3333. /**
  3334. * Returns a vector with the maximum values from the left and right vectors
  3335. * @param left left vector to maximize
  3336. * @param right right vector to maximize
  3337. * @returns a new vector with the maximum of the left and right vector values
  3338. */
  3339. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Returns the distance (float) between the vectors "value1" and "value2".
  3342. * @param value1 value to calulate the distance between
  3343. * @param value2 value to calulate the distance between
  3344. * @return the distance between the two vectors
  3345. */
  3346. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3347. /**
  3348. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3349. * @param value1 value to calulate the distance between
  3350. * @param value2 value to calulate the distance between
  3351. * @return the distance between the two vectors squared
  3352. */
  3353. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3354. /**
  3355. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3356. * @param value1 value to calulate the center between
  3357. * @param value2 value to calulate the center between
  3358. * @return the center between the two vectors
  3359. */
  3360. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3361. /**
  3362. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3363. * This methods computes transformed normalized direction vectors only.
  3364. * @param vector the vector to transform
  3365. * @param transformation the transformation matrix to apply
  3366. * @returns the new vector
  3367. */
  3368. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3369. /**
  3370. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3371. * This methods computes transformed normalized direction vectors only.
  3372. * @param vector the vector to transform
  3373. * @param transformation the transformation matrix to apply
  3374. * @param result the vector to store the result in
  3375. */
  3376. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3377. /**
  3378. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3379. * This methods computes transformed normalized direction vectors only.
  3380. * @param x value to transform
  3381. * @param y value to transform
  3382. * @param z value to transform
  3383. * @param w value to transform
  3384. * @param transformation the transformation matrix to apply
  3385. * @param result the vector to store the results in
  3386. */
  3387. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3388. /**
  3389. * Creates a new Vector4 from a Vector3
  3390. * @param source defines the source data
  3391. * @param w defines the 4th component (default is 0)
  3392. * @returns a new Vector4
  3393. */
  3394. static FromVector3(source: Vector3, w?: number): Vector4;
  3395. }
  3396. /**
  3397. * Class used to store quaternion data
  3398. * @see https://en.wikipedia.org/wiki/Quaternion
  3399. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3400. */
  3401. export class Quaternion {
  3402. /** defines the first component (0 by default) */
  3403. x: number;
  3404. /** defines the second component (0 by default) */
  3405. y: number;
  3406. /** defines the third component (0 by default) */
  3407. z: number;
  3408. /** defines the fourth component (1.0 by default) */
  3409. w: number;
  3410. /**
  3411. * Creates a new Quaternion from the given floats
  3412. * @param x defines the first component (0 by default)
  3413. * @param y defines the second component (0 by default)
  3414. * @param z defines the third component (0 by default)
  3415. * @param w defines the fourth component (1.0 by default)
  3416. */
  3417. constructor(
  3418. /** defines the first component (0 by default) */
  3419. x?: number,
  3420. /** defines the second component (0 by default) */
  3421. y?: number,
  3422. /** defines the third component (0 by default) */
  3423. z?: number,
  3424. /** defines the fourth component (1.0 by default) */
  3425. w?: number);
  3426. /**
  3427. * Gets a string representation for the current quaternion
  3428. * @returns a string with the Quaternion coordinates
  3429. */
  3430. toString(): string;
  3431. /**
  3432. * Gets the class name of the quaternion
  3433. * @returns the string "Quaternion"
  3434. */
  3435. getClassName(): string;
  3436. /**
  3437. * Gets a hash code for this quaternion
  3438. * @returns the quaternion hash code
  3439. */
  3440. getHashCode(): number;
  3441. /**
  3442. * Copy the quaternion to an array
  3443. * @returns a new array populated with 4 elements from the quaternion coordinates
  3444. */
  3445. asArray(): number[];
  3446. /**
  3447. * Check if two quaternions are equals
  3448. * @param otherQuaternion defines the second operand
  3449. * @return true if the current quaternion and the given one coordinates are strictly equals
  3450. */
  3451. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3452. /**
  3453. * Clone the current quaternion
  3454. * @returns a new quaternion copied from the current one
  3455. */
  3456. clone(): Quaternion;
  3457. /**
  3458. * Copy a quaternion to the current one
  3459. * @param other defines the other quaternion
  3460. * @returns the updated current quaternion
  3461. */
  3462. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3463. /**
  3464. * Updates the current quaternion with the given float coordinates
  3465. * @param x defines the x coordinate
  3466. * @param y defines the y coordinate
  3467. * @param z defines the z coordinate
  3468. * @param w defines the w coordinate
  3469. * @returns the updated current quaternion
  3470. */
  3471. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3472. /**
  3473. * Updates the current quaternion from the given float coordinates
  3474. * @param x defines the x coordinate
  3475. * @param y defines the y coordinate
  3476. * @param z defines the z coordinate
  3477. * @param w defines the w coordinate
  3478. * @returns the updated current quaternion
  3479. */
  3480. set(x: number, y: number, z: number, w: number): Quaternion;
  3481. /**
  3482. * Adds two quaternions
  3483. * @param other defines the second operand
  3484. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3485. */
  3486. add(other: DeepImmutable<Quaternion>): Quaternion;
  3487. /**
  3488. * Add a quaternion to the current one
  3489. * @param other defines the quaternion to add
  3490. * @returns the current quaternion
  3491. */
  3492. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3493. /**
  3494. * Subtract two quaternions
  3495. * @param other defines the second operand
  3496. * @returns a new quaternion as the subtraction result of the given one from the current one
  3497. */
  3498. subtract(other: Quaternion): Quaternion;
  3499. /**
  3500. * Multiplies the current quaternion by a scale factor
  3501. * @param value defines the scale factor
  3502. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3503. */
  3504. scale(value: number): Quaternion;
  3505. /**
  3506. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3507. * @param scale defines the scale factor
  3508. * @param result defines the Quaternion object where to store the result
  3509. * @returns the unmodified current quaternion
  3510. */
  3511. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3512. /**
  3513. * Multiplies in place the current quaternion by a scale factor
  3514. * @param value defines the scale factor
  3515. * @returns the current modified quaternion
  3516. */
  3517. scaleInPlace(value: number): Quaternion;
  3518. /**
  3519. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3520. * @param scale defines the scale factor
  3521. * @param result defines the Quaternion object where to store the result
  3522. * @returns the unmodified current quaternion
  3523. */
  3524. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies two quaternions
  3527. * @param q1 defines the second operand
  3528. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3529. */
  3530. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3531. /**
  3532. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3533. * @param q1 defines the second operand
  3534. * @param result defines the target quaternion
  3535. * @returns the current quaternion
  3536. */
  3537. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3538. /**
  3539. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3540. * @param q1 defines the second operand
  3541. * @returns the currentupdated quaternion
  3542. */
  3543. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3544. /**
  3545. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3546. * @param ref defines the target quaternion
  3547. * @returns the current quaternion
  3548. */
  3549. conjugateToRef(ref: Quaternion): Quaternion;
  3550. /**
  3551. * Conjugates in place (1-q) the current quaternion
  3552. * @returns the current updated quaternion
  3553. */
  3554. conjugateInPlace(): Quaternion;
  3555. /**
  3556. * Conjugates in place (1-q) the current quaternion
  3557. * @returns a new quaternion
  3558. */
  3559. conjugate(): Quaternion;
  3560. /**
  3561. * Gets length of current quaternion
  3562. * @returns the quaternion length (float)
  3563. */
  3564. length(): number;
  3565. /**
  3566. * Normalize in place the current quaternion
  3567. * @returns the current updated quaternion
  3568. */
  3569. normalize(): Quaternion;
  3570. /**
  3571. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3572. * @param order is a reserved parameter and is ignore for now
  3573. * @returns a new Vector3 containing the Euler angles
  3574. */
  3575. toEulerAngles(order?: string): Vector3;
  3576. /**
  3577. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3578. * @param result defines the vector which will be filled with the Euler angles
  3579. * @param order is a reserved parameter and is ignore for now
  3580. * @returns the current unchanged quaternion
  3581. */
  3582. toEulerAnglesToRef(result: Vector3): Quaternion;
  3583. /**
  3584. * Updates the given rotation matrix with the current quaternion values
  3585. * @param result defines the target matrix
  3586. * @returns the current unchanged quaternion
  3587. */
  3588. toRotationMatrix(result: Matrix): Quaternion;
  3589. /**
  3590. * Updates the current quaternion from the given rotation matrix values
  3591. * @param matrix defines the source matrix
  3592. * @returns the current updated quaternion
  3593. */
  3594. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3595. /**
  3596. * Creates a new quaternion from a rotation matrix
  3597. * @param matrix defines the source matrix
  3598. * @returns a new quaternion created from the given rotation matrix values
  3599. */
  3600. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3601. /**
  3602. * Updates the given quaternion with the given rotation matrix values
  3603. * @param matrix defines the source matrix
  3604. * @param result defines the target quaternion
  3605. */
  3606. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3607. /**
  3608. * Returns the dot product (float) between the quaternions "left" and "right"
  3609. * @param left defines the left operand
  3610. * @param right defines the right operand
  3611. * @returns the dot product
  3612. */
  3613. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3614. /**
  3615. * Checks if the two quaternions are close to each other
  3616. * @param quat0 defines the first quaternion to check
  3617. * @param quat1 defines the second quaternion to check
  3618. * @returns true if the two quaternions are close to each other
  3619. */
  3620. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3621. /**
  3622. * Creates an empty quaternion
  3623. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3624. */
  3625. static Zero(): Quaternion;
  3626. /**
  3627. * Inverse a given quaternion
  3628. * @param q defines the source quaternion
  3629. * @returns a new quaternion as the inverted current quaternion
  3630. */
  3631. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3632. /**
  3633. * Inverse a given quaternion
  3634. * @param q defines the source quaternion
  3635. * @param result the quaternion the result will be stored in
  3636. * @returns the result quaternion
  3637. */
  3638. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3639. /**
  3640. * Creates an identity quaternion
  3641. * @returns the identity quaternion
  3642. */
  3643. static Identity(): Quaternion;
  3644. /**
  3645. * Gets a boolean indicating if the given quaternion is identity
  3646. * @param quaternion defines the quaternion to check
  3647. * @returns true if the quaternion is identity
  3648. */
  3649. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3650. /**
  3651. * Creates a quaternion from a rotation around an axis
  3652. * @param axis defines the axis to use
  3653. * @param angle defines the angle to use
  3654. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3655. */
  3656. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3657. /**
  3658. * Creates a rotation around an axis and stores it into the given quaternion
  3659. * @param axis defines the axis to use
  3660. * @param angle defines the angle to use
  3661. * @param result defines the target quaternion
  3662. * @returns the target quaternion
  3663. */
  3664. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates a new quaternion from data stored into an array
  3667. * @param array defines the data source
  3668. * @param offset defines the offset in the source array where the data starts
  3669. * @returns a new quaternion
  3670. */
  3671. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3672. /**
  3673. * Create a quaternion from Euler rotation angles
  3674. * @param x Pitch
  3675. * @param y Yaw
  3676. * @param z Roll
  3677. * @returns the new Quaternion
  3678. */
  3679. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3680. /**
  3681. * Updates a quaternion from Euler rotation angles
  3682. * @param x Pitch
  3683. * @param y Yaw
  3684. * @param z Roll
  3685. * @param result the quaternion to store the result
  3686. * @returns the updated quaternion
  3687. */
  3688. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3689. /**
  3690. * Create a quaternion from Euler rotation vector
  3691. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3692. * @returns the new Quaternion
  3693. */
  3694. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3695. /**
  3696. * Updates a quaternion from Euler rotation vector
  3697. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3698. * @param result the quaternion to store the result
  3699. * @returns the updated quaternion
  3700. */
  3701. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3702. /**
  3703. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3704. * @param yaw defines the rotation around Y axis
  3705. * @param pitch defines the rotation around X axis
  3706. * @param roll defines the rotation around Z axis
  3707. * @returns the new quaternion
  3708. */
  3709. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3710. /**
  3711. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3712. * @param yaw defines the rotation around Y axis
  3713. * @param pitch defines the rotation around X axis
  3714. * @param roll defines the rotation around Z axis
  3715. * @param result defines the target quaternion
  3716. */
  3717. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3718. /**
  3719. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3720. * @param alpha defines the rotation around first axis
  3721. * @param beta defines the rotation around second axis
  3722. * @param gamma defines the rotation around third axis
  3723. * @returns the new quaternion
  3724. */
  3725. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3726. /**
  3727. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3728. * @param alpha defines the rotation around first axis
  3729. * @param beta defines the rotation around second axis
  3730. * @param gamma defines the rotation around third axis
  3731. * @param result defines the target quaternion
  3732. */
  3733. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3734. /**
  3735. * 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)
  3736. * @param axis1 defines the first axis
  3737. * @param axis2 defines the second axis
  3738. * @param axis3 defines the third axis
  3739. * @returns the new quaternion
  3740. */
  3741. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3742. /**
  3743. * 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
  3744. * @param axis1 defines the first axis
  3745. * @param axis2 defines the second axis
  3746. * @param axis3 defines the third axis
  3747. * @param ref defines the target quaternion
  3748. */
  3749. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3750. /**
  3751. * Interpolates between two quaternions
  3752. * @param left defines first quaternion
  3753. * @param right defines second quaternion
  3754. * @param amount defines the gradient to use
  3755. * @returns the new interpolated quaternion
  3756. */
  3757. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3758. /**
  3759. * Interpolates between two quaternions and stores it into a target quaternion
  3760. * @param left defines first quaternion
  3761. * @param right defines second quaternion
  3762. * @param amount defines the gradient to use
  3763. * @param result defines the target quaternion
  3764. */
  3765. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3766. /**
  3767. * Interpolate between two quaternions using Hermite interpolation
  3768. * @param value1 defines first quaternion
  3769. * @param tangent1 defines the incoming tangent
  3770. * @param value2 defines second quaternion
  3771. * @param tangent2 defines the outgoing tangent
  3772. * @param amount defines the target quaternion
  3773. * @returns the new interpolated quaternion
  3774. */
  3775. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3776. }
  3777. /**
  3778. * Class used to store matrix data (4x4)
  3779. */
  3780. export class Matrix {
  3781. private static _updateFlagSeed;
  3782. private static _identityReadOnly;
  3783. private _isIdentity;
  3784. private _isIdentityDirty;
  3785. private _isIdentity3x2;
  3786. private _isIdentity3x2Dirty;
  3787. /**
  3788. * Gets the update flag of the matrix which is an unique number for the matrix.
  3789. * It will be incremented every time the matrix data change.
  3790. * You can use it to speed the comparison between two versions of the same matrix.
  3791. */
  3792. updateFlag: number;
  3793. private readonly _m;
  3794. /**
  3795. * Gets the internal data of the matrix
  3796. */
  3797. readonly m: DeepImmutable<Float32Array>;
  3798. /** @hidden */
  3799. _markAsUpdated(): void;
  3800. /** @hidden */
  3801. private _updateIdentityStatus;
  3802. /**
  3803. * Creates an empty matrix (filled with zeros)
  3804. */
  3805. constructor();
  3806. /**
  3807. * Check if the current matrix is identity
  3808. * @returns true is the matrix is the identity matrix
  3809. */
  3810. isIdentity(): boolean;
  3811. /**
  3812. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3813. * @returns true is the matrix is the identity matrix
  3814. */
  3815. isIdentityAs3x2(): boolean;
  3816. /**
  3817. * Gets the determinant of the matrix
  3818. * @returns the matrix determinant
  3819. */
  3820. determinant(): number;
  3821. /**
  3822. * Returns the matrix as a Float32Array
  3823. * @returns the matrix underlying array
  3824. */
  3825. toArray(): DeepImmutable<Float32Array>;
  3826. /**
  3827. * Returns the matrix as a Float32Array
  3828. * @returns the matrix underlying array.
  3829. */
  3830. asArray(): DeepImmutable<Float32Array>;
  3831. /**
  3832. * Inverts the current matrix in place
  3833. * @returns the current inverted matrix
  3834. */
  3835. invert(): Matrix;
  3836. /**
  3837. * Sets all the matrix elements to zero
  3838. * @returns the current matrix
  3839. */
  3840. reset(): Matrix;
  3841. /**
  3842. * Adds the current matrix with a second one
  3843. * @param other defines the matrix to add
  3844. * @returns a new matrix as the addition of the current matrix and the given one
  3845. */
  3846. add(other: DeepImmutable<Matrix>): Matrix;
  3847. /**
  3848. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3849. * @param other defines the matrix to add
  3850. * @param result defines the target matrix
  3851. * @returns the current matrix
  3852. */
  3853. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3854. /**
  3855. * Adds in place the given matrix to the current matrix
  3856. * @param other defines the second operand
  3857. * @returns the current updated matrix
  3858. */
  3859. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3860. /**
  3861. * Sets the given matrix to the current inverted Matrix
  3862. * @param other defines the target matrix
  3863. * @returns the unmodified current matrix
  3864. */
  3865. invertToRef(other: Matrix): Matrix;
  3866. /**
  3867. * add a value at the specified position in the current Matrix
  3868. * @param index the index of the value within the matrix. between 0 and 15.
  3869. * @param value the value to be added
  3870. * @returns the current updated matrix
  3871. */
  3872. addAtIndex(index: number, value: number): Matrix;
  3873. /**
  3874. * mutiply the specified position in the current Matrix by a value
  3875. * @param index the index of the value within the matrix. between 0 and 15.
  3876. * @param value the value to be added
  3877. * @returns the current updated matrix
  3878. */
  3879. multiplyAtIndex(index: number, value: number): Matrix;
  3880. /**
  3881. * Inserts the translation vector (using 3 floats) in the current matrix
  3882. * @param x defines the 1st component of the translation
  3883. * @param y defines the 2nd component of the translation
  3884. * @param z defines the 3rd component of the translation
  3885. * @returns the current updated matrix
  3886. */
  3887. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3888. /**
  3889. * Adds the translation vector (using 3 floats) in the current matrix
  3890. * @param x defines the 1st component of the translation
  3891. * @param y defines the 2nd component of the translation
  3892. * @param z defines the 3rd component of the translation
  3893. * @returns the current updated matrix
  3894. */
  3895. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3896. /**
  3897. * Inserts the translation vector in the current matrix
  3898. * @param vector3 defines the translation to insert
  3899. * @returns the current updated matrix
  3900. */
  3901. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3902. /**
  3903. * Gets the translation value of the current matrix
  3904. * @returns a new Vector3 as the extracted translation from the matrix
  3905. */
  3906. getTranslation(): Vector3;
  3907. /**
  3908. * Fill a Vector3 with the extracted translation from the matrix
  3909. * @param result defines the Vector3 where to store the translation
  3910. * @returns the current matrix
  3911. */
  3912. getTranslationToRef(result: Vector3): Matrix;
  3913. /**
  3914. * Remove rotation and scaling part from the matrix
  3915. * @returns the updated matrix
  3916. */
  3917. removeRotationAndScaling(): Matrix;
  3918. /**
  3919. * Multiply two matrices
  3920. * @param other defines the second operand
  3921. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3922. */
  3923. multiply(other: DeepImmutable<Matrix>): Matrix;
  3924. /**
  3925. * Copy the current matrix from the given one
  3926. * @param other defines the source matrix
  3927. * @returns the current updated matrix
  3928. */
  3929. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Populates the given array from the starting index with the current matrix values
  3932. * @param array defines the target array
  3933. * @param offset defines the offset in the target array where to start storing values
  3934. * @returns the current matrix
  3935. */
  3936. copyToArray(array: Float32Array, offset?: number): Matrix;
  3937. /**
  3938. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3939. * @param other defines the second operand
  3940. * @param result defines the matrix where to store the multiplication
  3941. * @returns the current matrix
  3942. */
  3943. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3944. /**
  3945. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3946. * @param other defines the second operand
  3947. * @param result defines the array where to store the multiplication
  3948. * @param offset defines the offset in the target array where to start storing values
  3949. * @returns the current matrix
  3950. */
  3951. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3952. /**
  3953. * Check equality between this matrix and a second one
  3954. * @param value defines the second matrix to compare
  3955. * @returns true is the current matrix and the given one values are strictly equal
  3956. */
  3957. equals(value: DeepImmutable<Matrix>): boolean;
  3958. /**
  3959. * Clone the current matrix
  3960. * @returns a new matrix from the current matrix
  3961. */
  3962. clone(): Matrix;
  3963. /**
  3964. * Returns the name of the current matrix class
  3965. * @returns the string "Matrix"
  3966. */
  3967. getClassName(): string;
  3968. /**
  3969. * Gets the hash code of the current matrix
  3970. * @returns the hash code
  3971. */
  3972. getHashCode(): number;
  3973. /**
  3974. * Decomposes the current Matrix into a translation, rotation and scaling components
  3975. * @param scale defines the scale vector3 given as a reference to update
  3976. * @param rotation defines the rotation quaternion given as a reference to update
  3977. * @param translation defines the translation vector3 given as a reference to update
  3978. * @returns true if operation was successful
  3979. */
  3980. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3981. /**
  3982. * Gets specific row of the matrix
  3983. * @param index defines the number of the row to get
  3984. * @returns the index-th row of the current matrix as a new Vector4
  3985. */
  3986. getRow(index: number): Nullable<Vector4>;
  3987. /**
  3988. * Sets the index-th row of the current matrix to the vector4 values
  3989. * @param index defines the number of the row to set
  3990. * @param row defines the target vector4
  3991. * @returns the updated current matrix
  3992. */
  3993. setRow(index: number, row: Vector4): Matrix;
  3994. /**
  3995. * Compute the transpose of the matrix
  3996. * @returns the new transposed matrix
  3997. */
  3998. transpose(): Matrix;
  3999. /**
  4000. * Compute the transpose of the matrix and store it in a given matrix
  4001. * @param result defines the target matrix
  4002. * @returns the current matrix
  4003. */
  4004. transposeToRef(result: Matrix): Matrix;
  4005. /**
  4006. * Sets the index-th row of the current matrix with the given 4 x float values
  4007. * @param index defines the row index
  4008. * @param x defines the x component to set
  4009. * @param y defines the y component to set
  4010. * @param z defines the z component to set
  4011. * @param w defines the w component to set
  4012. * @returns the updated current matrix
  4013. */
  4014. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4015. /**
  4016. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4017. * @param scale defines the scale factor
  4018. * @returns a new matrix
  4019. */
  4020. scale(scale: number): Matrix;
  4021. /**
  4022. * Scale the current matrix values by a factor to a given result matrix
  4023. * @param scale defines the scale factor
  4024. * @param result defines the matrix to store the result
  4025. * @returns the current matrix
  4026. */
  4027. scaleToRef(scale: number, result: Matrix): Matrix;
  4028. /**
  4029. * Scale the current matrix values by a factor and add the result to a given matrix
  4030. * @param scale defines the scale factor
  4031. * @param result defines the Matrix to store the result
  4032. * @returns the current matrix
  4033. */
  4034. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4035. /**
  4036. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4037. * @param ref matrix to store the result
  4038. */
  4039. toNormalMatrix(ref: Matrix): void;
  4040. /**
  4041. * Gets only rotation part of the current matrix
  4042. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4043. */
  4044. getRotationMatrix(): Matrix;
  4045. /**
  4046. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4047. * @param result defines the target matrix to store data to
  4048. * @returns the current matrix
  4049. */
  4050. getRotationMatrixToRef(result: Matrix): Matrix;
  4051. /**
  4052. * Toggles model matrix from being right handed to left handed in place and vice versa
  4053. */
  4054. toggleModelMatrixHandInPlace(): void;
  4055. /**
  4056. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4057. */
  4058. toggleProjectionMatrixHandInPlace(): void;
  4059. /**
  4060. * Creates a matrix from an array
  4061. * @param array defines the source array
  4062. * @param offset defines an offset in the source array
  4063. * @returns a new Matrix set from the starting index of the given array
  4064. */
  4065. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4066. /**
  4067. * Copy the content of an array into a given matrix
  4068. * @param array defines the source array
  4069. * @param offset defines an offset in the source array
  4070. * @param result defines the target matrix
  4071. */
  4072. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4073. /**
  4074. * Stores an array into a matrix after having multiplied each component by a given factor
  4075. * @param array defines the source array
  4076. * @param offset defines the offset in the source array
  4077. * @param scale defines the scaling factor
  4078. * @param result defines the target matrix
  4079. */
  4080. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4081. /**
  4082. * Gets an identity matrix that must not be updated
  4083. */
  4084. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4085. /**
  4086. * Stores a list of values (16) inside a given matrix
  4087. * @param initialM11 defines 1st value of 1st row
  4088. * @param initialM12 defines 2nd value of 1st row
  4089. * @param initialM13 defines 3rd value of 1st row
  4090. * @param initialM14 defines 4th value of 1st row
  4091. * @param initialM21 defines 1st value of 2nd row
  4092. * @param initialM22 defines 2nd value of 2nd row
  4093. * @param initialM23 defines 3rd value of 2nd row
  4094. * @param initialM24 defines 4th value of 2nd row
  4095. * @param initialM31 defines 1st value of 3rd row
  4096. * @param initialM32 defines 2nd value of 3rd row
  4097. * @param initialM33 defines 3rd value of 3rd row
  4098. * @param initialM34 defines 4th value of 3rd row
  4099. * @param initialM41 defines 1st value of 4th row
  4100. * @param initialM42 defines 2nd value of 4th row
  4101. * @param initialM43 defines 3rd value of 4th row
  4102. * @param initialM44 defines 4th value of 4th row
  4103. * @param result defines the target matrix
  4104. */
  4105. 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;
  4106. /**
  4107. * Creates new matrix from a list of values (16)
  4108. * @param initialM11 defines 1st value of 1st row
  4109. * @param initialM12 defines 2nd value of 1st row
  4110. * @param initialM13 defines 3rd value of 1st row
  4111. * @param initialM14 defines 4th value of 1st row
  4112. * @param initialM21 defines 1st value of 2nd row
  4113. * @param initialM22 defines 2nd value of 2nd row
  4114. * @param initialM23 defines 3rd value of 2nd row
  4115. * @param initialM24 defines 4th value of 2nd row
  4116. * @param initialM31 defines 1st value of 3rd row
  4117. * @param initialM32 defines 2nd value of 3rd row
  4118. * @param initialM33 defines 3rd value of 3rd row
  4119. * @param initialM34 defines 4th value of 3rd row
  4120. * @param initialM41 defines 1st value of 4th row
  4121. * @param initialM42 defines 2nd value of 4th row
  4122. * @param initialM43 defines 3rd value of 4th row
  4123. * @param initialM44 defines 4th value of 4th row
  4124. * @returns the new matrix
  4125. */
  4126. 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;
  4127. /**
  4128. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4129. * @param scale defines the scale vector3
  4130. * @param rotation defines the rotation quaternion
  4131. * @param translation defines the translation vector3
  4132. * @returns a new matrix
  4133. */
  4134. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4135. /**
  4136. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4137. * @param scale defines the scale vector3
  4138. * @param rotation defines the rotation quaternion
  4139. * @param translation defines the translation vector3
  4140. * @param result defines the target matrix
  4141. */
  4142. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4143. /**
  4144. * Creates a new identity matrix
  4145. * @returns a new identity matrix
  4146. */
  4147. static Identity(): Matrix;
  4148. /**
  4149. * Creates a new identity matrix and stores the result in a given matrix
  4150. * @param result defines the target matrix
  4151. */
  4152. static IdentityToRef(result: Matrix): void;
  4153. /**
  4154. * Creates a new zero matrix
  4155. * @returns a new zero matrix
  4156. */
  4157. static Zero(): Matrix;
  4158. /**
  4159. * Creates a new rotation matrix for "angle" radians around the X axis
  4160. * @param angle defines the angle (in radians) to use
  4161. * @return the new matrix
  4162. */
  4163. static RotationX(angle: number): Matrix;
  4164. /**
  4165. * Creates a new matrix as the invert of a given matrix
  4166. * @param source defines the source matrix
  4167. * @returns the new matrix
  4168. */
  4169. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4170. /**
  4171. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4172. * @param angle defines the angle (in radians) to use
  4173. * @param result defines the target matrix
  4174. */
  4175. static RotationXToRef(angle: number, result: Matrix): void;
  4176. /**
  4177. * Creates a new rotation matrix for "angle" radians around the Y axis
  4178. * @param angle defines the angle (in radians) to use
  4179. * @return the new matrix
  4180. */
  4181. static RotationY(angle: number): Matrix;
  4182. /**
  4183. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4184. * @param angle defines the angle (in radians) to use
  4185. * @param result defines the target matrix
  4186. */
  4187. static RotationYToRef(angle: number, result: Matrix): void;
  4188. /**
  4189. * Creates a new rotation matrix for "angle" radians around the Z axis
  4190. * @param angle defines the angle (in radians) to use
  4191. * @return the new matrix
  4192. */
  4193. static RotationZ(angle: number): Matrix;
  4194. /**
  4195. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4196. * @param angle defines the angle (in radians) to use
  4197. * @param result defines the target matrix
  4198. */
  4199. static RotationZToRef(angle: number, result: Matrix): void;
  4200. /**
  4201. * Creates a new rotation matrix for "angle" radians around the given axis
  4202. * @param axis defines the axis to use
  4203. * @param angle defines the angle (in radians) to use
  4204. * @return the new matrix
  4205. */
  4206. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4207. /**
  4208. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4209. * @param axis defines the axis to use
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4214. /**
  4215. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4216. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4217. * @param from defines the vector to align
  4218. * @param to defines the vector to align to
  4219. * @param result defines the target matrix
  4220. */
  4221. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4222. /**
  4223. * Creates a rotation matrix
  4224. * @param yaw defines the yaw angle in radians (Y axis)
  4225. * @param pitch defines the pitch angle in radians (X axis)
  4226. * @param roll defines the roll angle in radians (X axis)
  4227. * @returns the new rotation matrix
  4228. */
  4229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4230. /**
  4231. * Creates a rotation matrix and stores it in a given matrix
  4232. * @param yaw defines the yaw angle in radians (Y axis)
  4233. * @param pitch defines the pitch angle in radians (X axis)
  4234. * @param roll defines the roll angle in radians (X axis)
  4235. * @param result defines the target matrix
  4236. */
  4237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4238. /**
  4239. * Creates a scaling matrix
  4240. * @param x defines the scale factor on X axis
  4241. * @param y defines the scale factor on Y axis
  4242. * @param z defines the scale factor on Z axis
  4243. * @returns the new matrix
  4244. */
  4245. static Scaling(x: number, y: number, z: number): Matrix;
  4246. /**
  4247. * Creates a scaling matrix and stores it in a given matrix
  4248. * @param x defines the scale factor on X axis
  4249. * @param y defines the scale factor on Y axis
  4250. * @param z defines the scale factor on Z axis
  4251. * @param result defines the target matrix
  4252. */
  4253. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4254. /**
  4255. * Creates a translation matrix
  4256. * @param x defines the translation on X axis
  4257. * @param y defines the translation on Y axis
  4258. * @param z defines the translationon Z axis
  4259. * @returns the new matrix
  4260. */
  4261. static Translation(x: number, y: number, z: number): Matrix;
  4262. /**
  4263. * Creates a translation matrix and stores it in a given matrix
  4264. * @param x defines the translation on X axis
  4265. * @param y defines the translation on Y axis
  4266. * @param z defines the translationon Z axis
  4267. * @param result defines the target matrix
  4268. */
  4269. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4270. /**
  4271. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4272. * @param startValue defines the start value
  4273. * @param endValue defines the end value
  4274. * @param gradient defines the gradient factor
  4275. * @returns the new matrix
  4276. */
  4277. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4278. /**
  4279. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4280. * @param startValue defines the start value
  4281. * @param endValue defines the end value
  4282. * @param gradient defines the gradient factor
  4283. * @param result defines the Matrix object where to store data
  4284. */
  4285. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4286. /**
  4287. * Builds a new matrix whose values are computed by:
  4288. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4289. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4290. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4291. * @param startValue defines the first matrix
  4292. * @param endValue defines the second matrix
  4293. * @param gradient defines the gradient between the two matrices
  4294. * @returns the new matrix
  4295. */
  4296. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4297. /**
  4298. * Update a matrix to values which are computed by:
  4299. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4300. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4301. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4302. * @param startValue defines the first matrix
  4303. * @param endValue defines the second matrix
  4304. * @param gradient defines the gradient between the two matrices
  4305. * @param result defines the target matrix
  4306. */
  4307. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4308. /**
  4309. * 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"
  4310. * This function works in left handed mode
  4311. * @param eye defines the final position of the entity
  4312. * @param target defines where the entity should look at
  4313. * @param up defines the up vector for the entity
  4314. * @returns the new matrix
  4315. */
  4316. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4317. /**
  4318. * 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".
  4319. * This function works in left handed mode
  4320. * @param eye defines the final position of the entity
  4321. * @param target defines where the entity should look at
  4322. * @param up defines the up vector for the entity
  4323. * @param result defines the target matrix
  4324. */
  4325. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4326. /**
  4327. * 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"
  4328. * This function works in right handed mode
  4329. * @param eye defines the final position of the entity
  4330. * @param target defines where the entity should look at
  4331. * @param up defines the up vector for the entity
  4332. * @returns the new matrix
  4333. */
  4334. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4335. /**
  4336. * 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".
  4337. * This function works in right handed mode
  4338. * @param eye defines the final position of the entity
  4339. * @param target defines where the entity should look at
  4340. * @param up defines the up vector for the entity
  4341. * @param result defines the target matrix
  4342. */
  4343. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4344. /**
  4345. * Create a left-handed orthographic projection matrix
  4346. * @param width defines the viewport width
  4347. * @param height defines the viewport height
  4348. * @param znear defines the near clip plane
  4349. * @param zfar defines the far clip plane
  4350. * @returns a new matrix as a left-handed orthographic projection matrix
  4351. */
  4352. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4353. /**
  4354. * Store a left-handed orthographic projection to a given matrix
  4355. * @param width defines the viewport width
  4356. * @param height defines the viewport height
  4357. * @param znear defines the near clip plane
  4358. * @param zfar defines the far clip plane
  4359. * @param result defines the target matrix
  4360. */
  4361. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4362. /**
  4363. * Create a left-handed orthographic projection matrix
  4364. * @param left defines the viewport left coordinate
  4365. * @param right defines the viewport right coordinate
  4366. * @param bottom defines the viewport bottom coordinate
  4367. * @param top defines the viewport top coordinate
  4368. * @param znear defines the near clip plane
  4369. * @param zfar defines the far clip plane
  4370. * @returns a new matrix as a left-handed orthographic projection matrix
  4371. */
  4372. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4373. /**
  4374. * Stores a left-handed orthographic projection into a given matrix
  4375. * @param left defines the viewport left coordinate
  4376. * @param right defines the viewport right coordinate
  4377. * @param bottom defines the viewport bottom coordinate
  4378. * @param top defines the viewport top coordinate
  4379. * @param znear defines the near clip plane
  4380. * @param zfar defines the far clip plane
  4381. * @param result defines the target matrix
  4382. */
  4383. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4384. /**
  4385. * Creates a right-handed orthographic projection matrix
  4386. * @param left defines the viewport left coordinate
  4387. * @param right defines the viewport right coordinate
  4388. * @param bottom defines the viewport bottom coordinate
  4389. * @param top defines the viewport top coordinate
  4390. * @param znear defines the near clip plane
  4391. * @param zfar defines the far clip plane
  4392. * @returns a new matrix as a right-handed orthographic projection matrix
  4393. */
  4394. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4395. /**
  4396. * Stores a right-handed orthographic projection into a given matrix
  4397. * @param left defines the viewport left coordinate
  4398. * @param right defines the viewport right coordinate
  4399. * @param bottom defines the viewport bottom coordinate
  4400. * @param top defines the viewport top coordinate
  4401. * @param znear defines the near clip plane
  4402. * @param zfar defines the far clip plane
  4403. * @param result defines the target matrix
  4404. */
  4405. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4406. /**
  4407. * Creates a left-handed perspective projection matrix
  4408. * @param width defines the viewport width
  4409. * @param height defines the viewport height
  4410. * @param znear defines the near clip plane
  4411. * @param zfar defines the far clip plane
  4412. * @returns a new matrix as a left-handed perspective projection matrix
  4413. */
  4414. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4415. /**
  4416. * Creates a left-handed perspective projection matrix
  4417. * @param fov defines the horizontal field of view
  4418. * @param aspect defines the aspect ratio
  4419. * @param znear defines the near clip plane
  4420. * @param zfar defines the far clip plane
  4421. * @returns a new matrix as a left-handed perspective projection matrix
  4422. */
  4423. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4424. /**
  4425. * Stores a left-handed perspective projection into a given matrix
  4426. * @param fov defines the horizontal field of view
  4427. * @param aspect defines the aspect ratio
  4428. * @param znear defines the near clip plane
  4429. * @param zfar defines the far clip plane
  4430. * @param result defines the target matrix
  4431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4432. */
  4433. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4434. /**
  4435. * Creates a right-handed perspective projection matrix
  4436. * @param fov defines the horizontal field of view
  4437. * @param aspect defines the aspect ratio
  4438. * @param znear defines the near clip plane
  4439. * @param zfar defines the far clip plane
  4440. * @returns a new matrix as a right-handed perspective projection matrix
  4441. */
  4442. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4443. /**
  4444. * Stores a right-handed perspective projection into a given matrix
  4445. * @param fov defines the horizontal field of view
  4446. * @param aspect defines the aspect ratio
  4447. * @param znear defines the near clip plane
  4448. * @param zfar defines the far clip plane
  4449. * @param result defines the target matrix
  4450. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4451. */
  4452. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4453. /**
  4454. * Stores a perspective projection for WebVR info a given matrix
  4455. * @param fov defines the field of view
  4456. * @param znear defines the near clip plane
  4457. * @param zfar defines the far clip plane
  4458. * @param result defines the target matrix
  4459. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4460. */
  4461. static PerspectiveFovWebVRToRef(fov: {
  4462. upDegrees: number;
  4463. downDegrees: number;
  4464. leftDegrees: number;
  4465. rightDegrees: number;
  4466. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4467. /**
  4468. * Computes a complete transformation matrix
  4469. * @param viewport defines the viewport to use
  4470. * @param world defines the world matrix
  4471. * @param view defines the view matrix
  4472. * @param projection defines the projection matrix
  4473. * @param zmin defines the near clip plane
  4474. * @param zmax defines the far clip plane
  4475. * @returns the transformation matrix
  4476. */
  4477. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4478. /**
  4479. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4480. * @param matrix defines the matrix to use
  4481. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4482. */
  4483. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4484. /**
  4485. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4486. * @param matrix defines the matrix to use
  4487. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4488. */
  4489. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4490. /**
  4491. * Compute the transpose of a given matrix
  4492. * @param matrix defines the matrix to transpose
  4493. * @returns the new matrix
  4494. */
  4495. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4496. /**
  4497. * Compute the transpose of a matrix and store it in a target matrix
  4498. * @param matrix defines the matrix to transpose
  4499. * @param result defines the target matrix
  4500. */
  4501. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4502. /**
  4503. * Computes a reflection matrix from a plane
  4504. * @param plane defines the reflection plane
  4505. * @returns a new matrix
  4506. */
  4507. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4508. /**
  4509. * Computes a reflection matrix from a plane
  4510. * @param plane defines the reflection plane
  4511. * @param result defines the target matrix
  4512. */
  4513. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4514. /**
  4515. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4516. * @param xaxis defines the value of the 1st axis
  4517. * @param yaxis defines the value of the 2nd axis
  4518. * @param zaxis defines the value of the 3rd axis
  4519. * @param result defines the target matrix
  4520. */
  4521. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4522. /**
  4523. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4524. * @param quat defines the quaternion to use
  4525. * @param result defines the target matrix
  4526. */
  4527. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4528. }
  4529. /**
  4530. * @hidden
  4531. */
  4532. export class TmpVectors {
  4533. static Vector2: Vector2[];
  4534. static Vector3: Vector3[];
  4535. static Vector4: Vector4[];
  4536. static Quaternion: Quaternion[];
  4537. static Matrix: Matrix[];
  4538. }
  4539. }
  4540. declare module "babylonjs/Maths/math.path" {
  4541. import { DeepImmutable, Nullable } from "babylonjs/types";
  4542. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4543. /**
  4544. * Defines potential orientation for back face culling
  4545. */
  4546. export enum Orientation {
  4547. /**
  4548. * Clockwise
  4549. */
  4550. CW = 0,
  4551. /** Counter clockwise */
  4552. CCW = 1
  4553. }
  4554. /** Class used to represent a Bezier curve */
  4555. export class BezierCurve {
  4556. /**
  4557. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4558. * @param t defines the time
  4559. * @param x1 defines the left coordinate on X axis
  4560. * @param y1 defines the left coordinate on Y axis
  4561. * @param x2 defines the right coordinate on X axis
  4562. * @param y2 defines the right coordinate on Y axis
  4563. * @returns the interpolated value
  4564. */
  4565. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4566. }
  4567. /**
  4568. * Defines angle representation
  4569. */
  4570. export class Angle {
  4571. private _radians;
  4572. /**
  4573. * Creates an Angle object of "radians" radians (float).
  4574. * @param radians the angle in radians
  4575. */
  4576. constructor(radians: number);
  4577. /**
  4578. * Get value in degrees
  4579. * @returns the Angle value in degrees (float)
  4580. */
  4581. degrees(): number;
  4582. /**
  4583. * Get value in radians
  4584. * @returns the Angle value in radians (float)
  4585. */
  4586. radians(): number;
  4587. /**
  4588. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4589. * @param a defines first vector
  4590. * @param b defines second vector
  4591. * @returns a new Angle
  4592. */
  4593. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4594. /**
  4595. * Gets a new Angle object from the given float in radians
  4596. * @param radians defines the angle value in radians
  4597. * @returns a new Angle
  4598. */
  4599. static FromRadians(radians: number): Angle;
  4600. /**
  4601. * Gets a new Angle object from the given float in degrees
  4602. * @param degrees defines the angle value in degrees
  4603. * @returns a new Angle
  4604. */
  4605. static FromDegrees(degrees: number): Angle;
  4606. }
  4607. /**
  4608. * This represents an arc in a 2d space.
  4609. */
  4610. export class Arc2 {
  4611. /** Defines the start point of the arc */
  4612. startPoint: Vector2;
  4613. /** Defines the mid point of the arc */
  4614. midPoint: Vector2;
  4615. /** Defines the end point of the arc */
  4616. endPoint: Vector2;
  4617. /**
  4618. * Defines the center point of the arc.
  4619. */
  4620. centerPoint: Vector2;
  4621. /**
  4622. * Defines the radius of the arc.
  4623. */
  4624. radius: number;
  4625. /**
  4626. * Defines the angle of the arc (from mid point to end point).
  4627. */
  4628. angle: Angle;
  4629. /**
  4630. * Defines the start angle of the arc (from start point to middle point).
  4631. */
  4632. startAngle: Angle;
  4633. /**
  4634. * Defines the orientation of the arc (clock wise/counter clock wise).
  4635. */
  4636. orientation: Orientation;
  4637. /**
  4638. * Creates an Arc object from the three given points : start, middle and end.
  4639. * @param startPoint Defines the start point of the arc
  4640. * @param midPoint Defines the midlle point of the arc
  4641. * @param endPoint Defines the end point of the arc
  4642. */
  4643. constructor(
  4644. /** Defines the start point of the arc */
  4645. startPoint: Vector2,
  4646. /** Defines the mid point of the arc */
  4647. midPoint: Vector2,
  4648. /** Defines the end point of the arc */
  4649. endPoint: Vector2);
  4650. }
  4651. /**
  4652. * Represents a 2D path made up of multiple 2D points
  4653. */
  4654. export class Path2 {
  4655. private _points;
  4656. private _length;
  4657. /**
  4658. * If the path start and end point are the same
  4659. */
  4660. closed: boolean;
  4661. /**
  4662. * Creates a Path2 object from the starting 2D coordinates x and y.
  4663. * @param x the starting points x value
  4664. * @param y the starting points y value
  4665. */
  4666. constructor(x: number, y: number);
  4667. /**
  4668. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4669. * @param x the added points x value
  4670. * @param y the added points y value
  4671. * @returns the updated Path2.
  4672. */
  4673. addLineTo(x: number, y: number): Path2;
  4674. /**
  4675. * 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.
  4676. * @param midX middle point x value
  4677. * @param midY middle point y value
  4678. * @param endX end point x value
  4679. * @param endY end point y value
  4680. * @param numberOfSegments (default: 36)
  4681. * @returns the updated Path2.
  4682. */
  4683. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4684. /**
  4685. * Closes the Path2.
  4686. * @returns the Path2.
  4687. */
  4688. close(): Path2;
  4689. /**
  4690. * Gets the sum of the distance between each sequential point in the path
  4691. * @returns the Path2 total length (float).
  4692. */
  4693. length(): number;
  4694. /**
  4695. * Gets the points which construct the path
  4696. * @returns the Path2 internal array of points.
  4697. */
  4698. getPoints(): Vector2[];
  4699. /**
  4700. * Retreives the point at the distance aways from the starting point
  4701. * @param normalizedLengthPosition the length along the path to retreive the point from
  4702. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4703. */
  4704. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4705. /**
  4706. * Creates a new path starting from an x and y position
  4707. * @param x starting x value
  4708. * @param y starting y value
  4709. * @returns a new Path2 starting at the coordinates (x, y).
  4710. */
  4711. static StartingAt(x: number, y: number): Path2;
  4712. }
  4713. /**
  4714. * Represents a 3D path made up of multiple 3D points
  4715. */
  4716. export class Path3D {
  4717. /**
  4718. * an array of Vector3, the curve axis of the Path3D
  4719. */
  4720. path: Vector3[];
  4721. private _curve;
  4722. private _distances;
  4723. private _tangents;
  4724. private _normals;
  4725. private _binormals;
  4726. private _raw;
  4727. /**
  4728. * new Path3D(path, normal, raw)
  4729. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4730. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4731. * @param path an array of Vector3, the curve axis of the Path3D
  4732. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4733. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4734. */
  4735. constructor(
  4736. /**
  4737. * an array of Vector3, the curve axis of the Path3D
  4738. */
  4739. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4740. /**
  4741. * Returns the Path3D array of successive Vector3 designing its curve.
  4742. * @returns the Path3D array of successive Vector3 designing its curve.
  4743. */
  4744. getCurve(): Vector3[];
  4745. /**
  4746. * Returns an array populated with tangent vectors on each Path3D curve point.
  4747. * @returns an array populated with tangent vectors on each Path3D curve point.
  4748. */
  4749. getTangents(): Vector3[];
  4750. /**
  4751. * Returns an array populated with normal vectors on each Path3D curve point.
  4752. * @returns an array populated with normal vectors on each Path3D curve point.
  4753. */
  4754. getNormals(): Vector3[];
  4755. /**
  4756. * Returns an array populated with binormal vectors on each Path3D curve point.
  4757. * @returns an array populated with binormal vectors on each Path3D curve point.
  4758. */
  4759. getBinormals(): Vector3[];
  4760. /**
  4761. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4762. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4763. */
  4764. getDistances(): number[];
  4765. /**
  4766. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4767. * @param path path which all values are copied into the curves points
  4768. * @param firstNormal which should be projected onto the curve
  4769. * @returns the same object updated.
  4770. */
  4771. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4772. private _compute;
  4773. private _getFirstNonNullVector;
  4774. private _getLastNonNullVector;
  4775. private _normalVector;
  4776. }
  4777. /**
  4778. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4779. * A Curve3 is designed from a series of successive Vector3.
  4780. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4781. */
  4782. export class Curve3 {
  4783. private _points;
  4784. private _length;
  4785. /**
  4786. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4787. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4788. * @param v1 (Vector3) the control point
  4789. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4790. * @param nbPoints (integer) the wanted number of points in the curve
  4791. * @returns the created Curve3
  4792. */
  4793. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4794. /**
  4795. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4796. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4797. * @param v1 (Vector3) the first control point
  4798. * @param v2 (Vector3) the second control point
  4799. * @param v3 (Vector3) the end point of the Cubic Bezier
  4800. * @param nbPoints (integer) the wanted number of points in the curve
  4801. * @returns the created Curve3
  4802. */
  4803. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4804. /**
  4805. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4806. * @param p1 (Vector3) the origin point of the Hermite Spline
  4807. * @param t1 (Vector3) the tangent vector at the origin point
  4808. * @param p2 (Vector3) the end point of the Hermite Spline
  4809. * @param t2 (Vector3) the tangent vector at the end point
  4810. * @param nbPoints (integer) the wanted number of points in the curve
  4811. * @returns the created Curve3
  4812. */
  4813. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4814. /**
  4815. * Returns a Curve3 object along a CatmullRom Spline curve :
  4816. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4817. * @param nbPoints (integer) the wanted number of points between each curve control points
  4818. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4819. * @returns the created Curve3
  4820. */
  4821. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4822. /**
  4823. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4824. * A Curve3 is designed from a series of successive Vector3.
  4825. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4826. * @param points points which make up the curve
  4827. */
  4828. constructor(points: Vector3[]);
  4829. /**
  4830. * @returns the Curve3 stored array of successive Vector3
  4831. */
  4832. getPoints(): Vector3[];
  4833. /**
  4834. * @returns the computed length (float) of the curve.
  4835. */
  4836. length(): number;
  4837. /**
  4838. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4839. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4840. * curveA and curveB keep unchanged.
  4841. * @param curve the curve to continue from this curve
  4842. * @returns the newly constructed curve
  4843. */
  4844. continue(curve: DeepImmutable<Curve3>): Curve3;
  4845. private _computeLength;
  4846. }
  4847. }
  4848. declare module "babylonjs/Animations/easing" {
  4849. /**
  4850. * This represents the main contract an easing function should follow.
  4851. * Easing functions are used throughout the animation system.
  4852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4853. */
  4854. export interface IEasingFunction {
  4855. /**
  4856. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4857. * of the easing function.
  4858. * The link below provides some of the most common examples of easing functions.
  4859. * @see https://easings.net/
  4860. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4861. * @returns the corresponding value on the curve defined by the easing function
  4862. */
  4863. ease(gradient: number): number;
  4864. }
  4865. /**
  4866. * Base class used for every default easing function.
  4867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4868. */
  4869. export class EasingFunction implements IEasingFunction {
  4870. /**
  4871. * Interpolation follows the mathematical formula associated with the easing function.
  4872. */
  4873. static readonly EASINGMODE_EASEIN: number;
  4874. /**
  4875. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4876. */
  4877. static readonly EASINGMODE_EASEOUT: number;
  4878. /**
  4879. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4880. */
  4881. static readonly EASINGMODE_EASEINOUT: number;
  4882. private _easingMode;
  4883. /**
  4884. * Sets the easing mode of the current function.
  4885. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4886. */
  4887. setEasingMode(easingMode: number): void;
  4888. /**
  4889. * Gets the current easing mode.
  4890. * @returns the easing mode
  4891. */
  4892. getEasingMode(): number;
  4893. /**
  4894. * @hidden
  4895. */
  4896. easeInCore(gradient: number): number;
  4897. /**
  4898. * Given an input gradient between 0 and 1, this returns the corresponding value
  4899. * of the easing function.
  4900. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4901. * @returns the corresponding value on the curve defined by the easing function
  4902. */
  4903. ease(gradient: number): number;
  4904. }
  4905. /**
  4906. * Easing function with a circle shape (see link below).
  4907. * @see https://easings.net/#easeInCirc
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export class CircleEase extends EasingFunction implements IEasingFunction {
  4911. /** @hidden */
  4912. easeInCore(gradient: number): number;
  4913. }
  4914. /**
  4915. * Easing function with a ease back shape (see link below).
  4916. * @see https://easings.net/#easeInBack
  4917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4918. */
  4919. export class BackEase extends EasingFunction implements IEasingFunction {
  4920. /** Defines the amplitude of the function */
  4921. amplitude: number;
  4922. /**
  4923. * Instantiates a back ease easing
  4924. * @see https://easings.net/#easeInBack
  4925. * @param amplitude Defines the amplitude of the function
  4926. */
  4927. constructor(
  4928. /** Defines the amplitude of the function */
  4929. amplitude?: number);
  4930. /** @hidden */
  4931. easeInCore(gradient: number): number;
  4932. }
  4933. /**
  4934. * Easing function with a bouncing shape (see link below).
  4935. * @see https://easings.net/#easeInBounce
  4936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4937. */
  4938. export class BounceEase extends EasingFunction implements IEasingFunction {
  4939. /** Defines the number of bounces */
  4940. bounces: number;
  4941. /** Defines the amplitude of the bounce */
  4942. bounciness: number;
  4943. /**
  4944. * Instantiates a bounce easing
  4945. * @see https://easings.net/#easeInBounce
  4946. * @param bounces Defines the number of bounces
  4947. * @param bounciness Defines the amplitude of the bounce
  4948. */
  4949. constructor(
  4950. /** Defines the number of bounces */
  4951. bounces?: number,
  4952. /** Defines the amplitude of the bounce */
  4953. bounciness?: number);
  4954. /** @hidden */
  4955. easeInCore(gradient: number): number;
  4956. }
  4957. /**
  4958. * Easing function with a power of 3 shape (see link below).
  4959. * @see https://easings.net/#easeInCubic
  4960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4961. */
  4962. export class CubicEase extends EasingFunction implements IEasingFunction {
  4963. /** @hidden */
  4964. easeInCore(gradient: number): number;
  4965. }
  4966. /**
  4967. * Easing function with an elastic shape (see link below).
  4968. * @see https://easings.net/#easeInElastic
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4972. /** Defines the number of oscillations*/
  4973. oscillations: number;
  4974. /** Defines the amplitude of the oscillations*/
  4975. springiness: number;
  4976. /**
  4977. * Instantiates an elastic easing function
  4978. * @see https://easings.net/#easeInElastic
  4979. * @param oscillations Defines the number of oscillations
  4980. * @param springiness Defines the amplitude of the oscillations
  4981. */
  4982. constructor(
  4983. /** Defines the number of oscillations*/
  4984. oscillations?: number,
  4985. /** Defines the amplitude of the oscillations*/
  4986. springiness?: number);
  4987. /** @hidden */
  4988. easeInCore(gradient: number): number;
  4989. }
  4990. /**
  4991. * Easing function with an exponential shape (see link below).
  4992. * @see https://easings.net/#easeInExpo
  4993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4994. */
  4995. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4996. /** Defines the exponent of the function */
  4997. exponent: number;
  4998. /**
  4999. * Instantiates an exponential easing function
  5000. * @see https://easings.net/#easeInExpo
  5001. * @param exponent Defines the exponent of the function
  5002. */
  5003. constructor(
  5004. /** Defines the exponent of the function */
  5005. exponent?: number);
  5006. /** @hidden */
  5007. easeInCore(gradient: number): number;
  5008. }
  5009. /**
  5010. * Easing function with a power shape (see link below).
  5011. * @see https://easings.net/#easeInQuad
  5012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5013. */
  5014. export class PowerEase extends EasingFunction implements IEasingFunction {
  5015. /** Defines the power of the function */
  5016. power: number;
  5017. /**
  5018. * Instantiates an power base easing function
  5019. * @see https://easings.net/#easeInQuad
  5020. * @param power Defines the power of the function
  5021. */
  5022. constructor(
  5023. /** Defines the power of the function */
  5024. power?: number);
  5025. /** @hidden */
  5026. easeInCore(gradient: number): number;
  5027. }
  5028. /**
  5029. * Easing function with a power of 2 shape (see link below).
  5030. * @see https://easings.net/#easeInQuad
  5031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5032. */
  5033. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5034. /** @hidden */
  5035. easeInCore(gradient: number): number;
  5036. }
  5037. /**
  5038. * Easing function with a power of 4 shape (see link below).
  5039. * @see https://easings.net/#easeInQuart
  5040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5041. */
  5042. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with a power of 5 shape (see link below).
  5048. * @see https://easings.net/#easeInQuint
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5052. /** @hidden */
  5053. easeInCore(gradient: number): number;
  5054. }
  5055. /**
  5056. * Easing function with a sin shape (see link below).
  5057. * @see https://easings.net/#easeInSine
  5058. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5059. */
  5060. export class SineEase extends EasingFunction implements IEasingFunction {
  5061. /** @hidden */
  5062. easeInCore(gradient: number): number;
  5063. }
  5064. /**
  5065. * Easing function with a bezier shape (see link below).
  5066. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5068. */
  5069. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5070. /** Defines the x component of the start tangent in the bezier curve */
  5071. x1: number;
  5072. /** Defines the y component of the start tangent in the bezier curve */
  5073. y1: number;
  5074. /** Defines the x component of the end tangent in the bezier curve */
  5075. x2: number;
  5076. /** Defines the y component of the end tangent in the bezier curve */
  5077. y2: number;
  5078. /**
  5079. * Instantiates a bezier function
  5080. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5081. * @param x1 Defines the x component of the start tangent in the bezier curve
  5082. * @param y1 Defines the y component of the start tangent in the bezier curve
  5083. * @param x2 Defines the x component of the end tangent in the bezier curve
  5084. * @param y2 Defines the y component of the end tangent in the bezier curve
  5085. */
  5086. constructor(
  5087. /** Defines the x component of the start tangent in the bezier curve */
  5088. x1?: number,
  5089. /** Defines the y component of the start tangent in the bezier curve */
  5090. y1?: number,
  5091. /** Defines the x component of the end tangent in the bezier curve */
  5092. x2?: number,
  5093. /** Defines the y component of the end tangent in the bezier curve */
  5094. y2?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. }
  5099. declare module "babylonjs/Maths/math.color" {
  5100. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5101. /**
  5102. * Class used to hold a RBG color
  5103. */
  5104. export class Color3 {
  5105. /**
  5106. * Defines the red component (between 0 and 1, default is 0)
  5107. */
  5108. r: number;
  5109. /**
  5110. * Defines the green component (between 0 and 1, default is 0)
  5111. */
  5112. g: number;
  5113. /**
  5114. * Defines the blue component (between 0 and 1, default is 0)
  5115. */
  5116. b: number;
  5117. /**
  5118. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5119. * @param r defines the red component (between 0 and 1, default is 0)
  5120. * @param g defines the green component (between 0 and 1, default is 0)
  5121. * @param b defines the blue component (between 0 and 1, default is 0)
  5122. */
  5123. constructor(
  5124. /**
  5125. * Defines the red component (between 0 and 1, default is 0)
  5126. */
  5127. r?: number,
  5128. /**
  5129. * Defines the green component (between 0 and 1, default is 0)
  5130. */
  5131. g?: number,
  5132. /**
  5133. * Defines the blue component (between 0 and 1, default is 0)
  5134. */
  5135. b?: number);
  5136. /**
  5137. * Creates a string with the Color3 current values
  5138. * @returns the string representation of the Color3 object
  5139. */
  5140. toString(): string;
  5141. /**
  5142. * Returns the string "Color3"
  5143. * @returns "Color3"
  5144. */
  5145. getClassName(): string;
  5146. /**
  5147. * Compute the Color3 hash code
  5148. * @returns an unique number that can be used to hash Color3 objects
  5149. */
  5150. getHashCode(): number;
  5151. /**
  5152. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5153. * @param array defines the array where to store the r,g,b components
  5154. * @param index defines an optional index in the target array to define where to start storing values
  5155. * @returns the current Color3 object
  5156. */
  5157. toArray(array: FloatArray, index?: number): Color3;
  5158. /**
  5159. * Returns a new Color4 object from the current Color3 and the given alpha
  5160. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5161. * @returns a new Color4 object
  5162. */
  5163. toColor4(alpha?: number): Color4;
  5164. /**
  5165. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5166. * @returns the new array
  5167. */
  5168. asArray(): number[];
  5169. /**
  5170. * Returns the luminance value
  5171. * @returns a float value
  5172. */
  5173. toLuminance(): number;
  5174. /**
  5175. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5176. * @param otherColor defines the second operand
  5177. * @returns the new Color3 object
  5178. */
  5179. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5180. /**
  5181. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5182. * @param otherColor defines the second operand
  5183. * @param result defines the Color3 object where to store the result
  5184. * @returns the current Color3
  5185. */
  5186. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5187. /**
  5188. * Determines equality between Color3 objects
  5189. * @param otherColor defines the second operand
  5190. * @returns true if the rgb values are equal to the given ones
  5191. */
  5192. equals(otherColor: DeepImmutable<Color3>): boolean;
  5193. /**
  5194. * Determines equality between the current Color3 object and a set of r,b,g values
  5195. * @param r defines the red component to check
  5196. * @param g defines the green component to check
  5197. * @param b defines the blue component to check
  5198. * @returns true if the rgb values are equal to the given ones
  5199. */
  5200. equalsFloats(r: number, g: number, b: number): boolean;
  5201. /**
  5202. * Multiplies in place each rgb value by scale
  5203. * @param scale defines the scaling factor
  5204. * @returns the updated Color3
  5205. */
  5206. scale(scale: number): Color3;
  5207. /**
  5208. * Multiplies the rgb values by scale and stores the result into "result"
  5209. * @param scale defines the scaling factor
  5210. * @param result defines the Color3 object where to store the result
  5211. * @returns the unmodified current Color3
  5212. */
  5213. scaleToRef(scale: number, result: Color3): Color3;
  5214. /**
  5215. * Scale the current Color3 values by a factor and add the result to a given Color3
  5216. * @param scale defines the scale factor
  5217. * @param result defines color to store the result into
  5218. * @returns the unmodified current Color3
  5219. */
  5220. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5221. /**
  5222. * Clamps the rgb values by the min and max values and stores the result into "result"
  5223. * @param min defines minimum clamping value (default is 0)
  5224. * @param max defines maximum clamping value (default is 1)
  5225. * @param result defines color to store the result into
  5226. * @returns the original Color3
  5227. */
  5228. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5229. /**
  5230. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5231. * @param otherColor defines the second operand
  5232. * @returns the new Color3
  5233. */
  5234. add(otherColor: DeepImmutable<Color3>): Color3;
  5235. /**
  5236. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5237. * @param otherColor defines the second operand
  5238. * @param result defines Color3 object to store the result into
  5239. * @returns the unmodified current Color3
  5240. */
  5241. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5242. /**
  5243. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5244. * @param otherColor defines the second operand
  5245. * @returns the new Color3
  5246. */
  5247. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5248. /**
  5249. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5250. * @param otherColor defines the second operand
  5251. * @param result defines Color3 object to store the result into
  5252. * @returns the unmodified current Color3
  5253. */
  5254. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5255. /**
  5256. * Copy the current object
  5257. * @returns a new Color3 copied the current one
  5258. */
  5259. clone(): Color3;
  5260. /**
  5261. * Copies the rgb values from the source in the current Color3
  5262. * @param source defines the source Color3 object
  5263. * @returns the updated Color3 object
  5264. */
  5265. copyFrom(source: DeepImmutable<Color3>): Color3;
  5266. /**
  5267. * Updates the Color3 rgb values from the given floats
  5268. * @param r defines the red component to read from
  5269. * @param g defines the green component to read from
  5270. * @param b defines the blue component to read from
  5271. * @returns the current Color3 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number): Color3;
  5274. /**
  5275. * Updates the Color3 rgb values from the given floats
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @returns the current Color3 object
  5280. */
  5281. set(r: number, g: number, b: number): Color3;
  5282. /**
  5283. * Compute the Color3 hexadecimal code as a string
  5284. * @returns a string containing the hexadecimal representation of the Color3 object
  5285. */
  5286. toHexString(): string;
  5287. /**
  5288. * Computes a new Color3 converted from the current one to linear space
  5289. * @returns a new Color3 object
  5290. */
  5291. toLinearSpace(): Color3;
  5292. /**
  5293. * Converts current color in rgb space to HSV values
  5294. * @returns a new color3 representing the HSV values
  5295. */
  5296. toHSV(): Color3;
  5297. /**
  5298. * Converts current color in rgb space to HSV values
  5299. * @param result defines the Color3 where to store the HSV values
  5300. */
  5301. toHSVToRef(result: Color3): void;
  5302. /**
  5303. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5304. * @param convertedColor defines the Color3 object where to store the linear space version
  5305. * @returns the unmodified Color3
  5306. */
  5307. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5308. /**
  5309. * Computes a new Color3 converted from the current one to gamma space
  5310. * @returns a new Color3 object
  5311. */
  5312. toGammaSpace(): Color3;
  5313. /**
  5314. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5315. * @param convertedColor defines the Color3 object where to store the gamma space version
  5316. * @returns the unmodified Color3
  5317. */
  5318. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5319. private static _BlackReadOnly;
  5320. /**
  5321. * Convert Hue, saturation and value to a Color3 (RGB)
  5322. * @param hue defines the hue
  5323. * @param saturation defines the saturation
  5324. * @param value defines the value
  5325. * @param result defines the Color3 where to store the RGB values
  5326. */
  5327. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5328. /**
  5329. * Creates a new Color3 from the string containing valid hexadecimal values
  5330. * @param hex defines a string containing valid hexadecimal values
  5331. * @returns a new Color3 object
  5332. */
  5333. static FromHexString(hex: string): Color3;
  5334. /**
  5335. * Creates a new Color3 from the starting index of the given array
  5336. * @param array defines the source array
  5337. * @param offset defines an offset in the source array
  5338. * @returns a new Color3 object
  5339. */
  5340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5341. /**
  5342. * Creates a new Color3 from integer values (< 256)
  5343. * @param r defines the red component to read from (value between 0 and 255)
  5344. * @param g defines the green component to read from (value between 0 and 255)
  5345. * @param b defines the blue component to read from (value between 0 and 255)
  5346. * @returns a new Color3 object
  5347. */
  5348. static FromInts(r: number, g: number, b: number): Color3;
  5349. /**
  5350. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5351. * @param start defines the start Color3 value
  5352. * @param end defines the end Color3 value
  5353. * @param amount defines the gradient value between start and end
  5354. * @returns a new Color3 object
  5355. */
  5356. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5357. /**
  5358. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5359. * @param left defines the start value
  5360. * @param right defines the end value
  5361. * @param amount defines the gradient factor
  5362. * @param result defines the Color3 object where to store the result
  5363. */
  5364. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5365. /**
  5366. * Returns a Color3 value containing a red color
  5367. * @returns a new Color3 object
  5368. */
  5369. static Red(): Color3;
  5370. /**
  5371. * Returns a Color3 value containing a green color
  5372. * @returns a new Color3 object
  5373. */
  5374. static Green(): Color3;
  5375. /**
  5376. * Returns a Color3 value containing a blue color
  5377. * @returns a new Color3 object
  5378. */
  5379. static Blue(): Color3;
  5380. /**
  5381. * Returns a Color3 value containing a black color
  5382. * @returns a new Color3 object
  5383. */
  5384. static Black(): Color3;
  5385. /**
  5386. * Gets a Color3 value containing a black color that must not be updated
  5387. */
  5388. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5389. /**
  5390. * Returns a Color3 value containing a white color
  5391. * @returns a new Color3 object
  5392. */
  5393. static White(): Color3;
  5394. /**
  5395. * Returns a Color3 value containing a purple color
  5396. * @returns a new Color3 object
  5397. */
  5398. static Purple(): Color3;
  5399. /**
  5400. * Returns a Color3 value containing a magenta color
  5401. * @returns a new Color3 object
  5402. */
  5403. static Magenta(): Color3;
  5404. /**
  5405. * Returns a Color3 value containing a yellow color
  5406. * @returns a new Color3 object
  5407. */
  5408. static Yellow(): Color3;
  5409. /**
  5410. * Returns a Color3 value containing a gray color
  5411. * @returns a new Color3 object
  5412. */
  5413. static Gray(): Color3;
  5414. /**
  5415. * Returns a Color3 value containing a teal color
  5416. * @returns a new Color3 object
  5417. */
  5418. static Teal(): Color3;
  5419. /**
  5420. * Returns a Color3 value containing a random color
  5421. * @returns a new Color3 object
  5422. */
  5423. static Random(): Color3;
  5424. }
  5425. /**
  5426. * Class used to hold a RBGA color
  5427. */
  5428. export class Color4 {
  5429. /**
  5430. * Defines the red component (between 0 and 1, default is 0)
  5431. */
  5432. r: number;
  5433. /**
  5434. * Defines the green component (between 0 and 1, default is 0)
  5435. */
  5436. g: number;
  5437. /**
  5438. * Defines the blue component (between 0 and 1, default is 0)
  5439. */
  5440. b: number;
  5441. /**
  5442. * Defines the alpha component (between 0 and 1, default is 1)
  5443. */
  5444. a: number;
  5445. /**
  5446. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5447. * @param r defines the red component (between 0 and 1, default is 0)
  5448. * @param g defines the green component (between 0 and 1, default is 0)
  5449. * @param b defines the blue component (between 0 and 1, default is 0)
  5450. * @param a defines the alpha component (between 0 and 1, default is 1)
  5451. */
  5452. constructor(
  5453. /**
  5454. * Defines the red component (between 0 and 1, default is 0)
  5455. */
  5456. r?: number,
  5457. /**
  5458. * Defines the green component (between 0 and 1, default is 0)
  5459. */
  5460. g?: number,
  5461. /**
  5462. * Defines the blue component (between 0 and 1, default is 0)
  5463. */
  5464. b?: number,
  5465. /**
  5466. * Defines the alpha component (between 0 and 1, default is 1)
  5467. */
  5468. a?: number);
  5469. /**
  5470. * Adds in place the given Color4 values to the current Color4 object
  5471. * @param right defines the second operand
  5472. * @returns the current updated Color4 object
  5473. */
  5474. addInPlace(right: DeepImmutable<Color4>): Color4;
  5475. /**
  5476. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5477. * @returns the new array
  5478. */
  5479. asArray(): number[];
  5480. /**
  5481. * Stores from the starting index in the given array the Color4 successive values
  5482. * @param array defines the array where to store the r,g,b components
  5483. * @param index defines an optional index in the target array to define where to start storing values
  5484. * @returns the current Color4 object
  5485. */
  5486. toArray(array: number[], index?: number): Color4;
  5487. /**
  5488. * Determines equality between Color4 objects
  5489. * @param otherColor defines the second operand
  5490. * @returns true if the rgba values are equal to the given ones
  5491. */
  5492. equals(otherColor: DeepImmutable<Color4>): boolean;
  5493. /**
  5494. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5495. * @param right defines the second operand
  5496. * @returns a new Color4 object
  5497. */
  5498. add(right: DeepImmutable<Color4>): Color4;
  5499. /**
  5500. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5501. * @param right defines the second operand
  5502. * @returns a new Color4 object
  5503. */
  5504. subtract(right: DeepImmutable<Color4>): Color4;
  5505. /**
  5506. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5507. * @param right defines the second operand
  5508. * @param result defines the Color4 object where to store the result
  5509. * @returns the current Color4 object
  5510. */
  5511. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5512. /**
  5513. * Creates a new Color4 with the current Color4 values multiplied by scale
  5514. * @param scale defines the scaling factor to apply
  5515. * @returns a new Color4 object
  5516. */
  5517. scale(scale: number): Color4;
  5518. /**
  5519. * Multiplies the current Color4 values by scale and stores the result in "result"
  5520. * @param scale defines the scaling factor to apply
  5521. * @param result defines the Color4 object where to store the result
  5522. * @returns the current unmodified Color4
  5523. */
  5524. scaleToRef(scale: number, result: Color4): Color4;
  5525. /**
  5526. * Scale the current Color4 values by a factor and add the result to a given Color4
  5527. * @param scale defines the scale factor
  5528. * @param result defines the Color4 object where to store the result
  5529. * @returns the unmodified current Color4
  5530. */
  5531. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5532. /**
  5533. * Clamps the rgb values by the min and max values and stores the result into "result"
  5534. * @param min defines minimum clamping value (default is 0)
  5535. * @param max defines maximum clamping value (default is 1)
  5536. * @param result defines color to store the result into.
  5537. * @returns the cuurent Color4
  5538. */
  5539. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5540. /**
  5541. * Multipy an Color4 value by another and return a new Color4 object
  5542. * @param color defines the Color4 value to multiply by
  5543. * @returns a new Color4 object
  5544. */
  5545. multiply(color: Color4): Color4;
  5546. /**
  5547. * Multipy a Color4 value by another and push the result in a reference value
  5548. * @param color defines the Color4 value to multiply by
  5549. * @param result defines the Color4 to fill the result in
  5550. * @returns the result Color4
  5551. */
  5552. multiplyToRef(color: Color4, result: Color4): Color4;
  5553. /**
  5554. * Creates a string with the Color4 current values
  5555. * @returns the string representation of the Color4 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color4"
  5560. * @returns "Color4"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color4 hash code
  5565. * @returns an unique number that can be used to hash Color4 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Creates a new Color4 copied from the current one
  5570. * @returns a new Color4 object
  5571. */
  5572. clone(): Color4;
  5573. /**
  5574. * Copies the given Color4 values into the current one
  5575. * @param source defines the source Color4 object
  5576. * @returns the current updated Color4 object
  5577. */
  5578. copyFrom(source: Color4): Color4;
  5579. /**
  5580. * Copies the given float values into the current one
  5581. * @param r defines the red component to read from
  5582. * @param g defines the green component to read from
  5583. * @param b defines the blue component to read from
  5584. * @param a defines the alpha component to read from
  5585. * @returns the current updated Color4 object
  5586. */
  5587. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5588. /**
  5589. * Copies the given float values into the current one
  5590. * @param r defines the red component to read from
  5591. * @param g defines the green component to read from
  5592. * @param b defines the blue component to read from
  5593. * @param a defines the alpha component to read from
  5594. * @returns the current updated Color4 object
  5595. */
  5596. set(r: number, g: number, b: number, a: number): Color4;
  5597. /**
  5598. * Compute the Color4 hexadecimal code as a string
  5599. * @returns a string containing the hexadecimal representation of the Color4 object
  5600. */
  5601. toHexString(): string;
  5602. /**
  5603. * Computes a new Color4 converted from the current one to linear space
  5604. * @returns a new Color4 object
  5605. */
  5606. toLinearSpace(): Color4;
  5607. /**
  5608. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5609. * @param convertedColor defines the Color4 object where to store the linear space version
  5610. * @returns the unmodified Color4
  5611. */
  5612. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5613. /**
  5614. * Computes a new Color4 converted from the current one to gamma space
  5615. * @returns a new Color4 object
  5616. */
  5617. toGammaSpace(): Color4;
  5618. /**
  5619. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5620. * @param convertedColor defines the Color4 object where to store the gamma space version
  5621. * @returns the unmodified Color4
  5622. */
  5623. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5624. /**
  5625. * Creates a new Color4 from the string containing valid hexadecimal values
  5626. * @param hex defines a string containing valid hexadecimal values
  5627. * @returns a new Color4 object
  5628. */
  5629. static FromHexString(hex: string): Color4;
  5630. /**
  5631. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5632. * @param left defines the start value
  5633. * @param right defines the end value
  5634. * @param amount defines the gradient factor
  5635. * @returns a new Color4 object
  5636. */
  5637. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5638. /**
  5639. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5640. * @param left defines the start value
  5641. * @param right defines the end value
  5642. * @param amount defines the gradient factor
  5643. * @param result defines the Color4 object where to store data
  5644. */
  5645. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5646. /**
  5647. * Creates a new Color4 from a Color3 and an alpha value
  5648. * @param color3 defines the source Color3 to read from
  5649. * @param alpha defines the alpha component (1.0 by default)
  5650. * @returns a new Color4 object
  5651. */
  5652. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5653. /**
  5654. * Creates a new Color4 from the starting index element of the given array
  5655. * @param array defines the source array to read from
  5656. * @param offset defines the offset in the source array
  5657. * @returns a new Color4 object
  5658. */
  5659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5660. /**
  5661. * Creates a new Color3 from integer values (< 256)
  5662. * @param r defines the red component to read from (value between 0 and 255)
  5663. * @param g defines the green component to read from (value between 0 and 255)
  5664. * @param b defines the blue component to read from (value between 0 and 255)
  5665. * @param a defines the alpha component to read from (value between 0 and 255)
  5666. * @returns a new Color3 object
  5667. */
  5668. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5669. /**
  5670. * Check the content of a given array and convert it to an array containing RGBA data
  5671. * If the original array was already containing count * 4 values then it is returned directly
  5672. * @param colors defines the array to check
  5673. * @param count defines the number of RGBA data to expect
  5674. * @returns an array containing count * 4 values (RGBA)
  5675. */
  5676. static CheckColors4(colors: number[], count: number): number[];
  5677. }
  5678. /**
  5679. * @hidden
  5680. */
  5681. export class TmpColors {
  5682. static Color3: Color3[];
  5683. static Color4: Color4[];
  5684. }
  5685. }
  5686. declare module "babylonjs/Animations/animationKey" {
  5687. /**
  5688. * Defines an interface which represents an animation key frame
  5689. */
  5690. export interface IAnimationKey {
  5691. /**
  5692. * Frame of the key frame
  5693. */
  5694. frame: number;
  5695. /**
  5696. * Value at the specifies key frame
  5697. */
  5698. value: any;
  5699. /**
  5700. * The input tangent for the cubic hermite spline
  5701. */
  5702. inTangent?: any;
  5703. /**
  5704. * The output tangent for the cubic hermite spline
  5705. */
  5706. outTangent?: any;
  5707. /**
  5708. * The animation interpolation type
  5709. */
  5710. interpolation?: AnimationKeyInterpolation;
  5711. }
  5712. /**
  5713. * Enum for the animation key frame interpolation type
  5714. */
  5715. export enum AnimationKeyInterpolation {
  5716. /**
  5717. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5718. */
  5719. STEP = 1
  5720. }
  5721. }
  5722. declare module "babylonjs/Animations/animationRange" {
  5723. /**
  5724. * Represents the range of an animation
  5725. */
  5726. export class AnimationRange {
  5727. /**The name of the animation range**/
  5728. name: string;
  5729. /**The starting frame of the animation */
  5730. from: number;
  5731. /**The ending frame of the animation*/
  5732. to: number;
  5733. /**
  5734. * Initializes the range of an animation
  5735. * @param name The name of the animation range
  5736. * @param from The starting frame of the animation
  5737. * @param to The ending frame of the animation
  5738. */
  5739. constructor(
  5740. /**The name of the animation range**/
  5741. name: string,
  5742. /**The starting frame of the animation */
  5743. from: number,
  5744. /**The ending frame of the animation*/
  5745. to: number);
  5746. /**
  5747. * Makes a copy of the animation range
  5748. * @returns A copy of the animation range
  5749. */
  5750. clone(): AnimationRange;
  5751. }
  5752. }
  5753. declare module "babylonjs/Animations/animationEvent" {
  5754. /**
  5755. * Composed of a frame, and an action function
  5756. */
  5757. export class AnimationEvent {
  5758. /** The frame for which the event is triggered **/
  5759. frame: number;
  5760. /** The event to perform when triggered **/
  5761. action: (currentFrame: number) => void;
  5762. /** Specifies if the event should be triggered only once**/
  5763. onlyOnce?: boolean | undefined;
  5764. /**
  5765. * Specifies if the animation event is done
  5766. */
  5767. isDone: boolean;
  5768. /**
  5769. * Initializes the animation event
  5770. * @param frame The frame for which the event is triggered
  5771. * @param action The event to perform when triggered
  5772. * @param onlyOnce Specifies if the event should be triggered only once
  5773. */
  5774. constructor(
  5775. /** The frame for which the event is triggered **/
  5776. frame: number,
  5777. /** The event to perform when triggered **/
  5778. action: (currentFrame: number) => void,
  5779. /** Specifies if the event should be triggered only once**/
  5780. onlyOnce?: boolean | undefined);
  5781. /** @hidden */
  5782. _clone(): AnimationEvent;
  5783. }
  5784. }
  5785. declare module "babylonjs/Behaviors/behavior" {
  5786. import { Nullable } from "babylonjs/types";
  5787. /**
  5788. * Interface used to define a behavior
  5789. */
  5790. export interface Behavior<T> {
  5791. /** gets or sets behavior's name */
  5792. name: string;
  5793. /**
  5794. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5795. */
  5796. init(): void;
  5797. /**
  5798. * Called when the behavior is attached to a target
  5799. * @param target defines the target where the behavior is attached to
  5800. */
  5801. attach(target: T): void;
  5802. /**
  5803. * Called when the behavior is detached from its target
  5804. */
  5805. detach(): void;
  5806. }
  5807. /**
  5808. * Interface implemented by classes supporting behaviors
  5809. */
  5810. export interface IBehaviorAware<T> {
  5811. /**
  5812. * Attach a behavior
  5813. * @param behavior defines the behavior to attach
  5814. * @returns the current host
  5815. */
  5816. addBehavior(behavior: Behavior<T>): T;
  5817. /**
  5818. * Remove a behavior from the current object
  5819. * @param behavior defines the behavior to detach
  5820. * @returns the current host
  5821. */
  5822. removeBehavior(behavior: Behavior<T>): T;
  5823. /**
  5824. * Gets a behavior using its name to search
  5825. * @param name defines the name to search
  5826. * @returns the behavior or null if not found
  5827. */
  5828. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5829. }
  5830. }
  5831. declare module "babylonjs/Misc/smartArray" {
  5832. /**
  5833. * Defines an array and its length.
  5834. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5835. */
  5836. export interface ISmartArrayLike<T> {
  5837. /**
  5838. * The data of the array.
  5839. */
  5840. data: Array<T>;
  5841. /**
  5842. * The active length of the array.
  5843. */
  5844. length: number;
  5845. }
  5846. /**
  5847. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5848. */
  5849. export class SmartArray<T> implements ISmartArrayLike<T> {
  5850. /**
  5851. * The full set of data from the array.
  5852. */
  5853. data: Array<T>;
  5854. /**
  5855. * The active length of the array.
  5856. */
  5857. length: number;
  5858. protected _id: number;
  5859. /**
  5860. * Instantiates a Smart Array.
  5861. * @param capacity defines the default capacity of the array.
  5862. */
  5863. constructor(capacity: number);
  5864. /**
  5865. * Pushes a value at the end of the active data.
  5866. * @param value defines the object to push in the array.
  5867. */
  5868. push(value: T): void;
  5869. /**
  5870. * Iterates over the active data and apply the lambda to them.
  5871. * @param func defines the action to apply on each value.
  5872. */
  5873. forEach(func: (content: T) => void): void;
  5874. /**
  5875. * Sorts the full sets of data.
  5876. * @param compareFn defines the comparison function to apply.
  5877. */
  5878. sort(compareFn: (a: T, b: T) => number): void;
  5879. /**
  5880. * Resets the active data to an empty array.
  5881. */
  5882. reset(): void;
  5883. /**
  5884. * Releases all the data from the array as well as the array.
  5885. */
  5886. dispose(): void;
  5887. /**
  5888. * Concats the active data with a given array.
  5889. * @param array defines the data to concatenate with.
  5890. */
  5891. concat(array: any): void;
  5892. /**
  5893. * Returns the position of a value in the active data.
  5894. * @param value defines the value to find the index for
  5895. * @returns the index if found in the active data otherwise -1
  5896. */
  5897. indexOf(value: T): number;
  5898. /**
  5899. * Returns whether an element is part of the active data.
  5900. * @param value defines the value to look for
  5901. * @returns true if found in the active data otherwise false
  5902. */
  5903. contains(value: T): boolean;
  5904. private static _GlobalId;
  5905. }
  5906. /**
  5907. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5908. * The data in this array can only be present once
  5909. */
  5910. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5911. private _duplicateId;
  5912. /**
  5913. * Pushes a value at the end of the active data.
  5914. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5915. * @param value defines the object to push in the array.
  5916. */
  5917. push(value: T): void;
  5918. /**
  5919. * Pushes a value at the end of the active data.
  5920. * If the data is already present, it won t be added again
  5921. * @param value defines the object to push in the array.
  5922. * @returns true if added false if it was already present
  5923. */
  5924. pushNoDuplicate(value: T): boolean;
  5925. /**
  5926. * Resets the active data to an empty array.
  5927. */
  5928. reset(): void;
  5929. /**
  5930. * Concats the active data with a given array.
  5931. * This ensures no dupplicate will be present in the result.
  5932. * @param array defines the data to concatenate with.
  5933. */
  5934. concatWithNoDuplicate(array: any): void;
  5935. }
  5936. }
  5937. declare module "babylonjs/Cameras/cameraInputsManager" {
  5938. import { Nullable } from "babylonjs/types";
  5939. import { Camera } from "babylonjs/Cameras/camera";
  5940. /**
  5941. * @ignore
  5942. * This is a list of all the different input types that are available in the application.
  5943. * Fo instance: ArcRotateCameraGamepadInput...
  5944. */
  5945. export var CameraInputTypes: {};
  5946. /**
  5947. * This is the contract to implement in order to create a new input class.
  5948. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5949. */
  5950. export interface ICameraInput<TCamera extends Camera> {
  5951. /**
  5952. * Defines the camera the input is attached to.
  5953. */
  5954. camera: Nullable<TCamera>;
  5955. /**
  5956. * Gets the class name of the current intput.
  5957. * @returns the class name
  5958. */
  5959. getClassName(): string;
  5960. /**
  5961. * Get the friendly name associated with the input class.
  5962. * @returns the input friendly name
  5963. */
  5964. getSimpleName(): string;
  5965. /**
  5966. * Attach the input controls to a specific dom element to get the input from.
  5967. * @param element Defines the element the controls should be listened from
  5968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5969. */
  5970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5971. /**
  5972. * Detach the current controls from the specified dom element.
  5973. * @param element Defines the element to stop listening the inputs from
  5974. */
  5975. detachControl(element: Nullable<HTMLElement>): void;
  5976. /**
  5977. * Update the current camera state depending on the inputs that have been used this frame.
  5978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5979. */
  5980. checkInputs?: () => void;
  5981. }
  5982. /**
  5983. * Represents a map of input types to input instance or input index to input instance.
  5984. */
  5985. export interface CameraInputsMap<TCamera extends Camera> {
  5986. /**
  5987. * Accessor to the input by input type.
  5988. */
  5989. [name: string]: ICameraInput<TCamera>;
  5990. /**
  5991. * Accessor to the input by input index.
  5992. */
  5993. [idx: number]: ICameraInput<TCamera>;
  5994. }
  5995. /**
  5996. * This represents the input manager used within a camera.
  5997. * It helps dealing with all the different kind of input attached to a camera.
  5998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5999. */
  6000. export class CameraInputsManager<TCamera extends Camera> {
  6001. /**
  6002. * Defines the list of inputs attahed to the camera.
  6003. */
  6004. attached: CameraInputsMap<TCamera>;
  6005. /**
  6006. * Defines the dom element the camera is collecting inputs from.
  6007. * This is null if the controls have not been attached.
  6008. */
  6009. attachedElement: Nullable<HTMLElement>;
  6010. /**
  6011. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6012. */
  6013. noPreventDefault: boolean;
  6014. /**
  6015. * Defined the camera the input manager belongs to.
  6016. */
  6017. camera: TCamera;
  6018. /**
  6019. * Update the current camera state depending on the inputs that have been used this frame.
  6020. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6021. */
  6022. checkInputs: () => void;
  6023. /**
  6024. * Instantiate a new Camera Input Manager.
  6025. * @param camera Defines the camera the input manager blongs to
  6026. */
  6027. constructor(camera: TCamera);
  6028. /**
  6029. * Add an input method to a camera
  6030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6031. * @param input camera input method
  6032. */
  6033. add(input: ICameraInput<TCamera>): void;
  6034. /**
  6035. * Remove a specific input method from a camera
  6036. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6037. * @param inputToRemove camera input method
  6038. */
  6039. remove(inputToRemove: ICameraInput<TCamera>): void;
  6040. /**
  6041. * Remove a specific input type from a camera
  6042. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6043. * @param inputType the type of the input to remove
  6044. */
  6045. removeByType(inputType: string): void;
  6046. private _addCheckInputs;
  6047. /**
  6048. * Attach the input controls to the currently attached dom element to listen the events from.
  6049. * @param input Defines the input to attach
  6050. */
  6051. attachInput(input: ICameraInput<TCamera>): void;
  6052. /**
  6053. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6054. * @param element Defines the dom element to collect the events from
  6055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6056. */
  6057. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6058. /**
  6059. * Detach the current manager inputs controls from a specific dom element.
  6060. * @param element Defines the dom element to collect the events from
  6061. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6062. */
  6063. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6064. /**
  6065. * Rebuild the dynamic inputCheck function from the current list of
  6066. * defined inputs in the manager.
  6067. */
  6068. rebuildInputCheck(): void;
  6069. /**
  6070. * Remove all attached input methods from a camera
  6071. */
  6072. clear(): void;
  6073. /**
  6074. * Serialize the current input manager attached to a camera.
  6075. * This ensures than once parsed,
  6076. * the input associated to the camera will be identical to the current ones
  6077. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6078. */
  6079. serialize(serializedCamera: any): void;
  6080. /**
  6081. * Parses an input manager serialized JSON to restore the previous list of inputs
  6082. * and states associated to a camera.
  6083. * @param parsedCamera Defines the JSON to parse
  6084. */
  6085. parse(parsedCamera: any): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/Meshes/buffer" {
  6089. import { Nullable, DataArray } from "babylonjs/types";
  6090. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6091. /**
  6092. * Class used to store data that will be store in GPU memory
  6093. */
  6094. export class Buffer {
  6095. private _engine;
  6096. private _buffer;
  6097. /** @hidden */
  6098. _data: Nullable<DataArray>;
  6099. private _updatable;
  6100. private _instanced;
  6101. /**
  6102. * Gets the byte stride.
  6103. */
  6104. readonly byteStride: number;
  6105. /**
  6106. * Constructor
  6107. * @param engine the engine
  6108. * @param data the data to use for this buffer
  6109. * @param updatable whether the data is updatable
  6110. * @param stride the stride (optional)
  6111. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6112. * @param instanced whether the buffer is instanced (optional)
  6113. * @param useBytes set to true if the stride in in bytes (optional)
  6114. */
  6115. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6116. /**
  6117. * Create a new VertexBuffer based on the current buffer
  6118. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6119. * @param offset defines offset in the buffer (0 by default)
  6120. * @param size defines the size in floats of attributes (position is 3 for instance)
  6121. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6122. * @param instanced defines if the vertex buffer contains indexed data
  6123. * @param useBytes defines if the offset and stride are in bytes
  6124. * @returns the new vertex buffer
  6125. */
  6126. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6127. /**
  6128. * Gets a boolean indicating if the Buffer is updatable?
  6129. * @returns true if the buffer is updatable
  6130. */
  6131. isUpdatable(): boolean;
  6132. /**
  6133. * Gets current buffer's data
  6134. * @returns a DataArray or null
  6135. */
  6136. getData(): Nullable<DataArray>;
  6137. /**
  6138. * Gets underlying native buffer
  6139. * @returns underlying native buffer
  6140. */
  6141. getBuffer(): Nullable<DataBuffer>;
  6142. /**
  6143. * Gets the stride in float32 units (i.e. byte stride / 4).
  6144. * May not be an integer if the byte stride is not divisible by 4.
  6145. * DEPRECATED. Use byteStride instead.
  6146. * @returns the stride in float32 units
  6147. */
  6148. getStrideSize(): number;
  6149. /**
  6150. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6151. * @param data defines the data to store
  6152. */
  6153. create(data?: Nullable<DataArray>): void;
  6154. /** @hidden */
  6155. _rebuild(): void;
  6156. /**
  6157. * Update current buffer data
  6158. * @param data defines the data to store
  6159. */
  6160. update(data: DataArray): void;
  6161. /**
  6162. * Updates the data directly.
  6163. * @param data the new data
  6164. * @param offset the new offset
  6165. * @param vertexCount the vertex count (optional)
  6166. * @param useBytes set to true if the offset is in bytes
  6167. */
  6168. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6169. /**
  6170. * Release all resources
  6171. */
  6172. dispose(): void;
  6173. }
  6174. /**
  6175. * Specialized buffer used to store vertex data
  6176. */
  6177. export class VertexBuffer {
  6178. /** @hidden */
  6179. _buffer: Buffer;
  6180. private _kind;
  6181. private _size;
  6182. private _ownsBuffer;
  6183. private _instanced;
  6184. private _instanceDivisor;
  6185. /**
  6186. * The byte type.
  6187. */
  6188. static readonly BYTE: number;
  6189. /**
  6190. * The unsigned byte type.
  6191. */
  6192. static readonly UNSIGNED_BYTE: number;
  6193. /**
  6194. * The short type.
  6195. */
  6196. static readonly SHORT: number;
  6197. /**
  6198. * The unsigned short type.
  6199. */
  6200. static readonly UNSIGNED_SHORT: number;
  6201. /**
  6202. * The integer type.
  6203. */
  6204. static readonly INT: number;
  6205. /**
  6206. * The unsigned integer type.
  6207. */
  6208. static readonly UNSIGNED_INT: number;
  6209. /**
  6210. * The float type.
  6211. */
  6212. static readonly FLOAT: number;
  6213. /**
  6214. * Gets or sets the instance divisor when in instanced mode
  6215. */
  6216. instanceDivisor: number;
  6217. /**
  6218. * Gets the byte stride.
  6219. */
  6220. readonly byteStride: number;
  6221. /**
  6222. * Gets the byte offset.
  6223. */
  6224. readonly byteOffset: number;
  6225. /**
  6226. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6227. */
  6228. readonly normalized: boolean;
  6229. /**
  6230. * Gets the data type of each component in the array.
  6231. */
  6232. readonly type: number;
  6233. /**
  6234. * Constructor
  6235. * @param engine the engine
  6236. * @param data the data to use for this vertex buffer
  6237. * @param kind the vertex buffer kind
  6238. * @param updatable whether the data is updatable
  6239. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6240. * @param stride the stride (optional)
  6241. * @param instanced whether the buffer is instanced (optional)
  6242. * @param offset the offset of the data (optional)
  6243. * @param size the number of components (optional)
  6244. * @param type the type of the component (optional)
  6245. * @param normalized whether the data contains normalized data (optional)
  6246. * @param useBytes set to true if stride and offset are in bytes (optional)
  6247. */
  6248. 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);
  6249. /** @hidden */
  6250. _rebuild(): void;
  6251. /**
  6252. * Returns the kind of the VertexBuffer (string)
  6253. * @returns a string
  6254. */
  6255. getKind(): string;
  6256. /**
  6257. * Gets a boolean indicating if the VertexBuffer is updatable?
  6258. * @returns true if the buffer is updatable
  6259. */
  6260. isUpdatable(): boolean;
  6261. /**
  6262. * Gets current buffer's data
  6263. * @returns a DataArray or null
  6264. */
  6265. getData(): Nullable<DataArray>;
  6266. /**
  6267. * Gets underlying native buffer
  6268. * @returns underlying native buffer
  6269. */
  6270. getBuffer(): Nullable<DataBuffer>;
  6271. /**
  6272. * Gets the stride in float32 units (i.e. byte stride / 4).
  6273. * May not be an integer if the byte stride is not divisible by 4.
  6274. * DEPRECATED. Use byteStride instead.
  6275. * @returns the stride in float32 units
  6276. */
  6277. getStrideSize(): number;
  6278. /**
  6279. * Returns the offset as a multiple of the type byte length.
  6280. * DEPRECATED. Use byteOffset instead.
  6281. * @returns the offset in bytes
  6282. */
  6283. getOffset(): number;
  6284. /**
  6285. * Returns the number of components per vertex attribute (integer)
  6286. * @returns the size in float
  6287. */
  6288. getSize(): number;
  6289. /**
  6290. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6291. * @returns true if this buffer is instanced
  6292. */
  6293. getIsInstanced(): boolean;
  6294. /**
  6295. * Returns the instancing divisor, zero for non-instanced (integer).
  6296. * @returns a number
  6297. */
  6298. getInstanceDivisor(): number;
  6299. /**
  6300. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6301. * @param data defines the data to store
  6302. */
  6303. create(data?: DataArray): void;
  6304. /**
  6305. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6306. * This function will create a new buffer if the current one is not updatable
  6307. * @param data defines the data to store
  6308. */
  6309. update(data: DataArray): void;
  6310. /**
  6311. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6312. * Returns the directly updated WebGLBuffer.
  6313. * @param data the new data
  6314. * @param offset the new offset
  6315. * @param useBytes set to true if the offset is in bytes
  6316. */
  6317. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6318. /**
  6319. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6320. */
  6321. dispose(): void;
  6322. /**
  6323. * Enumerates each value of this vertex buffer as numbers.
  6324. * @param count the number of values to enumerate
  6325. * @param callback the callback function called for each value
  6326. */
  6327. forEach(count: number, callback: (value: number, index: number) => void): void;
  6328. /**
  6329. * Positions
  6330. */
  6331. static readonly PositionKind: string;
  6332. /**
  6333. * Normals
  6334. */
  6335. static readonly NormalKind: string;
  6336. /**
  6337. * Tangents
  6338. */
  6339. static readonly TangentKind: string;
  6340. /**
  6341. * Texture coordinates
  6342. */
  6343. static readonly UVKind: string;
  6344. /**
  6345. * Texture coordinates 2
  6346. */
  6347. static readonly UV2Kind: string;
  6348. /**
  6349. * Texture coordinates 3
  6350. */
  6351. static readonly UV3Kind: string;
  6352. /**
  6353. * Texture coordinates 4
  6354. */
  6355. static readonly UV4Kind: string;
  6356. /**
  6357. * Texture coordinates 5
  6358. */
  6359. static readonly UV5Kind: string;
  6360. /**
  6361. * Texture coordinates 6
  6362. */
  6363. static readonly UV6Kind: string;
  6364. /**
  6365. * Colors
  6366. */
  6367. static readonly ColorKind: string;
  6368. /**
  6369. * Matrix indices (for bones)
  6370. */
  6371. static readonly MatricesIndicesKind: string;
  6372. /**
  6373. * Matrix weights (for bones)
  6374. */
  6375. static readonly MatricesWeightsKind: string;
  6376. /**
  6377. * Additional matrix indices (for bones)
  6378. */
  6379. static readonly MatricesIndicesExtraKind: string;
  6380. /**
  6381. * Additional matrix weights (for bones)
  6382. */
  6383. static readonly MatricesWeightsExtraKind: string;
  6384. /**
  6385. * Deduces the stride given a kind.
  6386. * @param kind The kind string to deduce
  6387. * @returns The deduced stride
  6388. */
  6389. static DeduceStride(kind: string): number;
  6390. /**
  6391. * Gets the byte length of the given type.
  6392. * @param type the type
  6393. * @returns the number of bytes
  6394. */
  6395. static GetTypeByteLength(type: number): number;
  6396. /**
  6397. * Enumerates each value of the given parameters as numbers.
  6398. * @param data the data to enumerate
  6399. * @param byteOffset the byte offset of the data
  6400. * @param byteStride the byte stride of the data
  6401. * @param componentCount the number of components per element
  6402. * @param componentType the type of the component
  6403. * @param count the number of values to enumerate
  6404. * @param normalized whether the data is normalized
  6405. * @param callback the callback function called for each value
  6406. */
  6407. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6408. private static _GetFloatValue;
  6409. }
  6410. }
  6411. declare module "babylonjs/Collisions/intersectionInfo" {
  6412. import { Nullable } from "babylonjs/types";
  6413. /**
  6414. * @hidden
  6415. */
  6416. export class IntersectionInfo {
  6417. bu: Nullable<number>;
  6418. bv: Nullable<number>;
  6419. distance: number;
  6420. faceId: number;
  6421. subMeshId: number;
  6422. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6423. }
  6424. }
  6425. declare module "babylonjs/Maths/math.plane" {
  6426. import { DeepImmutable } from "babylonjs/types";
  6427. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6428. /**
  6429. * Represens a plane by the equation ax + by + cz + d = 0
  6430. */
  6431. export class Plane {
  6432. private static _TmpMatrix;
  6433. /**
  6434. * Normal of the plane (a,b,c)
  6435. */
  6436. normal: Vector3;
  6437. /**
  6438. * d component of the plane
  6439. */
  6440. d: number;
  6441. /**
  6442. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6443. * @param a a component of the plane
  6444. * @param b b component of the plane
  6445. * @param c c component of the plane
  6446. * @param d d component of the plane
  6447. */
  6448. constructor(a: number, b: number, c: number, d: number);
  6449. /**
  6450. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6451. */
  6452. asArray(): number[];
  6453. /**
  6454. * @returns a new plane copied from the current Plane.
  6455. */
  6456. clone(): Plane;
  6457. /**
  6458. * @returns the string "Plane".
  6459. */
  6460. getClassName(): string;
  6461. /**
  6462. * @returns the Plane hash code.
  6463. */
  6464. getHashCode(): number;
  6465. /**
  6466. * Normalize the current Plane in place.
  6467. * @returns the updated Plane.
  6468. */
  6469. normalize(): Plane;
  6470. /**
  6471. * Applies a transformation the plane and returns the result
  6472. * @param transformation the transformation matrix to be applied to the plane
  6473. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6474. */
  6475. transform(transformation: DeepImmutable<Matrix>): Plane;
  6476. /**
  6477. * Calcualtte the dot product between the point and the plane normal
  6478. * @param point point to calculate the dot product with
  6479. * @returns the dot product (float) of the point coordinates and the plane normal.
  6480. */
  6481. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6482. /**
  6483. * Updates the current Plane from the plane defined by the three given points.
  6484. * @param point1 one of the points used to contruct the plane
  6485. * @param point2 one of the points used to contruct the plane
  6486. * @param point3 one of the points used to contruct the plane
  6487. * @returns the updated Plane.
  6488. */
  6489. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6490. /**
  6491. * Checks if the plane is facing a given direction
  6492. * @param direction the direction to check if the plane is facing
  6493. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6494. * @returns True is the vector "direction" is the same side than the plane normal.
  6495. */
  6496. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6497. /**
  6498. * Calculates the distance to a point
  6499. * @param point point to calculate distance to
  6500. * @returns the signed distance (float) from the given point to the Plane.
  6501. */
  6502. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6503. /**
  6504. * Creates a plane from an array
  6505. * @param array the array to create a plane from
  6506. * @returns a new Plane from the given array.
  6507. */
  6508. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6509. /**
  6510. * Creates a plane from three points
  6511. * @param point1 point used to create the plane
  6512. * @param point2 point used to create the plane
  6513. * @param point3 point used to create the plane
  6514. * @returns a new Plane defined by the three given points.
  6515. */
  6516. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6517. /**
  6518. * Creates a plane from an origin point and a normal
  6519. * @param origin origin of the plane to be constructed
  6520. * @param normal normal of the plane to be constructed
  6521. * @returns a new Plane the normal vector to this plane at the given origin point.
  6522. * Note : the vector "normal" is updated because normalized.
  6523. */
  6524. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6525. /**
  6526. * Calculates the distance from a plane and a point
  6527. * @param origin origin of the plane to be constructed
  6528. * @param normal normal of the plane to be constructed
  6529. * @param point point to calculate distance to
  6530. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6531. */
  6532. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6533. }
  6534. }
  6535. declare module "babylonjs/Culling/boundingSphere" {
  6536. import { DeepImmutable } from "babylonjs/types";
  6537. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6538. import { Plane } from "babylonjs/Maths/math.plane";
  6539. /**
  6540. * Class used to store bounding sphere information
  6541. */
  6542. export class BoundingSphere {
  6543. /**
  6544. * Gets the center of the bounding sphere in local space
  6545. */
  6546. readonly center: Vector3;
  6547. /**
  6548. * Radius of the bounding sphere in local space
  6549. */
  6550. radius: number;
  6551. /**
  6552. * Gets the center of the bounding sphere in world space
  6553. */
  6554. readonly centerWorld: Vector3;
  6555. /**
  6556. * Radius of the bounding sphere in world space
  6557. */
  6558. radiusWorld: number;
  6559. /**
  6560. * Gets the minimum vector in local space
  6561. */
  6562. readonly minimum: Vector3;
  6563. /**
  6564. * Gets the maximum vector in local space
  6565. */
  6566. readonly maximum: Vector3;
  6567. private _worldMatrix;
  6568. private static readonly TmpVector3;
  6569. /**
  6570. * Creates a new bounding sphere
  6571. * @param min defines the minimum vector (in local space)
  6572. * @param max defines the maximum vector (in local space)
  6573. * @param worldMatrix defines the new world matrix
  6574. */
  6575. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6576. /**
  6577. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6578. * @param min defines the new minimum vector (in local space)
  6579. * @param max defines the new maximum vector (in local space)
  6580. * @param worldMatrix defines the new world matrix
  6581. */
  6582. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6583. /**
  6584. * Scale the current bounding sphere by applying a scale factor
  6585. * @param factor defines the scale factor to apply
  6586. * @returns the current bounding box
  6587. */
  6588. scale(factor: number): BoundingSphere;
  6589. /**
  6590. * Gets the world matrix of the bounding box
  6591. * @returns a matrix
  6592. */
  6593. getWorldMatrix(): DeepImmutable<Matrix>;
  6594. /** @hidden */
  6595. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6596. /**
  6597. * Tests if the bounding sphere is intersecting the frustum planes
  6598. * @param frustumPlanes defines the frustum planes to test
  6599. * @returns true if there is an intersection
  6600. */
  6601. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6602. /**
  6603. * Tests if the bounding sphere center is in between the frustum planes.
  6604. * Used for optimistic fast inclusion.
  6605. * @param frustumPlanes defines the frustum planes to test
  6606. * @returns true if the sphere center is in between the frustum planes
  6607. */
  6608. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6609. /**
  6610. * Tests if a point is inside the bounding sphere
  6611. * @param point defines the point to test
  6612. * @returns true if the point is inside the bounding sphere
  6613. */
  6614. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6615. /**
  6616. * Checks if two sphere intersct
  6617. * @param sphere0 sphere 0
  6618. * @param sphere1 sphere 1
  6619. * @returns true if the speres intersect
  6620. */
  6621. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6622. }
  6623. }
  6624. declare module "babylonjs/Culling/boundingBox" {
  6625. import { DeepImmutable } from "babylonjs/types";
  6626. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6627. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6628. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6629. import { Plane } from "babylonjs/Maths/math.plane";
  6630. /**
  6631. * Class used to store bounding box information
  6632. */
  6633. export class BoundingBox implements ICullable {
  6634. /**
  6635. * Gets the 8 vectors representing the bounding box in local space
  6636. */
  6637. readonly vectors: Vector3[];
  6638. /**
  6639. * Gets the center of the bounding box in local space
  6640. */
  6641. readonly center: Vector3;
  6642. /**
  6643. * Gets the center of the bounding box in world space
  6644. */
  6645. readonly centerWorld: Vector3;
  6646. /**
  6647. * Gets the extend size in local space
  6648. */
  6649. readonly extendSize: Vector3;
  6650. /**
  6651. * Gets the extend size in world space
  6652. */
  6653. readonly extendSizeWorld: Vector3;
  6654. /**
  6655. * Gets the OBB (object bounding box) directions
  6656. */
  6657. readonly directions: Vector3[];
  6658. /**
  6659. * Gets the 8 vectors representing the bounding box in world space
  6660. */
  6661. readonly vectorsWorld: Vector3[];
  6662. /**
  6663. * Gets the minimum vector in world space
  6664. */
  6665. readonly minimumWorld: Vector3;
  6666. /**
  6667. * Gets the maximum vector in world space
  6668. */
  6669. readonly maximumWorld: Vector3;
  6670. /**
  6671. * Gets the minimum vector in local space
  6672. */
  6673. readonly minimum: Vector3;
  6674. /**
  6675. * Gets the maximum vector in local space
  6676. */
  6677. readonly maximum: Vector3;
  6678. private _worldMatrix;
  6679. private static readonly TmpVector3;
  6680. /**
  6681. * @hidden
  6682. */
  6683. _tag: number;
  6684. /**
  6685. * Creates a new bounding box
  6686. * @param min defines the minimum vector (in local space)
  6687. * @param max defines the maximum vector (in local space)
  6688. * @param worldMatrix defines the new world matrix
  6689. */
  6690. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6691. /**
  6692. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6693. * @param min defines the new minimum vector (in local space)
  6694. * @param max defines the new maximum vector (in local space)
  6695. * @param worldMatrix defines the new world matrix
  6696. */
  6697. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6698. /**
  6699. * Scale the current bounding box by applying a scale factor
  6700. * @param factor defines the scale factor to apply
  6701. * @returns the current bounding box
  6702. */
  6703. scale(factor: number): BoundingBox;
  6704. /**
  6705. * Gets the world matrix of the bounding box
  6706. * @returns a matrix
  6707. */
  6708. getWorldMatrix(): DeepImmutable<Matrix>;
  6709. /** @hidden */
  6710. _update(world: DeepImmutable<Matrix>): void;
  6711. /**
  6712. * Tests if the bounding box is intersecting the frustum planes
  6713. * @param frustumPlanes defines the frustum planes to test
  6714. * @returns true if there is an intersection
  6715. */
  6716. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6717. /**
  6718. * Tests if the bounding box is entirely inside the frustum planes
  6719. * @param frustumPlanes defines the frustum planes to test
  6720. * @returns true if there is an inclusion
  6721. */
  6722. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6723. /**
  6724. * Tests if a point is inside the bounding box
  6725. * @param point defines the point to test
  6726. * @returns true if the point is inside the bounding box
  6727. */
  6728. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6729. /**
  6730. * Tests if the bounding box intersects with a bounding sphere
  6731. * @param sphere defines the sphere to test
  6732. * @returns true if there is an intersection
  6733. */
  6734. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6735. /**
  6736. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6737. * @param min defines the min vector to use
  6738. * @param max defines the max vector to use
  6739. * @returns true if there is an intersection
  6740. */
  6741. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6742. /**
  6743. * Tests if two bounding boxes are intersections
  6744. * @param box0 defines the first box to test
  6745. * @param box1 defines the second box to test
  6746. * @returns true if there is an intersection
  6747. */
  6748. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6749. /**
  6750. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6751. * @param minPoint defines the minimum vector of the bounding box
  6752. * @param maxPoint defines the maximum vector of the bounding box
  6753. * @param sphereCenter defines the sphere center
  6754. * @param sphereRadius defines the sphere radius
  6755. * @returns true if there is an intersection
  6756. */
  6757. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6758. /**
  6759. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6760. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @return true if there is an inclusion
  6763. */
  6764. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. /**
  6766. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6767. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6768. * @param frustumPlanes defines the frustum planes to test
  6769. * @return true if there is an intersection
  6770. */
  6771. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6772. }
  6773. }
  6774. declare module "babylonjs/Collisions/collider" {
  6775. import { Nullable, IndicesArray } from "babylonjs/types";
  6776. import { Vector3 } from "babylonjs/Maths/math.vector";
  6777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6778. import { Plane } from "babylonjs/Maths/math.plane";
  6779. /** @hidden */
  6780. export class Collider {
  6781. /** Define if a collision was found */
  6782. collisionFound: boolean;
  6783. /**
  6784. * Define last intersection point in local space
  6785. */
  6786. intersectionPoint: Vector3;
  6787. /**
  6788. * Define last collided mesh
  6789. */
  6790. collidedMesh: Nullable<AbstractMesh>;
  6791. private _collisionPoint;
  6792. private _planeIntersectionPoint;
  6793. private _tempVector;
  6794. private _tempVector2;
  6795. private _tempVector3;
  6796. private _tempVector4;
  6797. private _edge;
  6798. private _baseToVertex;
  6799. private _destinationPoint;
  6800. private _slidePlaneNormal;
  6801. private _displacementVector;
  6802. /** @hidden */
  6803. _radius: Vector3;
  6804. /** @hidden */
  6805. _retry: number;
  6806. private _velocity;
  6807. private _basePoint;
  6808. private _epsilon;
  6809. /** @hidden */
  6810. _velocityWorldLength: number;
  6811. /** @hidden */
  6812. _basePointWorld: Vector3;
  6813. private _velocityWorld;
  6814. private _normalizedVelocity;
  6815. /** @hidden */
  6816. _initialVelocity: Vector3;
  6817. /** @hidden */
  6818. _initialPosition: Vector3;
  6819. private _nearestDistance;
  6820. private _collisionMask;
  6821. collisionMask: number;
  6822. /**
  6823. * Gets the plane normal used to compute the sliding response (in local space)
  6824. */
  6825. readonly slidePlaneNormal: Vector3;
  6826. /** @hidden */
  6827. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6828. /** @hidden */
  6829. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6830. /** @hidden */
  6831. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6832. /** @hidden */
  6833. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6834. /** @hidden */
  6835. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6836. /** @hidden */
  6837. _getResponse(pos: Vector3, vel: Vector3): void;
  6838. }
  6839. }
  6840. declare module "babylonjs/Culling/boundingInfo" {
  6841. import { DeepImmutable } from "babylonjs/types";
  6842. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6843. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6844. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6845. import { Plane } from "babylonjs/Maths/math.plane";
  6846. import { Collider } from "babylonjs/Collisions/collider";
  6847. /**
  6848. * Interface for cullable objects
  6849. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6850. */
  6851. export interface ICullable {
  6852. /**
  6853. * Checks if the object or part of the object is in the frustum
  6854. * @param frustumPlanes Camera near/planes
  6855. * @returns true if the object is in frustum otherwise false
  6856. */
  6857. isInFrustum(frustumPlanes: Plane[]): boolean;
  6858. /**
  6859. * Checks if a cullable object (mesh...) is in the camera frustum
  6860. * Unlike isInFrustum this cheks the full bounding box
  6861. * @param frustumPlanes Camera near/planes
  6862. * @returns true if the object is in frustum otherwise false
  6863. */
  6864. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6865. }
  6866. /**
  6867. * Info for a bounding data of a mesh
  6868. */
  6869. export class BoundingInfo implements ICullable {
  6870. /**
  6871. * Bounding box for the mesh
  6872. */
  6873. readonly boundingBox: BoundingBox;
  6874. /**
  6875. * Bounding sphere for the mesh
  6876. */
  6877. readonly boundingSphere: BoundingSphere;
  6878. private _isLocked;
  6879. private static readonly TmpVector3;
  6880. /**
  6881. * Constructs bounding info
  6882. * @param minimum min vector of the bounding box/sphere
  6883. * @param maximum max vector of the bounding box/sphere
  6884. * @param worldMatrix defines the new world matrix
  6885. */
  6886. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6887. /**
  6888. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6889. * @param min defines the new minimum vector (in local space)
  6890. * @param max defines the new maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6894. /**
  6895. * min vector of the bounding box/sphere
  6896. */
  6897. readonly minimum: Vector3;
  6898. /**
  6899. * max vector of the bounding box/sphere
  6900. */
  6901. readonly maximum: Vector3;
  6902. /**
  6903. * If the info is locked and won't be updated to avoid perf overhead
  6904. */
  6905. isLocked: boolean;
  6906. /**
  6907. * Updates the bounding sphere and box
  6908. * @param world world matrix to be used to update
  6909. */
  6910. update(world: DeepImmutable<Matrix>): void;
  6911. /**
  6912. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6913. * @param center New center of the bounding info
  6914. * @param extend New extend of the bounding info
  6915. * @returns the current bounding info
  6916. */
  6917. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6918. /**
  6919. * Scale the current bounding info by applying a scale factor
  6920. * @param factor defines the scale factor to apply
  6921. * @returns the current bounding info
  6922. */
  6923. scale(factor: number): BoundingInfo;
  6924. /**
  6925. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6926. * @param frustumPlanes defines the frustum to test
  6927. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6928. * @returns true if the bounding info is in the frustum planes
  6929. */
  6930. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6931. /**
  6932. * Gets the world distance between the min and max points of the bounding box
  6933. */
  6934. readonly diagonalLength: number;
  6935. /**
  6936. * Checks if a cullable object (mesh...) is in the camera frustum
  6937. * Unlike isInFrustum this cheks the full bounding box
  6938. * @param frustumPlanes Camera near/planes
  6939. * @returns true if the object is in frustum otherwise false
  6940. */
  6941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /** @hidden */
  6943. _checkCollision(collider: Collider): boolean;
  6944. /**
  6945. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6946. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6947. * @param point the point to check intersection with
  6948. * @returns if the point intersects
  6949. */
  6950. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6951. /**
  6952. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6953. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6954. * @param boundingInfo the bounding info to check intersection with
  6955. * @param precise if the intersection should be done using OBB
  6956. * @returns if the bounding info intersects
  6957. */
  6958. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6959. }
  6960. }
  6961. declare module "babylonjs/Maths/math.functions" {
  6962. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  6963. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  6964. /**
  6965. * Extracts minimum and maximum values from a list of indexed positions
  6966. * @param positions defines the positions to use
  6967. * @param indices defines the indices to the positions
  6968. * @param indexStart defines the start index
  6969. * @param indexCount defines the end index
  6970. * @param bias defines bias value to add to the result
  6971. * @return minimum and maximum values
  6972. */
  6973. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6974. minimum: Vector3;
  6975. maximum: Vector3;
  6976. };
  6977. /**
  6978. * Extracts minimum and maximum values from a list of positions
  6979. * @param positions defines the positions to use
  6980. * @param start defines the start index in the positions array
  6981. * @param count defines the number of positions to handle
  6982. * @param bias defines bias value to add to the result
  6983. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6984. * @return minimum and maximum values
  6985. */
  6986. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6987. minimum: Vector3;
  6988. maximum: Vector3;
  6989. };
  6990. }
  6991. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  6992. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6993. /** @hidden */
  6994. export class WebGLDataBuffer extends DataBuffer {
  6995. private _buffer;
  6996. constructor(resource: WebGLBuffer);
  6997. readonly underlyingResource: any;
  6998. }
  6999. }
  7000. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7001. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7002. import { Nullable } from "babylonjs/types";
  7003. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7004. /** @hidden */
  7005. export class WebGLPipelineContext implements IPipelineContext {
  7006. engine: ThinEngine;
  7007. program: Nullable<WebGLProgram>;
  7008. context?: WebGLRenderingContext;
  7009. vertexShader?: WebGLShader;
  7010. fragmentShader?: WebGLShader;
  7011. isParallelCompiled: boolean;
  7012. onCompiled?: () => void;
  7013. transformFeedback?: WebGLTransformFeedback | null;
  7014. readonly isAsync: boolean;
  7015. readonly isReady: boolean;
  7016. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7017. }
  7018. }
  7019. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7020. import { FloatArray, Nullable } from "babylonjs/types";
  7021. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7022. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7023. module "babylonjs/Engines/thinEngine" {
  7024. interface ThinEngine {
  7025. /**
  7026. * Create an uniform buffer
  7027. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7028. * @param elements defines the content of the uniform buffer
  7029. * @returns the webGL uniform buffer
  7030. */
  7031. createUniformBuffer(elements: FloatArray): DataBuffer;
  7032. /**
  7033. * Create a dynamic uniform buffer
  7034. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7035. * @param elements defines the content of the uniform buffer
  7036. * @returns the webGL uniform buffer
  7037. */
  7038. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7039. /**
  7040. * Update an existing uniform buffer
  7041. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7042. * @param uniformBuffer defines the target uniform buffer
  7043. * @param elements defines the content to update
  7044. * @param offset defines the offset in the uniform buffer where update should start
  7045. * @param count defines the size of the data to update
  7046. */
  7047. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7048. /**
  7049. * Bind an uniform buffer to the current webGL context
  7050. * @param buffer defines the buffer to bind
  7051. */
  7052. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7053. /**
  7054. * Bind a buffer to the current webGL context at a given location
  7055. * @param buffer defines the buffer to bind
  7056. * @param location defines the index where to bind the buffer
  7057. */
  7058. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7059. /**
  7060. * Bind a specific block at a given index in a specific shader program
  7061. * @param pipelineContext defines the pipeline context to use
  7062. * @param blockName defines the block name
  7063. * @param index defines the index where to bind the block
  7064. */
  7065. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7066. }
  7067. }
  7068. }
  7069. declare module "babylonjs/Materials/uniformBuffer" {
  7070. import { Nullable, FloatArray } from "babylonjs/types";
  7071. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7072. import { Engine } from "babylonjs/Engines/engine";
  7073. import { Effect } from "babylonjs/Materials/effect";
  7074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7075. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7076. import { Color3 } from "babylonjs/Maths/math.color";
  7077. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7078. /**
  7079. * Uniform buffer objects.
  7080. *
  7081. * Handles blocks of uniform on the GPU.
  7082. *
  7083. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7084. *
  7085. * For more information, please refer to :
  7086. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7087. */
  7088. export class UniformBuffer {
  7089. private _engine;
  7090. private _buffer;
  7091. private _data;
  7092. private _bufferData;
  7093. private _dynamic?;
  7094. private _uniformLocations;
  7095. private _uniformSizes;
  7096. private _uniformLocationPointer;
  7097. private _needSync;
  7098. private _noUBO;
  7099. private _currentEffect;
  7100. private static _MAX_UNIFORM_SIZE;
  7101. private static _tempBuffer;
  7102. /**
  7103. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7104. * This is dynamic to allow compat with webgl 1 and 2.
  7105. * You will need to pass the name of the uniform as well as the value.
  7106. */
  7107. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7108. /**
  7109. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7110. * This is dynamic to allow compat with webgl 1 and 2.
  7111. * You will need to pass the name of the uniform as well as the value.
  7112. */
  7113. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7114. /**
  7115. * Lambda to Update a single float in a uniform buffer.
  7116. * This is dynamic to allow compat with webgl 1 and 2.
  7117. * You will need to pass the name of the uniform as well as the value.
  7118. */
  7119. updateFloat: (name: string, x: number) => void;
  7120. /**
  7121. * Lambda to Update a vec2 of float in a uniform buffer.
  7122. * This is dynamic to allow compat with webgl 1 and 2.
  7123. * You will need to pass the name of the uniform as well as the value.
  7124. */
  7125. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7126. /**
  7127. * Lambda to Update a vec3 of float in a uniform buffer.
  7128. * This is dynamic to allow compat with webgl 1 and 2.
  7129. * You will need to pass the name of the uniform as well as the value.
  7130. */
  7131. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7132. /**
  7133. * Lambda to Update a vec4 of float in a uniform buffer.
  7134. * This is dynamic to allow compat with webgl 1 and 2.
  7135. * You will need to pass the name of the uniform as well as the value.
  7136. */
  7137. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7138. /**
  7139. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7140. * This is dynamic to allow compat with webgl 1 and 2.
  7141. * You will need to pass the name of the uniform as well as the value.
  7142. */
  7143. updateMatrix: (name: string, mat: Matrix) => void;
  7144. /**
  7145. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7146. * This is dynamic to allow compat with webgl 1 and 2.
  7147. * You will need to pass the name of the uniform as well as the value.
  7148. */
  7149. updateVector3: (name: string, vector: Vector3) => void;
  7150. /**
  7151. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7152. * This is dynamic to allow compat with webgl 1 and 2.
  7153. * You will need to pass the name of the uniform as well as the value.
  7154. */
  7155. updateVector4: (name: string, vector: Vector4) => void;
  7156. /**
  7157. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7158. * This is dynamic to allow compat with webgl 1 and 2.
  7159. * You will need to pass the name of the uniform as well as the value.
  7160. */
  7161. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7162. /**
  7163. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7164. * This is dynamic to allow compat with webgl 1 and 2.
  7165. * You will need to pass the name of the uniform as well as the value.
  7166. */
  7167. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7168. /**
  7169. * Instantiates a new Uniform buffer objects.
  7170. *
  7171. * Handles blocks of uniform on the GPU.
  7172. *
  7173. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7174. *
  7175. * For more information, please refer to :
  7176. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7177. * @param engine Define the engine the buffer is associated with
  7178. * @param data Define the data contained in the buffer
  7179. * @param dynamic Define if the buffer is updatable
  7180. */
  7181. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7182. /**
  7183. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7184. * or just falling back on setUniformXXX calls.
  7185. */
  7186. readonly useUbo: boolean;
  7187. /**
  7188. * Indicates if the WebGL underlying uniform buffer is in sync
  7189. * with the javascript cache data.
  7190. */
  7191. readonly isSync: boolean;
  7192. /**
  7193. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7194. * Also, a dynamic UniformBuffer will disable cache verification and always
  7195. * update the underlying WebGL uniform buffer to the GPU.
  7196. * @returns if Dynamic, otherwise false
  7197. */
  7198. isDynamic(): boolean;
  7199. /**
  7200. * The data cache on JS side.
  7201. * @returns the underlying data as a float array
  7202. */
  7203. getData(): Float32Array;
  7204. /**
  7205. * The underlying WebGL Uniform buffer.
  7206. * @returns the webgl buffer
  7207. */
  7208. getBuffer(): Nullable<DataBuffer>;
  7209. /**
  7210. * std140 layout specifies how to align data within an UBO structure.
  7211. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7212. * for specs.
  7213. */
  7214. private _fillAlignment;
  7215. /**
  7216. * Adds an uniform in the buffer.
  7217. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7218. * for the layout to be correct !
  7219. * @param name Name of the uniform, as used in the uniform block in the shader.
  7220. * @param size Data size, or data directly.
  7221. */
  7222. addUniform(name: string, size: number | number[]): void;
  7223. /**
  7224. * Adds a Matrix 4x4 to the uniform buffer.
  7225. * @param name Name of the uniform, as used in the uniform block in the shader.
  7226. * @param mat A 4x4 matrix.
  7227. */
  7228. addMatrix(name: string, mat: Matrix): void;
  7229. /**
  7230. * Adds a vec2 to the uniform buffer.
  7231. * @param name Name of the uniform, as used in the uniform block in the shader.
  7232. * @param x Define the x component value of the vec2
  7233. * @param y Define the y component value of the vec2
  7234. */
  7235. addFloat2(name: string, x: number, y: number): void;
  7236. /**
  7237. * Adds a vec3 to the uniform buffer.
  7238. * @param name Name of the uniform, as used in the uniform block in the shader.
  7239. * @param x Define the x component value of the vec3
  7240. * @param y Define the y component value of the vec3
  7241. * @param z Define the z component value of the vec3
  7242. */
  7243. addFloat3(name: string, x: number, y: number, z: number): void;
  7244. /**
  7245. * Adds a vec3 to the uniform buffer.
  7246. * @param name Name of the uniform, as used in the uniform block in the shader.
  7247. * @param color Define the vec3 from a Color
  7248. */
  7249. addColor3(name: string, color: Color3): void;
  7250. /**
  7251. * Adds a vec4 to the uniform buffer.
  7252. * @param name Name of the uniform, as used in the uniform block in the shader.
  7253. * @param color Define the rgb components from a Color
  7254. * @param alpha Define the a component of the vec4
  7255. */
  7256. addColor4(name: string, color: Color3, alpha: number): void;
  7257. /**
  7258. * Adds a vec3 to the uniform buffer.
  7259. * @param name Name of the uniform, as used in the uniform block in the shader.
  7260. * @param vector Define the vec3 components from a Vector
  7261. */
  7262. addVector3(name: string, vector: Vector3): void;
  7263. /**
  7264. * Adds a Matrix 3x3 to the uniform buffer.
  7265. * @param name Name of the uniform, as used in the uniform block in the shader.
  7266. */
  7267. addMatrix3x3(name: string): void;
  7268. /**
  7269. * Adds a Matrix 2x2 to the uniform buffer.
  7270. * @param name Name of the uniform, as used in the uniform block in the shader.
  7271. */
  7272. addMatrix2x2(name: string): void;
  7273. /**
  7274. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7275. */
  7276. create(): void;
  7277. /** @hidden */
  7278. _rebuild(): void;
  7279. /**
  7280. * Updates the WebGL Uniform Buffer on the GPU.
  7281. * If the `dynamic` flag is set to true, no cache comparison is done.
  7282. * Otherwise, the buffer will be updated only if the cache differs.
  7283. */
  7284. update(): void;
  7285. /**
  7286. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7287. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7288. * @param data Define the flattened data
  7289. * @param size Define the size of the data.
  7290. */
  7291. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7292. private _valueCache;
  7293. private _cacheMatrix;
  7294. private _updateMatrix3x3ForUniform;
  7295. private _updateMatrix3x3ForEffect;
  7296. private _updateMatrix2x2ForEffect;
  7297. private _updateMatrix2x2ForUniform;
  7298. private _updateFloatForEffect;
  7299. private _updateFloatForUniform;
  7300. private _updateFloat2ForEffect;
  7301. private _updateFloat2ForUniform;
  7302. private _updateFloat3ForEffect;
  7303. private _updateFloat3ForUniform;
  7304. private _updateFloat4ForEffect;
  7305. private _updateFloat4ForUniform;
  7306. private _updateMatrixForEffect;
  7307. private _updateMatrixForUniform;
  7308. private _updateVector3ForEffect;
  7309. private _updateVector3ForUniform;
  7310. private _updateVector4ForEffect;
  7311. private _updateVector4ForUniform;
  7312. private _updateColor3ForEffect;
  7313. private _updateColor3ForUniform;
  7314. private _updateColor4ForEffect;
  7315. private _updateColor4ForUniform;
  7316. /**
  7317. * Sets a sampler uniform on the effect.
  7318. * @param name Define the name of the sampler.
  7319. * @param texture Define the texture to set in the sampler
  7320. */
  7321. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7322. /**
  7323. * Directly updates the value of the uniform in the cache AND on the GPU.
  7324. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7325. * @param data Define the flattened data
  7326. */
  7327. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7328. /**
  7329. * Binds this uniform buffer to an effect.
  7330. * @param effect Define the effect to bind the buffer to
  7331. * @param name Name of the uniform block in the shader.
  7332. */
  7333. bindToEffect(effect: Effect, name: string): void;
  7334. /**
  7335. * Disposes the uniform buffer.
  7336. */
  7337. dispose(): void;
  7338. }
  7339. }
  7340. declare module "babylonjs/Misc/iInspectable" {
  7341. /**
  7342. * Enum that determines the text-wrapping mode to use.
  7343. */
  7344. export enum InspectableType {
  7345. /**
  7346. * Checkbox for booleans
  7347. */
  7348. Checkbox = 0,
  7349. /**
  7350. * Sliders for numbers
  7351. */
  7352. Slider = 1,
  7353. /**
  7354. * Vector3
  7355. */
  7356. Vector3 = 2,
  7357. /**
  7358. * Quaternions
  7359. */
  7360. Quaternion = 3,
  7361. /**
  7362. * Color3
  7363. */
  7364. Color3 = 4,
  7365. /**
  7366. * String
  7367. */
  7368. String = 5
  7369. }
  7370. /**
  7371. * Interface used to define custom inspectable properties.
  7372. * This interface is used by the inspector to display custom property grids
  7373. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7374. */
  7375. export interface IInspectable {
  7376. /**
  7377. * Gets the label to display
  7378. */
  7379. label: string;
  7380. /**
  7381. * Gets the name of the property to edit
  7382. */
  7383. propertyName: string;
  7384. /**
  7385. * Gets the type of the editor to use
  7386. */
  7387. type: InspectableType;
  7388. /**
  7389. * Gets the minimum value of the property when using in "slider" mode
  7390. */
  7391. min?: number;
  7392. /**
  7393. * Gets the maximum value of the property when using in "slider" mode
  7394. */
  7395. max?: number;
  7396. /**
  7397. * Gets the setp to use when using in "slider" mode
  7398. */
  7399. step?: number;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/timingTools" {
  7403. /**
  7404. * Class used to provide helper for timing
  7405. */
  7406. export class TimingTools {
  7407. /**
  7408. * Polyfill for setImmediate
  7409. * @param action defines the action to execute after the current execution block
  7410. */
  7411. static SetImmediate(action: () => void): void;
  7412. }
  7413. }
  7414. declare module "babylonjs/Misc/instantiationTools" {
  7415. /**
  7416. * Class used to enable instatition of objects by class name
  7417. */
  7418. export class InstantiationTools {
  7419. /**
  7420. * Use this object to register external classes like custom textures or material
  7421. * to allow the laoders to instantiate them
  7422. */
  7423. static RegisteredExternalClasses: {
  7424. [key: string]: Object;
  7425. };
  7426. /**
  7427. * Tries to instantiate a new object from a given class name
  7428. * @param className defines the class name to instantiate
  7429. * @returns the new object or null if the system was not able to do the instantiation
  7430. */
  7431. static Instantiate(className: string): any;
  7432. }
  7433. }
  7434. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7435. /**
  7436. * Define options used to create a depth texture
  7437. */
  7438. export class DepthTextureCreationOptions {
  7439. /** Specifies whether or not a stencil should be allocated in the texture */
  7440. generateStencil?: boolean;
  7441. /** Specifies whether or not bilinear filtering is enable on the texture */
  7442. bilinearFiltering?: boolean;
  7443. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7444. comparisonFunction?: number;
  7445. /** Specifies if the created texture is a cube texture */
  7446. isCube?: boolean;
  7447. }
  7448. }
  7449. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7451. import { Nullable } from "babylonjs/types";
  7452. import { Scene } from "babylonjs/scene";
  7453. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7454. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7455. module "babylonjs/Engines/thinEngine" {
  7456. interface ThinEngine {
  7457. /**
  7458. * Creates a depth stencil cube texture.
  7459. * This is only available in WebGL 2.
  7460. * @param size The size of face edge in the cube texture.
  7461. * @param options The options defining the cube texture.
  7462. * @returns The cube texture
  7463. */
  7464. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7465. /**
  7466. * Creates a cube texture
  7467. * @param rootUrl defines the url where the files to load is located
  7468. * @param scene defines the current scene
  7469. * @param files defines the list of files to load (1 per face)
  7470. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7471. * @param onLoad defines an optional callback raised when the texture is loaded
  7472. * @param onError defines an optional callback raised if there is an issue to load the texture
  7473. * @param format defines the format of the data
  7474. * @param forcedExtension defines the extension to use to pick the right loader
  7475. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7476. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7477. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7478. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7479. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7480. * @returns the cube texture as an InternalTexture
  7481. */
  7482. 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;
  7483. /**
  7484. * Creates a cube texture
  7485. * @param rootUrl defines the url where the files to load is located
  7486. * @param scene defines the current scene
  7487. * @param files defines the list of files to load (1 per face)
  7488. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7489. * @param onLoad defines an optional callback raised when the texture is loaded
  7490. * @param onError defines an optional callback raised if there is an issue to load the texture
  7491. * @param format defines the format of the data
  7492. * @param forcedExtension defines the extension to use to pick the right loader
  7493. * @returns the cube texture as an InternalTexture
  7494. */
  7495. 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;
  7496. /**
  7497. * Creates a cube texture
  7498. * @param rootUrl defines the url where the files to load is located
  7499. * @param scene defines the current scene
  7500. * @param files defines the list of files to load (1 per face)
  7501. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7502. * @param onLoad defines an optional callback raised when the texture is loaded
  7503. * @param onError defines an optional callback raised if there is an issue to load the texture
  7504. * @param format defines the format of the data
  7505. * @param forcedExtension defines the extension to use to pick the right loader
  7506. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7507. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7508. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7509. * @returns the cube texture as an InternalTexture
  7510. */
  7511. 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;
  7512. /** @hidden */
  7513. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7514. /** @hidden */
  7515. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7516. /** @hidden */
  7517. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7518. /** @hidden */
  7519. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7520. }
  7521. }
  7522. }
  7523. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7524. import { Nullable } from "babylonjs/types";
  7525. import { Scene } from "babylonjs/scene";
  7526. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7528. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7529. /**
  7530. * Class for creating a cube texture
  7531. */
  7532. export class CubeTexture extends BaseTexture {
  7533. private _delayedOnLoad;
  7534. /**
  7535. * The url of the texture
  7536. */
  7537. url: string;
  7538. /**
  7539. * Gets or sets the center of the bounding box associated with the cube texture.
  7540. * It must define where the camera used to render the texture was set
  7541. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7542. */
  7543. boundingBoxPosition: Vector3;
  7544. private _boundingBoxSize;
  7545. /**
  7546. * Gets or sets the size of the bounding box associated with the cube texture
  7547. * When defined, the cubemap will switch to local mode
  7548. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7549. * @example https://www.babylonjs-playground.com/#RNASML
  7550. */
  7551. /**
  7552. * Returns the bounding box size
  7553. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7554. */
  7555. boundingBoxSize: Vector3;
  7556. protected _rotationY: number;
  7557. /**
  7558. * Sets texture matrix rotation angle around Y axis in radians.
  7559. */
  7560. /**
  7561. * Gets texture matrix rotation angle around Y axis radians.
  7562. */
  7563. rotationY: number;
  7564. /**
  7565. * Are mip maps generated for this texture or not.
  7566. */
  7567. readonly noMipmap: boolean;
  7568. private _noMipmap;
  7569. private _files;
  7570. protected _forcedExtension: Nullable<string>;
  7571. private _extensions;
  7572. private _textureMatrix;
  7573. private _format;
  7574. private _createPolynomials;
  7575. /** @hidden */
  7576. _prefiltered: boolean;
  7577. /**
  7578. * Creates a cube texture from an array of image urls
  7579. * @param files defines an array of image urls
  7580. * @param scene defines the hosting scene
  7581. * @param noMipmap specifies if mip maps are not used
  7582. * @returns a cube texture
  7583. */
  7584. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7585. /**
  7586. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7587. * @param url defines the url of the prefiltered texture
  7588. * @param scene defines the scene the texture is attached to
  7589. * @param forcedExtension defines the extension of the file if different from the url
  7590. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7591. * @return the prefiltered texture
  7592. */
  7593. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7594. /**
  7595. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7596. * as prefiltered data.
  7597. * @param rootUrl defines the url of the texture or the root name of the six images
  7598. * @param scene defines the scene the texture is attached to
  7599. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7600. * @param noMipmap defines if mipmaps should be created or not
  7601. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7602. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7603. * @param onError defines a callback triggered in case of error during load
  7604. * @param format defines the internal format to use for the texture once loaded
  7605. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7606. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7607. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7608. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7609. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7610. * @return the cube texture
  7611. */
  7612. 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);
  7613. /**
  7614. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7615. */
  7616. readonly isPrefiltered: boolean;
  7617. /**
  7618. * Get the current class name of the texture useful for serialization or dynamic coding.
  7619. * @returns "CubeTexture"
  7620. */
  7621. getClassName(): string;
  7622. /**
  7623. * Update the url (and optional buffer) of this texture if url was null during construction.
  7624. * @param url the url of the texture
  7625. * @param forcedExtension defines the extension to use
  7626. * @param onLoad callback called when the texture is loaded (defaults to null)
  7627. */
  7628. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7629. /**
  7630. * Delays loading of the cube texture
  7631. * @param forcedExtension defines the extension to use
  7632. */
  7633. delayLoad(forcedExtension?: string): void;
  7634. /**
  7635. * Returns the reflection texture matrix
  7636. * @returns the reflection texture matrix
  7637. */
  7638. getReflectionTextureMatrix(): Matrix;
  7639. /**
  7640. * Sets the reflection texture matrix
  7641. * @param value Reflection texture matrix
  7642. */
  7643. setReflectionTextureMatrix(value: Matrix): void;
  7644. /**
  7645. * Parses text to create a cube texture
  7646. * @param parsedTexture define the serialized text to read from
  7647. * @param scene defines the hosting scene
  7648. * @param rootUrl defines the root url of the cube texture
  7649. * @returns a cube texture
  7650. */
  7651. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7652. /**
  7653. * Makes a clone, or deep copy, of the cube texture
  7654. * @returns a new cube texture
  7655. */
  7656. clone(): CubeTexture;
  7657. }
  7658. }
  7659. declare module "babylonjs/Materials/materialDefines" {
  7660. /**
  7661. * Manages the defines for the Material
  7662. */
  7663. export class MaterialDefines {
  7664. /** @hidden */
  7665. protected _keys: string[];
  7666. private _isDirty;
  7667. /** @hidden */
  7668. _renderId: number;
  7669. /** @hidden */
  7670. _areLightsDirty: boolean;
  7671. /** @hidden */
  7672. _areLightsDisposed: boolean;
  7673. /** @hidden */
  7674. _areAttributesDirty: boolean;
  7675. /** @hidden */
  7676. _areTexturesDirty: boolean;
  7677. /** @hidden */
  7678. _areFresnelDirty: boolean;
  7679. /** @hidden */
  7680. _areMiscDirty: boolean;
  7681. /** @hidden */
  7682. _areImageProcessingDirty: boolean;
  7683. /** @hidden */
  7684. _normals: boolean;
  7685. /** @hidden */
  7686. _uvs: boolean;
  7687. /** @hidden */
  7688. _needNormals: boolean;
  7689. /** @hidden */
  7690. _needUVs: boolean;
  7691. [id: string]: any;
  7692. /**
  7693. * Specifies if the material needs to be re-calculated
  7694. */
  7695. readonly isDirty: boolean;
  7696. /**
  7697. * Marks the material to indicate that it has been re-calculated
  7698. */
  7699. markAsProcessed(): void;
  7700. /**
  7701. * Marks the material to indicate that it needs to be re-calculated
  7702. */
  7703. markAsUnprocessed(): void;
  7704. /**
  7705. * Marks the material to indicate all of its defines need to be re-calculated
  7706. */
  7707. markAllAsDirty(): void;
  7708. /**
  7709. * Marks the material to indicate that image processing needs to be re-calculated
  7710. */
  7711. markAsImageProcessingDirty(): void;
  7712. /**
  7713. * Marks the material to indicate the lights need to be re-calculated
  7714. * @param disposed Defines whether the light is dirty due to dispose or not
  7715. */
  7716. markAsLightDirty(disposed?: boolean): void;
  7717. /**
  7718. * Marks the attribute state as changed
  7719. */
  7720. markAsAttributesDirty(): void;
  7721. /**
  7722. * Marks the texture state as changed
  7723. */
  7724. markAsTexturesDirty(): void;
  7725. /**
  7726. * Marks the fresnel state as changed
  7727. */
  7728. markAsFresnelDirty(): void;
  7729. /**
  7730. * Marks the misc state as changed
  7731. */
  7732. markAsMiscDirty(): void;
  7733. /**
  7734. * Rebuilds the material defines
  7735. */
  7736. rebuild(): void;
  7737. /**
  7738. * Specifies if two material defines are equal
  7739. * @param other - A material define instance to compare to
  7740. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7741. */
  7742. isEqual(other: MaterialDefines): boolean;
  7743. /**
  7744. * Clones this instance's defines to another instance
  7745. * @param other - material defines to clone values to
  7746. */
  7747. cloneTo(other: MaterialDefines): void;
  7748. /**
  7749. * Resets the material define values
  7750. */
  7751. reset(): void;
  7752. /**
  7753. * Converts the material define values to a string
  7754. * @returns - String of material define information
  7755. */
  7756. toString(): string;
  7757. }
  7758. }
  7759. declare module "babylonjs/Materials/colorCurves" {
  7760. import { Effect } from "babylonjs/Materials/effect";
  7761. /**
  7762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7764. * 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;
  7765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7766. */
  7767. export class ColorCurves {
  7768. private _dirty;
  7769. private _tempColor;
  7770. private _globalCurve;
  7771. private _highlightsCurve;
  7772. private _midtonesCurve;
  7773. private _shadowsCurve;
  7774. private _positiveCurve;
  7775. private _negativeCurve;
  7776. private _globalHue;
  7777. private _globalDensity;
  7778. private _globalSaturation;
  7779. private _globalExposure;
  7780. /**
  7781. * Gets the global Hue value.
  7782. * 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).
  7783. */
  7784. /**
  7785. * Sets the global Hue value.
  7786. * 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).
  7787. */
  7788. globalHue: number;
  7789. /**
  7790. * Gets the global Density value.
  7791. * 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.
  7792. * Values less than zero provide a filter of opposite hue.
  7793. */
  7794. /**
  7795. * Sets the global Density value.
  7796. * 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.
  7797. * Values less than zero provide a filter of opposite hue.
  7798. */
  7799. globalDensity: number;
  7800. /**
  7801. * Gets the global Saturation value.
  7802. * 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.
  7803. */
  7804. /**
  7805. * Sets the global Saturation value.
  7806. * 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.
  7807. */
  7808. globalSaturation: number;
  7809. /**
  7810. * Gets the global Exposure value.
  7811. * 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.
  7812. */
  7813. /**
  7814. * Sets the global Exposure value.
  7815. * 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.
  7816. */
  7817. globalExposure: number;
  7818. private _highlightsHue;
  7819. private _highlightsDensity;
  7820. private _highlightsSaturation;
  7821. private _highlightsExposure;
  7822. /**
  7823. * Gets the highlights Hue value.
  7824. * 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).
  7825. */
  7826. /**
  7827. * Sets the highlights Hue value.
  7828. * 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).
  7829. */
  7830. highlightsHue: number;
  7831. /**
  7832. * Gets the highlights Density value.
  7833. * 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.
  7834. * Values less than zero provide a filter of opposite hue.
  7835. */
  7836. /**
  7837. * Sets the highlights Density value.
  7838. * 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.
  7839. * Values less than zero provide a filter of opposite hue.
  7840. */
  7841. highlightsDensity: number;
  7842. /**
  7843. * Gets the highlights Saturation value.
  7844. * 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.
  7845. */
  7846. /**
  7847. * Sets the highlights Saturation value.
  7848. * 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.
  7849. */
  7850. highlightsSaturation: number;
  7851. /**
  7852. * Gets the highlights Exposure value.
  7853. * 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.
  7854. */
  7855. /**
  7856. * Sets the highlights Exposure value.
  7857. * 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.
  7858. */
  7859. highlightsExposure: number;
  7860. private _midtonesHue;
  7861. private _midtonesDensity;
  7862. private _midtonesSaturation;
  7863. private _midtonesExposure;
  7864. /**
  7865. * Gets the midtones Hue value.
  7866. * 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).
  7867. */
  7868. /**
  7869. * Sets the midtones Hue value.
  7870. * 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).
  7871. */
  7872. midtonesHue: number;
  7873. /**
  7874. * Gets the midtones Density value.
  7875. * 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.
  7876. * Values less than zero provide a filter of opposite hue.
  7877. */
  7878. /**
  7879. * Sets the midtones Density value.
  7880. * 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.
  7881. * Values less than zero provide a filter of opposite hue.
  7882. */
  7883. midtonesDensity: number;
  7884. /**
  7885. * Gets the midtones Saturation value.
  7886. * 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.
  7887. */
  7888. /**
  7889. * Sets the midtones Saturation value.
  7890. * 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.
  7891. */
  7892. midtonesSaturation: number;
  7893. /**
  7894. * Gets the midtones Exposure value.
  7895. * 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.
  7896. */
  7897. /**
  7898. * Sets the midtones Exposure value.
  7899. * 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.
  7900. */
  7901. midtonesExposure: number;
  7902. private _shadowsHue;
  7903. private _shadowsDensity;
  7904. private _shadowsSaturation;
  7905. private _shadowsExposure;
  7906. /**
  7907. * Gets the shadows Hue value.
  7908. * 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).
  7909. */
  7910. /**
  7911. * Sets the shadows Hue value.
  7912. * 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).
  7913. */
  7914. shadowsHue: number;
  7915. /**
  7916. * Gets the shadows Density value.
  7917. * 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.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. /**
  7921. * Sets the shadows Density value.
  7922. * 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.
  7923. * Values less than zero provide a filter of opposite hue.
  7924. */
  7925. shadowsDensity: number;
  7926. /**
  7927. * Gets the shadows Saturation value.
  7928. * 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.
  7929. */
  7930. /**
  7931. * Sets the shadows Saturation value.
  7932. * 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.
  7933. */
  7934. shadowsSaturation: number;
  7935. /**
  7936. * Gets the shadows Exposure value.
  7937. * 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.
  7938. */
  7939. /**
  7940. * Sets the shadows Exposure value.
  7941. * 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.
  7942. */
  7943. shadowsExposure: number;
  7944. /**
  7945. * Returns the class name
  7946. * @returns The class name
  7947. */
  7948. getClassName(): string;
  7949. /**
  7950. * Binds the color curves to the shader.
  7951. * @param colorCurves The color curve to bind
  7952. * @param effect The effect to bind to
  7953. * @param positiveUniform The positive uniform shader parameter
  7954. * @param neutralUniform The neutral uniform shader parameter
  7955. * @param negativeUniform The negative uniform shader parameter
  7956. */
  7957. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7958. /**
  7959. * Prepare the list of uniforms associated with the ColorCurves effects.
  7960. * @param uniformsList The list of uniforms used in the effect
  7961. */
  7962. static PrepareUniforms(uniformsList: string[]): void;
  7963. /**
  7964. * Returns color grading data based on a hue, density, saturation and exposure value.
  7965. * @param filterHue The hue of the color filter.
  7966. * @param filterDensity The density of the color filter.
  7967. * @param saturation The saturation.
  7968. * @param exposure The exposure.
  7969. * @param result The result data container.
  7970. */
  7971. private getColorGradingDataToRef;
  7972. /**
  7973. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7974. * @param value The input slider value in range [-100,100].
  7975. * @returns Adjusted value.
  7976. */
  7977. private static applyColorGradingSliderNonlinear;
  7978. /**
  7979. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7980. * @param hue The hue (H) input.
  7981. * @param saturation The saturation (S) input.
  7982. * @param brightness The brightness (B) input.
  7983. * @result An RGBA color represented as Vector4.
  7984. */
  7985. private static fromHSBToRef;
  7986. /**
  7987. * Returns a value clamped between min and max
  7988. * @param value The value to clamp
  7989. * @param min The minimum of value
  7990. * @param max The maximum of value
  7991. * @returns The clamped value.
  7992. */
  7993. private static clamp;
  7994. /**
  7995. * Clones the current color curve instance.
  7996. * @return The cloned curves
  7997. */
  7998. clone(): ColorCurves;
  7999. /**
  8000. * Serializes the current color curve instance to a json representation.
  8001. * @return a JSON representation
  8002. */
  8003. serialize(): any;
  8004. /**
  8005. * Parses the color curve from a json representation.
  8006. * @param source the JSON source to parse
  8007. * @return The parsed curves
  8008. */
  8009. static Parse(source: any): ColorCurves;
  8010. }
  8011. }
  8012. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8013. import { Observable } from "babylonjs/Misc/observable";
  8014. import { Nullable } from "babylonjs/types";
  8015. import { Color4 } from "babylonjs/Maths/math.color";
  8016. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8017. import { Effect } from "babylonjs/Materials/effect";
  8018. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8019. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8020. /**
  8021. * Interface to follow in your material defines to integrate easily the
  8022. * Image proccessing functions.
  8023. * @hidden
  8024. */
  8025. export interface IImageProcessingConfigurationDefines {
  8026. IMAGEPROCESSING: boolean;
  8027. VIGNETTE: boolean;
  8028. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8029. VIGNETTEBLENDMODEOPAQUE: boolean;
  8030. TONEMAPPING: boolean;
  8031. TONEMAPPING_ACES: boolean;
  8032. CONTRAST: boolean;
  8033. EXPOSURE: boolean;
  8034. COLORCURVES: boolean;
  8035. COLORGRADING: boolean;
  8036. COLORGRADING3D: boolean;
  8037. SAMPLER3DGREENDEPTH: boolean;
  8038. SAMPLER3DBGRMAP: boolean;
  8039. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8040. }
  8041. /**
  8042. * @hidden
  8043. */
  8044. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8045. IMAGEPROCESSING: boolean;
  8046. VIGNETTE: boolean;
  8047. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8048. VIGNETTEBLENDMODEOPAQUE: boolean;
  8049. TONEMAPPING: boolean;
  8050. TONEMAPPING_ACES: boolean;
  8051. CONTRAST: boolean;
  8052. COLORCURVES: boolean;
  8053. COLORGRADING: boolean;
  8054. COLORGRADING3D: boolean;
  8055. SAMPLER3DGREENDEPTH: boolean;
  8056. SAMPLER3DBGRMAP: boolean;
  8057. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8058. EXPOSURE: boolean;
  8059. constructor();
  8060. }
  8061. /**
  8062. * This groups together the common properties used for image processing either in direct forward pass
  8063. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8064. * or not.
  8065. */
  8066. export class ImageProcessingConfiguration {
  8067. /**
  8068. * Default tone mapping applied in BabylonJS.
  8069. */
  8070. static readonly TONEMAPPING_STANDARD: number;
  8071. /**
  8072. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8073. * to other engines rendering to increase portability.
  8074. */
  8075. static readonly TONEMAPPING_ACES: number;
  8076. /**
  8077. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8078. */
  8079. colorCurves: Nullable<ColorCurves>;
  8080. private _colorCurvesEnabled;
  8081. /**
  8082. * Gets wether the color curves effect is enabled.
  8083. */
  8084. /**
  8085. * Sets wether the color curves effect is enabled.
  8086. */
  8087. colorCurvesEnabled: boolean;
  8088. private _colorGradingTexture;
  8089. /**
  8090. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8091. */
  8092. /**
  8093. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8094. */
  8095. colorGradingTexture: Nullable<BaseTexture>;
  8096. private _colorGradingEnabled;
  8097. /**
  8098. * Gets wether the color grading effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color grading effect is enabled.
  8102. */
  8103. colorGradingEnabled: boolean;
  8104. private _colorGradingWithGreenDepth;
  8105. /**
  8106. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8107. */
  8108. /**
  8109. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8110. */
  8111. colorGradingWithGreenDepth: boolean;
  8112. private _colorGradingBGR;
  8113. /**
  8114. * Gets wether the color grading texture contains BGR values.
  8115. */
  8116. /**
  8117. * Sets wether the color grading texture contains BGR values.
  8118. */
  8119. colorGradingBGR: boolean;
  8120. /** @hidden */
  8121. _exposure: number;
  8122. /**
  8123. * Gets the Exposure used in the effect.
  8124. */
  8125. /**
  8126. * Sets the Exposure used in the effect.
  8127. */
  8128. exposure: number;
  8129. private _toneMappingEnabled;
  8130. /**
  8131. * Gets wether the tone mapping effect is enabled.
  8132. */
  8133. /**
  8134. * Sets wether the tone mapping effect is enabled.
  8135. */
  8136. toneMappingEnabled: boolean;
  8137. private _toneMappingType;
  8138. /**
  8139. * Gets the type of tone mapping effect.
  8140. */
  8141. /**
  8142. * Sets the type of tone mapping effect used in BabylonJS.
  8143. */
  8144. toneMappingType: number;
  8145. protected _contrast: number;
  8146. /**
  8147. * Gets the contrast used in the effect.
  8148. */
  8149. /**
  8150. * Sets the contrast used in the effect.
  8151. */
  8152. contrast: number;
  8153. /**
  8154. * Vignette stretch size.
  8155. */
  8156. vignetteStretch: number;
  8157. /**
  8158. * Vignette centre X Offset.
  8159. */
  8160. vignetteCentreX: number;
  8161. /**
  8162. * Vignette centre Y Offset.
  8163. */
  8164. vignetteCentreY: number;
  8165. /**
  8166. * Vignette weight or intensity of the vignette effect.
  8167. */
  8168. vignetteWeight: number;
  8169. /**
  8170. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8171. * if vignetteEnabled is set to true.
  8172. */
  8173. vignetteColor: Color4;
  8174. /**
  8175. * Camera field of view used by the Vignette effect.
  8176. */
  8177. vignetteCameraFov: number;
  8178. private _vignetteBlendMode;
  8179. /**
  8180. * Gets the vignette blend mode allowing different kind of effect.
  8181. */
  8182. /**
  8183. * Sets the vignette blend mode allowing different kind of effect.
  8184. */
  8185. vignetteBlendMode: number;
  8186. private _vignetteEnabled;
  8187. /**
  8188. * Gets wether the vignette effect is enabled.
  8189. */
  8190. /**
  8191. * Sets wether the vignette effect is enabled.
  8192. */
  8193. vignetteEnabled: boolean;
  8194. private _applyByPostProcess;
  8195. /**
  8196. * Gets wether the image processing is applied through a post process or not.
  8197. */
  8198. /**
  8199. * Sets wether the image processing is applied through a post process or not.
  8200. */
  8201. applyByPostProcess: boolean;
  8202. private _isEnabled;
  8203. /**
  8204. * Gets wether the image processing is enabled or not.
  8205. */
  8206. /**
  8207. * Sets wether the image processing is enabled or not.
  8208. */
  8209. isEnabled: boolean;
  8210. /**
  8211. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8212. */
  8213. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8214. /**
  8215. * Method called each time the image processing information changes requires to recompile the effect.
  8216. */
  8217. protected _updateParameters(): void;
  8218. /**
  8219. * Gets the current class name.
  8220. * @return "ImageProcessingConfiguration"
  8221. */
  8222. getClassName(): string;
  8223. /**
  8224. * Prepare the list of uniforms associated with the Image Processing effects.
  8225. * @param uniforms The list of uniforms used in the effect
  8226. * @param defines the list of defines currently in use
  8227. */
  8228. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8229. /**
  8230. * Prepare the list of samplers associated with the Image Processing effects.
  8231. * @param samplersList The list of uniforms used in the effect
  8232. * @param defines the list of defines currently in use
  8233. */
  8234. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8235. /**
  8236. * Prepare the list of defines associated to the shader.
  8237. * @param defines the list of defines to complete
  8238. * @param forPostProcess Define if we are currently in post process mode or not
  8239. */
  8240. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8241. /**
  8242. * Returns true if all the image processing information are ready.
  8243. * @returns True if ready, otherwise, false
  8244. */
  8245. isReady(): boolean;
  8246. /**
  8247. * Binds the image processing to the shader.
  8248. * @param effect The effect to bind to
  8249. * @param aspectRatio Define the current aspect ratio of the effect
  8250. */
  8251. bind(effect: Effect, aspectRatio?: number): void;
  8252. /**
  8253. * Clones the current image processing instance.
  8254. * @return The cloned image processing
  8255. */
  8256. clone(): ImageProcessingConfiguration;
  8257. /**
  8258. * Serializes the current image processing instance to a json representation.
  8259. * @return a JSON representation
  8260. */
  8261. serialize(): any;
  8262. /**
  8263. * Parses the image processing from a json representation.
  8264. * @param source the JSON source to parse
  8265. * @return The parsed image processing
  8266. */
  8267. static Parse(source: any): ImageProcessingConfiguration;
  8268. private static _VIGNETTEMODE_MULTIPLY;
  8269. private static _VIGNETTEMODE_OPAQUE;
  8270. /**
  8271. * Used to apply the vignette as a mix with the pixel color.
  8272. */
  8273. static readonly VIGNETTEMODE_MULTIPLY: number;
  8274. /**
  8275. * Used to apply the vignette as a replacement of the pixel color.
  8276. */
  8277. static readonly VIGNETTEMODE_OPAQUE: number;
  8278. }
  8279. }
  8280. declare module "babylonjs/Shaders/postprocess.vertex" {
  8281. /** @hidden */
  8282. export var postprocessVertexShader: {
  8283. name: string;
  8284. shader: string;
  8285. };
  8286. }
  8287. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8288. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8289. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8290. module "babylonjs/Engines/thinEngine" {
  8291. interface ThinEngine {
  8292. /**
  8293. * Creates a new render target texture
  8294. * @param size defines the size of the texture
  8295. * @param options defines the options used to create the texture
  8296. * @returns a new render target texture stored in an InternalTexture
  8297. */
  8298. createRenderTargetTexture(size: number | {
  8299. width: number;
  8300. height: number;
  8301. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8302. }
  8303. }
  8304. }
  8305. declare module "babylonjs/Maths/math.axis" {
  8306. import { Vector3 } from "babylonjs/Maths/math.vector";
  8307. /** Defines supported spaces */
  8308. export enum Space {
  8309. /** Local (object) space */
  8310. LOCAL = 0,
  8311. /** World space */
  8312. WORLD = 1,
  8313. /** Bone space */
  8314. BONE = 2
  8315. }
  8316. /** Defines the 3 main axes */
  8317. export class Axis {
  8318. /** X axis */
  8319. static X: Vector3;
  8320. /** Y axis */
  8321. static Y: Vector3;
  8322. /** Z axis */
  8323. static Z: Vector3;
  8324. }
  8325. }
  8326. declare module "babylonjs/Cameras/targetCamera" {
  8327. import { Nullable } from "babylonjs/types";
  8328. import { Camera } from "babylonjs/Cameras/camera";
  8329. import { Scene } from "babylonjs/scene";
  8330. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8331. /**
  8332. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8333. * This is the base of the follow, arc rotate cameras and Free camera
  8334. * @see http://doc.babylonjs.com/features/cameras
  8335. */
  8336. export class TargetCamera extends Camera {
  8337. private static _RigCamTransformMatrix;
  8338. private static _TargetTransformMatrix;
  8339. private static _TargetFocalPoint;
  8340. /**
  8341. * Define the current direction the camera is moving to
  8342. */
  8343. cameraDirection: Vector3;
  8344. /**
  8345. * Define the current rotation the camera is rotating to
  8346. */
  8347. cameraRotation: Vector2;
  8348. /**
  8349. * When set, the up vector of the camera will be updated by the rotation of the camera
  8350. */
  8351. updateUpVectorFromRotation: boolean;
  8352. private _tmpQuaternion;
  8353. /**
  8354. * Define the current rotation of the camera
  8355. */
  8356. rotation: Vector3;
  8357. /**
  8358. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8359. */
  8360. rotationQuaternion: Quaternion;
  8361. /**
  8362. * Define the current speed of the camera
  8363. */
  8364. speed: number;
  8365. /**
  8366. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8367. * around all axis.
  8368. */
  8369. noRotationConstraint: boolean;
  8370. /**
  8371. * Define the current target of the camera as an object or a position.
  8372. */
  8373. lockedTarget: any;
  8374. /** @hidden */
  8375. _currentTarget: Vector3;
  8376. /** @hidden */
  8377. _initialFocalDistance: number;
  8378. /** @hidden */
  8379. _viewMatrix: Matrix;
  8380. /** @hidden */
  8381. _camMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraTransformMatrix: Matrix;
  8384. /** @hidden */
  8385. _cameraRotationMatrix: Matrix;
  8386. /** @hidden */
  8387. _referencePoint: Vector3;
  8388. /** @hidden */
  8389. _transformedReferencePoint: Vector3;
  8390. protected _globalCurrentTarget: Vector3;
  8391. protected _globalCurrentUpVector: Vector3;
  8392. /** @hidden */
  8393. _reset: () => void;
  8394. private _defaultUp;
  8395. /**
  8396. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8397. * This is the base of the follow, arc rotate cameras and Free camera
  8398. * @see http://doc.babylonjs.com/features/cameras
  8399. * @param name Defines the name of the camera in the scene
  8400. * @param position Defines the start position of the camera in the scene
  8401. * @param scene Defines the scene the camera belongs to
  8402. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8403. */
  8404. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8405. /**
  8406. * Gets the position in front of the camera at a given distance.
  8407. * @param distance The distance from the camera we want the position to be
  8408. * @returns the position
  8409. */
  8410. getFrontPosition(distance: number): Vector3;
  8411. /** @hidden */
  8412. _getLockedTargetPosition(): Nullable<Vector3>;
  8413. private _storedPosition;
  8414. private _storedRotation;
  8415. private _storedRotationQuaternion;
  8416. /**
  8417. * Store current camera state of the camera (fov, position, rotation, etc..)
  8418. * @returns the camera
  8419. */
  8420. storeState(): Camera;
  8421. /**
  8422. * Restored camera state. You must call storeState() first
  8423. * @returns whether it was successful or not
  8424. * @hidden
  8425. */
  8426. _restoreStateValues(): boolean;
  8427. /** @hidden */
  8428. _initCache(): void;
  8429. /** @hidden */
  8430. _updateCache(ignoreParentClass?: boolean): void;
  8431. /** @hidden */
  8432. _isSynchronizedViewMatrix(): boolean;
  8433. /** @hidden */
  8434. _computeLocalCameraSpeed(): number;
  8435. /**
  8436. * Defines the target the camera should look at.
  8437. * @param target Defines the new target as a Vector or a mesh
  8438. */
  8439. setTarget(target: Vector3): void;
  8440. /**
  8441. * Return the current target position of the camera. This value is expressed in local space.
  8442. * @returns the target position
  8443. */
  8444. getTarget(): Vector3;
  8445. /** @hidden */
  8446. _decideIfNeedsToMove(): boolean;
  8447. /** @hidden */
  8448. _updatePosition(): void;
  8449. /** @hidden */
  8450. _checkInputs(): void;
  8451. protected _updateCameraRotationMatrix(): void;
  8452. /**
  8453. * 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)
  8454. * @returns the current camera
  8455. */
  8456. private _rotateUpVectorWithCameraRotationMatrix;
  8457. private _cachedRotationZ;
  8458. private _cachedQuaternionRotationZ;
  8459. /** @hidden */
  8460. _getViewMatrix(): Matrix;
  8461. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8462. /**
  8463. * @hidden
  8464. */
  8465. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8466. /**
  8467. * @hidden
  8468. */
  8469. _updateRigCameras(): void;
  8470. private _getRigCamPositionAndTarget;
  8471. /**
  8472. * Gets the current object class name.
  8473. * @return the class name
  8474. */
  8475. getClassName(): string;
  8476. }
  8477. }
  8478. declare module "babylonjs/Events/keyboardEvents" {
  8479. /**
  8480. * Gather the list of keyboard event types as constants.
  8481. */
  8482. export class KeyboardEventTypes {
  8483. /**
  8484. * The keydown event is fired when a key becomes active (pressed).
  8485. */
  8486. static readonly KEYDOWN: number;
  8487. /**
  8488. * The keyup event is fired when a key has been released.
  8489. */
  8490. static readonly KEYUP: number;
  8491. }
  8492. /**
  8493. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8494. */
  8495. export class KeyboardInfo {
  8496. /**
  8497. * Defines the type of event (KeyboardEventTypes)
  8498. */
  8499. type: number;
  8500. /**
  8501. * Defines the related dom event
  8502. */
  8503. event: KeyboardEvent;
  8504. /**
  8505. * Instantiates a new keyboard info.
  8506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8507. * @param type Defines the type of event (KeyboardEventTypes)
  8508. * @param event Defines the related dom event
  8509. */
  8510. constructor(
  8511. /**
  8512. * Defines the type of event (KeyboardEventTypes)
  8513. */
  8514. type: number,
  8515. /**
  8516. * Defines the related dom event
  8517. */
  8518. event: KeyboardEvent);
  8519. }
  8520. /**
  8521. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8522. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8523. */
  8524. export class KeyboardInfoPre extends KeyboardInfo {
  8525. /**
  8526. * Defines the type of event (KeyboardEventTypes)
  8527. */
  8528. type: number;
  8529. /**
  8530. * Defines the related dom event
  8531. */
  8532. event: KeyboardEvent;
  8533. /**
  8534. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8535. */
  8536. skipOnPointerObservable: boolean;
  8537. /**
  8538. * Instantiates a new keyboard pre info.
  8539. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8540. * @param type Defines the type of event (KeyboardEventTypes)
  8541. * @param event Defines the related dom event
  8542. */
  8543. constructor(
  8544. /**
  8545. * Defines the type of event (KeyboardEventTypes)
  8546. */
  8547. type: number,
  8548. /**
  8549. * Defines the related dom event
  8550. */
  8551. event: KeyboardEvent);
  8552. }
  8553. }
  8554. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8555. import { Nullable } from "babylonjs/types";
  8556. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8557. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8558. /**
  8559. * Manage the keyboard inputs to control the movement of a free camera.
  8560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8561. */
  8562. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8563. /**
  8564. * Defines the camera the input is attached to.
  8565. */
  8566. camera: FreeCamera;
  8567. /**
  8568. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8569. */
  8570. keysUp: number[];
  8571. /**
  8572. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8573. */
  8574. keysDown: number[];
  8575. /**
  8576. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8577. */
  8578. keysLeft: number[];
  8579. /**
  8580. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8581. */
  8582. keysRight: number[];
  8583. private _keys;
  8584. private _onCanvasBlurObserver;
  8585. private _onKeyboardObserver;
  8586. private _engine;
  8587. private _scene;
  8588. /**
  8589. * Attach the input controls to a specific dom element to get the input from.
  8590. * @param element Defines the element the controls should be listened from
  8591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8592. */
  8593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8594. /**
  8595. * Detach the current controls from the specified dom element.
  8596. * @param element Defines the element to stop listening the inputs from
  8597. */
  8598. detachControl(element: Nullable<HTMLElement>): void;
  8599. /**
  8600. * Update the current camera state depending on the inputs that have been used this frame.
  8601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8602. */
  8603. checkInputs(): void;
  8604. /**
  8605. * Gets the class name of the current intput.
  8606. * @returns the class name
  8607. */
  8608. getClassName(): string;
  8609. /** @hidden */
  8610. _onLostFocus(): void;
  8611. /**
  8612. * Get the friendly name associated with the input class.
  8613. * @returns the input friendly name
  8614. */
  8615. getSimpleName(): string;
  8616. }
  8617. }
  8618. declare module "babylonjs/Lights/shadowLight" {
  8619. import { Camera } from "babylonjs/Cameras/camera";
  8620. import { Scene } from "babylonjs/scene";
  8621. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8623. import { Light } from "babylonjs/Lights/light";
  8624. /**
  8625. * Interface describing all the common properties and methods a shadow light needs to implement.
  8626. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8627. * as well as binding the different shadow properties to the effects.
  8628. */
  8629. export interface IShadowLight extends Light {
  8630. /**
  8631. * The light id in the scene (used in scene.findLighById for instance)
  8632. */
  8633. id: string;
  8634. /**
  8635. * The position the shdow will be casted from.
  8636. */
  8637. position: Vector3;
  8638. /**
  8639. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8640. */
  8641. direction: Vector3;
  8642. /**
  8643. * The transformed position. Position of the light in world space taking parenting in account.
  8644. */
  8645. transformedPosition: Vector3;
  8646. /**
  8647. * The transformed direction. Direction of the light in world space taking parenting in account.
  8648. */
  8649. transformedDirection: Vector3;
  8650. /**
  8651. * The friendly name of the light in the scene.
  8652. */
  8653. name: string;
  8654. /**
  8655. * Defines the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. /**
  8659. * Defines the shadow projection clipping maximum z value.
  8660. */
  8661. shadowMaxZ: number;
  8662. /**
  8663. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8664. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8665. */
  8666. computeTransformedInformation(): boolean;
  8667. /**
  8668. * Gets the scene the light belongs to.
  8669. * @returns The scene
  8670. */
  8671. getScene(): Scene;
  8672. /**
  8673. * Callback defining a custom Projection Matrix Builder.
  8674. * This can be used to override the default projection matrix computation.
  8675. */
  8676. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8677. /**
  8678. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8679. * @param matrix The materix to updated with the projection information
  8680. * @param viewMatrix The transform matrix of the light
  8681. * @param renderList The list of mesh to render in the map
  8682. * @returns The current light
  8683. */
  8684. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8685. /**
  8686. * Gets the current depth scale used in ESM.
  8687. * @returns The scale
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8692. * @returns true if a cube texture needs to be use
  8693. */
  8694. needCube(): boolean;
  8695. /**
  8696. * Detects if the projection matrix requires to be recomputed this frame.
  8697. * @returns true if it requires to be recomputed otherwise, false.
  8698. */
  8699. needProjectionMatrixCompute(): boolean;
  8700. /**
  8701. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8702. */
  8703. forceProjectionMatrixCompute(): void;
  8704. /**
  8705. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8706. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8707. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8708. */
  8709. getShadowDirection(faceIndex?: number): Vector3;
  8710. /**
  8711. * Gets the minZ used for shadow according to both the scene and the light.
  8712. * @param activeCamera The camera we are returning the min for
  8713. * @returns the depth min z
  8714. */
  8715. getDepthMinZ(activeCamera: Camera): number;
  8716. /**
  8717. * Gets the maxZ used for shadow according to both the scene and the light.
  8718. * @param activeCamera The camera we are returning the max for
  8719. * @returns the depth max z
  8720. */
  8721. getDepthMaxZ(activeCamera: Camera): number;
  8722. }
  8723. /**
  8724. * Base implementation IShadowLight
  8725. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8726. */
  8727. export abstract class ShadowLight extends Light implements IShadowLight {
  8728. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8729. protected _position: Vector3;
  8730. protected _setPosition(value: Vector3): void;
  8731. /**
  8732. * Sets the position the shadow will be casted from. Also use as the light position for both
  8733. * point and spot lights.
  8734. */
  8735. /**
  8736. * Sets the position the shadow will be casted from. Also use as the light position for both
  8737. * point and spot lights.
  8738. */
  8739. position: Vector3;
  8740. protected _direction: Vector3;
  8741. protected _setDirection(value: Vector3): void;
  8742. /**
  8743. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8744. * Also use as the light direction on spot and directional lights.
  8745. */
  8746. /**
  8747. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8748. * Also use as the light direction on spot and directional lights.
  8749. */
  8750. direction: Vector3;
  8751. private _shadowMinZ;
  8752. /**
  8753. * Gets the shadow projection clipping minimum z value.
  8754. */
  8755. /**
  8756. * Sets the shadow projection clipping minimum z value.
  8757. */
  8758. shadowMinZ: number;
  8759. private _shadowMaxZ;
  8760. /**
  8761. * Sets the shadow projection clipping maximum z value.
  8762. */
  8763. /**
  8764. * Gets the shadow projection clipping maximum z value.
  8765. */
  8766. shadowMaxZ: number;
  8767. /**
  8768. * Callback defining a custom Projection Matrix Builder.
  8769. * This can be used to override the default projection matrix computation.
  8770. */
  8771. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8772. /**
  8773. * The transformed position. Position of the light in world space taking parenting in account.
  8774. */
  8775. transformedPosition: Vector3;
  8776. /**
  8777. * The transformed direction. Direction of the light in world space taking parenting in account.
  8778. */
  8779. transformedDirection: Vector3;
  8780. private _needProjectionMatrixCompute;
  8781. /**
  8782. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8783. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8784. */
  8785. computeTransformedInformation(): boolean;
  8786. /**
  8787. * Return the depth scale used for the shadow map.
  8788. * @returns the depth scale.
  8789. */
  8790. getDepthScale(): number;
  8791. /**
  8792. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8793. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8794. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8795. */
  8796. getShadowDirection(faceIndex?: number): Vector3;
  8797. /**
  8798. * Returns the ShadowLight absolute position in the World.
  8799. * @returns the position vector in world space
  8800. */
  8801. getAbsolutePosition(): Vector3;
  8802. /**
  8803. * Sets the ShadowLight direction toward the passed target.
  8804. * @param target The point to target in local space
  8805. * @returns the updated ShadowLight direction
  8806. */
  8807. setDirectionToTarget(target: Vector3): Vector3;
  8808. /**
  8809. * Returns the light rotation in euler definition.
  8810. * @returns the x y z rotation in local space.
  8811. */
  8812. getRotation(): Vector3;
  8813. /**
  8814. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8815. * @returns true if a cube texture needs to be use
  8816. */
  8817. needCube(): boolean;
  8818. /**
  8819. * Detects if the projection matrix requires to be recomputed this frame.
  8820. * @returns true if it requires to be recomputed otherwise, false.
  8821. */
  8822. needProjectionMatrixCompute(): boolean;
  8823. /**
  8824. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8825. */
  8826. forceProjectionMatrixCompute(): void;
  8827. /** @hidden */
  8828. _initCache(): void;
  8829. /** @hidden */
  8830. _isSynchronized(): boolean;
  8831. /**
  8832. * Computes the world matrix of the node
  8833. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8834. * @returns the world matrix
  8835. */
  8836. computeWorldMatrix(force?: boolean): Matrix;
  8837. /**
  8838. * Gets the minZ used for shadow according to both the scene and the light.
  8839. * @param activeCamera The camera we are returning the min for
  8840. * @returns the depth min z
  8841. */
  8842. getDepthMinZ(activeCamera: Camera): number;
  8843. /**
  8844. * Gets the maxZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the max for
  8846. * @returns the depth max z
  8847. */
  8848. getDepthMaxZ(activeCamera: Camera): number;
  8849. /**
  8850. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8851. * @param matrix The materix to updated with the projection information
  8852. * @param viewMatrix The transform matrix of the light
  8853. * @param renderList The list of mesh to render in the map
  8854. * @returns The current light
  8855. */
  8856. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8857. }
  8858. }
  8859. declare module "babylonjs/Materials/effectFallbacks" {
  8860. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8861. import { Effect } from "babylonjs/Materials/effect";
  8862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8863. /**
  8864. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8865. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8866. */
  8867. export class EffectFallbacks implements IEffectFallbacks {
  8868. private _defines;
  8869. private _currentRank;
  8870. private _maxRank;
  8871. private _mesh;
  8872. /**
  8873. * Removes the fallback from the bound mesh.
  8874. */
  8875. unBindMesh(): void;
  8876. /**
  8877. * Adds a fallback on the specified property.
  8878. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8879. * @param define The name of the define in the shader
  8880. */
  8881. addFallback(rank: number, define: string): void;
  8882. /**
  8883. * Sets the mesh to use CPU skinning when needing to fallback.
  8884. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8885. * @param mesh The mesh to use the fallbacks.
  8886. */
  8887. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8888. /**
  8889. * Checks to see if more fallbacks are still availible.
  8890. */
  8891. readonly hasMoreFallbacks: boolean;
  8892. /**
  8893. * Removes the defines that should be removed when falling back.
  8894. * @param currentDefines defines the current define statements for the shader.
  8895. * @param effect defines the current effect we try to compile
  8896. * @returns The resulting defines with defines of the current rank removed.
  8897. */
  8898. reduce(currentDefines: string, effect: Effect): string;
  8899. }
  8900. }
  8901. declare module "babylonjs/Materials/materialHelper" {
  8902. import { Nullable } from "babylonjs/types";
  8903. import { Scene } from "babylonjs/scene";
  8904. import { Engine } from "babylonjs/Engines/engine";
  8905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8906. import { Light } from "babylonjs/Lights/light";
  8907. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8908. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8909. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8910. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8911. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8912. /**
  8913. * "Static Class" containing the most commonly used helper while dealing with material for
  8914. * rendering purpose.
  8915. *
  8916. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8917. *
  8918. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8919. */
  8920. export class MaterialHelper {
  8921. /**
  8922. * Bind the current view position to an effect.
  8923. * @param effect The effect to be bound
  8924. * @param scene The scene the eyes position is used from
  8925. */
  8926. static BindEyePosition(effect: Effect, scene: Scene): void;
  8927. /**
  8928. * Helps preparing the defines values about the UVs in used in the effect.
  8929. * UVs are shared as much as we can accross channels in the shaders.
  8930. * @param texture The texture we are preparing the UVs for
  8931. * @param defines The defines to update
  8932. * @param key The channel key "diffuse", "specular"... used in the shader
  8933. */
  8934. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8935. /**
  8936. * Binds a texture matrix value to its corrsponding uniform
  8937. * @param texture The texture to bind the matrix for
  8938. * @param uniformBuffer The uniform buffer receivin the data
  8939. * @param key The channel key "diffuse", "specular"... used in the shader
  8940. */
  8941. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8942. /**
  8943. * Gets the current status of the fog (should it be enabled?)
  8944. * @param mesh defines the mesh to evaluate for fog support
  8945. * @param scene defines the hosting scene
  8946. * @returns true if fog must be enabled
  8947. */
  8948. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8949. /**
  8950. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8951. * @param mesh defines the current mesh
  8952. * @param scene defines the current scene
  8953. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8954. * @param pointsCloud defines if point cloud rendering has to be turned on
  8955. * @param fogEnabled defines if fog has to be turned on
  8956. * @param alphaTest defines if alpha testing has to be turned on
  8957. * @param defines defines the current list of defines
  8958. */
  8959. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8960. /**
  8961. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8962. * @param scene defines the current scene
  8963. * @param engine defines the current engine
  8964. * @param defines specifies the list of active defines
  8965. * @param useInstances defines if instances have to be turned on
  8966. * @param useClipPlane defines if clip plane have to be turned on
  8967. */
  8968. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8969. /**
  8970. * Prepares the defines for bones
  8971. * @param mesh The mesh containing the geometry data we will draw
  8972. * @param defines The defines to update
  8973. */
  8974. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8975. /**
  8976. * Prepares the defines for morph targets
  8977. * @param mesh The mesh containing the geometry data we will draw
  8978. * @param defines The defines to update
  8979. */
  8980. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8981. /**
  8982. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8983. * @param mesh The mesh containing the geometry data we will draw
  8984. * @param defines The defines to update
  8985. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8986. * @param useBones Precise whether bones should be used or not (override mesh info)
  8987. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8988. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8989. * @returns false if defines are considered not dirty and have not been checked
  8990. */
  8991. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8992. /**
  8993. * Prepares the defines related to multiview
  8994. * @param scene The scene we are intending to draw
  8995. * @param defines The defines to update
  8996. */
  8997. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8998. /**
  8999. * Prepares the defines related to the light information passed in parameter
  9000. * @param scene The scene we are intending to draw
  9001. * @param mesh The mesh the effect is compiling for
  9002. * @param light The light the effect is compiling for
  9003. * @param lightIndex The index of the light
  9004. * @param defines The defines to update
  9005. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9006. * @param state Defines the current state regarding what is needed (normals, etc...)
  9007. */
  9008. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9009. needNormals: boolean;
  9010. needRebuild: boolean;
  9011. shadowEnabled: boolean;
  9012. specularEnabled: boolean;
  9013. lightmapMode: boolean;
  9014. }): void;
  9015. /**
  9016. * Prepares the defines related to the light information passed in parameter
  9017. * @param scene The scene we are intending to draw
  9018. * @param mesh The mesh the effect is compiling for
  9019. * @param defines The defines to update
  9020. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9021. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9022. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9023. * @returns true if normals will be required for the rest of the effect
  9024. */
  9025. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9026. /**
  9027. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9028. * @param lightIndex defines the light index
  9029. * @param uniformsList The uniform list
  9030. * @param samplersList The sampler list
  9031. * @param projectedLightTexture defines if projected texture must be used
  9032. * @param uniformBuffersList defines an optional list of uniform buffers
  9033. */
  9034. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9035. /**
  9036. * Prepares the uniforms and samplers list to be used in the effect
  9037. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9038. * @param samplersList The sampler list
  9039. * @param defines The defines helping in the list generation
  9040. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9041. */
  9042. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9043. /**
  9044. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9045. * @param defines The defines to update while falling back
  9046. * @param fallbacks The authorized effect fallbacks
  9047. * @param maxSimultaneousLights The maximum number of lights allowed
  9048. * @param rank the current rank of the Effect
  9049. * @returns The newly affected rank
  9050. */
  9051. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9052. private static _TmpMorphInfluencers;
  9053. /**
  9054. * Prepares the list of attributes required for morph targets according to the effect defines.
  9055. * @param attribs The current list of supported attribs
  9056. * @param mesh The mesh to prepare the morph targets attributes for
  9057. * @param influencers The number of influencers
  9058. */
  9059. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9060. /**
  9061. * Prepares the list of attributes required for morph targets according to the effect defines.
  9062. * @param attribs The current list of supported attribs
  9063. * @param mesh The mesh to prepare the morph targets attributes for
  9064. * @param defines The current Defines of the effect
  9065. */
  9066. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9067. /**
  9068. * Prepares the list of attributes required for bones according to the effect defines.
  9069. * @param attribs The current list of supported attribs
  9070. * @param mesh The mesh to prepare the bones attributes for
  9071. * @param defines The current Defines of the effect
  9072. * @param fallbacks The current efffect fallback strategy
  9073. */
  9074. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9075. /**
  9076. * Check and prepare the list of attributes required for instances according to the effect defines.
  9077. * @param attribs The current list of supported attribs
  9078. * @param defines The current MaterialDefines of the effect
  9079. */
  9080. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9081. /**
  9082. * Add the list of attributes required for instances to the attribs array.
  9083. * @param attribs The current list of supported attribs
  9084. */
  9085. static PushAttributesForInstances(attribs: string[]): void;
  9086. /**
  9087. * Binds the light shadow information to the effect for the given mesh.
  9088. * @param light The light containing the generator
  9089. * @param scene The scene the lights belongs to
  9090. * @param mesh The mesh we are binding the information to render
  9091. * @param lightIndex The light index in the effect used to render the mesh
  9092. * @param effect The effect we are binding the data to
  9093. */
  9094. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9095. /**
  9096. * Binds the light information to the effect.
  9097. * @param light The light containing the generator
  9098. * @param effect The effect we are binding the data to
  9099. * @param lightIndex The light index in the effect used to render
  9100. */
  9101. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9102. /**
  9103. * Binds the lights information from the scene to the effect for the given mesh.
  9104. * @param light Light to bind
  9105. * @param lightIndex Light index
  9106. * @param scene The scene where the light belongs to
  9107. * @param mesh The mesh we are binding the information to render
  9108. * @param effect The effect we are binding the data to
  9109. * @param useSpecular Defines if specular is supported
  9110. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9111. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9112. */
  9113. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9114. /**
  9115. * Binds the lights information from the scene to the effect for the given mesh.
  9116. * @param scene The scene the lights belongs to
  9117. * @param mesh The mesh we are binding the information to render
  9118. * @param effect The effect we are binding the data to
  9119. * @param defines The generated defines for the effect
  9120. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9121. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9122. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9123. */
  9124. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9125. private static _tempFogColor;
  9126. /**
  9127. * Binds the fog information from the scene to the effect for the given mesh.
  9128. * @param scene The scene the lights belongs to
  9129. * @param mesh The mesh we are binding the information to render
  9130. * @param effect The effect we are binding the data to
  9131. * @param linearSpace Defines if the fog effect is applied in linear space
  9132. */
  9133. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9134. /**
  9135. * Binds the bones information from the mesh to the effect.
  9136. * @param mesh The mesh we are binding the information to render
  9137. * @param effect The effect we are binding the data to
  9138. */
  9139. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9140. /**
  9141. * Binds the morph targets information from the mesh to the effect.
  9142. * @param abstractMesh The mesh we are binding the information to render
  9143. * @param effect The effect we are binding the data to
  9144. */
  9145. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9146. /**
  9147. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9148. * @param defines The generated defines used in the effect
  9149. * @param effect The effect we are binding the data to
  9150. * @param scene The scene we are willing to render with logarithmic scale for
  9151. */
  9152. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9153. /**
  9154. * Binds the clip plane information from the scene to the effect.
  9155. * @param scene The scene the clip plane information are extracted from
  9156. * @param effect The effect we are binding the data to
  9157. */
  9158. static BindClipPlane(effect: Effect, scene: Scene): void;
  9159. }
  9160. }
  9161. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9162. /** @hidden */
  9163. export var packingFunctions: {
  9164. name: string;
  9165. shader: string;
  9166. };
  9167. }
  9168. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9169. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9170. /** @hidden */
  9171. export var shadowMapPixelShader: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9177. /** @hidden */
  9178. export var bonesDeclaration: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9184. /** @hidden */
  9185. export var morphTargetsVertexGlobalDeclaration: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9191. /** @hidden */
  9192. export var morphTargetsVertexDeclaration: {
  9193. name: string;
  9194. shader: string;
  9195. };
  9196. }
  9197. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9198. /** @hidden */
  9199. export var instancesDeclaration: {
  9200. name: string;
  9201. shader: string;
  9202. };
  9203. }
  9204. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9205. /** @hidden */
  9206. export var helperFunctions: {
  9207. name: string;
  9208. shader: string;
  9209. };
  9210. }
  9211. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9212. /** @hidden */
  9213. export var morphTargetsVertex: {
  9214. name: string;
  9215. shader: string;
  9216. };
  9217. }
  9218. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9219. /** @hidden */
  9220. export var instancesVertex: {
  9221. name: string;
  9222. shader: string;
  9223. };
  9224. }
  9225. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9226. /** @hidden */
  9227. export var bonesVertex: {
  9228. name: string;
  9229. shader: string;
  9230. };
  9231. }
  9232. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9233. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9234. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9235. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9236. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9237. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9238. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9239. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9240. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9241. /** @hidden */
  9242. export var shadowMapVertexShader: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9248. /** @hidden */
  9249. export var depthBoxBlurPixelShader: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9255. import { Nullable } from "babylonjs/types";
  9256. import { Scene } from "babylonjs/scene";
  9257. import { Matrix } from "babylonjs/Maths/math.vector";
  9258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9260. import { Mesh } from "babylonjs/Meshes/mesh";
  9261. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9262. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9263. import { Effect } from "babylonjs/Materials/effect";
  9264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9265. import "babylonjs/Shaders/shadowMap.fragment";
  9266. import "babylonjs/Shaders/shadowMap.vertex";
  9267. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9268. import { Observable } from "babylonjs/Misc/observable";
  9269. /**
  9270. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9271. */
  9272. export interface ICustomShaderOptions {
  9273. /**
  9274. * Gets or sets the custom shader name to use
  9275. */
  9276. shaderName: string;
  9277. /**
  9278. * The list of attribute names used in the shader
  9279. */
  9280. attributes?: string[];
  9281. /**
  9282. * The list of unifrom names used in the shader
  9283. */
  9284. uniforms?: string[];
  9285. /**
  9286. * The list of sampler names used in the shader
  9287. */
  9288. samplers?: string[];
  9289. /**
  9290. * The list of defines used in the shader
  9291. */
  9292. defines?: string[];
  9293. }
  9294. /**
  9295. * Interface to implement to create a shadow generator compatible with BJS.
  9296. */
  9297. export interface IShadowGenerator {
  9298. /**
  9299. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9300. * @returns The render target texture if present otherwise, null
  9301. */
  9302. getShadowMap(): Nullable<RenderTargetTexture>;
  9303. /**
  9304. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9305. * @returns The render target texture if the shadow map is present otherwise, null
  9306. */
  9307. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9308. /**
  9309. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9310. * @param subMesh The submesh we want to render in the shadow map
  9311. * @param useInstances Defines wether will draw in the map using instances
  9312. * @returns true if ready otherwise, false
  9313. */
  9314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9315. /**
  9316. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9317. * @param defines Defines of the material we want to update
  9318. * @param lightIndex Index of the light in the enabled light list of the material
  9319. */
  9320. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9321. /**
  9322. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9323. * defined in the generator but impacting the effect).
  9324. * It implies the unifroms available on the materials are the standard BJS ones.
  9325. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9326. * @param effect The effect we are binfing the information for
  9327. */
  9328. bindShadowLight(lightIndex: string, effect: Effect): void;
  9329. /**
  9330. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9331. * (eq to shadow prjection matrix * light transform matrix)
  9332. * @returns The transform matrix used to create the shadow map
  9333. */
  9334. getTransformMatrix(): Matrix;
  9335. /**
  9336. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9337. * Cube and 2D textures for instance.
  9338. */
  9339. recreateShadowMap(): void;
  9340. /**
  9341. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9342. * @param onCompiled Callback triggered at the and of the effects compilation
  9343. * @param options Sets of optional options forcing the compilation with different modes
  9344. */
  9345. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9346. useInstances: boolean;
  9347. }>): void;
  9348. /**
  9349. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9350. * @param options Sets of optional options forcing the compilation with different modes
  9351. * @returns A promise that resolves when the compilation completes
  9352. */
  9353. forceCompilationAsync(options?: Partial<{
  9354. useInstances: boolean;
  9355. }>): Promise<void>;
  9356. /**
  9357. * Serializes the shadow generator setup to a json object.
  9358. * @returns The serialized JSON object
  9359. */
  9360. serialize(): any;
  9361. /**
  9362. * Disposes the Shadow map and related Textures and effects.
  9363. */
  9364. dispose(): void;
  9365. }
  9366. /**
  9367. * Default implementation IShadowGenerator.
  9368. * This is the main object responsible of generating shadows in the framework.
  9369. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9370. */
  9371. export class ShadowGenerator implements IShadowGenerator {
  9372. /**
  9373. * Shadow generator mode None: no filtering applied.
  9374. */
  9375. static readonly FILTER_NONE: number;
  9376. /**
  9377. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9378. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9379. */
  9380. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9381. /**
  9382. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9383. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9384. */
  9385. static readonly FILTER_POISSONSAMPLING: number;
  9386. /**
  9387. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9389. */
  9390. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9391. /**
  9392. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9393. * edge artifacts on steep falloff.
  9394. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9395. */
  9396. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9397. /**
  9398. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9399. * edge artifacts on steep falloff.
  9400. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9401. */
  9402. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9403. /**
  9404. * Shadow generator mode PCF: Percentage Closer Filtering
  9405. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9406. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9407. */
  9408. static readonly FILTER_PCF: number;
  9409. /**
  9410. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9411. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9412. * Contact Hardening
  9413. */
  9414. static readonly FILTER_PCSS: number;
  9415. /**
  9416. * Reserved for PCF and PCSS
  9417. * Highest Quality.
  9418. *
  9419. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9420. *
  9421. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9422. */
  9423. static readonly QUALITY_HIGH: number;
  9424. /**
  9425. * Reserved for PCF and PCSS
  9426. * Good tradeoff for quality/perf cross devices
  9427. *
  9428. * Execute PCF on a 3*3 kernel.
  9429. *
  9430. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9431. */
  9432. static readonly QUALITY_MEDIUM: number;
  9433. /**
  9434. * Reserved for PCF and PCSS
  9435. * The lowest quality but the fastest.
  9436. *
  9437. * Execute PCF on a 1*1 kernel.
  9438. *
  9439. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9440. */
  9441. static readonly QUALITY_LOW: number;
  9442. /** Gets or sets the custom shader name to use */
  9443. customShaderOptions: ICustomShaderOptions;
  9444. /**
  9445. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9446. */
  9447. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9448. /**
  9449. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9450. */
  9451. onAfterShadowMapRenderObservable: Observable<Effect>;
  9452. /**
  9453. * Observable triggered before a mesh is rendered in the shadow map.
  9454. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9455. */
  9456. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9457. /**
  9458. * Observable triggered after a mesh is rendered in the shadow map.
  9459. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9460. */
  9461. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9462. private _bias;
  9463. /**
  9464. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9465. */
  9466. /**
  9467. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9468. */
  9469. bias: number;
  9470. private _normalBias;
  9471. /**
  9472. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9473. */
  9474. /**
  9475. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9476. */
  9477. normalBias: number;
  9478. private _blurBoxOffset;
  9479. /**
  9480. * Gets the blur box offset: offset applied during the blur pass.
  9481. * Only useful if useKernelBlur = false
  9482. */
  9483. /**
  9484. * Sets the blur box offset: offset applied during the blur pass.
  9485. * Only useful if useKernelBlur = false
  9486. */
  9487. blurBoxOffset: number;
  9488. private _blurScale;
  9489. /**
  9490. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9491. * 2 means half of the size.
  9492. */
  9493. /**
  9494. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9495. * 2 means half of the size.
  9496. */
  9497. blurScale: number;
  9498. private _blurKernel;
  9499. /**
  9500. * Gets the blur kernel: kernel size of the blur pass.
  9501. * Only useful if useKernelBlur = true
  9502. */
  9503. /**
  9504. * Sets the blur kernel: kernel size of the blur pass.
  9505. * Only useful if useKernelBlur = true
  9506. */
  9507. blurKernel: number;
  9508. private _useKernelBlur;
  9509. /**
  9510. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9511. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9512. */
  9513. /**
  9514. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9515. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9516. */
  9517. useKernelBlur: boolean;
  9518. private _depthScale;
  9519. /**
  9520. * Gets the depth scale used in ESM mode.
  9521. */
  9522. /**
  9523. * Sets the depth scale used in ESM mode.
  9524. * This can override the scale stored on the light.
  9525. */
  9526. depthScale: number;
  9527. private _filter;
  9528. /**
  9529. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9530. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9531. */
  9532. /**
  9533. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9534. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9535. */
  9536. filter: number;
  9537. /**
  9538. * Gets if the current filter is set to Poisson Sampling.
  9539. */
  9540. /**
  9541. * Sets the current filter to Poisson Sampling.
  9542. */
  9543. usePoissonSampling: boolean;
  9544. /**
  9545. * Gets if the current filter is set to ESM.
  9546. */
  9547. /**
  9548. * Sets the current filter is to ESM.
  9549. */
  9550. useExponentialShadowMap: boolean;
  9551. /**
  9552. * Gets if the current filter is set to filtered ESM.
  9553. */
  9554. /**
  9555. * Gets if the current filter is set to filtered ESM.
  9556. */
  9557. useBlurExponentialShadowMap: boolean;
  9558. /**
  9559. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9560. * exponential to prevent steep falloff artifacts).
  9561. */
  9562. /**
  9563. * Sets the current filter to "close ESM" (using the inverse of the
  9564. * exponential to prevent steep falloff artifacts).
  9565. */
  9566. useCloseExponentialShadowMap: boolean;
  9567. /**
  9568. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9569. * exponential to prevent steep falloff artifacts).
  9570. */
  9571. /**
  9572. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9573. * exponential to prevent steep falloff artifacts).
  9574. */
  9575. useBlurCloseExponentialShadowMap: boolean;
  9576. /**
  9577. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9578. */
  9579. /**
  9580. * Sets the current filter to "PCF" (percentage closer filtering).
  9581. */
  9582. usePercentageCloserFiltering: boolean;
  9583. private _filteringQuality;
  9584. /**
  9585. * Gets the PCF or PCSS Quality.
  9586. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9587. */
  9588. /**
  9589. * Sets the PCF or PCSS Quality.
  9590. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9591. */
  9592. filteringQuality: number;
  9593. /**
  9594. * Gets if the current filter is set to "PCSS" (contact hardening).
  9595. */
  9596. /**
  9597. * Sets the current filter to "PCSS" (contact hardening).
  9598. */
  9599. useContactHardeningShadow: boolean;
  9600. private _contactHardeningLightSizeUVRatio;
  9601. /**
  9602. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9603. * Using a ratio helps keeping shape stability independently of the map size.
  9604. *
  9605. * It does not account for the light projection as it was having too much
  9606. * instability during the light setup or during light position changes.
  9607. *
  9608. * Only valid if useContactHardeningShadow is true.
  9609. */
  9610. /**
  9611. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9612. * Using a ratio helps keeping shape stability independently of the map size.
  9613. *
  9614. * It does not account for the light projection as it was having too much
  9615. * instability during the light setup or during light position changes.
  9616. *
  9617. * Only valid if useContactHardeningShadow is true.
  9618. */
  9619. contactHardeningLightSizeUVRatio: number;
  9620. private _darkness;
  9621. /** Gets or sets the actual darkness of a shadow */
  9622. darkness: number;
  9623. /**
  9624. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9625. * 0 means strongest and 1 would means no shadow.
  9626. * @returns the darkness.
  9627. */
  9628. getDarkness(): number;
  9629. /**
  9630. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9631. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9632. * @returns the shadow generator allowing fluent coding.
  9633. */
  9634. setDarkness(darkness: number): ShadowGenerator;
  9635. private _transparencyShadow;
  9636. /** Gets or sets the ability to have transparent shadow */
  9637. transparencyShadow: boolean;
  9638. /**
  9639. * Sets the ability to have transparent shadow (boolean).
  9640. * @param transparent True if transparent else False
  9641. * @returns the shadow generator allowing fluent coding
  9642. */
  9643. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9644. private _shadowMap;
  9645. private _shadowMap2;
  9646. /**
  9647. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9648. * @returns The render target texture if present otherwise, null
  9649. */
  9650. getShadowMap(): Nullable<RenderTargetTexture>;
  9651. /**
  9652. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9653. * @returns The render target texture if the shadow map is present otherwise, null
  9654. */
  9655. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9656. /**
  9657. * Gets the class name of that object
  9658. * @returns "ShadowGenerator"
  9659. */
  9660. getClassName(): string;
  9661. /**
  9662. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9663. * @param mesh Mesh to add
  9664. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9665. * @returns the Shadow Generator itself
  9666. */
  9667. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9668. /**
  9669. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9670. * @param mesh Mesh to remove
  9671. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9672. * @returns the Shadow Generator itself
  9673. */
  9674. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9675. /**
  9676. * Controls the extent to which the shadows fade out at the edge of the frustum
  9677. * Used only by directionals and spots
  9678. */
  9679. frustumEdgeFalloff: number;
  9680. private _light;
  9681. /**
  9682. * Returns the associated light object.
  9683. * @returns the light generating the shadow
  9684. */
  9685. getLight(): IShadowLight;
  9686. /**
  9687. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9688. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9689. * It might on the other hand introduce peter panning.
  9690. */
  9691. forceBackFacesOnly: boolean;
  9692. private _scene;
  9693. private _lightDirection;
  9694. private _effect;
  9695. private _viewMatrix;
  9696. private _projectionMatrix;
  9697. private _transformMatrix;
  9698. private _cachedPosition;
  9699. private _cachedDirection;
  9700. private _cachedDefines;
  9701. private _currentRenderID;
  9702. private _boxBlurPostprocess;
  9703. private _kernelBlurXPostprocess;
  9704. private _kernelBlurYPostprocess;
  9705. private _blurPostProcesses;
  9706. private _mapSize;
  9707. private _currentFaceIndex;
  9708. private _currentFaceIndexCache;
  9709. private _textureType;
  9710. private _defaultTextureMatrix;
  9711. private _storedUniqueId;
  9712. /** @hidden */
  9713. static _SceneComponentInitialization: (scene: Scene) => void;
  9714. /**
  9715. * Creates a ShadowGenerator object.
  9716. * A ShadowGenerator is the required tool to use the shadows.
  9717. * Each light casting shadows needs to use its own ShadowGenerator.
  9718. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9719. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9720. * @param light The light object generating the shadows.
  9721. * @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.
  9722. */
  9723. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9724. private _initializeGenerator;
  9725. private _initializeShadowMap;
  9726. private _initializeBlurRTTAndPostProcesses;
  9727. private _renderForShadowMap;
  9728. private _renderSubMeshForShadowMap;
  9729. private _applyFilterValues;
  9730. /**
  9731. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9732. * @param onCompiled Callback triggered at the and of the effects compilation
  9733. * @param options Sets of optional options forcing the compilation with different modes
  9734. */
  9735. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9736. useInstances: boolean;
  9737. }>): void;
  9738. /**
  9739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9740. * @param options Sets of optional options forcing the compilation with different modes
  9741. * @returns A promise that resolves when the compilation completes
  9742. */
  9743. forceCompilationAsync(options?: Partial<{
  9744. useInstances: boolean;
  9745. }>): Promise<void>;
  9746. /**
  9747. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9748. * @param subMesh The submesh we want to render in the shadow map
  9749. * @param useInstances Defines wether will draw in the map using instances
  9750. * @returns true if ready otherwise, false
  9751. */
  9752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9753. /**
  9754. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9755. * @param defines Defines of the material we want to update
  9756. * @param lightIndex Index of the light in the enabled light list of the material
  9757. */
  9758. prepareDefines(defines: any, lightIndex: number): void;
  9759. /**
  9760. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9761. * defined in the generator but impacting the effect).
  9762. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9763. * @param effect The effect we are binfing the information for
  9764. */
  9765. bindShadowLight(lightIndex: string, effect: Effect): void;
  9766. /**
  9767. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9768. * (eq to shadow prjection matrix * light transform matrix)
  9769. * @returns The transform matrix used to create the shadow map
  9770. */
  9771. getTransformMatrix(): Matrix;
  9772. /**
  9773. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9774. * Cube and 2D textures for instance.
  9775. */
  9776. recreateShadowMap(): void;
  9777. private _disposeBlurPostProcesses;
  9778. private _disposeRTTandPostProcesses;
  9779. /**
  9780. * Disposes the ShadowGenerator.
  9781. * Returns nothing.
  9782. */
  9783. dispose(): void;
  9784. /**
  9785. * Serializes the shadow generator setup to a json object.
  9786. * @returns The serialized JSON object
  9787. */
  9788. serialize(): any;
  9789. /**
  9790. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9791. * @param parsedShadowGenerator The JSON object to parse
  9792. * @param scene The scene to create the shadow map for
  9793. * @returns The parsed shadow generator
  9794. */
  9795. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9796. }
  9797. }
  9798. declare module "babylonjs/Lights/light" {
  9799. import { Nullable } from "babylonjs/types";
  9800. import { Scene } from "babylonjs/scene";
  9801. import { Vector3 } from "babylonjs/Maths/math.vector";
  9802. import { Color3 } from "babylonjs/Maths/math.color";
  9803. import { Node } from "babylonjs/node";
  9804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9805. import { Effect } from "babylonjs/Materials/effect";
  9806. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9807. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9808. /**
  9809. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9810. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9811. * 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.
  9812. */
  9813. export abstract class Light extends Node {
  9814. /**
  9815. * Falloff Default: light is falling off following the material specification:
  9816. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9817. */
  9818. static readonly FALLOFF_DEFAULT: number;
  9819. /**
  9820. * Falloff Physical: light is falling off following the inverse squared distance law.
  9821. */
  9822. static readonly FALLOFF_PHYSICAL: number;
  9823. /**
  9824. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9825. * to enhance interoperability with other engines.
  9826. */
  9827. static readonly FALLOFF_GLTF: number;
  9828. /**
  9829. * Falloff Standard: light is falling off like in the standard material
  9830. * to enhance interoperability with other materials.
  9831. */
  9832. static readonly FALLOFF_STANDARD: number;
  9833. /**
  9834. * If every light affecting the material is in this lightmapMode,
  9835. * material.lightmapTexture adds or multiplies
  9836. * (depends on material.useLightmapAsShadowmap)
  9837. * after every other light calculations.
  9838. */
  9839. static readonly LIGHTMAP_DEFAULT: number;
  9840. /**
  9841. * material.lightmapTexture as only diffuse lighting from this light
  9842. * adds only specular lighting from this light
  9843. * adds dynamic shadows
  9844. */
  9845. static readonly LIGHTMAP_SPECULAR: number;
  9846. /**
  9847. * material.lightmapTexture as only lighting
  9848. * no light calculation from this light
  9849. * only adds dynamic shadows from this light
  9850. */
  9851. static readonly LIGHTMAP_SHADOWSONLY: number;
  9852. /**
  9853. * Each light type uses the default quantity according to its type:
  9854. * point/spot lights use luminous intensity
  9855. * directional lights use illuminance
  9856. */
  9857. static readonly INTENSITYMODE_AUTOMATIC: number;
  9858. /**
  9859. * lumen (lm)
  9860. */
  9861. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9862. /**
  9863. * candela (lm/sr)
  9864. */
  9865. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9866. /**
  9867. * lux (lm/m^2)
  9868. */
  9869. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9870. /**
  9871. * nit (cd/m^2)
  9872. */
  9873. static readonly INTENSITYMODE_LUMINANCE: number;
  9874. /**
  9875. * Light type const id of the point light.
  9876. */
  9877. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9878. /**
  9879. * Light type const id of the directional light.
  9880. */
  9881. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9882. /**
  9883. * Light type const id of the spot light.
  9884. */
  9885. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9886. /**
  9887. * Light type const id of the hemispheric light.
  9888. */
  9889. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9890. /**
  9891. * Diffuse gives the basic color to an object.
  9892. */
  9893. diffuse: Color3;
  9894. /**
  9895. * Specular produces a highlight color on an object.
  9896. * Note: This is note affecting PBR materials.
  9897. */
  9898. specular: Color3;
  9899. /**
  9900. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9901. * falling off base on range or angle.
  9902. * This can be set to any values in Light.FALLOFF_x.
  9903. *
  9904. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9905. * other types of materials.
  9906. */
  9907. falloffType: number;
  9908. /**
  9909. * Strength of the light.
  9910. * Note: By default it is define in the framework own unit.
  9911. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9912. */
  9913. intensity: number;
  9914. private _range;
  9915. protected _inverseSquaredRange: number;
  9916. /**
  9917. * Defines how far from the source the light is impacting in scene units.
  9918. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9919. */
  9920. /**
  9921. * Defines how far from the source the light is impacting in scene units.
  9922. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9923. */
  9924. range: number;
  9925. /**
  9926. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9927. * of light.
  9928. */
  9929. private _photometricScale;
  9930. private _intensityMode;
  9931. /**
  9932. * Gets the photometric scale used to interpret the intensity.
  9933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9934. */
  9935. /**
  9936. * Sets the photometric scale used to interpret the intensity.
  9937. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9938. */
  9939. intensityMode: number;
  9940. private _radius;
  9941. /**
  9942. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9943. */
  9944. /**
  9945. * sets the light radius used by PBR Materials to simulate soft area lights.
  9946. */
  9947. radius: number;
  9948. private _renderPriority;
  9949. /**
  9950. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9951. * exceeding the number allowed of the materials.
  9952. */
  9953. renderPriority: number;
  9954. private _shadowEnabled;
  9955. /**
  9956. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9957. * the current shadow generator.
  9958. */
  9959. /**
  9960. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9961. * the current shadow generator.
  9962. */
  9963. shadowEnabled: boolean;
  9964. private _includedOnlyMeshes;
  9965. /**
  9966. * Gets the only meshes impacted by this light.
  9967. */
  9968. /**
  9969. * Sets the only meshes impacted by this light.
  9970. */
  9971. includedOnlyMeshes: AbstractMesh[];
  9972. private _excludedMeshes;
  9973. /**
  9974. * Gets the meshes not impacted by this light.
  9975. */
  9976. /**
  9977. * Sets the meshes not impacted by this light.
  9978. */
  9979. excludedMeshes: AbstractMesh[];
  9980. private _excludeWithLayerMask;
  9981. /**
  9982. * Gets the layer id use to find what meshes are not impacted by the light.
  9983. * Inactive if 0
  9984. */
  9985. /**
  9986. * Sets the layer id use to find what meshes are not impacted by the light.
  9987. * Inactive if 0
  9988. */
  9989. excludeWithLayerMask: number;
  9990. private _includeOnlyWithLayerMask;
  9991. /**
  9992. * Gets the layer id use to find what meshes are impacted by the light.
  9993. * Inactive if 0
  9994. */
  9995. /**
  9996. * Sets the layer id use to find what meshes are impacted by the light.
  9997. * Inactive if 0
  9998. */
  9999. includeOnlyWithLayerMask: number;
  10000. private _lightmapMode;
  10001. /**
  10002. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10003. */
  10004. /**
  10005. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10006. */
  10007. lightmapMode: number;
  10008. /**
  10009. * Shadow generator associted to the light.
  10010. * @hidden Internal use only.
  10011. */
  10012. _shadowGenerator: Nullable<IShadowGenerator>;
  10013. /**
  10014. * @hidden Internal use only.
  10015. */
  10016. _excludedMeshesIds: string[];
  10017. /**
  10018. * @hidden Internal use only.
  10019. */
  10020. _includedOnlyMeshesIds: string[];
  10021. /**
  10022. * The current light unifom buffer.
  10023. * @hidden Internal use only.
  10024. */
  10025. _uniformBuffer: UniformBuffer;
  10026. /**
  10027. * Creates a Light object in the scene.
  10028. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10029. * @param name The firendly name of the light
  10030. * @param scene The scene the light belongs too
  10031. */
  10032. constructor(name: string, scene: Scene);
  10033. protected abstract _buildUniformLayout(): void;
  10034. /**
  10035. * Sets the passed Effect "effect" with the Light information.
  10036. * @param effect The effect to update
  10037. * @param lightIndex The index of the light in the effect to update
  10038. * @returns The light
  10039. */
  10040. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10041. /**
  10042. * Sets the passed Effect "effect" with the Light information.
  10043. * @param effect The effect to update
  10044. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10045. * @returns The light
  10046. */
  10047. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10048. /**
  10049. * Returns the string "Light".
  10050. * @returns the class name
  10051. */
  10052. getClassName(): string;
  10053. /** @hidden */
  10054. readonly _isLight: boolean;
  10055. /**
  10056. * Converts the light information to a readable string for debug purpose.
  10057. * @param fullDetails Supports for multiple levels of logging within scene loading
  10058. * @returns the human readable light info
  10059. */
  10060. toString(fullDetails?: boolean): string;
  10061. /** @hidden */
  10062. protected _syncParentEnabledState(): void;
  10063. /**
  10064. * Set the enabled state of this node.
  10065. * @param value - the new enabled state
  10066. */
  10067. setEnabled(value: boolean): void;
  10068. /**
  10069. * Returns the Light associated shadow generator if any.
  10070. * @return the associated shadow generator.
  10071. */
  10072. getShadowGenerator(): Nullable<IShadowGenerator>;
  10073. /**
  10074. * Returns a Vector3, the absolute light position in the World.
  10075. * @returns the world space position of the light
  10076. */
  10077. getAbsolutePosition(): Vector3;
  10078. /**
  10079. * Specifies if the light will affect the passed mesh.
  10080. * @param mesh The mesh to test against the light
  10081. * @return true the mesh is affected otherwise, false.
  10082. */
  10083. canAffectMesh(mesh: AbstractMesh): boolean;
  10084. /**
  10085. * Sort function to order lights for rendering.
  10086. * @param a First Light object to compare to second.
  10087. * @param b Second Light object to compare first.
  10088. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10089. */
  10090. static CompareLightsPriority(a: Light, b: Light): number;
  10091. /**
  10092. * Releases resources associated with this node.
  10093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10095. */
  10096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10097. /**
  10098. * Returns the light type ID (integer).
  10099. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10100. */
  10101. getTypeID(): number;
  10102. /**
  10103. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10104. * @returns the scaled intensity in intensity mode unit
  10105. */
  10106. getScaledIntensity(): number;
  10107. /**
  10108. * Returns a new Light object, named "name", from the current one.
  10109. * @param name The name of the cloned light
  10110. * @returns the new created light
  10111. */
  10112. clone(name: string): Nullable<Light>;
  10113. /**
  10114. * Serializes the current light into a Serialization object.
  10115. * @returns the serialized object.
  10116. */
  10117. serialize(): any;
  10118. /**
  10119. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10120. * This new light is named "name" and added to the passed scene.
  10121. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10122. * @param name The friendly name of the light
  10123. * @param scene The scene the new light will belong to
  10124. * @returns the constructor function
  10125. */
  10126. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10127. /**
  10128. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10129. * @param parsedLight The JSON representation of the light
  10130. * @param scene The scene to create the parsed light in
  10131. * @returns the created light after parsing
  10132. */
  10133. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10134. private _hookArrayForExcluded;
  10135. private _hookArrayForIncludedOnly;
  10136. private _resyncMeshes;
  10137. /**
  10138. * Forces the meshes to update their light related information in their rendering used effects
  10139. * @hidden Internal Use Only
  10140. */
  10141. _markMeshesAsLightDirty(): void;
  10142. /**
  10143. * Recomputes the cached photometric scale if needed.
  10144. */
  10145. private _computePhotometricScale;
  10146. /**
  10147. * Returns the Photometric Scale according to the light type and intensity mode.
  10148. */
  10149. private _getPhotometricScale;
  10150. /**
  10151. * Reorder the light in the scene according to their defined priority.
  10152. * @hidden Internal Use Only
  10153. */
  10154. _reorderLightsInScene(): void;
  10155. /**
  10156. * Prepares the list of defines specific to the light type.
  10157. * @param defines the list of defines
  10158. * @param lightIndex defines the index of the light for the effect
  10159. */
  10160. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10161. }
  10162. }
  10163. declare module "babylonjs/Actions/action" {
  10164. import { Observable } from "babylonjs/Misc/observable";
  10165. import { Condition } from "babylonjs/Actions/condition";
  10166. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10167. import { ActionManager } from "babylonjs/Actions/actionManager";
  10168. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10169. /**
  10170. * Interface used to define Action
  10171. */
  10172. export interface IAction {
  10173. /**
  10174. * Trigger for the action
  10175. */
  10176. trigger: number;
  10177. /** Options of the trigger */
  10178. triggerOptions: any;
  10179. /**
  10180. * Gets the trigger parameters
  10181. * @returns the trigger parameters
  10182. */
  10183. getTriggerParameter(): any;
  10184. /**
  10185. * Internal only - executes current action event
  10186. * @hidden
  10187. */
  10188. _executeCurrent(evt?: ActionEvent): void;
  10189. /**
  10190. * Serialize placeholder for child classes
  10191. * @param parent of child
  10192. * @returns the serialized object
  10193. */
  10194. serialize(parent: any): any;
  10195. /**
  10196. * Internal only
  10197. * @hidden
  10198. */
  10199. _prepare(): void;
  10200. /**
  10201. * Internal only - manager for action
  10202. * @hidden
  10203. */
  10204. _actionManager: AbstractActionManager;
  10205. /**
  10206. * Adds action to chain of actions, may be a DoNothingAction
  10207. * @param action defines the next action to execute
  10208. * @returns The action passed in
  10209. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10210. */
  10211. then(action: IAction): IAction;
  10212. }
  10213. /**
  10214. * The action to be carried out following a trigger
  10215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10216. */
  10217. export class Action implements IAction {
  10218. /** the trigger, with or without parameters, for the action */
  10219. triggerOptions: any;
  10220. /**
  10221. * Trigger for the action
  10222. */
  10223. trigger: number;
  10224. /**
  10225. * Internal only - manager for action
  10226. * @hidden
  10227. */
  10228. _actionManager: ActionManager;
  10229. private _nextActiveAction;
  10230. private _child;
  10231. private _condition?;
  10232. private _triggerParameter;
  10233. /**
  10234. * An event triggered prior to action being executed.
  10235. */
  10236. onBeforeExecuteObservable: Observable<Action>;
  10237. /**
  10238. * Creates a new Action
  10239. * @param triggerOptions the trigger, with or without parameters, for the action
  10240. * @param condition an optional determinant of action
  10241. */
  10242. constructor(
  10243. /** the trigger, with or without parameters, for the action */
  10244. triggerOptions: any, condition?: Condition);
  10245. /**
  10246. * Internal only
  10247. * @hidden
  10248. */
  10249. _prepare(): void;
  10250. /**
  10251. * Gets the trigger parameters
  10252. * @returns the trigger parameters
  10253. */
  10254. getTriggerParameter(): any;
  10255. /**
  10256. * Internal only - executes current action event
  10257. * @hidden
  10258. */
  10259. _executeCurrent(evt?: ActionEvent): void;
  10260. /**
  10261. * Execute placeholder for child classes
  10262. * @param evt optional action event
  10263. */
  10264. execute(evt?: ActionEvent): void;
  10265. /**
  10266. * Skips to next active action
  10267. */
  10268. skipToNextActiveAction(): void;
  10269. /**
  10270. * Adds action to chain of actions, may be a DoNothingAction
  10271. * @param action defines the next action to execute
  10272. * @returns The action passed in
  10273. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10274. */
  10275. then(action: Action): Action;
  10276. /**
  10277. * Internal only
  10278. * @hidden
  10279. */
  10280. _getProperty(propertyPath: string): string;
  10281. /**
  10282. * Internal only
  10283. * @hidden
  10284. */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /**
  10287. * Serialize placeholder for child classes
  10288. * @param parent of child
  10289. * @returns the serialized object
  10290. */
  10291. serialize(parent: any): any;
  10292. /**
  10293. * Internal only called by serialize
  10294. * @hidden
  10295. */
  10296. protected _serialize(serializedAction: any, parent?: any): any;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. static _SerializeValueAsString: (value: any) => string;
  10302. /**
  10303. * Internal only
  10304. * @hidden
  10305. */
  10306. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10307. name: string;
  10308. targetType: string;
  10309. value: string;
  10310. };
  10311. }
  10312. }
  10313. declare module "babylonjs/Actions/condition" {
  10314. import { ActionManager } from "babylonjs/Actions/actionManager";
  10315. /**
  10316. * A Condition applied to an Action
  10317. */
  10318. export class Condition {
  10319. /**
  10320. * Internal only - manager for action
  10321. * @hidden
  10322. */
  10323. _actionManager: ActionManager;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. _evaluationId: number;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. _currentResult: boolean;
  10334. /**
  10335. * Creates a new Condition
  10336. * @param actionManager the manager of the action the condition is applied to
  10337. */
  10338. constructor(actionManager: ActionManager);
  10339. /**
  10340. * Check if the current condition is valid
  10341. * @returns a boolean
  10342. */
  10343. isValid(): boolean;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. _getProperty(propertyPath: string): string;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. _getEffectiveTarget(target: any, propertyPath: string): any;
  10354. /**
  10355. * Serialize placeholder for child classes
  10356. * @returns the serialized object
  10357. */
  10358. serialize(): any;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. protected _serialize(serializedCondition: any): any;
  10364. }
  10365. /**
  10366. * Defines specific conditional operators as extensions of Condition
  10367. */
  10368. export class ValueCondition extends Condition {
  10369. /** path to specify the property of the target the conditional operator uses */
  10370. propertyPath: string;
  10371. /** the value compared by the conditional operator against the current value of the property */
  10372. value: any;
  10373. /** the conditional operator, default ValueCondition.IsEqual */
  10374. operator: number;
  10375. /**
  10376. * Internal only
  10377. * @hidden
  10378. */
  10379. private static _IsEqual;
  10380. /**
  10381. * Internal only
  10382. * @hidden
  10383. */
  10384. private static _IsDifferent;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private static _IsGreater;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private static _IsLesser;
  10395. /**
  10396. * returns the number for IsEqual
  10397. */
  10398. static readonly IsEqual: number;
  10399. /**
  10400. * Returns the number for IsDifferent
  10401. */
  10402. static readonly IsDifferent: number;
  10403. /**
  10404. * Returns the number for IsGreater
  10405. */
  10406. static readonly IsGreater: number;
  10407. /**
  10408. * Returns the number for IsLesser
  10409. */
  10410. static readonly IsLesser: number;
  10411. /**
  10412. * Internal only The action manager for the condition
  10413. * @hidden
  10414. */
  10415. _actionManager: ActionManager;
  10416. /**
  10417. * Internal only
  10418. * @hidden
  10419. */
  10420. private _target;
  10421. /**
  10422. * Internal only
  10423. * @hidden
  10424. */
  10425. private _effectiveTarget;
  10426. /**
  10427. * Internal only
  10428. * @hidden
  10429. */
  10430. private _property;
  10431. /**
  10432. * Creates a new ValueCondition
  10433. * @param actionManager manager for the action the condition applies to
  10434. * @param target for the action
  10435. * @param propertyPath path to specify the property of the target the conditional operator uses
  10436. * @param value the value compared by the conditional operator against the current value of the property
  10437. * @param operator the conditional operator, default ValueCondition.IsEqual
  10438. */
  10439. constructor(actionManager: ActionManager, target: any,
  10440. /** path to specify the property of the target the conditional operator uses */
  10441. propertyPath: string,
  10442. /** the value compared by the conditional operator against the current value of the property */
  10443. value: any,
  10444. /** the conditional operator, default ValueCondition.IsEqual */
  10445. operator?: number);
  10446. /**
  10447. * Compares the given value with the property value for the specified conditional operator
  10448. * @returns the result of the comparison
  10449. */
  10450. isValid(): boolean;
  10451. /**
  10452. * Serialize the ValueCondition into a JSON compatible object
  10453. * @returns serialization object
  10454. */
  10455. serialize(): any;
  10456. /**
  10457. * Gets the name of the conditional operator for the ValueCondition
  10458. * @param operator the conditional operator
  10459. * @returns the name
  10460. */
  10461. static GetOperatorName(operator: number): string;
  10462. }
  10463. /**
  10464. * Defines a predicate condition as an extension of Condition
  10465. */
  10466. export class PredicateCondition extends Condition {
  10467. /** defines the predicate function used to validate the condition */
  10468. predicate: () => boolean;
  10469. /**
  10470. * Internal only - manager for action
  10471. * @hidden
  10472. */
  10473. _actionManager: ActionManager;
  10474. /**
  10475. * Creates a new PredicateCondition
  10476. * @param actionManager manager for the action the condition applies to
  10477. * @param predicate defines the predicate function used to validate the condition
  10478. */
  10479. constructor(actionManager: ActionManager,
  10480. /** defines the predicate function used to validate the condition */
  10481. predicate: () => boolean);
  10482. /**
  10483. * @returns the validity of the predicate condition
  10484. */
  10485. isValid(): boolean;
  10486. }
  10487. /**
  10488. * Defines a state condition as an extension of Condition
  10489. */
  10490. export class StateCondition extends Condition {
  10491. /** Value to compare with target state */
  10492. value: string;
  10493. /**
  10494. * Internal only - manager for action
  10495. * @hidden
  10496. */
  10497. _actionManager: ActionManager;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. private _target;
  10503. /**
  10504. * Creates a new StateCondition
  10505. * @param actionManager manager for the action the condition applies to
  10506. * @param target of the condition
  10507. * @param value to compare with target state
  10508. */
  10509. constructor(actionManager: ActionManager, target: any,
  10510. /** Value to compare with target state */
  10511. value: string);
  10512. /**
  10513. * Gets a boolean indicating if the current condition is met
  10514. * @returns the validity of the state
  10515. */
  10516. isValid(): boolean;
  10517. /**
  10518. * Serialize the StateCondition into a JSON compatible object
  10519. * @returns serialization object
  10520. */
  10521. serialize(): any;
  10522. }
  10523. }
  10524. declare module "babylonjs/Actions/directActions" {
  10525. import { Action } from "babylonjs/Actions/action";
  10526. import { Condition } from "babylonjs/Actions/condition";
  10527. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10528. /**
  10529. * This defines an action responsible to toggle a boolean once triggered.
  10530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10531. */
  10532. export class SwitchBooleanAction extends Action {
  10533. /**
  10534. * The path to the boolean property in the target object
  10535. */
  10536. propertyPath: string;
  10537. private _target;
  10538. private _effectiveTarget;
  10539. private _property;
  10540. /**
  10541. * Instantiate the action
  10542. * @param triggerOptions defines the trigger options
  10543. * @param target defines the object containing the boolean
  10544. * @param propertyPath defines the path to the boolean property in the target object
  10545. * @param condition defines the trigger related conditions
  10546. */
  10547. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10548. /** @hidden */
  10549. _prepare(): void;
  10550. /**
  10551. * Execute the action toggle the boolean value.
  10552. */
  10553. execute(): void;
  10554. /**
  10555. * Serializes the actions and its related information.
  10556. * @param parent defines the object to serialize in
  10557. * @returns the serialized object
  10558. */
  10559. serialize(parent: any): any;
  10560. }
  10561. /**
  10562. * This defines an action responsible to set a the state field of the target
  10563. * to a desired value once triggered.
  10564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10565. */
  10566. export class SetStateAction extends Action {
  10567. /**
  10568. * The value to store in the state field.
  10569. */
  10570. value: string;
  10571. private _target;
  10572. /**
  10573. * Instantiate the action
  10574. * @param triggerOptions defines the trigger options
  10575. * @param target defines the object containing the state property
  10576. * @param value defines the value to store in the state field
  10577. * @param condition defines the trigger related conditions
  10578. */
  10579. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10580. /**
  10581. * Execute the action and store the value on the target state property.
  10582. */
  10583. execute(): void;
  10584. /**
  10585. * Serializes the actions and its related information.
  10586. * @param parent defines the object to serialize in
  10587. * @returns the serialized object
  10588. */
  10589. serialize(parent: any): any;
  10590. }
  10591. /**
  10592. * This defines an action responsible to set a property of the target
  10593. * to a desired value once triggered.
  10594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10595. */
  10596. export class SetValueAction extends Action {
  10597. /**
  10598. * The path of the property to set in the target.
  10599. */
  10600. propertyPath: string;
  10601. /**
  10602. * The value to set in the property
  10603. */
  10604. value: any;
  10605. private _target;
  10606. private _effectiveTarget;
  10607. private _property;
  10608. /**
  10609. * Instantiate the action
  10610. * @param triggerOptions defines the trigger options
  10611. * @param target defines the object containing the property
  10612. * @param propertyPath defines the path of the property to set in the target
  10613. * @param value defines the value to set in the property
  10614. * @param condition defines the trigger related conditions
  10615. */
  10616. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10617. /** @hidden */
  10618. _prepare(): void;
  10619. /**
  10620. * Execute the action and set the targetted property to the desired value.
  10621. */
  10622. execute(): void;
  10623. /**
  10624. * Serializes the actions and its related information.
  10625. * @param parent defines the object to serialize in
  10626. * @returns the serialized object
  10627. */
  10628. serialize(parent: any): any;
  10629. }
  10630. /**
  10631. * This defines an action responsible to increment the target value
  10632. * to a desired value once triggered.
  10633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class IncrementValueAction extends Action {
  10636. /**
  10637. * The path of the property to increment in the target.
  10638. */
  10639. propertyPath: string;
  10640. /**
  10641. * The value we should increment the property by.
  10642. */
  10643. value: any;
  10644. private _target;
  10645. private _effectiveTarget;
  10646. private _property;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the property
  10651. * @param propertyPath defines the path of the property to increment in the target
  10652. * @param value defines the value value we should increment the property by
  10653. * @param condition defines the trigger related conditions
  10654. */
  10655. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10656. /** @hidden */
  10657. _prepare(): void;
  10658. /**
  10659. * Execute the action and increment the target of the value amount.
  10660. */
  10661. execute(): void;
  10662. /**
  10663. * Serializes the actions and its related information.
  10664. * @param parent defines the object to serialize in
  10665. * @returns the serialized object
  10666. */
  10667. serialize(parent: any): any;
  10668. }
  10669. /**
  10670. * This defines an action responsible to start an animation once triggered.
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10672. */
  10673. export class PlayAnimationAction extends Action {
  10674. /**
  10675. * Where the animation should start (animation frame)
  10676. */
  10677. from: number;
  10678. /**
  10679. * Where the animation should stop (animation frame)
  10680. */
  10681. to: number;
  10682. /**
  10683. * Define if the animation should loop or stop after the first play.
  10684. */
  10685. loop?: boolean;
  10686. private _target;
  10687. /**
  10688. * Instantiate the action
  10689. * @param triggerOptions defines the trigger options
  10690. * @param target defines the target animation or animation name
  10691. * @param from defines from where the animation should start (animation frame)
  10692. * @param end defines where the animation should stop (animation frame)
  10693. * @param loop defines if the animation should loop or stop after the first play
  10694. * @param condition defines the trigger related conditions
  10695. */
  10696. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10697. /** @hidden */
  10698. _prepare(): void;
  10699. /**
  10700. * Execute the action and play the animation.
  10701. */
  10702. execute(): void;
  10703. /**
  10704. * Serializes the actions and its related information.
  10705. * @param parent defines the object to serialize in
  10706. * @returns the serialized object
  10707. */
  10708. serialize(parent: any): any;
  10709. }
  10710. /**
  10711. * This defines an action responsible to stop an animation once triggered.
  10712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10713. */
  10714. export class StopAnimationAction extends Action {
  10715. private _target;
  10716. /**
  10717. * Instantiate the action
  10718. * @param triggerOptions defines the trigger options
  10719. * @param target defines the target animation or animation name
  10720. * @param condition defines the trigger related conditions
  10721. */
  10722. constructor(triggerOptions: any, target: any, condition?: Condition);
  10723. /** @hidden */
  10724. _prepare(): void;
  10725. /**
  10726. * Execute the action and stop the animation.
  10727. */
  10728. execute(): void;
  10729. /**
  10730. * Serializes the actions and its related information.
  10731. * @param parent defines the object to serialize in
  10732. * @returns the serialized object
  10733. */
  10734. serialize(parent: any): any;
  10735. }
  10736. /**
  10737. * This defines an action responsible that does nothing once triggered.
  10738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10739. */
  10740. export class DoNothingAction extends Action {
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param condition defines the trigger related conditions
  10745. */
  10746. constructor(triggerOptions?: any, condition?: Condition);
  10747. /**
  10748. * Execute the action and do nothing.
  10749. */
  10750. execute(): void;
  10751. /**
  10752. * Serializes the actions and its related information.
  10753. * @param parent defines the object to serialize in
  10754. * @returns the serialized object
  10755. */
  10756. serialize(parent: any): any;
  10757. }
  10758. /**
  10759. * This defines an action responsible to trigger several actions once triggered.
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10761. */
  10762. export class CombineAction extends Action {
  10763. /**
  10764. * The list of aggregated animations to run.
  10765. */
  10766. children: Action[];
  10767. /**
  10768. * Instantiate the action
  10769. * @param triggerOptions defines the trigger options
  10770. * @param children defines the list of aggregated animations to run
  10771. * @param condition defines the trigger related conditions
  10772. */
  10773. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10774. /** @hidden */
  10775. _prepare(): void;
  10776. /**
  10777. * Execute the action and executes all the aggregated actions.
  10778. */
  10779. execute(evt: ActionEvent): void;
  10780. /**
  10781. * Serializes the actions and its related information.
  10782. * @param parent defines the object to serialize in
  10783. * @returns the serialized object
  10784. */
  10785. serialize(parent: any): any;
  10786. }
  10787. /**
  10788. * This defines an action responsible to run code (external event) once triggered.
  10789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10790. */
  10791. export class ExecuteCodeAction extends Action {
  10792. /**
  10793. * The callback function to run.
  10794. */
  10795. func: (evt: ActionEvent) => void;
  10796. /**
  10797. * Instantiate the action
  10798. * @param triggerOptions defines the trigger options
  10799. * @param func defines the callback function to run
  10800. * @param condition defines the trigger related conditions
  10801. */
  10802. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10803. /**
  10804. * Execute the action and run the attached code.
  10805. */
  10806. execute(evt: ActionEvent): void;
  10807. }
  10808. /**
  10809. * This defines an action responsible to set the parent property of the target once triggered.
  10810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10811. */
  10812. export class SetParentAction extends Action {
  10813. private _parent;
  10814. private _target;
  10815. /**
  10816. * Instantiate the action
  10817. * @param triggerOptions defines the trigger options
  10818. * @param target defines the target containing the parent property
  10819. * @param parent defines from where the animation should start (animation frame)
  10820. * @param condition defines the trigger related conditions
  10821. */
  10822. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10823. /** @hidden */
  10824. _prepare(): void;
  10825. /**
  10826. * Execute the action and set the parent property.
  10827. */
  10828. execute(): void;
  10829. /**
  10830. * Serializes the actions and its related information.
  10831. * @param parent defines the object to serialize in
  10832. * @returns the serialized object
  10833. */
  10834. serialize(parent: any): any;
  10835. }
  10836. }
  10837. declare module "babylonjs/Actions/actionManager" {
  10838. import { Nullable } from "babylonjs/types";
  10839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10840. import { Scene } from "babylonjs/scene";
  10841. import { IAction } from "babylonjs/Actions/action";
  10842. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10843. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10844. /**
  10845. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10846. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10848. */
  10849. export class ActionManager extends AbstractActionManager {
  10850. /**
  10851. * Nothing
  10852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10853. */
  10854. static readonly NothingTrigger: number;
  10855. /**
  10856. * On pick
  10857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10858. */
  10859. static readonly OnPickTrigger: number;
  10860. /**
  10861. * On left pick
  10862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnLeftPickTrigger: number;
  10865. /**
  10866. * On right pick
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnRightPickTrigger: number;
  10870. /**
  10871. * On center pick
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnCenterPickTrigger: number;
  10875. /**
  10876. * On pick down
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnPickDownTrigger: number;
  10880. /**
  10881. * On double pick
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnDoublePickTrigger: number;
  10885. /**
  10886. * On pick up
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnPickUpTrigger: number;
  10890. /**
  10891. * On pick out.
  10892. * This trigger will only be raised if you also declared a OnPickDown
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10894. */
  10895. static readonly OnPickOutTrigger: number;
  10896. /**
  10897. * On long press
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10899. */
  10900. static readonly OnLongPressTrigger: number;
  10901. /**
  10902. * On pointer over
  10903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10904. */
  10905. static readonly OnPointerOverTrigger: number;
  10906. /**
  10907. * On pointer out
  10908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10909. */
  10910. static readonly OnPointerOutTrigger: number;
  10911. /**
  10912. * On every frame
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10914. */
  10915. static readonly OnEveryFrameTrigger: number;
  10916. /**
  10917. * On intersection enter
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10919. */
  10920. static readonly OnIntersectionEnterTrigger: number;
  10921. /**
  10922. * On intersection exit
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnIntersectionExitTrigger: number;
  10926. /**
  10927. * On key down
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnKeyDownTrigger: number;
  10931. /**
  10932. * On key up
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnKeyUpTrigger: number;
  10936. private _scene;
  10937. /**
  10938. * Creates a new action manager
  10939. * @param scene defines the hosting scene
  10940. */
  10941. constructor(scene: Scene);
  10942. /**
  10943. * Releases all associated resources
  10944. */
  10945. dispose(): void;
  10946. /**
  10947. * Gets hosting scene
  10948. * @returns the hosting scene
  10949. */
  10950. getScene(): Scene;
  10951. /**
  10952. * Does this action manager handles actions of any of the given triggers
  10953. * @param triggers defines the triggers to be tested
  10954. * @return a boolean indicating whether one (or more) of the triggers is handled
  10955. */
  10956. hasSpecificTriggers(triggers: number[]): boolean;
  10957. /**
  10958. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10959. * speed.
  10960. * @param triggerA defines the trigger to be tested
  10961. * @param triggerB defines the trigger to be tested
  10962. * @return a boolean indicating whether one (or more) of the triggers is handled
  10963. */
  10964. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10965. /**
  10966. * Does this action manager handles actions of a given trigger
  10967. * @param trigger defines the trigger to be tested
  10968. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10969. * @return whether the trigger is handled
  10970. */
  10971. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10972. /**
  10973. * Does this action manager has pointer triggers
  10974. */
  10975. readonly hasPointerTriggers: boolean;
  10976. /**
  10977. * Does this action manager has pick triggers
  10978. */
  10979. readonly hasPickTriggers: boolean;
  10980. /**
  10981. * Registers an action to this action manager
  10982. * @param action defines the action to be registered
  10983. * @return the action amended (prepared) after registration
  10984. */
  10985. registerAction(action: IAction): Nullable<IAction>;
  10986. /**
  10987. * Unregisters an action to this action manager
  10988. * @param action defines the action to be unregistered
  10989. * @return a boolean indicating whether the action has been unregistered
  10990. */
  10991. unregisterAction(action: IAction): Boolean;
  10992. /**
  10993. * Process a specific trigger
  10994. * @param trigger defines the trigger to process
  10995. * @param evt defines the event details to be processed
  10996. */
  10997. processTrigger(trigger: number, evt?: IActionEvent): void;
  10998. /** @hidden */
  10999. _getEffectiveTarget(target: any, propertyPath: string): any;
  11000. /** @hidden */
  11001. _getProperty(propertyPath: string): string;
  11002. /**
  11003. * Serialize this manager to a JSON object
  11004. * @param name defines the property name to store this manager
  11005. * @returns a JSON representation of this manager
  11006. */
  11007. serialize(name: string): any;
  11008. /**
  11009. * Creates a new ActionManager from a JSON data
  11010. * @param parsedActions defines the JSON data to read from
  11011. * @param object defines the hosting mesh
  11012. * @param scene defines the hosting scene
  11013. */
  11014. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11015. /**
  11016. * Get a trigger name by index
  11017. * @param trigger defines the trigger index
  11018. * @returns a trigger name
  11019. */
  11020. static GetTriggerName(trigger: number): string;
  11021. }
  11022. }
  11023. declare module "babylonjs/Culling/ray" {
  11024. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11025. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11027. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11028. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11029. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11030. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11031. import { Plane } from "babylonjs/Maths/math.plane";
  11032. /**
  11033. * Class representing a ray with position and direction
  11034. */
  11035. export class Ray {
  11036. /** origin point */
  11037. origin: Vector3;
  11038. /** direction */
  11039. direction: Vector3;
  11040. /** length of the ray */
  11041. length: number;
  11042. private static readonly TmpVector3;
  11043. private _tmpRay;
  11044. /**
  11045. * Creates a new ray
  11046. * @param origin origin point
  11047. * @param direction direction
  11048. * @param length length of the ray
  11049. */
  11050. constructor(
  11051. /** origin point */
  11052. origin: Vector3,
  11053. /** direction */
  11054. direction: Vector3,
  11055. /** length of the ray */
  11056. length?: number);
  11057. /**
  11058. * Checks if the ray intersects a box
  11059. * @param minimum bound of the box
  11060. * @param maximum bound of the box
  11061. * @param intersectionTreshold extra extend to be added to the box in all direction
  11062. * @returns if the box was hit
  11063. */
  11064. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11065. /**
  11066. * Checks if the ray intersects a box
  11067. * @param box the bounding box to check
  11068. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11069. * @returns if the box was hit
  11070. */
  11071. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11072. /**
  11073. * If the ray hits a sphere
  11074. * @param sphere the bounding sphere to check
  11075. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11076. * @returns true if it hits the sphere
  11077. */
  11078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11079. /**
  11080. * If the ray hits a triange
  11081. * @param vertex0 triangle vertex
  11082. * @param vertex1 triangle vertex
  11083. * @param vertex2 triangle vertex
  11084. * @returns intersection information if hit
  11085. */
  11086. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11087. /**
  11088. * Checks if ray intersects a plane
  11089. * @param plane the plane to check
  11090. * @returns the distance away it was hit
  11091. */
  11092. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11093. /**
  11094. * Calculate the intercept of a ray on a given axis
  11095. * @param axis to check 'x' | 'y' | 'z'
  11096. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11097. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11098. */
  11099. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11100. /**
  11101. * Checks if ray intersects a mesh
  11102. * @param mesh the mesh to check
  11103. * @param fastCheck if only the bounding box should checked
  11104. * @returns picking info of the intersecton
  11105. */
  11106. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11107. /**
  11108. * Checks if ray intersects a mesh
  11109. * @param meshes the meshes to check
  11110. * @param fastCheck if only the bounding box should checked
  11111. * @param results array to store result in
  11112. * @returns Array of picking infos
  11113. */
  11114. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11115. private _comparePickingInfo;
  11116. private static smallnum;
  11117. private static rayl;
  11118. /**
  11119. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11120. * @param sega the first point of the segment to test the intersection against
  11121. * @param segb the second point of the segment to test the intersection against
  11122. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11123. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11124. */
  11125. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11126. /**
  11127. * Update the ray from viewport position
  11128. * @param x position
  11129. * @param y y position
  11130. * @param viewportWidth viewport width
  11131. * @param viewportHeight viewport height
  11132. * @param world world matrix
  11133. * @param view view matrix
  11134. * @param projection projection matrix
  11135. * @returns this ray updated
  11136. */
  11137. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11138. /**
  11139. * Creates a ray with origin and direction of 0,0,0
  11140. * @returns the new ray
  11141. */
  11142. static Zero(): Ray;
  11143. /**
  11144. * Creates a new ray from screen space and viewport
  11145. * @param x position
  11146. * @param y y position
  11147. * @param viewportWidth viewport width
  11148. * @param viewportHeight viewport height
  11149. * @param world world matrix
  11150. * @param view view matrix
  11151. * @param projection projection matrix
  11152. * @returns new ray
  11153. */
  11154. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11155. /**
  11156. * 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
  11157. * transformed to the given world matrix.
  11158. * @param origin The origin point
  11159. * @param end The end point
  11160. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11161. * @returns the new ray
  11162. */
  11163. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11164. /**
  11165. * Transforms a ray by a matrix
  11166. * @param ray ray to transform
  11167. * @param matrix matrix to apply
  11168. * @returns the resulting new ray
  11169. */
  11170. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11171. /**
  11172. * Transforms a ray by a matrix
  11173. * @param ray ray to transform
  11174. * @param matrix matrix to apply
  11175. * @param result ray to store result in
  11176. */
  11177. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11178. /**
  11179. * Unproject a ray from screen space to object space
  11180. * @param sourceX defines the screen space x coordinate to use
  11181. * @param sourceY defines the screen space y coordinate to use
  11182. * @param viewportWidth defines the current width of the viewport
  11183. * @param viewportHeight defines the current height of the viewport
  11184. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11185. * @param view defines the view matrix to use
  11186. * @param projection defines the projection matrix to use
  11187. */
  11188. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11189. }
  11190. /**
  11191. * Type used to define predicate used to select faces when a mesh intersection is detected
  11192. */
  11193. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11194. module "babylonjs/scene" {
  11195. interface Scene {
  11196. /** @hidden */
  11197. _tempPickingRay: Nullable<Ray>;
  11198. /** @hidden */
  11199. _cachedRayForTransform: Ray;
  11200. /** @hidden */
  11201. _pickWithRayInverseMatrix: Matrix;
  11202. /** @hidden */
  11203. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11204. /** @hidden */
  11205. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11206. }
  11207. }
  11208. }
  11209. declare module "babylonjs/sceneComponent" {
  11210. import { Scene } from "babylonjs/scene";
  11211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11212. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11213. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11214. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11215. import { Nullable } from "babylonjs/types";
  11216. import { Camera } from "babylonjs/Cameras/camera";
  11217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11218. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11219. import { AbstractScene } from "babylonjs/abstractScene";
  11220. /**
  11221. * Groups all the scene component constants in one place to ease maintenance.
  11222. * @hidden
  11223. */
  11224. export class SceneComponentConstants {
  11225. static readonly NAME_EFFECTLAYER: string;
  11226. static readonly NAME_LAYER: string;
  11227. static readonly NAME_LENSFLARESYSTEM: string;
  11228. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11229. static readonly NAME_PARTICLESYSTEM: string;
  11230. static readonly NAME_GAMEPAD: string;
  11231. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11232. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11233. static readonly NAME_DEPTHRENDERER: string;
  11234. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11235. static readonly NAME_SPRITE: string;
  11236. static readonly NAME_OUTLINERENDERER: string;
  11237. static readonly NAME_PROCEDURALTEXTURE: string;
  11238. static readonly NAME_SHADOWGENERATOR: string;
  11239. static readonly NAME_OCTREE: string;
  11240. static readonly NAME_PHYSICSENGINE: string;
  11241. static readonly NAME_AUDIO: string;
  11242. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11243. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11244. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11245. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11246. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11247. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11248. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11249. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11250. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11251. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11252. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11253. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11255. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11256. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11257. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11258. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11259. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11260. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11261. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11262. static readonly STEP_AFTERRENDER_AUDIO: number;
  11263. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11264. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11265. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11266. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11267. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11268. static readonly STEP_POINTERMOVE_SPRITE: number;
  11269. static readonly STEP_POINTERDOWN_SPRITE: number;
  11270. static readonly STEP_POINTERUP_SPRITE: number;
  11271. }
  11272. /**
  11273. * This represents a scene component.
  11274. *
  11275. * This is used to decouple the dependency the scene is having on the different workloads like
  11276. * layers, post processes...
  11277. */
  11278. export interface ISceneComponent {
  11279. /**
  11280. * The name of the component. Each component must have a unique name.
  11281. */
  11282. name: string;
  11283. /**
  11284. * The scene the component belongs to.
  11285. */
  11286. scene: Scene;
  11287. /**
  11288. * Register the component to one instance of a scene.
  11289. */
  11290. register(): void;
  11291. /**
  11292. * Rebuilds the elements related to this component in case of
  11293. * context lost for instance.
  11294. */
  11295. rebuild(): void;
  11296. /**
  11297. * Disposes the component and the associated ressources.
  11298. */
  11299. dispose(): void;
  11300. }
  11301. /**
  11302. * This represents a SERIALIZABLE scene component.
  11303. *
  11304. * This extends Scene Component to add Serialization methods on top.
  11305. */
  11306. export interface ISceneSerializableComponent extends ISceneComponent {
  11307. /**
  11308. * Adds all the elements from the container to the scene
  11309. * @param container the container holding the elements
  11310. */
  11311. addFromContainer(container: AbstractScene): void;
  11312. /**
  11313. * Removes all the elements in the container from the scene
  11314. * @param container contains the elements to remove
  11315. * @param dispose if the removed element should be disposed (default: false)
  11316. */
  11317. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11318. /**
  11319. * Serializes the component data to the specified json object
  11320. * @param serializationObject The object to serialize to
  11321. */
  11322. serialize(serializationObject: any): void;
  11323. }
  11324. /**
  11325. * Strong typing of a Mesh related stage step action
  11326. */
  11327. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11328. /**
  11329. * Strong typing of a Evaluate Sub Mesh related stage step action
  11330. */
  11331. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11332. /**
  11333. * Strong typing of a Active Mesh related stage step action
  11334. */
  11335. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11336. /**
  11337. * Strong typing of a Camera related stage step action
  11338. */
  11339. export type CameraStageAction = (camera: Camera) => void;
  11340. /**
  11341. * Strong typing of a Camera Frame buffer related stage step action
  11342. */
  11343. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11344. /**
  11345. * Strong typing of a Render Target related stage step action
  11346. */
  11347. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11348. /**
  11349. * Strong typing of a RenderingGroup related stage step action
  11350. */
  11351. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11352. /**
  11353. * Strong typing of a Mesh Render related stage step action
  11354. */
  11355. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11356. /**
  11357. * Strong typing of a simple stage step action
  11358. */
  11359. export type SimpleStageAction = () => void;
  11360. /**
  11361. * Strong typing of a render target action.
  11362. */
  11363. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11364. /**
  11365. * Strong typing of a pointer move action.
  11366. */
  11367. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11368. /**
  11369. * Strong typing of a pointer up/down action.
  11370. */
  11371. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11372. /**
  11373. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11374. * @hidden
  11375. */
  11376. export class Stage<T extends Function> extends Array<{
  11377. index: number;
  11378. component: ISceneComponent;
  11379. action: T;
  11380. }> {
  11381. /**
  11382. * Hide ctor from the rest of the world.
  11383. * @param items The items to add.
  11384. */
  11385. private constructor();
  11386. /**
  11387. * Creates a new Stage.
  11388. * @returns A new instance of a Stage
  11389. */
  11390. static Create<T extends Function>(): Stage<T>;
  11391. /**
  11392. * Registers a step in an ordered way in the targeted stage.
  11393. * @param index Defines the position to register the step in
  11394. * @param component Defines the component attached to the step
  11395. * @param action Defines the action to launch during the step
  11396. */
  11397. registerStep(index: number, component: ISceneComponent, action: T): void;
  11398. /**
  11399. * Clears all the steps from the stage.
  11400. */
  11401. clear(): void;
  11402. }
  11403. }
  11404. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11405. import { Nullable } from "babylonjs/types";
  11406. import { Observable } from "babylonjs/Misc/observable";
  11407. import { Scene } from "babylonjs/scene";
  11408. import { Sprite } from "babylonjs/Sprites/sprite";
  11409. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11410. import { Ray } from "babylonjs/Culling/ray";
  11411. import { Camera } from "babylonjs/Cameras/camera";
  11412. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11413. import { ISceneComponent } from "babylonjs/sceneComponent";
  11414. module "babylonjs/scene" {
  11415. interface Scene {
  11416. /** @hidden */
  11417. _pointerOverSprite: Nullable<Sprite>;
  11418. /** @hidden */
  11419. _pickedDownSprite: Nullable<Sprite>;
  11420. /** @hidden */
  11421. _tempSpritePickingRay: Nullable<Ray>;
  11422. /**
  11423. * All of the sprite managers added to this scene
  11424. * @see http://doc.babylonjs.com/babylon101/sprites
  11425. */
  11426. spriteManagers: Array<ISpriteManager>;
  11427. /**
  11428. * An event triggered when sprites rendering is about to start
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11432. /**
  11433. * An event triggered when sprites rendering is done
  11434. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11435. */
  11436. onAfterSpritesRenderingObservable: Observable<Scene>;
  11437. /** @hidden */
  11438. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11439. /** Launch a ray to try to pick a sprite in the scene
  11440. * @param x position on screen
  11441. * @param y position on screen
  11442. * @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
  11443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11445. * @returns a PickingInfo
  11446. */
  11447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11448. /** Use the given ray to pick a sprite in the scene
  11449. * @param ray The ray (in world space) to use to pick meshes
  11450. * @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
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** @hidden */
  11457. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11458. /** Launch a ray to try to pick sprites in the scene
  11459. * @param x position on screen
  11460. * @param y position on screen
  11461. * @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
  11462. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11463. * @returns a PickingInfo array
  11464. */
  11465. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Use the given ray to pick sprites in the scene
  11467. * @param ray The ray (in world space) to use to pick meshes
  11468. * @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
  11469. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11470. * @returns a PickingInfo array
  11471. */
  11472. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11473. /**
  11474. * Force the sprite under the pointer
  11475. * @param sprite defines the sprite to use
  11476. */
  11477. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11478. /**
  11479. * Gets the sprite under the pointer
  11480. * @returns a Sprite or null if no sprite is under the pointer
  11481. */
  11482. getPointerOverSprite(): Nullable<Sprite>;
  11483. }
  11484. }
  11485. /**
  11486. * Defines the sprite scene component responsible to manage sprites
  11487. * in a given scene.
  11488. */
  11489. export class SpriteSceneComponent implements ISceneComponent {
  11490. /**
  11491. * The component name helpfull to identify the component in the list of scene components.
  11492. */
  11493. readonly name: string;
  11494. /**
  11495. * The scene the component belongs to.
  11496. */
  11497. scene: Scene;
  11498. /** @hidden */
  11499. private _spritePredicate;
  11500. /**
  11501. * Creates a new instance of the component for the given scene
  11502. * @param scene Defines the scene to register the component in
  11503. */
  11504. constructor(scene: Scene);
  11505. /**
  11506. * Registers the component in a given scene
  11507. */
  11508. register(): void;
  11509. /**
  11510. * Rebuilds the elements related to this component in case of
  11511. * context lost for instance.
  11512. */
  11513. rebuild(): void;
  11514. /**
  11515. * Disposes the component and the associated ressources.
  11516. */
  11517. dispose(): void;
  11518. private _pickSpriteButKeepRay;
  11519. private _pointerMove;
  11520. private _pointerDown;
  11521. private _pointerUp;
  11522. }
  11523. }
  11524. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11525. /** @hidden */
  11526. export var fogFragmentDeclaration: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11532. /** @hidden */
  11533. export var fogFragment: {
  11534. name: string;
  11535. shader: string;
  11536. };
  11537. }
  11538. declare module "babylonjs/Shaders/sprites.fragment" {
  11539. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11540. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11541. /** @hidden */
  11542. export var spritesPixelShader: {
  11543. name: string;
  11544. shader: string;
  11545. };
  11546. }
  11547. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11548. /** @hidden */
  11549. export var fogVertexDeclaration: {
  11550. name: string;
  11551. shader: string;
  11552. };
  11553. }
  11554. declare module "babylonjs/Shaders/sprites.vertex" {
  11555. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11556. /** @hidden */
  11557. export var spritesVertexShader: {
  11558. name: string;
  11559. shader: string;
  11560. };
  11561. }
  11562. declare module "babylonjs/Sprites/spriteManager" {
  11563. import { IDisposable, Scene } from "babylonjs/scene";
  11564. import { Nullable } from "babylonjs/types";
  11565. import { Observable } from "babylonjs/Misc/observable";
  11566. import { Sprite } from "babylonjs/Sprites/sprite";
  11567. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11568. import { Camera } from "babylonjs/Cameras/camera";
  11569. import { Texture } from "babylonjs/Materials/Textures/texture";
  11570. import "babylonjs/Shaders/sprites.fragment";
  11571. import "babylonjs/Shaders/sprites.vertex";
  11572. import { Ray } from "babylonjs/Culling/ray";
  11573. /**
  11574. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11575. */
  11576. export interface ISpriteManager extends IDisposable {
  11577. /**
  11578. * Restricts the camera to viewing objects with the same layerMask.
  11579. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11580. */
  11581. layerMask: number;
  11582. /**
  11583. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11584. */
  11585. isPickable: boolean;
  11586. /**
  11587. * Specifies the rendering group id for this mesh (0 by default)
  11588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11589. */
  11590. renderingGroupId: number;
  11591. /**
  11592. * Defines the list of sprites managed by the manager.
  11593. */
  11594. sprites: Array<Sprite>;
  11595. /**
  11596. * Tests the intersection of a sprite with a specific ray.
  11597. * @param ray The ray we are sending to test the collision
  11598. * @param camera The camera space we are sending rays in
  11599. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11600. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11601. * @returns picking info or null.
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Intersects the sprites with a ray
  11606. * @param ray defines the ray to intersect with
  11607. * @param camera defines the current active camera
  11608. * @param predicate defines a predicate used to select candidate sprites
  11609. * @returns null if no hit or a PickingInfo array
  11610. */
  11611. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11612. /**
  11613. * Renders the list of sprites on screen.
  11614. */
  11615. render(): void;
  11616. }
  11617. /**
  11618. * Class used to manage multiple sprites on the same spritesheet
  11619. * @see http://doc.babylonjs.com/babylon101/sprites
  11620. */
  11621. export class SpriteManager implements ISpriteManager {
  11622. /** defines the manager's name */
  11623. name: string;
  11624. /** Gets the list of sprites */
  11625. sprites: Sprite[];
  11626. /** Gets or sets the rendering group id (0 by default) */
  11627. renderingGroupId: number;
  11628. /** Gets or sets camera layer mask */
  11629. layerMask: number;
  11630. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11631. fogEnabled: boolean;
  11632. /** Gets or sets a boolean indicating if the sprites are pickable */
  11633. isPickable: boolean;
  11634. /** Defines the default width of a cell in the spritesheet */
  11635. cellWidth: number;
  11636. /** Defines the default height of a cell in the spritesheet */
  11637. cellHeight: number;
  11638. /** Associative array from JSON sprite data file */
  11639. private _cellData;
  11640. /** Array of sprite names from JSON sprite data file */
  11641. private _spriteMap;
  11642. /** True when packed cell data from JSON file is ready*/
  11643. private _packedAndReady;
  11644. /**
  11645. * An event triggered when the manager is disposed.
  11646. */
  11647. onDisposeObservable: Observable<SpriteManager>;
  11648. private _onDisposeObserver;
  11649. /**
  11650. * Callback called when the manager is disposed
  11651. */
  11652. onDispose: () => void;
  11653. private _capacity;
  11654. private _fromPacked;
  11655. private _spriteTexture;
  11656. private _epsilon;
  11657. private _scene;
  11658. private _vertexData;
  11659. private _buffer;
  11660. private _vertexBuffers;
  11661. private _indexBuffer;
  11662. private _effectBase;
  11663. private _effectFog;
  11664. /**
  11665. * Gets or sets the spritesheet texture
  11666. */
  11667. texture: Texture;
  11668. /**
  11669. * Creates a new sprite manager
  11670. * @param name defines the manager's name
  11671. * @param imgUrl defines the sprite sheet url
  11672. * @param capacity defines the maximum allowed number of sprites
  11673. * @param cellSize defines the size of a sprite cell
  11674. * @param scene defines the hosting scene
  11675. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11676. * @param samplingMode defines the smapling mode to use with spritesheet
  11677. * @param fromPacked set to false; do not alter
  11678. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11679. */
  11680. constructor(
  11681. /** defines the manager's name */
  11682. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11683. private _makePacked;
  11684. private _appendSpriteVertex;
  11685. /**
  11686. * Intersects the sprites with a ray
  11687. * @param ray defines the ray to intersect with
  11688. * @param camera defines the current active camera
  11689. * @param predicate defines a predicate used to select candidate sprites
  11690. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11691. * @returns null if no hit or a PickingInfo
  11692. */
  11693. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11694. /**
  11695. * Intersects the sprites with a ray
  11696. * @param ray defines the ray to intersect with
  11697. * @param camera defines the current active camera
  11698. * @param predicate defines a predicate used to select candidate sprites
  11699. * @returns null if no hit or a PickingInfo array
  11700. */
  11701. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11702. /**
  11703. * Render all child sprites
  11704. */
  11705. render(): void;
  11706. /**
  11707. * Release associated resources
  11708. */
  11709. dispose(): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Sprites/sprite" {
  11713. import { Vector3 } from "babylonjs/Maths/math.vector";
  11714. import { Nullable } from "babylonjs/types";
  11715. import { ActionManager } from "babylonjs/Actions/actionManager";
  11716. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11717. import { Color4 } from "babylonjs/Maths/math.color";
  11718. /**
  11719. * Class used to represent a sprite
  11720. * @see http://doc.babylonjs.com/babylon101/sprites
  11721. */
  11722. export class Sprite {
  11723. /** defines the name */
  11724. name: string;
  11725. /** Gets or sets the current world position */
  11726. position: Vector3;
  11727. /** Gets or sets the main color */
  11728. color: Color4;
  11729. /** Gets or sets the width */
  11730. width: number;
  11731. /** Gets or sets the height */
  11732. height: number;
  11733. /** Gets or sets rotation angle */
  11734. angle: number;
  11735. /** Gets or sets the cell index in the sprite sheet */
  11736. cellIndex: number;
  11737. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11738. cellRef: string;
  11739. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11740. invertU: number;
  11741. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11742. invertV: number;
  11743. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11744. disposeWhenFinishedAnimating: boolean;
  11745. /** Gets the list of attached animations */
  11746. animations: Animation[];
  11747. /** Gets or sets a boolean indicating if the sprite can be picked */
  11748. isPickable: boolean;
  11749. /**
  11750. * Gets or sets the associated action manager
  11751. */
  11752. actionManager: Nullable<ActionManager>;
  11753. private _animationStarted;
  11754. private _loopAnimation;
  11755. private _fromIndex;
  11756. private _toIndex;
  11757. private _delay;
  11758. private _direction;
  11759. private _manager;
  11760. private _time;
  11761. private _onAnimationEnd;
  11762. /**
  11763. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11764. */
  11765. isVisible: boolean;
  11766. /**
  11767. * Gets or sets the sprite size
  11768. */
  11769. size: number;
  11770. /**
  11771. * Creates a new Sprite
  11772. * @param name defines the name
  11773. * @param manager defines the manager
  11774. */
  11775. constructor(
  11776. /** defines the name */
  11777. name: string, manager: ISpriteManager);
  11778. /**
  11779. * Starts an animation
  11780. * @param from defines the initial key
  11781. * @param to defines the end key
  11782. * @param loop defines if the animation must loop
  11783. * @param delay defines the start delay (in ms)
  11784. * @param onAnimationEnd defines a callback to call when animation ends
  11785. */
  11786. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11787. /** Stops current animation (if any) */
  11788. stopAnimation(): void;
  11789. /** @hidden */
  11790. _animate(deltaTime: number): void;
  11791. /** Release associated resources */
  11792. dispose(): void;
  11793. }
  11794. }
  11795. declare module "babylonjs/Collisions/pickingInfo" {
  11796. import { Nullable } from "babylonjs/types";
  11797. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11799. import { Sprite } from "babylonjs/Sprites/sprite";
  11800. import { Ray } from "babylonjs/Culling/ray";
  11801. /**
  11802. * Information about the result of picking within a scene
  11803. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11804. */
  11805. export class PickingInfo {
  11806. /** @hidden */
  11807. _pickingUnavailable: boolean;
  11808. /**
  11809. * If the pick collided with an object
  11810. */
  11811. hit: boolean;
  11812. /**
  11813. * Distance away where the pick collided
  11814. */
  11815. distance: number;
  11816. /**
  11817. * The location of pick collision
  11818. */
  11819. pickedPoint: Nullable<Vector3>;
  11820. /**
  11821. * The mesh corresponding the the pick collision
  11822. */
  11823. pickedMesh: Nullable<AbstractMesh>;
  11824. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11825. bu: number;
  11826. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11827. bv: number;
  11828. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11829. faceId: number;
  11830. /** Id of the the submesh that was picked */
  11831. subMeshId: number;
  11832. /** If a sprite was picked, this will be the sprite the pick collided with */
  11833. pickedSprite: Nullable<Sprite>;
  11834. /**
  11835. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11836. */
  11837. originMesh: Nullable<AbstractMesh>;
  11838. /**
  11839. * The ray that was used to perform the picking.
  11840. */
  11841. ray: Nullable<Ray>;
  11842. /**
  11843. * Gets the normal correspodning to the face the pick collided with
  11844. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11845. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11846. * @returns The normal correspodning to the face the pick collided with
  11847. */
  11848. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11849. /**
  11850. * Gets the texture coordinates of where the pick occured
  11851. * @returns the vector containing the coordnates of the texture
  11852. */
  11853. getTextureCoordinates(): Nullable<Vector2>;
  11854. }
  11855. }
  11856. declare module "babylonjs/Events/pointerEvents" {
  11857. import { Nullable } from "babylonjs/types";
  11858. import { Vector2 } from "babylonjs/Maths/math.vector";
  11859. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11860. import { Ray } from "babylonjs/Culling/ray";
  11861. /**
  11862. * Gather the list of pointer event types as constants.
  11863. */
  11864. export class PointerEventTypes {
  11865. /**
  11866. * 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.
  11867. */
  11868. static readonly POINTERDOWN: number;
  11869. /**
  11870. * The pointerup event is fired when a pointer is no longer active.
  11871. */
  11872. static readonly POINTERUP: number;
  11873. /**
  11874. * The pointermove event is fired when a pointer changes coordinates.
  11875. */
  11876. static readonly POINTERMOVE: number;
  11877. /**
  11878. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11879. */
  11880. static readonly POINTERWHEEL: number;
  11881. /**
  11882. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11883. */
  11884. static readonly POINTERPICK: number;
  11885. /**
  11886. * The pointertap event is fired when a the object has been touched and released without drag.
  11887. */
  11888. static readonly POINTERTAP: number;
  11889. /**
  11890. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11891. */
  11892. static readonly POINTERDOUBLETAP: number;
  11893. }
  11894. /**
  11895. * Base class of pointer info types.
  11896. */
  11897. export class PointerInfoBase {
  11898. /**
  11899. * Defines the type of event (PointerEventTypes)
  11900. */
  11901. type: number;
  11902. /**
  11903. * Defines the related dom event
  11904. */
  11905. event: PointerEvent | MouseWheelEvent;
  11906. /**
  11907. * Instantiates the base class of pointers info.
  11908. * @param type Defines the type of event (PointerEventTypes)
  11909. * @param event Defines the related dom event
  11910. */
  11911. constructor(
  11912. /**
  11913. * Defines the type of event (PointerEventTypes)
  11914. */
  11915. type: number,
  11916. /**
  11917. * Defines the related dom event
  11918. */
  11919. event: PointerEvent | MouseWheelEvent);
  11920. }
  11921. /**
  11922. * This class is used to store pointer related info for the onPrePointerObservable event.
  11923. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11924. */
  11925. export class PointerInfoPre extends PointerInfoBase {
  11926. /**
  11927. * Ray from a pointer if availible (eg. 6dof controller)
  11928. */
  11929. ray: Nullable<Ray>;
  11930. /**
  11931. * Defines the local position of the pointer on the canvas.
  11932. */
  11933. localPosition: Vector2;
  11934. /**
  11935. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11936. */
  11937. skipOnPointerObservable: boolean;
  11938. /**
  11939. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11940. * @param type Defines the type of event (PointerEventTypes)
  11941. * @param event Defines the related dom event
  11942. * @param localX Defines the local x coordinates of the pointer when the event occured
  11943. * @param localY Defines the local y coordinates of the pointer when the event occured
  11944. */
  11945. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11946. }
  11947. /**
  11948. * This type contains all the data related to a pointer event in Babylon.js.
  11949. * 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.
  11950. */
  11951. export class PointerInfo extends PointerInfoBase {
  11952. /**
  11953. * Defines the picking info associated to the info (if any)\
  11954. */
  11955. pickInfo: Nullable<PickingInfo>;
  11956. /**
  11957. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11958. * @param type Defines the type of event (PointerEventTypes)
  11959. * @param event Defines the related dom event
  11960. * @param pickInfo Defines the picking info associated to the info (if any)\
  11961. */
  11962. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11963. /**
  11964. * Defines the picking info associated to the info (if any)\
  11965. */
  11966. pickInfo: Nullable<PickingInfo>);
  11967. }
  11968. /**
  11969. * Data relating to a touch event on the screen.
  11970. */
  11971. export interface PointerTouch {
  11972. /**
  11973. * X coordinate of touch.
  11974. */
  11975. x: number;
  11976. /**
  11977. * Y coordinate of touch.
  11978. */
  11979. y: number;
  11980. /**
  11981. * Id of touch. Unique for each finger.
  11982. */
  11983. pointerId: number;
  11984. /**
  11985. * Event type passed from DOM.
  11986. */
  11987. type: any;
  11988. }
  11989. }
  11990. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11991. import { Observable } from "babylonjs/Misc/observable";
  11992. import { Nullable } from "babylonjs/types";
  11993. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11994. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11995. /**
  11996. * Manage the mouse inputs to control the movement of a free camera.
  11997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11998. */
  11999. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12000. /**
  12001. * Define if touch is enabled in the mouse input
  12002. */
  12003. touchEnabled: boolean;
  12004. /**
  12005. * Defines the camera the input is attached to.
  12006. */
  12007. camera: FreeCamera;
  12008. /**
  12009. * Defines the buttons associated with the input to handle camera move.
  12010. */
  12011. buttons: number[];
  12012. /**
  12013. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12014. */
  12015. angularSensibility: number;
  12016. private _pointerInput;
  12017. private _onMouseMove;
  12018. private _observer;
  12019. private previousPosition;
  12020. /**
  12021. * Observable for when a pointer move event occurs containing the move offset
  12022. */
  12023. onPointerMovedObservable: Observable<{
  12024. offsetX: number;
  12025. offsetY: number;
  12026. }>;
  12027. /**
  12028. * @hidden
  12029. * If the camera should be rotated automatically based on pointer movement
  12030. */
  12031. _allowCameraRotation: boolean;
  12032. /**
  12033. * Manage the mouse inputs to control the movement of a free camera.
  12034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12035. * @param touchEnabled Defines if touch is enabled or not
  12036. */
  12037. constructor(
  12038. /**
  12039. * Define if touch is enabled in the mouse input
  12040. */
  12041. touchEnabled?: boolean);
  12042. /**
  12043. * Attach the input controls to a specific dom element to get the input from.
  12044. * @param element Defines the element the controls should be listened from
  12045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12046. */
  12047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12048. /**
  12049. * Called on JS contextmenu event.
  12050. * Override this method to provide functionality.
  12051. */
  12052. protected onContextMenu(evt: PointerEvent): void;
  12053. /**
  12054. * Detach the current controls from the specified dom element.
  12055. * @param element Defines the element to stop listening the inputs from
  12056. */
  12057. detachControl(element: Nullable<HTMLElement>): void;
  12058. /**
  12059. * Gets the class name of the current intput.
  12060. * @returns the class name
  12061. */
  12062. getClassName(): string;
  12063. /**
  12064. * Get the friendly name associated with the input class.
  12065. * @returns the input friendly name
  12066. */
  12067. getSimpleName(): string;
  12068. }
  12069. }
  12070. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12071. import { Nullable } from "babylonjs/types";
  12072. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12074. /**
  12075. * Manage the touch inputs to control the movement of a free camera.
  12076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12077. */
  12078. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12079. /**
  12080. * Defines the camera the input is attached to.
  12081. */
  12082. camera: FreeCamera;
  12083. /**
  12084. * Defines the touch sensibility for rotation.
  12085. * The higher the faster.
  12086. */
  12087. touchAngularSensibility: number;
  12088. /**
  12089. * Defines the touch sensibility for move.
  12090. * The higher the faster.
  12091. */
  12092. touchMoveSensibility: number;
  12093. private _offsetX;
  12094. private _offsetY;
  12095. private _pointerPressed;
  12096. private _pointerInput;
  12097. private _observer;
  12098. private _onLostFocus;
  12099. /**
  12100. * Attach the input controls to a specific dom element to get the input from.
  12101. * @param element Defines the element the controls should be listened from
  12102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12103. */
  12104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12105. /**
  12106. * Detach the current controls from the specified dom element.
  12107. * @param element Defines the element to stop listening the inputs from
  12108. */
  12109. detachControl(element: Nullable<HTMLElement>): void;
  12110. /**
  12111. * Update the current camera state depending on the inputs that have been used this frame.
  12112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12113. */
  12114. checkInputs(): void;
  12115. /**
  12116. * Gets the class name of the current intput.
  12117. * @returns the class name
  12118. */
  12119. getClassName(): string;
  12120. /**
  12121. * Get the friendly name associated with the input class.
  12122. * @returns the input friendly name
  12123. */
  12124. getSimpleName(): string;
  12125. }
  12126. }
  12127. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12128. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12129. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12130. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12131. import { Nullable } from "babylonjs/types";
  12132. /**
  12133. * Default Inputs manager for the FreeCamera.
  12134. * It groups all the default supported inputs for ease of use.
  12135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12136. */
  12137. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12138. /**
  12139. * @hidden
  12140. */
  12141. _mouseInput: Nullable<FreeCameraMouseInput>;
  12142. /**
  12143. * Instantiates a new FreeCameraInputsManager.
  12144. * @param camera Defines the camera the inputs belong to
  12145. */
  12146. constructor(camera: FreeCamera);
  12147. /**
  12148. * Add keyboard input support to the input manager.
  12149. * @returns the current input manager
  12150. */
  12151. addKeyboard(): FreeCameraInputsManager;
  12152. /**
  12153. * Add mouse input support to the input manager.
  12154. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12155. * @returns the current input manager
  12156. */
  12157. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12158. /**
  12159. * Removes the mouse input support from the manager
  12160. * @returns the current input manager
  12161. */
  12162. removeMouse(): FreeCameraInputsManager;
  12163. /**
  12164. * Add touch input support to the input manager.
  12165. * @returns the current input manager
  12166. */
  12167. addTouch(): FreeCameraInputsManager;
  12168. /**
  12169. * Remove all attached input methods from a camera
  12170. */
  12171. clear(): void;
  12172. }
  12173. }
  12174. declare module "babylonjs/Cameras/freeCamera" {
  12175. import { Vector3 } from "babylonjs/Maths/math.vector";
  12176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12177. import { Scene } from "babylonjs/scene";
  12178. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12179. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12180. /**
  12181. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12182. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12183. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12184. */
  12185. export class FreeCamera extends TargetCamera {
  12186. /**
  12187. * Define the collision ellipsoid of the camera.
  12188. * This is helpful to simulate a camera body like the player body around the camera
  12189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12190. */
  12191. ellipsoid: Vector3;
  12192. /**
  12193. * Define an offset for the position of the ellipsoid around the camera.
  12194. * This can be helpful to determine the center of the body near the gravity center of the body
  12195. * instead of its head.
  12196. */
  12197. ellipsoidOffset: Vector3;
  12198. /**
  12199. * Enable or disable collisions of the camera with the rest of the scene objects.
  12200. */
  12201. checkCollisions: boolean;
  12202. /**
  12203. * Enable or disable gravity on the camera.
  12204. */
  12205. applyGravity: boolean;
  12206. /**
  12207. * Define the input manager associated to the camera.
  12208. */
  12209. inputs: FreeCameraInputsManager;
  12210. /**
  12211. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12212. * Higher values reduce sensitivity.
  12213. */
  12214. /**
  12215. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12216. * Higher values reduce sensitivity.
  12217. */
  12218. angularSensibility: number;
  12219. /**
  12220. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12221. */
  12222. keysUp: number[];
  12223. /**
  12224. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12225. */
  12226. keysDown: number[];
  12227. /**
  12228. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12229. */
  12230. keysLeft: number[];
  12231. /**
  12232. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12233. */
  12234. keysRight: number[];
  12235. /**
  12236. * Event raised when the camera collide with a mesh in the scene.
  12237. */
  12238. onCollide: (collidedMesh: AbstractMesh) => void;
  12239. private _collider;
  12240. private _needMoveForGravity;
  12241. private _oldPosition;
  12242. private _diffPosition;
  12243. private _newPosition;
  12244. /** @hidden */
  12245. _localDirection: Vector3;
  12246. /** @hidden */
  12247. _transformedDirection: Vector3;
  12248. /**
  12249. * Instantiates a Free Camera.
  12250. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12251. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12253. * @param name Define the name of the camera in the scene
  12254. * @param position Define the start position of the camera in the scene
  12255. * @param scene Define the scene the camera belongs to
  12256. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12257. */
  12258. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12259. /**
  12260. * Attached controls to the current camera.
  12261. * @param element Defines the element the controls should be listened from
  12262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12263. */
  12264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12265. /**
  12266. * Detach the current controls from the camera.
  12267. * The camera will stop reacting to inputs.
  12268. * @param element Defines the element to stop listening the inputs from
  12269. */
  12270. detachControl(element: HTMLElement): void;
  12271. private _collisionMask;
  12272. /**
  12273. * Define a collision mask to limit the list of object the camera can collide with
  12274. */
  12275. collisionMask: number;
  12276. /** @hidden */
  12277. _collideWithWorld(displacement: Vector3): void;
  12278. private _onCollisionPositionChange;
  12279. /** @hidden */
  12280. _checkInputs(): void;
  12281. /** @hidden */
  12282. _decideIfNeedsToMove(): boolean;
  12283. /** @hidden */
  12284. _updatePosition(): void;
  12285. /**
  12286. * Destroy the camera and release the current resources hold by it.
  12287. */
  12288. dispose(): void;
  12289. /**
  12290. * Gets the current object class name.
  12291. * @return the class name
  12292. */
  12293. getClassName(): string;
  12294. }
  12295. }
  12296. declare module "babylonjs/Gamepads/gamepad" {
  12297. import { Observable } from "babylonjs/Misc/observable";
  12298. /**
  12299. * Represents a gamepad control stick position
  12300. */
  12301. export class StickValues {
  12302. /**
  12303. * The x component of the control stick
  12304. */
  12305. x: number;
  12306. /**
  12307. * The y component of the control stick
  12308. */
  12309. y: number;
  12310. /**
  12311. * Initializes the gamepad x and y control stick values
  12312. * @param x The x component of the gamepad control stick value
  12313. * @param y The y component of the gamepad control stick value
  12314. */
  12315. constructor(
  12316. /**
  12317. * The x component of the control stick
  12318. */
  12319. x: number,
  12320. /**
  12321. * The y component of the control stick
  12322. */
  12323. y: number);
  12324. }
  12325. /**
  12326. * An interface which manages callbacks for gamepad button changes
  12327. */
  12328. export interface GamepadButtonChanges {
  12329. /**
  12330. * Called when a gamepad has been changed
  12331. */
  12332. changed: boolean;
  12333. /**
  12334. * Called when a gamepad press event has been triggered
  12335. */
  12336. pressChanged: boolean;
  12337. /**
  12338. * Called when a touch event has been triggered
  12339. */
  12340. touchChanged: boolean;
  12341. /**
  12342. * Called when a value has changed
  12343. */
  12344. valueChanged: boolean;
  12345. }
  12346. /**
  12347. * Represents a gamepad
  12348. */
  12349. export class Gamepad {
  12350. /**
  12351. * The id of the gamepad
  12352. */
  12353. id: string;
  12354. /**
  12355. * The index of the gamepad
  12356. */
  12357. index: number;
  12358. /**
  12359. * The browser gamepad
  12360. */
  12361. browserGamepad: any;
  12362. /**
  12363. * Specifies what type of gamepad this represents
  12364. */
  12365. type: number;
  12366. private _leftStick;
  12367. private _rightStick;
  12368. /** @hidden */
  12369. _isConnected: boolean;
  12370. private _leftStickAxisX;
  12371. private _leftStickAxisY;
  12372. private _rightStickAxisX;
  12373. private _rightStickAxisY;
  12374. /**
  12375. * Triggered when the left control stick has been changed
  12376. */
  12377. private _onleftstickchanged;
  12378. /**
  12379. * Triggered when the right control stick has been changed
  12380. */
  12381. private _onrightstickchanged;
  12382. /**
  12383. * Represents a gamepad controller
  12384. */
  12385. static GAMEPAD: number;
  12386. /**
  12387. * Represents a generic controller
  12388. */
  12389. static GENERIC: number;
  12390. /**
  12391. * Represents an XBox controller
  12392. */
  12393. static XBOX: number;
  12394. /**
  12395. * Represents a pose-enabled controller
  12396. */
  12397. static POSE_ENABLED: number;
  12398. /**
  12399. * Represents an Dual Shock controller
  12400. */
  12401. static DUALSHOCK: number;
  12402. /**
  12403. * Specifies whether the left control stick should be Y-inverted
  12404. */
  12405. protected _invertLeftStickY: boolean;
  12406. /**
  12407. * Specifies if the gamepad has been connected
  12408. */
  12409. readonly isConnected: boolean;
  12410. /**
  12411. * Initializes the gamepad
  12412. * @param id The id of the gamepad
  12413. * @param index The index of the gamepad
  12414. * @param browserGamepad The browser gamepad
  12415. * @param leftStickX The x component of the left joystick
  12416. * @param leftStickY The y component of the left joystick
  12417. * @param rightStickX The x component of the right joystick
  12418. * @param rightStickY The y component of the right joystick
  12419. */
  12420. constructor(
  12421. /**
  12422. * The id of the gamepad
  12423. */
  12424. id: string,
  12425. /**
  12426. * The index of the gamepad
  12427. */
  12428. index: number,
  12429. /**
  12430. * The browser gamepad
  12431. */
  12432. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12433. /**
  12434. * Callback triggered when the left joystick has changed
  12435. * @param callback
  12436. */
  12437. onleftstickchanged(callback: (values: StickValues) => void): void;
  12438. /**
  12439. * Callback triggered when the right joystick has changed
  12440. * @param callback
  12441. */
  12442. onrightstickchanged(callback: (values: StickValues) => void): void;
  12443. /**
  12444. * Gets the left joystick
  12445. */
  12446. /**
  12447. * Sets the left joystick values
  12448. */
  12449. leftStick: StickValues;
  12450. /**
  12451. * Gets the right joystick
  12452. */
  12453. /**
  12454. * Sets the right joystick value
  12455. */
  12456. rightStick: StickValues;
  12457. /**
  12458. * Updates the gamepad joystick positions
  12459. */
  12460. update(): void;
  12461. /**
  12462. * Disposes the gamepad
  12463. */
  12464. dispose(): void;
  12465. }
  12466. /**
  12467. * Represents a generic gamepad
  12468. */
  12469. export class GenericPad extends Gamepad {
  12470. private _buttons;
  12471. private _onbuttondown;
  12472. private _onbuttonup;
  12473. /**
  12474. * Observable triggered when a button has been pressed
  12475. */
  12476. onButtonDownObservable: Observable<number>;
  12477. /**
  12478. * Observable triggered when a button has been released
  12479. */
  12480. onButtonUpObservable: Observable<number>;
  12481. /**
  12482. * Callback triggered when a button has been pressed
  12483. * @param callback Called when a button has been pressed
  12484. */
  12485. onbuttondown(callback: (buttonPressed: number) => void): void;
  12486. /**
  12487. * Callback triggered when a button has been released
  12488. * @param callback Called when a button has been released
  12489. */
  12490. onbuttonup(callback: (buttonReleased: number) => void): void;
  12491. /**
  12492. * Initializes the generic gamepad
  12493. * @param id The id of the generic gamepad
  12494. * @param index The index of the generic gamepad
  12495. * @param browserGamepad The browser gamepad
  12496. */
  12497. constructor(id: string, index: number, browserGamepad: any);
  12498. private _setButtonValue;
  12499. /**
  12500. * Updates the generic gamepad
  12501. */
  12502. update(): void;
  12503. /**
  12504. * Disposes the generic gamepad
  12505. */
  12506. dispose(): void;
  12507. }
  12508. }
  12509. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12510. import { Nullable } from "babylonjs/types";
  12511. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12512. import { Scene } from "babylonjs/scene";
  12513. module "babylonjs/Engines/engine" {
  12514. interface Engine {
  12515. /**
  12516. * Creates a raw texture
  12517. * @param data defines the data to store in the texture
  12518. * @param width defines the width of the texture
  12519. * @param height defines the height of the texture
  12520. * @param format defines the format of the data
  12521. * @param generateMipMaps defines if the engine should generate the mip levels
  12522. * @param invertY defines if data must be stored with Y axis inverted
  12523. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12524. * @param compression defines the compression used (null by default)
  12525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12526. * @returns the raw texture inside an InternalTexture
  12527. */
  12528. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12529. /**
  12530. * Update a raw texture
  12531. * @param texture defines the texture to update
  12532. * @param data defines the data to store in the texture
  12533. * @param format defines the format of the data
  12534. * @param invertY defines if data must be stored with Y axis inverted
  12535. */
  12536. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12537. /**
  12538. * Update a raw texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store in the texture
  12541. * @param format defines the format of the data
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. * @param compression defines the compression used (null by default)
  12544. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12545. */
  12546. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12547. /**
  12548. * Creates a new raw cube texture
  12549. * @param data defines the array of data to use to create each face
  12550. * @param size defines the size of the textures
  12551. * @param format defines the format of the data
  12552. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12553. * @param generateMipMaps defines if the engine should generate the mip levels
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12556. * @param compression defines the compression used (null by default)
  12557. * @returns the cube texture as an InternalTexture
  12558. */
  12559. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12560. /**
  12561. * Update a raw cube texture
  12562. * @param texture defines the texture to udpdate
  12563. * @param data defines the data to store
  12564. * @param format defines the data format
  12565. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12566. * @param invertY defines if data must be stored with Y axis inverted
  12567. */
  12568. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12569. /**
  12570. * Update a raw cube texture
  12571. * @param texture defines the texture to udpdate
  12572. * @param data defines the data to store
  12573. * @param format defines the data format
  12574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @param compression defines the compression used (null by default)
  12577. */
  12578. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12579. /**
  12580. * Update a raw cube texture
  12581. * @param texture defines the texture to udpdate
  12582. * @param data defines the data to store
  12583. * @param format defines the data format
  12584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12585. * @param invertY defines if data must be stored with Y axis inverted
  12586. * @param compression defines the compression used (null by default)
  12587. * @param level defines which level of the texture to update
  12588. */
  12589. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12590. /**
  12591. * Creates a new raw cube texture from a specified url
  12592. * @param url defines the url where the data is located
  12593. * @param scene defines the current scene
  12594. * @param size defines the size of the textures
  12595. * @param format defines the format of the data
  12596. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12597. * @param noMipmap defines if the engine should avoid generating the mip levels
  12598. * @param callback defines a callback used to extract texture data from loaded data
  12599. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12600. * @param onLoad defines a callback called when texture is loaded
  12601. * @param onError defines a callback called if there is an error
  12602. * @returns the cube texture as an InternalTexture
  12603. */
  12604. 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;
  12605. /**
  12606. * Creates a new raw cube texture from a specified url
  12607. * @param url defines the url where the data is located
  12608. * @param scene defines the current scene
  12609. * @param size defines the size of the textures
  12610. * @param format defines the format of the data
  12611. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12612. * @param noMipmap defines if the engine should avoid generating the mip levels
  12613. * @param callback defines a callback used to extract texture data from loaded data
  12614. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12615. * @param onLoad defines a callback called when texture is loaded
  12616. * @param onError defines a callback called if there is an error
  12617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @returns the cube texture as an InternalTexture
  12620. */
  12621. 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;
  12622. /**
  12623. * Creates a new raw 3D texture
  12624. * @param data defines the data used to create the texture
  12625. * @param width defines the width of the texture
  12626. * @param height defines the height of the texture
  12627. * @param depth defines the depth of the texture
  12628. * @param format defines the format of the texture
  12629. * @param generateMipMaps defines if the engine must generate mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compressed used (can be null)
  12633. * @param textureType defines the compressed used (can be null)
  12634. * @returns a new raw 3D texture (stored in an InternalTexture)
  12635. */
  12636. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12637. /**
  12638. * Update a raw 3D texture
  12639. * @param texture defines the texture to update
  12640. * @param data defines the data to store
  12641. * @param format defines the data format
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw 3D texture
  12647. * @param texture defines the texture to update
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param invertY defines if data must be stored with Y axis inverted
  12651. * @param compression defines the used compression (can be null)
  12652. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12653. */
  12654. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12655. }
  12656. }
  12657. }
  12658. declare module "babylonjs/Materials/Textures/rawTexture" {
  12659. import { Scene } from "babylonjs/scene";
  12660. import { Texture } from "babylonjs/Materials/Textures/texture";
  12661. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12662. /**
  12663. * Raw texture can help creating a texture directly from an array of data.
  12664. * This can be super useful if you either get the data from an uncompressed source or
  12665. * if you wish to create your texture pixel by pixel.
  12666. */
  12667. export class RawTexture extends Texture {
  12668. /**
  12669. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12670. */
  12671. format: number;
  12672. private _engine;
  12673. /**
  12674. * Instantiates a new RawTexture.
  12675. * Raw texture can help creating a texture directly from an array of data.
  12676. * This can be super useful if you either get the data from an uncompressed source or
  12677. * if you wish to create your texture pixel by pixel.
  12678. * @param data define the array of data to use to create the texture
  12679. * @param width define the width of the texture
  12680. * @param height define the height of the texture
  12681. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12682. * @param scene define the scene the texture belongs to
  12683. * @param generateMipMaps define whether mip maps should be generated or not
  12684. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12685. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12686. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12687. */
  12688. constructor(data: ArrayBufferView, width: number, height: number,
  12689. /**
  12690. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12691. */
  12692. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12693. /**
  12694. * Updates the texture underlying data.
  12695. * @param data Define the new data of the texture
  12696. */
  12697. update(data: ArrayBufferView): void;
  12698. /**
  12699. * Creates a luminance texture from some data.
  12700. * @param data Define the texture data
  12701. * @param width Define the width of the texture
  12702. * @param height Define the height of the texture
  12703. * @param scene Define the scene the texture belongs to
  12704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12707. * @returns the luminance texture
  12708. */
  12709. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12710. /**
  12711. * Creates a luminance alpha 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. * @returns the luminance alpha texture
  12720. */
  12721. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12722. /**
  12723. * Creates an alpha texture from some data.
  12724. * @param data Define the texture data
  12725. * @param width Define the width of the texture
  12726. * @param height Define the height of the texture
  12727. * @param scene Define the scene the texture belongs to
  12728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12731. * @returns the alpha texture
  12732. */
  12733. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12734. /**
  12735. * Creates a RGB texture from some data.
  12736. * @param data Define the texture data
  12737. * @param width Define the width of the texture
  12738. * @param height Define the height of the texture
  12739. * @param scene Define the scene the texture belongs to
  12740. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12743. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12744. * @returns the RGB alpha texture
  12745. */
  12746. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12747. /**
  12748. * Creates a RGBA texture from some data.
  12749. * @param data Define the texture data
  12750. * @param width Define the width of the texture
  12751. * @param height Define the height of the texture
  12752. * @param scene Define the scene the texture belongs to
  12753. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12754. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12755. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12756. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12757. * @returns the RGBA texture
  12758. */
  12759. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12760. /**
  12761. * Creates a R texture from some data.
  12762. * @param data Define the texture data
  12763. * @param width Define the width of the texture
  12764. * @param height Define the height of the texture
  12765. * @param scene Define the scene the texture belongs to
  12766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12769. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12770. * @returns the R texture
  12771. */
  12772. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12773. }
  12774. }
  12775. declare module "babylonjs/Maths/math.size" {
  12776. /**
  12777. * Interface for the size containing width and height
  12778. */
  12779. export interface ISize {
  12780. /**
  12781. * Width
  12782. */
  12783. width: number;
  12784. /**
  12785. * Heighht
  12786. */
  12787. height: number;
  12788. }
  12789. /**
  12790. * Size containing widht and height
  12791. */
  12792. export class Size implements ISize {
  12793. /**
  12794. * Width
  12795. */
  12796. width: number;
  12797. /**
  12798. * Height
  12799. */
  12800. height: number;
  12801. /**
  12802. * Creates a Size object from the given width and height (floats).
  12803. * @param width width of the new size
  12804. * @param height height of the new size
  12805. */
  12806. constructor(width: number, height: number);
  12807. /**
  12808. * Returns a string with the Size width and height
  12809. * @returns a string with the Size width and height
  12810. */
  12811. toString(): string;
  12812. /**
  12813. * "Size"
  12814. * @returns the string "Size"
  12815. */
  12816. getClassName(): string;
  12817. /**
  12818. * Returns the Size hash code.
  12819. * @returns a hash code for a unique width and height
  12820. */
  12821. getHashCode(): number;
  12822. /**
  12823. * Updates the current size from the given one.
  12824. * @param src the given size
  12825. */
  12826. copyFrom(src: Size): void;
  12827. /**
  12828. * Updates in place the current Size from the given floats.
  12829. * @param width width of the new size
  12830. * @param height height of the new size
  12831. * @returns the updated Size.
  12832. */
  12833. copyFromFloats(width: number, height: number): Size;
  12834. /**
  12835. * Updates in place the current Size from the given floats.
  12836. * @param width width to set
  12837. * @param height height to set
  12838. * @returns the updated Size.
  12839. */
  12840. set(width: number, height: number): Size;
  12841. /**
  12842. * Multiplies the width and height by numbers
  12843. * @param w factor to multiple the width by
  12844. * @param h factor to multiple the height by
  12845. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12846. */
  12847. multiplyByFloats(w: number, h: number): Size;
  12848. /**
  12849. * Clones the size
  12850. * @returns a new Size copied from the given one.
  12851. */
  12852. clone(): Size;
  12853. /**
  12854. * True if the current Size and the given one width and height are strictly equal.
  12855. * @param other the other size to compare against
  12856. * @returns True if the current Size and the given one width and height are strictly equal.
  12857. */
  12858. equals(other: Size): boolean;
  12859. /**
  12860. * The surface of the Size : width * height (float).
  12861. */
  12862. readonly surface: number;
  12863. /**
  12864. * Create a new size of zero
  12865. * @returns a new Size set to (0.0, 0.0)
  12866. */
  12867. static Zero(): Size;
  12868. /**
  12869. * Sums the width and height of two sizes
  12870. * @param otherSize size to add to this size
  12871. * @returns a new Size set as the addition result of the current Size and the given one.
  12872. */
  12873. add(otherSize: Size): Size;
  12874. /**
  12875. * Subtracts the width and height of two
  12876. * @param otherSize size to subtract to this size
  12877. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12878. */
  12879. subtract(otherSize: Size): Size;
  12880. /**
  12881. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12882. * @param start starting size to lerp between
  12883. * @param end end size to lerp between
  12884. * @param amount amount to lerp between the start and end values
  12885. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12886. */
  12887. static Lerp(start: Size, end: Size, amount: number): Size;
  12888. }
  12889. }
  12890. declare module "babylonjs/Animations/runtimeAnimation" {
  12891. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12892. import { Animatable } from "babylonjs/Animations/animatable";
  12893. import { Scene } from "babylonjs/scene";
  12894. /**
  12895. * Defines a runtime animation
  12896. */
  12897. export class RuntimeAnimation {
  12898. private _events;
  12899. /**
  12900. * The current frame of the runtime animation
  12901. */
  12902. private _currentFrame;
  12903. /**
  12904. * The animation used by the runtime animation
  12905. */
  12906. private _animation;
  12907. /**
  12908. * The target of the runtime animation
  12909. */
  12910. private _target;
  12911. /**
  12912. * The initiating animatable
  12913. */
  12914. private _host;
  12915. /**
  12916. * The original value of the runtime animation
  12917. */
  12918. private _originalValue;
  12919. /**
  12920. * The original blend value of the runtime animation
  12921. */
  12922. private _originalBlendValue;
  12923. /**
  12924. * The offsets cache of the runtime animation
  12925. */
  12926. private _offsetsCache;
  12927. /**
  12928. * The high limits cache of the runtime animation
  12929. */
  12930. private _highLimitsCache;
  12931. /**
  12932. * Specifies if the runtime animation has been stopped
  12933. */
  12934. private _stopped;
  12935. /**
  12936. * The blending factor of the runtime animation
  12937. */
  12938. private _blendingFactor;
  12939. /**
  12940. * The BabylonJS scene
  12941. */
  12942. private _scene;
  12943. /**
  12944. * The current value of the runtime animation
  12945. */
  12946. private _currentValue;
  12947. /** @hidden */
  12948. _animationState: _IAnimationState;
  12949. /**
  12950. * The active target of the runtime animation
  12951. */
  12952. private _activeTargets;
  12953. private _currentActiveTarget;
  12954. private _directTarget;
  12955. /**
  12956. * The target path of the runtime animation
  12957. */
  12958. private _targetPath;
  12959. /**
  12960. * The weight of the runtime animation
  12961. */
  12962. private _weight;
  12963. /**
  12964. * The ratio offset of the runtime animation
  12965. */
  12966. private _ratioOffset;
  12967. /**
  12968. * The previous delay of the runtime animation
  12969. */
  12970. private _previousDelay;
  12971. /**
  12972. * The previous ratio of the runtime animation
  12973. */
  12974. private _previousRatio;
  12975. private _enableBlending;
  12976. private _keys;
  12977. private _minFrame;
  12978. private _maxFrame;
  12979. private _minValue;
  12980. private _maxValue;
  12981. private _targetIsArray;
  12982. /**
  12983. * Gets the current frame of the runtime animation
  12984. */
  12985. readonly currentFrame: number;
  12986. /**
  12987. * Gets the weight of the runtime animation
  12988. */
  12989. readonly weight: number;
  12990. /**
  12991. * Gets the current value of the runtime animation
  12992. */
  12993. readonly currentValue: any;
  12994. /**
  12995. * Gets the target path of the runtime animation
  12996. */
  12997. readonly targetPath: string;
  12998. /**
  12999. * Gets the actual target of the runtime animation
  13000. */
  13001. readonly target: any;
  13002. /** @hidden */
  13003. _onLoop: () => void;
  13004. /**
  13005. * Create a new RuntimeAnimation object
  13006. * @param target defines the target of the animation
  13007. * @param animation defines the source animation object
  13008. * @param scene defines the hosting scene
  13009. * @param host defines the initiating Animatable
  13010. */
  13011. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13012. private _preparePath;
  13013. /**
  13014. * Gets the animation from the runtime animation
  13015. */
  13016. readonly animation: Animation;
  13017. /**
  13018. * Resets the runtime animation to the beginning
  13019. * @param restoreOriginal defines whether to restore the target property to the original value
  13020. */
  13021. reset(restoreOriginal?: boolean): void;
  13022. /**
  13023. * Specifies if the runtime animation is stopped
  13024. * @returns Boolean specifying if the runtime animation is stopped
  13025. */
  13026. isStopped(): boolean;
  13027. /**
  13028. * Disposes of the runtime animation
  13029. */
  13030. dispose(): void;
  13031. /**
  13032. * Apply the interpolated value to the target
  13033. * @param currentValue defines the value computed by the animation
  13034. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13035. */
  13036. setValue(currentValue: any, weight: number): void;
  13037. private _getOriginalValues;
  13038. private _setValue;
  13039. /**
  13040. * Gets the loop pmode of the runtime animation
  13041. * @returns Loop Mode
  13042. */
  13043. private _getCorrectLoopMode;
  13044. /**
  13045. * Move the current animation to a given frame
  13046. * @param frame defines the frame to move to
  13047. */
  13048. goToFrame(frame: number): void;
  13049. /**
  13050. * @hidden Internal use only
  13051. */
  13052. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13053. /**
  13054. * Execute the current animation
  13055. * @param delay defines the delay to add to the current frame
  13056. * @param from defines the lower bound of the animation range
  13057. * @param to defines the upper bound of the animation range
  13058. * @param loop defines if the current animation must loop
  13059. * @param speedRatio defines the current speed ratio
  13060. * @param weight defines the weight of the animation (default is -1 so no weight)
  13061. * @param onLoop optional callback called when animation loops
  13062. * @returns a boolean indicating if the animation is running
  13063. */
  13064. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13065. }
  13066. }
  13067. declare module "babylonjs/Animations/animatable" {
  13068. import { Animation } from "babylonjs/Animations/animation";
  13069. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13070. import { Nullable } from "babylonjs/types";
  13071. import { Observable } from "babylonjs/Misc/observable";
  13072. import { Scene } from "babylonjs/scene";
  13073. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13074. import { Node } from "babylonjs/node";
  13075. /**
  13076. * Class used to store an actual running animation
  13077. */
  13078. export class Animatable {
  13079. /** defines the target object */
  13080. target: any;
  13081. /** defines the starting frame number (default is 0) */
  13082. fromFrame: number;
  13083. /** defines the ending frame number (default is 100) */
  13084. toFrame: number;
  13085. /** defines if the animation must loop (default is false) */
  13086. loopAnimation: boolean;
  13087. /** defines a callback to call when animation ends if it is not looping */
  13088. onAnimationEnd?: (() => void) | null | undefined;
  13089. /** defines a callback to call when animation loops */
  13090. onAnimationLoop?: (() => void) | null | undefined;
  13091. private _localDelayOffset;
  13092. private _pausedDelay;
  13093. private _runtimeAnimations;
  13094. private _paused;
  13095. private _scene;
  13096. private _speedRatio;
  13097. private _weight;
  13098. private _syncRoot;
  13099. /**
  13100. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13101. * This will only apply for non looping animation (default is true)
  13102. */
  13103. disposeOnEnd: boolean;
  13104. /**
  13105. * Gets a boolean indicating if the animation has started
  13106. */
  13107. animationStarted: boolean;
  13108. /**
  13109. * Observer raised when the animation ends
  13110. */
  13111. onAnimationEndObservable: Observable<Animatable>;
  13112. /**
  13113. * Observer raised when the animation loops
  13114. */
  13115. onAnimationLoopObservable: Observable<Animatable>;
  13116. /**
  13117. * Gets the root Animatable used to synchronize and normalize animations
  13118. */
  13119. readonly syncRoot: Nullable<Animatable>;
  13120. /**
  13121. * Gets the current frame of the first RuntimeAnimation
  13122. * Used to synchronize Animatables
  13123. */
  13124. readonly masterFrame: number;
  13125. /**
  13126. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13127. */
  13128. weight: number;
  13129. /**
  13130. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13131. */
  13132. speedRatio: number;
  13133. /**
  13134. * Creates a new Animatable
  13135. * @param scene defines the hosting scene
  13136. * @param target defines the target object
  13137. * @param fromFrame defines the starting frame number (default is 0)
  13138. * @param toFrame defines the ending frame number (default is 100)
  13139. * @param loopAnimation defines if the animation must loop (default is false)
  13140. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13141. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13142. * @param animations defines a group of animation to add to the new Animatable
  13143. * @param onAnimationLoop defines a callback to call when animation loops
  13144. */
  13145. constructor(scene: Scene,
  13146. /** defines the target object */
  13147. target: any,
  13148. /** defines the starting frame number (default is 0) */
  13149. fromFrame?: number,
  13150. /** defines the ending frame number (default is 100) */
  13151. toFrame?: number,
  13152. /** defines if the animation must loop (default is false) */
  13153. loopAnimation?: boolean, speedRatio?: number,
  13154. /** defines a callback to call when animation ends if it is not looping */
  13155. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13156. /** defines a callback to call when animation loops */
  13157. onAnimationLoop?: (() => void) | null | undefined);
  13158. /**
  13159. * Synchronize and normalize current Animatable with a source Animatable
  13160. * This is useful when using animation weights and when animations are not of the same length
  13161. * @param root defines the root Animatable to synchronize with
  13162. * @returns the current Animatable
  13163. */
  13164. syncWith(root: Animatable): Animatable;
  13165. /**
  13166. * Gets the list of runtime animations
  13167. * @returns an array of RuntimeAnimation
  13168. */
  13169. getAnimations(): RuntimeAnimation[];
  13170. /**
  13171. * Adds more animations to the current animatable
  13172. * @param target defines the target of the animations
  13173. * @param animations defines the new animations to add
  13174. */
  13175. appendAnimations(target: any, animations: Animation[]): void;
  13176. /**
  13177. * Gets the source animation for a specific property
  13178. * @param property defines the propertyu to look for
  13179. * @returns null or the source animation for the given property
  13180. */
  13181. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13182. /**
  13183. * Gets the runtime animation for a specific property
  13184. * @param property defines the propertyu to look for
  13185. * @returns null or the runtime animation for the given property
  13186. */
  13187. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13188. /**
  13189. * Resets the animatable to its original state
  13190. */
  13191. reset(): void;
  13192. /**
  13193. * Allows the animatable to blend with current running animations
  13194. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13195. * @param blendingSpeed defines the blending speed to use
  13196. */
  13197. enableBlending(blendingSpeed: number): void;
  13198. /**
  13199. * Disable animation blending
  13200. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13201. */
  13202. disableBlending(): void;
  13203. /**
  13204. * Jump directly to a given frame
  13205. * @param frame defines the frame to jump to
  13206. */
  13207. goToFrame(frame: number): void;
  13208. /**
  13209. * Pause the animation
  13210. */
  13211. pause(): void;
  13212. /**
  13213. * Restart the animation
  13214. */
  13215. restart(): void;
  13216. private _raiseOnAnimationEnd;
  13217. /**
  13218. * Stop and delete the current animation
  13219. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13220. * @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)
  13221. */
  13222. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13223. /**
  13224. * Wait asynchronously for the animation to end
  13225. * @returns a promise which will be fullfilled when the animation ends
  13226. */
  13227. waitAsync(): Promise<Animatable>;
  13228. /** @hidden */
  13229. _animate(delay: number): boolean;
  13230. }
  13231. module "babylonjs/scene" {
  13232. interface Scene {
  13233. /** @hidden */
  13234. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13235. /** @hidden */
  13236. _processLateAnimationBindingsForMatrices(holder: {
  13237. totalWeight: number;
  13238. animations: RuntimeAnimation[];
  13239. originalValue: Matrix;
  13240. }): any;
  13241. /** @hidden */
  13242. _processLateAnimationBindingsForQuaternions(holder: {
  13243. totalWeight: number;
  13244. animations: RuntimeAnimation[];
  13245. originalValue: Quaternion;
  13246. }, refQuaternion: Quaternion): Quaternion;
  13247. /** @hidden */
  13248. _processLateAnimationBindings(): void;
  13249. /**
  13250. * Will start the animation sequence of a given target
  13251. * @param target defines the target
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param weight defines the weight to apply to the animation (1.0 by default)
  13255. * @param loop defines if the animation loops
  13256. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13257. * @param onAnimationEnd defines the function to be executed when the animation ends
  13258. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the animatable object created for this animation
  13262. */
  13263. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13264. /**
  13265. * Will start the animation sequence of a given target
  13266. * @param target defines the target
  13267. * @param from defines from which frame should animation start
  13268. * @param to defines until which frame should animation run.
  13269. * @param loop defines if the animation loops
  13270. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13271. * @param onAnimationEnd defines the function to be executed when the animation ends
  13272. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13273. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13274. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13275. * @param onAnimationLoop defines the callback to call when an animation loops
  13276. * @returns the animatable object created for this animation
  13277. */
  13278. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13279. /**
  13280. * Will start the animation sequence of a given target and its hierarchy
  13281. * @param target defines the target
  13282. * @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.
  13283. * @param from defines from which frame should animation start
  13284. * @param to defines until which frame should animation run.
  13285. * @param loop defines if the animation loops
  13286. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13287. * @param onAnimationEnd defines the function to be executed when the animation ends
  13288. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13289. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13290. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13291. * @param onAnimationLoop defines the callback to call when an animation loops
  13292. * @returns the list of created animatables
  13293. */
  13294. 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[];
  13295. /**
  13296. * Begin a new animation on a given node
  13297. * @param target defines the target where the animation will take place
  13298. * @param animations defines the list of animations to start
  13299. * @param from defines the initial value
  13300. * @param to defines the final value
  13301. * @param loop defines if you want animation to loop (off by default)
  13302. * @param speedRatio defines the speed ratio to apply to all animations
  13303. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13304. * @param onAnimationLoop defines the callback to call when an animation loops
  13305. * @returns the list of created animatables
  13306. */
  13307. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13308. /**
  13309. * Begin a new animation on a given node and its hierarchy
  13310. * @param target defines the root node where the animation will take place
  13311. * @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.
  13312. * @param animations defines the list of animations to start
  13313. * @param from defines the initial value
  13314. * @param to defines the final value
  13315. * @param loop defines if you want animation to loop (off by default)
  13316. * @param speedRatio defines the speed ratio to apply to all animations
  13317. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13318. * @param onAnimationLoop defines the callback to call when an animation loops
  13319. * @returns the list of animatables created for all nodes
  13320. */
  13321. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13322. /**
  13323. * Gets the animatable associated with a specific target
  13324. * @param target defines the target of the animatable
  13325. * @returns the required animatable if found
  13326. */
  13327. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13328. /**
  13329. * Gets all animatables associated with a given target
  13330. * @param target defines the target to look animatables for
  13331. * @returns an array of Animatables
  13332. */
  13333. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13334. /**
  13335. * Stops and removes all animations that have been applied to the scene
  13336. */
  13337. stopAllAnimations(): void;
  13338. /**
  13339. * Gets the current delta time used by animation engine
  13340. */
  13341. deltaTime: number;
  13342. }
  13343. }
  13344. module "babylonjs/Bones/bone" {
  13345. interface Bone {
  13346. /**
  13347. * Copy an animation range from another bone
  13348. * @param source defines the source bone
  13349. * @param rangeName defines the range name to copy
  13350. * @param frameOffset defines the frame offset
  13351. * @param rescaleAsRequired defines if rescaling must be applied if required
  13352. * @param skelDimensionsRatio defines the scaling ratio
  13353. * @returns true if operation was successful
  13354. */
  13355. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13356. }
  13357. }
  13358. }
  13359. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13360. /**
  13361. * Class used to override all child animations of a given target
  13362. */
  13363. export class AnimationPropertiesOverride {
  13364. /**
  13365. * Gets or sets a value indicating if animation blending must be used
  13366. */
  13367. enableBlending: boolean;
  13368. /**
  13369. * Gets or sets the blending speed to use when enableBlending is true
  13370. */
  13371. blendingSpeed: number;
  13372. /**
  13373. * Gets or sets the default loop mode to use
  13374. */
  13375. loopMode: number;
  13376. }
  13377. }
  13378. declare module "babylonjs/Bones/skeleton" {
  13379. import { Bone } from "babylonjs/Bones/bone";
  13380. import { Observable } from "babylonjs/Misc/observable";
  13381. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13382. import { Scene } from "babylonjs/scene";
  13383. import { Nullable } from "babylonjs/types";
  13384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13386. import { Animatable } from "babylonjs/Animations/animatable";
  13387. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13388. import { Animation } from "babylonjs/Animations/animation";
  13389. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13390. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13391. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13392. /**
  13393. * Class used to handle skinning animations
  13394. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13395. */
  13396. export class Skeleton implements IAnimatable {
  13397. /** defines the skeleton name */
  13398. name: string;
  13399. /** defines the skeleton Id */
  13400. id: string;
  13401. /**
  13402. * Defines the list of child bones
  13403. */
  13404. bones: Bone[];
  13405. /**
  13406. * Defines an estimate of the dimension of the skeleton at rest
  13407. */
  13408. dimensionsAtRest: Vector3;
  13409. /**
  13410. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13411. */
  13412. needInitialSkinMatrix: boolean;
  13413. /**
  13414. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13415. */
  13416. overrideMesh: Nullable<AbstractMesh>;
  13417. /**
  13418. * Gets the list of animations attached to this skeleton
  13419. */
  13420. animations: Array<Animation>;
  13421. private _scene;
  13422. private _isDirty;
  13423. private _transformMatrices;
  13424. private _transformMatrixTexture;
  13425. private _meshesWithPoseMatrix;
  13426. private _animatables;
  13427. private _identity;
  13428. private _synchronizedWithMesh;
  13429. private _ranges;
  13430. private _lastAbsoluteTransformsUpdateId;
  13431. private _canUseTextureForBones;
  13432. private _uniqueId;
  13433. /** @hidden */
  13434. _numBonesWithLinkedTransformNode: number;
  13435. /** @hidden */
  13436. _hasWaitingData: Nullable<boolean>;
  13437. /**
  13438. * Specifies if the skeleton should be serialized
  13439. */
  13440. doNotSerialize: boolean;
  13441. private _useTextureToStoreBoneMatrices;
  13442. /**
  13443. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13444. * Please note that this option is not available if the hardware does not support it
  13445. */
  13446. useTextureToStoreBoneMatrices: boolean;
  13447. private _animationPropertiesOverride;
  13448. /**
  13449. * Gets or sets the animation properties override
  13450. */
  13451. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13452. /**
  13453. * List of inspectable custom properties (used by the Inspector)
  13454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13455. */
  13456. inspectableCustomProperties: IInspectable[];
  13457. /**
  13458. * An observable triggered before computing the skeleton's matrices
  13459. */
  13460. onBeforeComputeObservable: Observable<Skeleton>;
  13461. /**
  13462. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13463. */
  13464. readonly isUsingTextureForMatrices: boolean;
  13465. /**
  13466. * Gets the unique ID of this skeleton
  13467. */
  13468. readonly uniqueId: number;
  13469. /**
  13470. * Creates a new skeleton
  13471. * @param name defines the skeleton name
  13472. * @param id defines the skeleton Id
  13473. * @param scene defines the hosting scene
  13474. */
  13475. constructor(
  13476. /** defines the skeleton name */
  13477. name: string,
  13478. /** defines the skeleton Id */
  13479. id: string, scene: Scene);
  13480. /**
  13481. * Gets the current object class name.
  13482. * @return the class name
  13483. */
  13484. getClassName(): string;
  13485. /**
  13486. * Returns an array containing the root bones
  13487. * @returns an array containing the root bones
  13488. */
  13489. getChildren(): Array<Bone>;
  13490. /**
  13491. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13492. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13493. * @returns a Float32Array containing matrices data
  13494. */
  13495. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13496. /**
  13497. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13498. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13499. * @returns a raw texture containing the data
  13500. */
  13501. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13502. /**
  13503. * Gets the current hosting scene
  13504. * @returns a scene object
  13505. */
  13506. getScene(): Scene;
  13507. /**
  13508. * Gets a string representing the current skeleton data
  13509. * @param fullDetails defines a boolean indicating if we want a verbose version
  13510. * @returns a string representing the current skeleton data
  13511. */
  13512. toString(fullDetails?: boolean): string;
  13513. /**
  13514. * Get bone's index searching by name
  13515. * @param name defines bone's name to search for
  13516. * @return the indice of the bone. Returns -1 if not found
  13517. */
  13518. getBoneIndexByName(name: string): number;
  13519. /**
  13520. * Creater a new animation range
  13521. * @param name defines the name of the range
  13522. * @param from defines the start key
  13523. * @param to defines the end key
  13524. */
  13525. createAnimationRange(name: string, from: number, to: number): void;
  13526. /**
  13527. * Delete a specific animation range
  13528. * @param name defines the name of the range
  13529. * @param deleteFrames defines if frames must be removed as well
  13530. */
  13531. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13532. /**
  13533. * Gets a specific animation range
  13534. * @param name defines the name of the range to look for
  13535. * @returns the requested animation range or null if not found
  13536. */
  13537. getAnimationRange(name: string): Nullable<AnimationRange>;
  13538. /**
  13539. * Gets the list of all animation ranges defined on this skeleton
  13540. * @returns an array
  13541. */
  13542. getAnimationRanges(): Nullable<AnimationRange>[];
  13543. /**
  13544. * Copy animation range from a source skeleton.
  13545. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13546. * @param source defines the source skeleton
  13547. * @param name defines the name of the range to copy
  13548. * @param rescaleAsRequired defines if rescaling must be applied if required
  13549. * @returns true if operation was successful
  13550. */
  13551. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13552. /**
  13553. * Forces the skeleton to go to rest pose
  13554. */
  13555. returnToRest(): void;
  13556. private _getHighestAnimationFrame;
  13557. /**
  13558. * Begin a specific animation range
  13559. * @param name defines the name of the range to start
  13560. * @param loop defines if looping must be turned on (false by default)
  13561. * @param speedRatio defines the speed ratio to apply (1 by default)
  13562. * @param onAnimationEnd defines a callback which will be called when animation will end
  13563. * @returns a new animatable
  13564. */
  13565. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13566. /** @hidden */
  13567. _markAsDirty(): void;
  13568. /** @hidden */
  13569. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13570. /** @hidden */
  13571. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13572. private _computeTransformMatrices;
  13573. /**
  13574. * Build all resources required to render a skeleton
  13575. */
  13576. prepare(): void;
  13577. /**
  13578. * Gets the list of animatables currently running for this skeleton
  13579. * @returns an array of animatables
  13580. */
  13581. getAnimatables(): IAnimatable[];
  13582. /**
  13583. * Clone the current skeleton
  13584. * @param name defines the name of the new skeleton
  13585. * @param id defines the id of the new skeleton
  13586. * @returns the new skeleton
  13587. */
  13588. clone(name: string, id: string): Skeleton;
  13589. /**
  13590. * Enable animation blending for this skeleton
  13591. * @param blendingSpeed defines the blending speed to apply
  13592. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13593. */
  13594. enableBlending(blendingSpeed?: number): void;
  13595. /**
  13596. * Releases all resources associated with the current skeleton
  13597. */
  13598. dispose(): void;
  13599. /**
  13600. * Serialize the skeleton in a JSON object
  13601. * @returns a JSON object
  13602. */
  13603. serialize(): any;
  13604. /**
  13605. * Creates a new skeleton from serialized data
  13606. * @param parsedSkeleton defines the serialized data
  13607. * @param scene defines the hosting scene
  13608. * @returns a new skeleton
  13609. */
  13610. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13611. /**
  13612. * Compute all node absolute transforms
  13613. * @param forceUpdate defines if computation must be done even if cache is up to date
  13614. */
  13615. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13616. /**
  13617. * Gets the root pose matrix
  13618. * @returns a matrix
  13619. */
  13620. getPoseMatrix(): Nullable<Matrix>;
  13621. /**
  13622. * Sorts bones per internal index
  13623. */
  13624. sortBones(): void;
  13625. private _sortBones;
  13626. }
  13627. }
  13628. declare module "babylonjs/Bones/bone" {
  13629. import { Skeleton } from "babylonjs/Bones/skeleton";
  13630. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13631. import { Nullable } from "babylonjs/types";
  13632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13633. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13634. import { Node } from "babylonjs/node";
  13635. import { Space } from "babylonjs/Maths/math.axis";
  13636. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13637. /**
  13638. * Class used to store bone information
  13639. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13640. */
  13641. export class Bone extends Node {
  13642. /**
  13643. * defines the bone name
  13644. */
  13645. name: string;
  13646. private static _tmpVecs;
  13647. private static _tmpQuat;
  13648. private static _tmpMats;
  13649. /**
  13650. * Gets the list of child bones
  13651. */
  13652. children: Bone[];
  13653. /** Gets the animations associated with this bone */
  13654. animations: import("babylonjs/Animations/animation").Animation[];
  13655. /**
  13656. * Gets or sets bone length
  13657. */
  13658. length: number;
  13659. /**
  13660. * @hidden Internal only
  13661. * Set this value to map this bone to a different index in the transform matrices
  13662. * Set this value to -1 to exclude the bone from the transform matrices
  13663. */
  13664. _index: Nullable<number>;
  13665. private _skeleton;
  13666. private _localMatrix;
  13667. private _restPose;
  13668. private _baseMatrix;
  13669. private _absoluteTransform;
  13670. private _invertedAbsoluteTransform;
  13671. private _parent;
  13672. private _scalingDeterminant;
  13673. private _worldTransform;
  13674. private _localScaling;
  13675. private _localRotation;
  13676. private _localPosition;
  13677. private _needToDecompose;
  13678. private _needToCompose;
  13679. /** @hidden */
  13680. _linkedTransformNode: Nullable<TransformNode>;
  13681. /** @hidden */
  13682. _waitingTransformNodeId: Nullable<string>;
  13683. /** @hidden */
  13684. /** @hidden */
  13685. _matrix: Matrix;
  13686. /**
  13687. * Create a new bone
  13688. * @param name defines the bone name
  13689. * @param skeleton defines the parent skeleton
  13690. * @param parentBone defines the parent (can be null if the bone is the root)
  13691. * @param localMatrix defines the local matrix
  13692. * @param restPose defines the rest pose matrix
  13693. * @param baseMatrix defines the base matrix
  13694. * @param index defines index of the bone in the hiearchy
  13695. */
  13696. constructor(
  13697. /**
  13698. * defines the bone name
  13699. */
  13700. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13701. /**
  13702. * Gets the current object class name.
  13703. * @return the class name
  13704. */
  13705. getClassName(): string;
  13706. /**
  13707. * Gets the parent skeleton
  13708. * @returns a skeleton
  13709. */
  13710. getSkeleton(): Skeleton;
  13711. /**
  13712. * Gets parent bone
  13713. * @returns a bone or null if the bone is the root of the bone hierarchy
  13714. */
  13715. getParent(): Nullable<Bone>;
  13716. /**
  13717. * Returns an array containing the root bones
  13718. * @returns an array containing the root bones
  13719. */
  13720. getChildren(): Array<Bone>;
  13721. /**
  13722. * Sets the parent bone
  13723. * @param parent defines the parent (can be null if the bone is the root)
  13724. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13725. */
  13726. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13727. /**
  13728. * Gets the local matrix
  13729. * @returns a matrix
  13730. */
  13731. getLocalMatrix(): Matrix;
  13732. /**
  13733. * Gets the base matrix (initial matrix which remains unchanged)
  13734. * @returns a matrix
  13735. */
  13736. getBaseMatrix(): Matrix;
  13737. /**
  13738. * Gets the rest pose matrix
  13739. * @returns a matrix
  13740. */
  13741. getRestPose(): Matrix;
  13742. /**
  13743. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13744. */
  13745. getWorldMatrix(): Matrix;
  13746. /**
  13747. * Sets the local matrix to rest pose matrix
  13748. */
  13749. returnToRest(): void;
  13750. /**
  13751. * Gets the inverse of the absolute transform matrix.
  13752. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13753. * @returns a matrix
  13754. */
  13755. getInvertedAbsoluteTransform(): Matrix;
  13756. /**
  13757. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13758. * @returns a matrix
  13759. */
  13760. getAbsoluteTransform(): Matrix;
  13761. /**
  13762. * Links with the given transform node.
  13763. * The local matrix of this bone is copied from the transform node every frame.
  13764. * @param transformNode defines the transform node to link to
  13765. */
  13766. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13767. /**
  13768. * Gets the node used to drive the bone's transformation
  13769. * @returns a transform node or null
  13770. */
  13771. getTransformNode(): Nullable<TransformNode>;
  13772. /** Gets or sets current position (in local space) */
  13773. position: Vector3;
  13774. /** Gets or sets current rotation (in local space) */
  13775. rotation: Vector3;
  13776. /** Gets or sets current rotation quaternion (in local space) */
  13777. rotationQuaternion: Quaternion;
  13778. /** Gets or sets current scaling (in local space) */
  13779. scaling: Vector3;
  13780. /**
  13781. * Gets the animation properties override
  13782. */
  13783. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13784. private _decompose;
  13785. private _compose;
  13786. /**
  13787. * Update the base and local matrices
  13788. * @param matrix defines the new base or local matrix
  13789. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13790. * @param updateLocalMatrix defines if the local matrix should be updated
  13791. */
  13792. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13793. /** @hidden */
  13794. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13795. /**
  13796. * Flag the bone as dirty (Forcing it to update everything)
  13797. */
  13798. markAsDirty(): void;
  13799. /** @hidden */
  13800. _markAsDirtyAndCompose(): void;
  13801. private _markAsDirtyAndDecompose;
  13802. /**
  13803. * Translate the bone in local or world space
  13804. * @param vec The amount to translate the bone
  13805. * @param space The space that the translation is in
  13806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13807. */
  13808. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13809. /**
  13810. * Set the postion of the bone in local or world space
  13811. * @param position The position to set the bone
  13812. * @param space The space that the position is in
  13813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13814. */
  13815. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13816. /**
  13817. * Set the absolute position of the bone (world space)
  13818. * @param position The position to set the bone
  13819. * @param mesh The mesh that this bone is attached to
  13820. */
  13821. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13822. /**
  13823. * Scale the bone on the x, y and z axes (in local space)
  13824. * @param x The amount to scale the bone on the x axis
  13825. * @param y The amount to scale the bone on the y axis
  13826. * @param z The amount to scale the bone on the z axis
  13827. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13828. */
  13829. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13830. /**
  13831. * Set the bone scaling in local space
  13832. * @param scale defines the scaling vector
  13833. */
  13834. setScale(scale: Vector3): void;
  13835. /**
  13836. * Gets the current scaling in local space
  13837. * @returns the current scaling vector
  13838. */
  13839. getScale(): Vector3;
  13840. /**
  13841. * Gets the current scaling in local space and stores it in a target vector
  13842. * @param result defines the target vector
  13843. */
  13844. getScaleToRef(result: Vector3): void;
  13845. /**
  13846. * Set the yaw, pitch, and roll of the bone in local or world space
  13847. * @param yaw The rotation of the bone on the y axis
  13848. * @param pitch The rotation of the bone on the x axis
  13849. * @param roll The rotation of the bone on the z axis
  13850. * @param space The space that the axes of rotation are in
  13851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13852. */
  13853. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13854. /**
  13855. * Add a rotation to the bone on an axis in local or world space
  13856. * @param axis The axis to rotate the bone on
  13857. * @param amount The amount to rotate the bone
  13858. * @param space The space that the axis is in
  13859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13860. */
  13861. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13862. /**
  13863. * Set the rotation of the bone to a particular axis angle in local or world space
  13864. * @param axis The axis to rotate the bone on
  13865. * @param angle The angle that the bone should be rotated to
  13866. * @param space The space that the axis is in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. */
  13869. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13870. /**
  13871. * Set the euler rotation of the bone in local of world space
  13872. * @param rotation The euler rotation that the bone should be set to
  13873. * @param space The space that the rotation is in
  13874. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13875. */
  13876. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13877. /**
  13878. * Set the quaternion rotation of the bone in local of world space
  13879. * @param quat The quaternion rotation that the bone should be set to
  13880. * @param space The space that the rotation is in
  13881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13882. */
  13883. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13884. /**
  13885. * Set the rotation matrix of the bone in local of world space
  13886. * @param rotMat The rotation matrix that the bone should be set to
  13887. * @param space The space that the rotation is in
  13888. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13889. */
  13890. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13891. private _rotateWithMatrix;
  13892. private _getNegativeRotationToRef;
  13893. /**
  13894. * Get the position of the bone in local or world space
  13895. * @param space The space that the returned position is in
  13896. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13897. * @returns The position of the bone
  13898. */
  13899. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13900. /**
  13901. * Copy the position of the bone to a vector3 in local or world space
  13902. * @param space The space that the returned position is in
  13903. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13904. * @param result The vector3 to copy the position to
  13905. */
  13906. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13907. /**
  13908. * Get the absolute position of the bone (world space)
  13909. * @param mesh The mesh that this bone is attached to
  13910. * @returns The absolute position of the bone
  13911. */
  13912. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13913. /**
  13914. * Copy the absolute position of the bone (world space) to the result param
  13915. * @param mesh The mesh that this bone is attached to
  13916. * @param result The vector3 to copy the absolute position to
  13917. */
  13918. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13919. /**
  13920. * Compute the absolute transforms of this bone and its children
  13921. */
  13922. computeAbsoluteTransforms(): void;
  13923. /**
  13924. * Get the world direction from an axis that is in the local space of the bone
  13925. * @param localAxis The local direction that is used to compute the world direction
  13926. * @param mesh The mesh that this bone is attached to
  13927. * @returns The world direction
  13928. */
  13929. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13930. /**
  13931. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13932. * @param localAxis The local direction that is used to compute the world direction
  13933. * @param mesh The mesh that this bone is attached to
  13934. * @param result The vector3 that the world direction will be copied to
  13935. */
  13936. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13937. /**
  13938. * Get the euler rotation of the bone in local or world space
  13939. * @param space The space that the rotation should be in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. * @returns The euler rotation
  13942. */
  13943. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13944. /**
  13945. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13946. * @param space The space that the rotation should be in
  13947. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13948. * @param result The vector3 that the rotation should be copied to
  13949. */
  13950. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13951. /**
  13952. * Get the quaternion rotation of the bone in either local or world space
  13953. * @param space The space that the rotation should be in
  13954. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13955. * @returns The quaternion rotation
  13956. */
  13957. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13958. /**
  13959. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13960. * @param space The space that the rotation should be in
  13961. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13962. * @param result The quaternion that the rotation should be copied to
  13963. */
  13964. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13965. /**
  13966. * Get the rotation matrix of the bone in local or world space
  13967. * @param space The space that the rotation should be in
  13968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13969. * @returns The rotation matrix
  13970. */
  13971. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13972. /**
  13973. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13974. * @param space The space that the rotation should be in
  13975. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13976. * @param result The quaternion that the rotation should be copied to
  13977. */
  13978. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13979. /**
  13980. * Get the world position of a point that is in the local space of the bone
  13981. * @param position The local position
  13982. * @param mesh The mesh that this bone is attached to
  13983. * @returns The world position
  13984. */
  13985. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13986. /**
  13987. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13988. * @param position The local position
  13989. * @param mesh The mesh that this bone is attached to
  13990. * @param result The vector3 that the world position should be copied to
  13991. */
  13992. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13993. /**
  13994. * Get the local position of a point that is in world space
  13995. * @param position The world position
  13996. * @param mesh The mesh that this bone is attached to
  13997. * @returns The local position
  13998. */
  13999. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14000. /**
  14001. * Get the local position of a point that is in world space and copy it to the result param
  14002. * @param position The world position
  14003. * @param mesh The mesh that this bone is attached to
  14004. * @param result The vector3 that the local position should be copied to
  14005. */
  14006. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14007. }
  14008. }
  14009. declare module "babylonjs/Meshes/transformNode" {
  14010. import { DeepImmutable } from "babylonjs/types";
  14011. import { Observable } from "babylonjs/Misc/observable";
  14012. import { Nullable } from "babylonjs/types";
  14013. import { Camera } from "babylonjs/Cameras/camera";
  14014. import { Scene } from "babylonjs/scene";
  14015. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14016. import { Node } from "babylonjs/node";
  14017. import { Bone } from "babylonjs/Bones/bone";
  14018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14019. import { Space } from "babylonjs/Maths/math.axis";
  14020. /**
  14021. * 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.
  14022. * @see https://doc.babylonjs.com/how_to/transformnode
  14023. */
  14024. export class TransformNode extends Node {
  14025. /**
  14026. * Object will not rotate to face the camera
  14027. */
  14028. static BILLBOARDMODE_NONE: number;
  14029. /**
  14030. * Object will rotate to face the camera but only on the x axis
  14031. */
  14032. static BILLBOARDMODE_X: number;
  14033. /**
  14034. * Object will rotate to face the camera but only on the y axis
  14035. */
  14036. static BILLBOARDMODE_Y: number;
  14037. /**
  14038. * Object will rotate to face the camera but only on the z axis
  14039. */
  14040. static BILLBOARDMODE_Z: number;
  14041. /**
  14042. * Object will rotate to face the camera
  14043. */
  14044. static BILLBOARDMODE_ALL: number;
  14045. /**
  14046. * Object will rotate to face the camera's position instead of orientation
  14047. */
  14048. static BILLBOARDMODE_USE_POSITION: number;
  14049. private _forward;
  14050. private _forwardInverted;
  14051. private _up;
  14052. private _right;
  14053. private _rightInverted;
  14054. private _position;
  14055. private _rotation;
  14056. private _rotationQuaternion;
  14057. protected _scaling: Vector3;
  14058. protected _isDirty: boolean;
  14059. private _transformToBoneReferal;
  14060. private _isAbsoluteSynced;
  14061. private _billboardMode;
  14062. /**
  14063. * Gets or sets the billboard mode. Default is 0.
  14064. *
  14065. * | Value | Type | Description |
  14066. * | --- | --- | --- |
  14067. * | 0 | BILLBOARDMODE_NONE | |
  14068. * | 1 | BILLBOARDMODE_X | |
  14069. * | 2 | BILLBOARDMODE_Y | |
  14070. * | 4 | BILLBOARDMODE_Z | |
  14071. * | 7 | BILLBOARDMODE_ALL | |
  14072. *
  14073. */
  14074. billboardMode: number;
  14075. private _preserveParentRotationForBillboard;
  14076. /**
  14077. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14078. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14079. */
  14080. preserveParentRotationForBillboard: boolean;
  14081. /**
  14082. * 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
  14083. */
  14084. scalingDeterminant: number;
  14085. private _infiniteDistance;
  14086. /**
  14087. * Gets or sets the distance of the object to max, often used by skybox
  14088. */
  14089. infiniteDistance: boolean;
  14090. /**
  14091. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14092. * By default the system will update normals to compensate
  14093. */
  14094. ignoreNonUniformScaling: boolean;
  14095. /**
  14096. * 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
  14097. */
  14098. reIntegrateRotationIntoRotationQuaternion: boolean;
  14099. /** @hidden */
  14100. _poseMatrix: Nullable<Matrix>;
  14101. /** @hidden */
  14102. _localMatrix: Matrix;
  14103. private _usePivotMatrix;
  14104. private _absolutePosition;
  14105. private _absoluteScaling;
  14106. private _absoluteRotationQuaternion;
  14107. private _pivotMatrix;
  14108. private _pivotMatrixInverse;
  14109. protected _postMultiplyPivotMatrix: boolean;
  14110. protected _isWorldMatrixFrozen: boolean;
  14111. /** @hidden */
  14112. _indexInSceneTransformNodesArray: number;
  14113. /**
  14114. * An event triggered after the world matrix is updated
  14115. */
  14116. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14117. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14118. /**
  14119. * Gets a string identifying the name of the class
  14120. * @returns "TransformNode" string
  14121. */
  14122. getClassName(): string;
  14123. /**
  14124. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14125. */
  14126. position: Vector3;
  14127. /**
  14128. * 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)).
  14129. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14130. */
  14131. rotation: Vector3;
  14132. /**
  14133. * 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)).
  14134. */
  14135. scaling: Vector3;
  14136. /**
  14137. * 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).
  14138. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14139. */
  14140. rotationQuaternion: Nullable<Quaternion>;
  14141. /**
  14142. * The forward direction of that transform in world space.
  14143. */
  14144. readonly forward: Vector3;
  14145. /**
  14146. * The up direction of that transform in world space.
  14147. */
  14148. readonly up: Vector3;
  14149. /**
  14150. * The right direction of that transform in world space.
  14151. */
  14152. readonly right: Vector3;
  14153. /**
  14154. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14155. * @param matrix the matrix to copy the pose from
  14156. * @returns this TransformNode.
  14157. */
  14158. updatePoseMatrix(matrix: Matrix): TransformNode;
  14159. /**
  14160. * Returns the mesh Pose matrix.
  14161. * @returns the pose matrix
  14162. */
  14163. getPoseMatrix(): Matrix;
  14164. /** @hidden */
  14165. _isSynchronized(): boolean;
  14166. /** @hidden */
  14167. _initCache(): void;
  14168. /**
  14169. * Flag the transform node as dirty (Forcing it to update everything)
  14170. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14171. * @returns this transform node
  14172. */
  14173. markAsDirty(property: string): TransformNode;
  14174. /**
  14175. * Returns the current mesh absolute position.
  14176. * Returns a Vector3.
  14177. */
  14178. readonly absolutePosition: Vector3;
  14179. /**
  14180. * Returns the current mesh absolute scaling.
  14181. * Returns a Vector3.
  14182. */
  14183. readonly absoluteScaling: Vector3;
  14184. /**
  14185. * Returns the current mesh absolute rotation.
  14186. * Returns a Quaternion.
  14187. */
  14188. readonly absoluteRotationQuaternion: Quaternion;
  14189. /**
  14190. * Sets a new matrix to apply before all other transformation
  14191. * @param matrix defines the transform matrix
  14192. * @returns the current TransformNode
  14193. */
  14194. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14195. /**
  14196. * Sets a new pivot matrix to the current node
  14197. * @param matrix defines the new pivot matrix to use
  14198. * @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
  14199. * @returns the current TransformNode
  14200. */
  14201. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14202. /**
  14203. * Returns the mesh pivot matrix.
  14204. * Default : Identity.
  14205. * @returns the matrix
  14206. */
  14207. getPivotMatrix(): Matrix;
  14208. /**
  14209. * Instantiate (when possible) or clone that node with its hierarchy
  14210. * @param newParent defines the new parent to use for the instance (or clone)
  14211. * @returns an instance (or a clone) of the current node with its hiearchy
  14212. */
  14213. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14214. /**
  14215. * Prevents the World matrix to be computed any longer
  14216. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14217. * @returns the TransformNode.
  14218. */
  14219. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14220. /**
  14221. * Allows back the World matrix computation.
  14222. * @returns the TransformNode.
  14223. */
  14224. unfreezeWorldMatrix(): this;
  14225. /**
  14226. * True if the World matrix has been frozen.
  14227. */
  14228. readonly isWorldMatrixFrozen: boolean;
  14229. /**
  14230. * Retuns the mesh absolute position in the World.
  14231. * @returns a Vector3.
  14232. */
  14233. getAbsolutePosition(): Vector3;
  14234. /**
  14235. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14236. * @param absolutePosition the absolute position to set
  14237. * @returns the TransformNode.
  14238. */
  14239. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14240. /**
  14241. * Sets the mesh position in its local space.
  14242. * @param vector3 the position to set in localspace
  14243. * @returns the TransformNode.
  14244. */
  14245. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14246. /**
  14247. * Returns the mesh position in the local space from the current World matrix values.
  14248. * @returns a new Vector3.
  14249. */
  14250. getPositionExpressedInLocalSpace(): Vector3;
  14251. /**
  14252. * Translates the mesh along the passed Vector3 in its local space.
  14253. * @param vector3 the distance to translate in localspace
  14254. * @returns the TransformNode.
  14255. */
  14256. locallyTranslate(vector3: Vector3): TransformNode;
  14257. private static _lookAtVectorCache;
  14258. /**
  14259. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14260. * @param targetPoint the position (must be in same space as current mesh) to look at
  14261. * @param yawCor optional yaw (y-axis) correction in radians
  14262. * @param pitchCor optional pitch (x-axis) correction in radians
  14263. * @param rollCor optional roll (z-axis) correction in radians
  14264. * @param space the choosen space of the target
  14265. * @returns the TransformNode.
  14266. */
  14267. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14268. /**
  14269. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14270. * This Vector3 is expressed in the World space.
  14271. * @param localAxis axis to rotate
  14272. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14273. */
  14274. getDirection(localAxis: Vector3): Vector3;
  14275. /**
  14276. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14277. * localAxis is expressed in the mesh local space.
  14278. * result is computed in the Wordl space from the mesh World matrix.
  14279. * @param localAxis axis to rotate
  14280. * @param result the resulting transformnode
  14281. * @returns this TransformNode.
  14282. */
  14283. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14284. /**
  14285. * Sets this transform node rotation to the given local axis.
  14286. * @param localAxis the axis in local space
  14287. * @param yawCor optional yaw (y-axis) correction in radians
  14288. * @param pitchCor optional pitch (x-axis) correction in radians
  14289. * @param rollCor optional roll (z-axis) correction in radians
  14290. * @returns this TransformNode
  14291. */
  14292. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14293. /**
  14294. * Sets a new pivot point to the current node
  14295. * @param point defines the new pivot point to use
  14296. * @param space defines if the point is in world or local space (local by default)
  14297. * @returns the current TransformNode
  14298. */
  14299. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14300. /**
  14301. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14302. * @returns the pivot point
  14303. */
  14304. getPivotPoint(): Vector3;
  14305. /**
  14306. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14307. * @param result the vector3 to store the result
  14308. * @returns this TransformNode.
  14309. */
  14310. getPivotPointToRef(result: Vector3): TransformNode;
  14311. /**
  14312. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14313. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14314. */
  14315. getAbsolutePivotPoint(): Vector3;
  14316. /**
  14317. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14318. * @param result vector3 to store the result
  14319. * @returns this TransformNode.
  14320. */
  14321. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14322. /**
  14323. * Defines the passed node as the parent of the current node.
  14324. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14325. * @see https://doc.babylonjs.com/how_to/parenting
  14326. * @param node the node ot set as the parent
  14327. * @returns this TransformNode.
  14328. */
  14329. setParent(node: Nullable<Node>): TransformNode;
  14330. private _nonUniformScaling;
  14331. /**
  14332. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14333. */
  14334. readonly nonUniformScaling: boolean;
  14335. /** @hidden */
  14336. _updateNonUniformScalingState(value: boolean): boolean;
  14337. /**
  14338. * Attach the current TransformNode to another TransformNode associated with a bone
  14339. * @param bone Bone affecting the TransformNode
  14340. * @param affectedTransformNode TransformNode associated with the bone
  14341. * @returns this object
  14342. */
  14343. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14344. /**
  14345. * Detach the transform node if its associated with a bone
  14346. * @returns this object
  14347. */
  14348. detachFromBone(): TransformNode;
  14349. private static _rotationAxisCache;
  14350. /**
  14351. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14352. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14353. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14354. * The passed axis is also normalized.
  14355. * @param axis the axis to rotate around
  14356. * @param amount the amount to rotate in radians
  14357. * @param space Space to rotate in (Default: local)
  14358. * @returns the TransformNode.
  14359. */
  14360. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14361. /**
  14362. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14363. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14364. * The passed axis is also normalized. .
  14365. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14366. * @param point the point to rotate around
  14367. * @param axis the axis to rotate around
  14368. * @param amount the amount to rotate in radians
  14369. * @returns the TransformNode
  14370. */
  14371. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14372. /**
  14373. * Translates the mesh along the axis vector for the passed distance in the given space.
  14374. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14375. * @param axis the axis to translate in
  14376. * @param distance the distance to translate
  14377. * @param space Space to rotate in (Default: local)
  14378. * @returns the TransformNode.
  14379. */
  14380. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14381. /**
  14382. * Adds a rotation step to the mesh current rotation.
  14383. * x, y, z are Euler angles expressed in radians.
  14384. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14385. * This means this rotation is made in the mesh local space only.
  14386. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14387. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14388. * ```javascript
  14389. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14390. * ```
  14391. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14392. * 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.
  14393. * @param x Rotation to add
  14394. * @param y Rotation to add
  14395. * @param z Rotation to add
  14396. * @returns the TransformNode.
  14397. */
  14398. addRotation(x: number, y: number, z: number): TransformNode;
  14399. /**
  14400. * @hidden
  14401. */
  14402. protected _getEffectiveParent(): Nullable<Node>;
  14403. /**
  14404. * Computes the world matrix of the node
  14405. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14406. * @returns the world matrix
  14407. */
  14408. computeWorldMatrix(force?: boolean): Matrix;
  14409. protected _afterComputeWorldMatrix(): void;
  14410. /**
  14411. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14412. * @param func callback function to add
  14413. *
  14414. * @returns the TransformNode.
  14415. */
  14416. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14417. /**
  14418. * Removes a registered callback function.
  14419. * @param func callback function to remove
  14420. * @returns the TransformNode.
  14421. */
  14422. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14423. /**
  14424. * Gets the position of the current mesh in camera space
  14425. * @param camera defines the camera to use
  14426. * @returns a position
  14427. */
  14428. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14429. /**
  14430. * Returns the distance from the mesh to the active camera
  14431. * @param camera defines the camera to use
  14432. * @returns the distance
  14433. */
  14434. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14435. /**
  14436. * Clone the current transform node
  14437. * @param name Name of the new clone
  14438. * @param newParent New parent for the clone
  14439. * @param doNotCloneChildren Do not clone children hierarchy
  14440. * @returns the new transform node
  14441. */
  14442. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14443. /**
  14444. * Serializes the objects information.
  14445. * @param currentSerializationObject defines the object to serialize in
  14446. * @returns the serialized object
  14447. */
  14448. serialize(currentSerializationObject?: any): any;
  14449. /**
  14450. * Returns a new TransformNode object parsed from the source provided.
  14451. * @param parsedTransformNode is the source.
  14452. * @param scene the scne the object belongs to
  14453. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14454. * @returns a new TransformNode object parsed from the source provided.
  14455. */
  14456. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14457. /**
  14458. * Get all child-transformNodes of this node
  14459. * @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
  14460. * @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
  14461. * @returns an array of TransformNode
  14462. */
  14463. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14464. /**
  14465. * Releases resources associated with this transform node.
  14466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14468. */
  14469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14470. /**
  14471. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14472. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14473. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14474. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14475. * @returns the current mesh
  14476. */
  14477. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14478. private _syncAbsoluteScalingAndRotation;
  14479. }
  14480. }
  14481. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14482. import { Observable } from "babylonjs/Misc/observable";
  14483. import { Nullable } from "babylonjs/types";
  14484. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14487. import { Ray } from "babylonjs/Culling/ray";
  14488. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14489. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14490. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14491. /**
  14492. * Defines the types of pose enabled controllers that are supported
  14493. */
  14494. export enum PoseEnabledControllerType {
  14495. /**
  14496. * HTC Vive
  14497. */
  14498. VIVE = 0,
  14499. /**
  14500. * Oculus Rift
  14501. */
  14502. OCULUS = 1,
  14503. /**
  14504. * Windows mixed reality
  14505. */
  14506. WINDOWS = 2,
  14507. /**
  14508. * Samsung gear VR
  14509. */
  14510. GEAR_VR = 3,
  14511. /**
  14512. * Google Daydream
  14513. */
  14514. DAYDREAM = 4,
  14515. /**
  14516. * Generic
  14517. */
  14518. GENERIC = 5
  14519. }
  14520. /**
  14521. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14522. */
  14523. export interface MutableGamepadButton {
  14524. /**
  14525. * Value of the button/trigger
  14526. */
  14527. value: number;
  14528. /**
  14529. * If the button/trigger is currently touched
  14530. */
  14531. touched: boolean;
  14532. /**
  14533. * If the button/trigger is currently pressed
  14534. */
  14535. pressed: boolean;
  14536. }
  14537. /**
  14538. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14539. * @hidden
  14540. */
  14541. export interface ExtendedGamepadButton extends GamepadButton {
  14542. /**
  14543. * If the button/trigger is currently pressed
  14544. */
  14545. readonly pressed: boolean;
  14546. /**
  14547. * If the button/trigger is currently touched
  14548. */
  14549. readonly touched: boolean;
  14550. /**
  14551. * Value of the button/trigger
  14552. */
  14553. readonly value: number;
  14554. }
  14555. /** @hidden */
  14556. export interface _GamePadFactory {
  14557. /**
  14558. * Returns wether or not the current gamepad can be created for this type of controller.
  14559. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14560. * @returns true if it can be created, otherwise false
  14561. */
  14562. canCreate(gamepadInfo: any): boolean;
  14563. /**
  14564. * Creates a new instance of the Gamepad.
  14565. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14566. * @returns the new gamepad instance
  14567. */
  14568. create(gamepadInfo: any): Gamepad;
  14569. }
  14570. /**
  14571. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14572. */
  14573. export class PoseEnabledControllerHelper {
  14574. /** @hidden */
  14575. static _ControllerFactories: _GamePadFactory[];
  14576. /** @hidden */
  14577. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14578. /**
  14579. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14580. * @param vrGamepad the gamepad to initialized
  14581. * @returns a vr controller of the type the gamepad identified as
  14582. */
  14583. static InitiateController(vrGamepad: any): Gamepad;
  14584. }
  14585. /**
  14586. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14587. */
  14588. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14589. /**
  14590. * If the controller is used in a webXR session
  14591. */
  14592. isXR: boolean;
  14593. private _deviceRoomPosition;
  14594. private _deviceRoomRotationQuaternion;
  14595. /**
  14596. * The device position in babylon space
  14597. */
  14598. devicePosition: Vector3;
  14599. /**
  14600. * The device rotation in babylon space
  14601. */
  14602. deviceRotationQuaternion: Quaternion;
  14603. /**
  14604. * The scale factor of the device in babylon space
  14605. */
  14606. deviceScaleFactor: number;
  14607. /**
  14608. * (Likely devicePosition should be used instead) The device position in its room space
  14609. */
  14610. position: Vector3;
  14611. /**
  14612. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14613. */
  14614. rotationQuaternion: Quaternion;
  14615. /**
  14616. * The type of controller (Eg. Windows mixed reality)
  14617. */
  14618. controllerType: PoseEnabledControllerType;
  14619. protected _calculatedPosition: Vector3;
  14620. private _calculatedRotation;
  14621. /**
  14622. * The raw pose from the device
  14623. */
  14624. rawPose: DevicePose;
  14625. private _trackPosition;
  14626. private _maxRotationDistFromHeadset;
  14627. private _draggedRoomRotation;
  14628. /**
  14629. * @hidden
  14630. */
  14631. _disableTrackPosition(fixedPosition: Vector3): void;
  14632. /**
  14633. * Internal, the mesh attached to the controller
  14634. * @hidden
  14635. */
  14636. _mesh: Nullable<AbstractMesh>;
  14637. private _poseControlledCamera;
  14638. private _leftHandSystemQuaternion;
  14639. /**
  14640. * Internal, matrix used to convert room space to babylon space
  14641. * @hidden
  14642. */
  14643. _deviceToWorld: Matrix;
  14644. /**
  14645. * Node to be used when casting a ray from the controller
  14646. * @hidden
  14647. */
  14648. _pointingPoseNode: Nullable<TransformNode>;
  14649. /**
  14650. * Name of the child mesh that can be used to cast a ray from the controller
  14651. */
  14652. static readonly POINTING_POSE: string;
  14653. /**
  14654. * Creates a new PoseEnabledController from a gamepad
  14655. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14656. */
  14657. constructor(browserGamepad: any);
  14658. private _workingMatrix;
  14659. /**
  14660. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14661. */
  14662. update(): void;
  14663. /**
  14664. * Updates only the pose device and mesh without doing any button event checking
  14665. */
  14666. protected _updatePoseAndMesh(): void;
  14667. /**
  14668. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14669. * @param poseData raw pose fromthe device
  14670. */
  14671. updateFromDevice(poseData: DevicePose): void;
  14672. /**
  14673. * @hidden
  14674. */
  14675. _meshAttachedObservable: Observable<AbstractMesh>;
  14676. /**
  14677. * Attaches a mesh to the controller
  14678. * @param mesh the mesh to be attached
  14679. */
  14680. attachToMesh(mesh: AbstractMesh): void;
  14681. /**
  14682. * Attaches the controllers mesh to a camera
  14683. * @param camera the camera the mesh should be attached to
  14684. */
  14685. attachToPoseControlledCamera(camera: TargetCamera): void;
  14686. /**
  14687. * Disposes of the controller
  14688. */
  14689. dispose(): void;
  14690. /**
  14691. * The mesh that is attached to the controller
  14692. */
  14693. readonly mesh: Nullable<AbstractMesh>;
  14694. /**
  14695. * Gets the ray of the controller in the direction the controller is pointing
  14696. * @param length the length the resulting ray should be
  14697. * @returns a ray in the direction the controller is pointing
  14698. */
  14699. getForwardRay(length?: number): Ray;
  14700. }
  14701. }
  14702. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14703. import { Observable } from "babylonjs/Misc/observable";
  14704. import { Scene } from "babylonjs/scene";
  14705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14706. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14707. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14708. import { Nullable } from "babylonjs/types";
  14709. /**
  14710. * Defines the WebVRController object that represents controllers tracked in 3D space
  14711. */
  14712. export abstract class WebVRController extends PoseEnabledController {
  14713. /**
  14714. * Internal, the default controller model for the controller
  14715. */
  14716. protected _defaultModel: Nullable<AbstractMesh>;
  14717. /**
  14718. * Fired when the trigger state has changed
  14719. */
  14720. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14721. /**
  14722. * Fired when the main button state has changed
  14723. */
  14724. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14725. /**
  14726. * Fired when the secondary button state has changed
  14727. */
  14728. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14729. /**
  14730. * Fired when the pad state has changed
  14731. */
  14732. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14733. /**
  14734. * Fired when controllers stick values have changed
  14735. */
  14736. onPadValuesChangedObservable: Observable<StickValues>;
  14737. /**
  14738. * Array of button availible on the controller
  14739. */
  14740. protected _buttons: Array<MutableGamepadButton>;
  14741. private _onButtonStateChange;
  14742. /**
  14743. * Fired when a controller button's state has changed
  14744. * @param callback the callback containing the button that was modified
  14745. */
  14746. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14747. /**
  14748. * X and Y axis corresponding to the controllers joystick
  14749. */
  14750. pad: StickValues;
  14751. /**
  14752. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14753. */
  14754. hand: string;
  14755. /**
  14756. * The default controller model for the controller
  14757. */
  14758. readonly defaultModel: Nullable<AbstractMesh>;
  14759. /**
  14760. * Creates a new WebVRController from a gamepad
  14761. * @param vrGamepad the gamepad that the WebVRController should be created from
  14762. */
  14763. constructor(vrGamepad: any);
  14764. /**
  14765. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14766. */
  14767. update(): void;
  14768. /**
  14769. * Function to be called when a button is modified
  14770. */
  14771. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14772. /**
  14773. * Loads a mesh and attaches it to the controller
  14774. * @param scene the scene the mesh should be added to
  14775. * @param meshLoaded callback for when the mesh has been loaded
  14776. */
  14777. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14778. private _setButtonValue;
  14779. private _changes;
  14780. private _checkChanges;
  14781. /**
  14782. * Disposes of th webVRCOntroller
  14783. */
  14784. dispose(): void;
  14785. }
  14786. }
  14787. declare module "babylonjs/Lights/hemisphericLight" {
  14788. import { Nullable } from "babylonjs/types";
  14789. import { Scene } from "babylonjs/scene";
  14790. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14791. import { Color3 } from "babylonjs/Maths/math.color";
  14792. import { Effect } from "babylonjs/Materials/effect";
  14793. import { Light } from "babylonjs/Lights/light";
  14794. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14795. /**
  14796. * The HemisphericLight simulates the ambient environment light,
  14797. * so the passed direction is the light reflection direction, not the incoming direction.
  14798. */
  14799. export class HemisphericLight extends Light {
  14800. /**
  14801. * The groundColor is the light in the opposite direction to the one specified during creation.
  14802. * 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.
  14803. */
  14804. groundColor: Color3;
  14805. /**
  14806. * The light reflection direction, not the incoming direction.
  14807. */
  14808. direction: Vector3;
  14809. /**
  14810. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14811. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14812. * The HemisphericLight can't cast shadows.
  14813. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14814. * @param name The friendly name of the light
  14815. * @param direction The direction of the light reflection
  14816. * @param scene The scene the light belongs to
  14817. */
  14818. constructor(name: string, direction: Vector3, scene: Scene);
  14819. protected _buildUniformLayout(): void;
  14820. /**
  14821. * Returns the string "HemisphericLight".
  14822. * @return The class name
  14823. */
  14824. getClassName(): string;
  14825. /**
  14826. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14827. * Returns the updated direction.
  14828. * @param target The target the direction should point to
  14829. * @return The computed direction
  14830. */
  14831. setDirectionToTarget(target: Vector3): Vector3;
  14832. /**
  14833. * Returns the shadow generator associated to the light.
  14834. * @returns Always null for hemispheric lights because it does not support shadows.
  14835. */
  14836. getShadowGenerator(): Nullable<IShadowGenerator>;
  14837. /**
  14838. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14839. * @param effect The effect to update
  14840. * @param lightIndex The index of the light in the effect to update
  14841. * @returns The hemispheric light
  14842. */
  14843. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14844. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14845. /**
  14846. * Computes the world matrix of the node
  14847. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14848. * @param useWasUpdatedFlag defines a reserved property
  14849. * @returns the world matrix
  14850. */
  14851. computeWorldMatrix(): Matrix;
  14852. /**
  14853. * Returns the integer 3.
  14854. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14855. */
  14856. getTypeID(): number;
  14857. /**
  14858. * Prepares the list of defines specific to the light type.
  14859. * @param defines the list of defines
  14860. * @param lightIndex defines the index of the light for the effect
  14861. */
  14862. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14863. }
  14864. }
  14865. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14866. /** @hidden */
  14867. export var vrMultiviewToSingleviewPixelShader: {
  14868. name: string;
  14869. shader: string;
  14870. };
  14871. }
  14872. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14874. import { Scene } from "babylonjs/scene";
  14875. /**
  14876. * Renders to multiple views with a single draw call
  14877. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14878. */
  14879. export class MultiviewRenderTarget extends RenderTargetTexture {
  14880. /**
  14881. * Creates a multiview render target
  14882. * @param scene scene used with the render target
  14883. * @param size the size of the render target (used for each view)
  14884. */
  14885. constructor(scene: Scene, size?: number | {
  14886. width: number;
  14887. height: number;
  14888. } | {
  14889. ratio: number;
  14890. });
  14891. /**
  14892. * @hidden
  14893. * @param faceIndex the face index, if its a cube texture
  14894. */
  14895. _bindFrameBuffer(faceIndex?: number): void;
  14896. /**
  14897. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14898. * @returns the view count
  14899. */
  14900. getViewCount(): number;
  14901. }
  14902. }
  14903. declare module "babylonjs/Maths/math.frustum" {
  14904. import { Matrix } from "babylonjs/Maths/math.vector";
  14905. import { DeepImmutable } from "babylonjs/types";
  14906. import { Plane } from "babylonjs/Maths/math.plane";
  14907. /**
  14908. * Represents a camera frustum
  14909. */
  14910. export class Frustum {
  14911. /**
  14912. * Gets the planes representing the frustum
  14913. * @param transform matrix to be applied to the returned planes
  14914. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14915. */
  14916. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14917. /**
  14918. * Gets the near frustum plane transformed by the transform matrix
  14919. * @param transform transformation matrix to be applied to the resulting frustum plane
  14920. * @param frustumPlane the resuling frustum plane
  14921. */
  14922. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14923. /**
  14924. * Gets the far frustum plane transformed by the transform matrix
  14925. * @param transform transformation matrix to be applied to the resulting frustum plane
  14926. * @param frustumPlane the resuling frustum plane
  14927. */
  14928. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14929. /**
  14930. * Gets the left frustum plane transformed by the transform matrix
  14931. * @param transform transformation matrix to be applied to the resulting frustum plane
  14932. * @param frustumPlane the resuling frustum plane
  14933. */
  14934. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14935. /**
  14936. * Gets the right frustum plane transformed by the transform matrix
  14937. * @param transform transformation matrix to be applied to the resulting frustum plane
  14938. * @param frustumPlane the resuling frustum plane
  14939. */
  14940. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14941. /**
  14942. * Gets the top frustum plane transformed by the transform matrix
  14943. * @param transform transformation matrix to be applied to the resulting frustum plane
  14944. * @param frustumPlane the resuling frustum plane
  14945. */
  14946. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14947. /**
  14948. * Gets the bottom frustum plane transformed by the transform matrix
  14949. * @param transform transformation matrix to be applied to the resulting frustum plane
  14950. * @param frustumPlane the resuling frustum plane
  14951. */
  14952. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14953. /**
  14954. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14955. * @param transform transformation matrix to be applied to the resulting frustum planes
  14956. * @param frustumPlanes the resuling frustum planes
  14957. */
  14958. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14959. }
  14960. }
  14961. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14962. import { Camera } from "babylonjs/Cameras/camera";
  14963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14964. import { Nullable } from "babylonjs/types";
  14965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14966. import { Matrix } from "babylonjs/Maths/math.vector";
  14967. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14968. module "babylonjs/Engines/engine" {
  14969. interface Engine {
  14970. /**
  14971. * Creates a new multiview render target
  14972. * @param width defines the width of the texture
  14973. * @param height defines the height of the texture
  14974. * @returns the created multiview texture
  14975. */
  14976. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14977. /**
  14978. * Binds a multiview framebuffer to be drawn to
  14979. * @param multiviewTexture texture to bind
  14980. */
  14981. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14982. }
  14983. }
  14984. module "babylonjs/Cameras/camera" {
  14985. interface Camera {
  14986. /**
  14987. * @hidden
  14988. * 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)
  14989. */
  14990. _useMultiviewToSingleView: boolean;
  14991. /**
  14992. * @hidden
  14993. * 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)
  14994. */
  14995. _multiviewTexture: Nullable<RenderTargetTexture>;
  14996. /**
  14997. * @hidden
  14998. * ensures the multiview texture of the camera exists and has the specified width/height
  14999. * @param width height to set on the multiview texture
  15000. * @param height width to set on the multiview texture
  15001. */
  15002. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15003. }
  15004. }
  15005. module "babylonjs/scene" {
  15006. interface Scene {
  15007. /** @hidden */
  15008. _transformMatrixR: Matrix;
  15009. /** @hidden */
  15010. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15011. /** @hidden */
  15012. _createMultiviewUbo(): void;
  15013. /** @hidden */
  15014. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15015. /** @hidden */
  15016. _renderMultiviewToSingleView(camera: Camera): void;
  15017. }
  15018. }
  15019. }
  15020. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15021. import { Camera } from "babylonjs/Cameras/camera";
  15022. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15023. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15024. import "babylonjs/Engines/Extensions/engine.multiview";
  15025. /**
  15026. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15027. * This will not be used for webXR as it supports displaying texture arrays directly
  15028. */
  15029. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15030. /**
  15031. * Initializes a VRMultiviewToSingleview
  15032. * @param name name of the post process
  15033. * @param camera camera to be applied to
  15034. * @param scaleFactor scaling factor to the size of the output texture
  15035. */
  15036. constructor(name: string, camera: Camera, scaleFactor: number);
  15037. }
  15038. }
  15039. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15040. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15041. import { Nullable } from "babylonjs/types";
  15042. import { Size } from "babylonjs/Maths/math.size";
  15043. import { Observable } from "babylonjs/Misc/observable";
  15044. module "babylonjs/Engines/engine" {
  15045. interface Engine {
  15046. /** @hidden */
  15047. _vrDisplay: any;
  15048. /** @hidden */
  15049. _vrSupported: boolean;
  15050. /** @hidden */
  15051. _oldSize: Size;
  15052. /** @hidden */
  15053. _oldHardwareScaleFactor: number;
  15054. /** @hidden */
  15055. _vrExclusivePointerMode: boolean;
  15056. /** @hidden */
  15057. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15058. /** @hidden */
  15059. _onVRDisplayPointerRestricted: () => void;
  15060. /** @hidden */
  15061. _onVRDisplayPointerUnrestricted: () => void;
  15062. /** @hidden */
  15063. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15064. /** @hidden */
  15065. _onVrDisplayDisconnect: Nullable<() => void>;
  15066. /** @hidden */
  15067. _onVrDisplayPresentChange: Nullable<() => void>;
  15068. /**
  15069. * Observable signaled when VR display mode changes
  15070. */
  15071. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15072. /**
  15073. * Observable signaled when VR request present is complete
  15074. */
  15075. onVRRequestPresentComplete: Observable<boolean>;
  15076. /**
  15077. * Observable signaled when VR request present starts
  15078. */
  15079. onVRRequestPresentStart: Observable<Engine>;
  15080. /**
  15081. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15082. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15083. */
  15084. isInVRExclusivePointerMode: boolean;
  15085. /**
  15086. * Gets a boolean indicating if a webVR device was detected
  15087. * @returns true if a webVR device was detected
  15088. */
  15089. isVRDevicePresent(): boolean;
  15090. /**
  15091. * Gets the current webVR device
  15092. * @returns the current webVR device (or null)
  15093. */
  15094. getVRDevice(): any;
  15095. /**
  15096. * Initializes a webVR display and starts listening to display change events
  15097. * The onVRDisplayChangedObservable will be notified upon these changes
  15098. * @returns A promise containing a VRDisplay and if vr is supported
  15099. */
  15100. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15101. /** @hidden */
  15102. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15103. /**
  15104. * Call this function to switch to webVR mode
  15105. * Will do nothing if webVR is not supported or if there is no webVR device
  15106. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15107. */
  15108. enableVR(): void;
  15109. /** @hidden */
  15110. _onVRFullScreenTriggered(): void;
  15111. }
  15112. }
  15113. }
  15114. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15115. import { Nullable } from "babylonjs/types";
  15116. import { Observable } from "babylonjs/Misc/observable";
  15117. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15118. import { Scene } from "babylonjs/scene";
  15119. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15120. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15121. import { Node } from "babylonjs/node";
  15122. import { Ray } from "babylonjs/Culling/ray";
  15123. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15124. import "babylonjs/Engines/Extensions/engine.webVR";
  15125. /**
  15126. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15127. * IMPORTANT!! The data is right-hand data.
  15128. * @export
  15129. * @interface DevicePose
  15130. */
  15131. export interface DevicePose {
  15132. /**
  15133. * The position of the device, values in array are [x,y,z].
  15134. */
  15135. readonly position: Nullable<Float32Array>;
  15136. /**
  15137. * The linearVelocity of the device, values in array are [x,y,z].
  15138. */
  15139. readonly linearVelocity: Nullable<Float32Array>;
  15140. /**
  15141. * The linearAcceleration of the device, values in array are [x,y,z].
  15142. */
  15143. readonly linearAcceleration: Nullable<Float32Array>;
  15144. /**
  15145. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15146. */
  15147. readonly orientation: Nullable<Float32Array>;
  15148. /**
  15149. * The angularVelocity of the device, values in array are [x,y,z].
  15150. */
  15151. readonly angularVelocity: Nullable<Float32Array>;
  15152. /**
  15153. * The angularAcceleration of the device, values in array are [x,y,z].
  15154. */
  15155. readonly angularAcceleration: Nullable<Float32Array>;
  15156. }
  15157. /**
  15158. * Interface representing a pose controlled object in Babylon.
  15159. * A pose controlled object has both regular pose values as well as pose values
  15160. * from an external device such as a VR head mounted display
  15161. */
  15162. export interface PoseControlled {
  15163. /**
  15164. * The position of the object in babylon space.
  15165. */
  15166. position: Vector3;
  15167. /**
  15168. * The rotation quaternion of the object in babylon space.
  15169. */
  15170. rotationQuaternion: Quaternion;
  15171. /**
  15172. * The position of the device in babylon space.
  15173. */
  15174. devicePosition?: Vector3;
  15175. /**
  15176. * The rotation quaternion of the device in babylon space.
  15177. */
  15178. deviceRotationQuaternion: Quaternion;
  15179. /**
  15180. * The raw pose coming from the device.
  15181. */
  15182. rawPose: Nullable<DevicePose>;
  15183. /**
  15184. * The scale of the device to be used when translating from device space to babylon space.
  15185. */
  15186. deviceScaleFactor: number;
  15187. /**
  15188. * Updates the poseControlled values based on the input device pose.
  15189. * @param poseData the pose data to update the object with
  15190. */
  15191. updateFromDevice(poseData: DevicePose): void;
  15192. }
  15193. /**
  15194. * Set of options to customize the webVRCamera
  15195. */
  15196. export interface WebVROptions {
  15197. /**
  15198. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15199. */
  15200. trackPosition?: boolean;
  15201. /**
  15202. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15203. */
  15204. positionScale?: number;
  15205. /**
  15206. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15207. */
  15208. displayName?: string;
  15209. /**
  15210. * Should the native controller meshes be initialized. (default: true)
  15211. */
  15212. controllerMeshes?: boolean;
  15213. /**
  15214. * Creating a default HemiLight only on controllers. (default: true)
  15215. */
  15216. defaultLightingOnControllers?: boolean;
  15217. /**
  15218. * If you don't want to use the default VR button of the helper. (default: false)
  15219. */
  15220. useCustomVRButton?: boolean;
  15221. /**
  15222. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15223. */
  15224. customVRButton?: HTMLButtonElement;
  15225. /**
  15226. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15227. */
  15228. rayLength?: number;
  15229. /**
  15230. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15231. */
  15232. defaultHeight?: number;
  15233. /**
  15234. * If multiview should be used if availible (default: false)
  15235. */
  15236. useMultiview?: boolean;
  15237. }
  15238. /**
  15239. * This represents a WebVR camera.
  15240. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15241. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15242. */
  15243. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15244. private webVROptions;
  15245. /**
  15246. * @hidden
  15247. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15248. */
  15249. _vrDevice: any;
  15250. /**
  15251. * The rawPose of the vrDevice.
  15252. */
  15253. rawPose: Nullable<DevicePose>;
  15254. private _onVREnabled;
  15255. private _specsVersion;
  15256. private _attached;
  15257. private _frameData;
  15258. protected _descendants: Array<Node>;
  15259. private _deviceRoomPosition;
  15260. /** @hidden */
  15261. _deviceRoomRotationQuaternion: Quaternion;
  15262. private _standingMatrix;
  15263. /**
  15264. * Represents device position in babylon space.
  15265. */
  15266. devicePosition: Vector3;
  15267. /**
  15268. * Represents device rotation in babylon space.
  15269. */
  15270. deviceRotationQuaternion: Quaternion;
  15271. /**
  15272. * The scale of the device to be used when translating from device space to babylon space.
  15273. */
  15274. deviceScaleFactor: number;
  15275. private _deviceToWorld;
  15276. private _worldToDevice;
  15277. /**
  15278. * References to the webVR controllers for the vrDevice.
  15279. */
  15280. controllers: Array<WebVRController>;
  15281. /**
  15282. * Emits an event when a controller is attached.
  15283. */
  15284. onControllersAttachedObservable: Observable<WebVRController[]>;
  15285. /**
  15286. * Emits an event when a controller's mesh has been loaded;
  15287. */
  15288. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15289. /**
  15290. * Emits an event when the HMD's pose has been updated.
  15291. */
  15292. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15293. private _poseSet;
  15294. /**
  15295. * If the rig cameras be used as parent instead of this camera.
  15296. */
  15297. rigParenting: boolean;
  15298. private _lightOnControllers;
  15299. private _defaultHeight?;
  15300. /**
  15301. * Instantiates a WebVRFreeCamera.
  15302. * @param name The name of the WebVRFreeCamera
  15303. * @param position The starting anchor position for the camera
  15304. * @param scene The scene the camera belongs to
  15305. * @param webVROptions a set of customizable options for the webVRCamera
  15306. */
  15307. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15308. /**
  15309. * Gets the device distance from the ground in meters.
  15310. * @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.
  15311. */
  15312. deviceDistanceToRoomGround(): number;
  15313. /**
  15314. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15315. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15316. */
  15317. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15318. /**
  15319. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15320. * @returns A promise with a boolean set to if the standing matrix is supported.
  15321. */
  15322. useStandingMatrixAsync(): Promise<boolean>;
  15323. /**
  15324. * Disposes the camera
  15325. */
  15326. dispose(): void;
  15327. /**
  15328. * Gets a vrController by name.
  15329. * @param name The name of the controller to retreive
  15330. * @returns the controller matching the name specified or null if not found
  15331. */
  15332. getControllerByName(name: string): Nullable<WebVRController>;
  15333. private _leftController;
  15334. /**
  15335. * The controller corresponding to the users left hand.
  15336. */
  15337. readonly leftController: Nullable<WebVRController>;
  15338. private _rightController;
  15339. /**
  15340. * The controller corresponding to the users right hand.
  15341. */
  15342. readonly rightController: Nullable<WebVRController>;
  15343. /**
  15344. * Casts a ray forward from the vrCamera's gaze.
  15345. * @param length Length of the ray (default: 100)
  15346. * @returns the ray corresponding to the gaze
  15347. */
  15348. getForwardRay(length?: number): Ray;
  15349. /**
  15350. * @hidden
  15351. * Updates the camera based on device's frame data
  15352. */
  15353. _checkInputs(): void;
  15354. /**
  15355. * Updates the poseControlled values based on the input device pose.
  15356. * @param poseData Pose coming from the device
  15357. */
  15358. updateFromDevice(poseData: DevicePose): void;
  15359. private _htmlElementAttached;
  15360. private _detachIfAttached;
  15361. /**
  15362. * WebVR's attach control will start broadcasting frames to the device.
  15363. * Note that in certain browsers (chrome for example) this function must be called
  15364. * within a user-interaction callback. Example:
  15365. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15366. *
  15367. * @param element html element to attach the vrDevice to
  15368. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15369. */
  15370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15371. /**
  15372. * Detaches the camera from the html element and disables VR
  15373. *
  15374. * @param element html element to detach from
  15375. */
  15376. detachControl(element: HTMLElement): void;
  15377. /**
  15378. * @returns the name of this class
  15379. */
  15380. getClassName(): string;
  15381. /**
  15382. * Calls resetPose on the vrDisplay
  15383. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15384. */
  15385. resetToCurrentRotation(): void;
  15386. /**
  15387. * @hidden
  15388. * Updates the rig cameras (left and right eye)
  15389. */
  15390. _updateRigCameras(): void;
  15391. private _workingVector;
  15392. private _oneVector;
  15393. private _workingMatrix;
  15394. private updateCacheCalled;
  15395. private _correctPositionIfNotTrackPosition;
  15396. /**
  15397. * @hidden
  15398. * Updates the cached values of the camera
  15399. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15400. */
  15401. _updateCache(ignoreParentClass?: boolean): void;
  15402. /**
  15403. * @hidden
  15404. * Get current device position in babylon world
  15405. */
  15406. _computeDevicePosition(): void;
  15407. /**
  15408. * Updates the current device position and rotation in the babylon world
  15409. */
  15410. update(): void;
  15411. /**
  15412. * @hidden
  15413. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15414. * @returns an identity matrix
  15415. */
  15416. _getViewMatrix(): Matrix;
  15417. private _tmpMatrix;
  15418. /**
  15419. * This function is called by the two RIG cameras.
  15420. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15421. * @hidden
  15422. */
  15423. _getWebVRViewMatrix(): Matrix;
  15424. /** @hidden */
  15425. _getWebVRProjectionMatrix(): Matrix;
  15426. private _onGamepadConnectedObserver;
  15427. private _onGamepadDisconnectedObserver;
  15428. private _updateCacheWhenTrackingDisabledObserver;
  15429. /**
  15430. * Initializes the controllers and their meshes
  15431. */
  15432. initControllers(): void;
  15433. }
  15434. }
  15435. declare module "babylonjs/PostProcesses/postProcess" {
  15436. import { Nullable } from "babylonjs/types";
  15437. import { SmartArray } from "babylonjs/Misc/smartArray";
  15438. import { Observable } from "babylonjs/Misc/observable";
  15439. import { Vector2 } from "babylonjs/Maths/math.vector";
  15440. import { Camera } from "babylonjs/Cameras/camera";
  15441. import { Effect } from "babylonjs/Materials/effect";
  15442. import "babylonjs/Shaders/postprocess.vertex";
  15443. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15444. import { Engine } from "babylonjs/Engines/engine";
  15445. import { Color4 } from "babylonjs/Maths/math.color";
  15446. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15448. /**
  15449. * Size options for a post process
  15450. */
  15451. export type PostProcessOptions = {
  15452. width: number;
  15453. height: number;
  15454. };
  15455. /**
  15456. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15457. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15458. */
  15459. export class PostProcess {
  15460. /** Name of the PostProcess. */
  15461. name: string;
  15462. /**
  15463. * Gets or sets the unique id of the post process
  15464. */
  15465. uniqueId: number;
  15466. /**
  15467. * Width of the texture to apply the post process on
  15468. */
  15469. width: number;
  15470. /**
  15471. * Height of the texture to apply the post process on
  15472. */
  15473. height: number;
  15474. /**
  15475. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15476. * @hidden
  15477. */
  15478. _outputTexture: Nullable<InternalTexture>;
  15479. /**
  15480. * Sampling mode used by the shader
  15481. * See https://doc.babylonjs.com/classes/3.1/texture
  15482. */
  15483. renderTargetSamplingMode: number;
  15484. /**
  15485. * Clear color to use when screen clearing
  15486. */
  15487. clearColor: Color4;
  15488. /**
  15489. * If the buffer needs to be cleared before applying the post process. (default: true)
  15490. * Should be set to false if shader will overwrite all previous pixels.
  15491. */
  15492. autoClear: boolean;
  15493. /**
  15494. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15495. */
  15496. alphaMode: number;
  15497. /**
  15498. * Sets the setAlphaBlendConstants of the babylon engine
  15499. */
  15500. alphaConstants: Color4;
  15501. /**
  15502. * Animations to be used for the post processing
  15503. */
  15504. animations: import("babylonjs/Animations/animation").Animation[];
  15505. /**
  15506. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15507. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15508. */
  15509. enablePixelPerfectMode: boolean;
  15510. /**
  15511. * Force the postprocess to be applied without taking in account viewport
  15512. */
  15513. forceFullscreenViewport: boolean;
  15514. /**
  15515. * List of inspectable custom properties (used by the Inspector)
  15516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15517. */
  15518. inspectableCustomProperties: IInspectable[];
  15519. /**
  15520. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15521. *
  15522. * | Value | Type | Description |
  15523. * | ----- | ----------------------------------- | ----------- |
  15524. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15525. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15526. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15527. *
  15528. */
  15529. scaleMode: number;
  15530. /**
  15531. * Force textures to be a power of two (default: false)
  15532. */
  15533. alwaysForcePOT: boolean;
  15534. private _samples;
  15535. /**
  15536. * Number of sample textures (default: 1)
  15537. */
  15538. samples: number;
  15539. /**
  15540. * Modify the scale of the post process to be the same as the viewport (default: false)
  15541. */
  15542. adaptScaleToCurrentViewport: boolean;
  15543. private _camera;
  15544. private _scene;
  15545. private _engine;
  15546. private _options;
  15547. private _reusable;
  15548. private _textureType;
  15549. /**
  15550. * Smart array of input and output textures for the post process.
  15551. * @hidden
  15552. */
  15553. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15554. /**
  15555. * The index in _textures that corresponds to the output texture.
  15556. * @hidden
  15557. */
  15558. _currentRenderTextureInd: number;
  15559. private _effect;
  15560. private _samplers;
  15561. private _fragmentUrl;
  15562. private _vertexUrl;
  15563. private _parameters;
  15564. private _scaleRatio;
  15565. protected _indexParameters: any;
  15566. private _shareOutputWithPostProcess;
  15567. private _texelSize;
  15568. private _forcedOutputTexture;
  15569. /**
  15570. * Returns the fragment url or shader name used in the post process.
  15571. * @returns the fragment url or name in the shader store.
  15572. */
  15573. getEffectName(): string;
  15574. /**
  15575. * An event triggered when the postprocess is activated.
  15576. */
  15577. onActivateObservable: Observable<Camera>;
  15578. private _onActivateObserver;
  15579. /**
  15580. * A function that is added to the onActivateObservable
  15581. */
  15582. onActivate: Nullable<(camera: Camera) => void>;
  15583. /**
  15584. * An event triggered when the postprocess changes its size.
  15585. */
  15586. onSizeChangedObservable: Observable<PostProcess>;
  15587. private _onSizeChangedObserver;
  15588. /**
  15589. * A function that is added to the onSizeChangedObservable
  15590. */
  15591. onSizeChanged: (postProcess: PostProcess) => void;
  15592. /**
  15593. * An event triggered when the postprocess applies its effect.
  15594. */
  15595. onApplyObservable: Observable<Effect>;
  15596. private _onApplyObserver;
  15597. /**
  15598. * A function that is added to the onApplyObservable
  15599. */
  15600. onApply: (effect: Effect) => void;
  15601. /**
  15602. * An event triggered before rendering the postprocess
  15603. */
  15604. onBeforeRenderObservable: Observable<Effect>;
  15605. private _onBeforeRenderObserver;
  15606. /**
  15607. * A function that is added to the onBeforeRenderObservable
  15608. */
  15609. onBeforeRender: (effect: Effect) => void;
  15610. /**
  15611. * An event triggered after rendering the postprocess
  15612. */
  15613. onAfterRenderObservable: Observable<Effect>;
  15614. private _onAfterRenderObserver;
  15615. /**
  15616. * A function that is added to the onAfterRenderObservable
  15617. */
  15618. onAfterRender: (efect: Effect) => void;
  15619. /**
  15620. * 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
  15621. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15622. */
  15623. inputTexture: InternalTexture;
  15624. /**
  15625. * Gets the camera which post process is applied to.
  15626. * @returns The camera the post process is applied to.
  15627. */
  15628. getCamera(): Camera;
  15629. /**
  15630. * Gets the texel size of the postprocess.
  15631. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15632. */
  15633. readonly texelSize: Vector2;
  15634. /**
  15635. * Creates a new instance PostProcess
  15636. * @param name The name of the PostProcess.
  15637. * @param fragmentUrl The url of the fragment shader to be used.
  15638. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15639. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15640. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15641. * @param camera The camera to apply the render pass to.
  15642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15643. * @param engine The engine which the post process will be applied. (default: current engine)
  15644. * @param reusable If the post process can be reused on the same frame. (default: false)
  15645. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15646. * @param textureType Type of textures used when performing the post process. (default: 0)
  15647. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15648. * @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
  15649. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15650. */
  15651. constructor(
  15652. /** Name of the PostProcess. */
  15653. 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);
  15654. /**
  15655. * Gets a string idenfifying the name of the class
  15656. * @returns "PostProcess" string
  15657. */
  15658. getClassName(): string;
  15659. /**
  15660. * Gets the engine which this post process belongs to.
  15661. * @returns The engine the post process was enabled with.
  15662. */
  15663. getEngine(): Engine;
  15664. /**
  15665. * The effect that is created when initializing the post process.
  15666. * @returns The created effect corresponding the the postprocess.
  15667. */
  15668. getEffect(): Effect;
  15669. /**
  15670. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15671. * @param postProcess The post process to share the output with.
  15672. * @returns This post process.
  15673. */
  15674. shareOutputWith(postProcess: PostProcess): PostProcess;
  15675. /**
  15676. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15677. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15678. */
  15679. useOwnOutput(): void;
  15680. /**
  15681. * Updates the effect with the current post process compile time values and recompiles the shader.
  15682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15685. * @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
  15686. * @param onCompiled Called when the shader has been compiled.
  15687. * @param onError Called if there is an error when compiling a shader.
  15688. */
  15689. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15690. /**
  15691. * The post process is reusable if it can be used multiple times within one frame.
  15692. * @returns If the post process is reusable
  15693. */
  15694. isReusable(): boolean;
  15695. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15696. markTextureDirty(): void;
  15697. /**
  15698. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15699. * 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.
  15700. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15701. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15702. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15703. * @returns The target texture that was bound to be written to.
  15704. */
  15705. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15706. /**
  15707. * If the post process is supported.
  15708. */
  15709. readonly isSupported: boolean;
  15710. /**
  15711. * The aspect ratio of the output texture.
  15712. */
  15713. readonly aspectRatio: number;
  15714. /**
  15715. * Get a value indicating if the post-process is ready to be used
  15716. * @returns true if the post-process is ready (shader is compiled)
  15717. */
  15718. isReady(): boolean;
  15719. /**
  15720. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15721. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15722. */
  15723. apply(): Nullable<Effect>;
  15724. private _disposeTextures;
  15725. /**
  15726. * Disposes the post process.
  15727. * @param camera The camera to dispose the post process on.
  15728. */
  15729. dispose(camera?: Camera): void;
  15730. }
  15731. }
  15732. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15733. /** @hidden */
  15734. export var kernelBlurVaryingDeclaration: {
  15735. name: string;
  15736. shader: string;
  15737. };
  15738. }
  15739. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15740. /** @hidden */
  15741. export var kernelBlurFragment: {
  15742. name: string;
  15743. shader: string;
  15744. };
  15745. }
  15746. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15747. /** @hidden */
  15748. export var kernelBlurFragment2: {
  15749. name: string;
  15750. shader: string;
  15751. };
  15752. }
  15753. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15754. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15755. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15756. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15757. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15758. /** @hidden */
  15759. export var kernelBlurPixelShader: {
  15760. name: string;
  15761. shader: string;
  15762. };
  15763. }
  15764. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15765. /** @hidden */
  15766. export var kernelBlurVertex: {
  15767. name: string;
  15768. shader: string;
  15769. };
  15770. }
  15771. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15772. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15773. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15774. /** @hidden */
  15775. export var kernelBlurVertexShader: {
  15776. name: string;
  15777. shader: string;
  15778. };
  15779. }
  15780. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15781. import { Vector2 } from "babylonjs/Maths/math.vector";
  15782. import { Nullable } from "babylonjs/types";
  15783. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15784. import { Camera } from "babylonjs/Cameras/camera";
  15785. import { Effect } from "babylonjs/Materials/effect";
  15786. import { Engine } from "babylonjs/Engines/engine";
  15787. import "babylonjs/Shaders/kernelBlur.fragment";
  15788. import "babylonjs/Shaders/kernelBlur.vertex";
  15789. /**
  15790. * The Blur Post Process which blurs an image based on a kernel and direction.
  15791. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15792. */
  15793. export class BlurPostProcess extends PostProcess {
  15794. /** The direction in which to blur the image. */
  15795. direction: Vector2;
  15796. private blockCompilation;
  15797. protected _kernel: number;
  15798. protected _idealKernel: number;
  15799. protected _packedFloat: boolean;
  15800. private _staticDefines;
  15801. /**
  15802. * Sets the length in pixels of the blur sample region
  15803. */
  15804. /**
  15805. * Gets the length in pixels of the blur sample region
  15806. */
  15807. kernel: number;
  15808. /**
  15809. * Sets wether or not the blur needs to unpack/repack floats
  15810. */
  15811. /**
  15812. * Gets wether or not the blur is unpacking/repacking floats
  15813. */
  15814. packedFloat: boolean;
  15815. /**
  15816. * Creates a new instance BlurPostProcess
  15817. * @param name The name of the effect.
  15818. * @param direction The direction in which to blur the image.
  15819. * @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.
  15820. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15821. * @param camera The camera to apply the render pass to.
  15822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15823. * @param engine The engine which the post process will be applied. (default: current engine)
  15824. * @param reusable If the post process can be reused on the same frame. (default: false)
  15825. * @param textureType Type of textures used when performing the post process. (default: 0)
  15826. * @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)
  15827. */
  15828. constructor(name: string,
  15829. /** The direction in which to blur the image. */
  15830. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15831. /**
  15832. * Updates the effect with the current post process compile time values and recompiles the shader.
  15833. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15834. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15835. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15836. * @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
  15837. * @param onCompiled Called when the shader has been compiled.
  15838. * @param onError Called if there is an error when compiling a shader.
  15839. */
  15840. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15841. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15842. /**
  15843. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15844. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15845. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15846. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15847. * The gaps between physical kernels are compensated for in the weighting of the samples
  15848. * @param idealKernel Ideal blur kernel.
  15849. * @return Nearest best kernel.
  15850. */
  15851. protected _nearestBestKernel(idealKernel: number): number;
  15852. /**
  15853. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15854. * @param x The point on the Gaussian distribution to sample.
  15855. * @return the value of the Gaussian function at x.
  15856. */
  15857. protected _gaussianWeight(x: number): number;
  15858. /**
  15859. * Generates a string that can be used as a floating point number in GLSL.
  15860. * @param x Value to print.
  15861. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15862. * @return GLSL float string.
  15863. */
  15864. protected _glslFloat(x: number, decimalFigures?: number): string;
  15865. }
  15866. }
  15867. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15868. import { Scene } from "babylonjs/scene";
  15869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15870. import { Plane } from "babylonjs/Maths/math.plane";
  15871. /**
  15872. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15873. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15874. * You can then easily use it as a reflectionTexture on a flat surface.
  15875. * In case the surface is not a plane, please consider relying on reflection probes.
  15876. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15877. */
  15878. export class MirrorTexture extends RenderTargetTexture {
  15879. private scene;
  15880. /**
  15881. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15882. * 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.
  15883. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15884. */
  15885. mirrorPlane: Plane;
  15886. /**
  15887. * Define the blur ratio used to blur the reflection if needed.
  15888. */
  15889. blurRatio: number;
  15890. /**
  15891. * Define the adaptive blur kernel used to blur the reflection if needed.
  15892. * This will autocompute the closest best match for the `blurKernel`
  15893. */
  15894. adaptiveBlurKernel: number;
  15895. /**
  15896. * Define the blur kernel used to blur the reflection if needed.
  15897. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15898. */
  15899. blurKernel: number;
  15900. /**
  15901. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15902. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15903. */
  15904. blurKernelX: number;
  15905. /**
  15906. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15907. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15908. */
  15909. blurKernelY: number;
  15910. private _autoComputeBlurKernel;
  15911. protected _onRatioRescale(): void;
  15912. private _updateGammaSpace;
  15913. private _imageProcessingConfigChangeObserver;
  15914. private _transformMatrix;
  15915. private _mirrorMatrix;
  15916. private _savedViewMatrix;
  15917. private _blurX;
  15918. private _blurY;
  15919. private _adaptiveBlurKernel;
  15920. private _blurKernelX;
  15921. private _blurKernelY;
  15922. private _blurRatio;
  15923. /**
  15924. * Instantiates a Mirror Texture.
  15925. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15926. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15927. * You can then easily use it as a reflectionTexture on a flat surface.
  15928. * In case the surface is not a plane, please consider relying on reflection probes.
  15929. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15930. * @param name
  15931. * @param size
  15932. * @param scene
  15933. * @param generateMipMaps
  15934. * @param type
  15935. * @param samplingMode
  15936. * @param generateDepthBuffer
  15937. */
  15938. constructor(name: string, size: number | {
  15939. width: number;
  15940. height: number;
  15941. } | {
  15942. ratio: number;
  15943. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15944. private _preparePostProcesses;
  15945. /**
  15946. * Clone the mirror texture.
  15947. * @returns the cloned texture
  15948. */
  15949. clone(): MirrorTexture;
  15950. /**
  15951. * Serialize the texture to a JSON representation you could use in Parse later on
  15952. * @returns the serialized JSON representation
  15953. */
  15954. serialize(): any;
  15955. /**
  15956. * Dispose the texture and release its associated resources.
  15957. */
  15958. dispose(): void;
  15959. }
  15960. }
  15961. declare module "babylonjs/Materials/Textures/texture" {
  15962. import { Observable } from "babylonjs/Misc/observable";
  15963. import { Nullable } from "babylonjs/types";
  15964. import { Matrix } from "babylonjs/Maths/math.vector";
  15965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15966. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15967. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15968. import { Scene } from "babylonjs/scene";
  15969. /**
  15970. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15971. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15972. */
  15973. export class Texture extends BaseTexture {
  15974. /**
  15975. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15976. */
  15977. static SerializeBuffers: boolean;
  15978. /** @hidden */
  15979. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15980. /** @hidden */
  15981. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15982. /** @hidden */
  15983. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15984. /** nearest is mag = nearest and min = nearest and mip = linear */
  15985. static readonly NEAREST_SAMPLINGMODE: number;
  15986. /** nearest is mag = nearest and min = nearest and mip = linear */
  15987. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15988. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15989. static readonly BILINEAR_SAMPLINGMODE: number;
  15990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15991. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15992. /** Trilinear is mag = linear and min = linear and mip = linear */
  15993. static readonly TRILINEAR_SAMPLINGMODE: number;
  15994. /** Trilinear is mag = linear and min = linear and mip = linear */
  15995. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15996. /** mag = nearest and min = nearest and mip = nearest */
  15997. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15998. /** mag = nearest and min = linear and mip = nearest */
  15999. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16000. /** mag = nearest and min = linear and mip = linear */
  16001. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16002. /** mag = nearest and min = linear and mip = none */
  16003. static readonly NEAREST_LINEAR: number;
  16004. /** mag = nearest and min = nearest and mip = none */
  16005. static readonly NEAREST_NEAREST: number;
  16006. /** mag = linear and min = nearest and mip = nearest */
  16007. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16008. /** mag = linear and min = nearest and mip = linear */
  16009. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16010. /** mag = linear and min = linear and mip = none */
  16011. static readonly LINEAR_LINEAR: number;
  16012. /** mag = linear and min = nearest and mip = none */
  16013. static readonly LINEAR_NEAREST: number;
  16014. /** Explicit coordinates mode */
  16015. static readonly EXPLICIT_MODE: number;
  16016. /** Spherical coordinates mode */
  16017. static readonly SPHERICAL_MODE: number;
  16018. /** Planar coordinates mode */
  16019. static readonly PLANAR_MODE: number;
  16020. /** Cubic coordinates mode */
  16021. static readonly CUBIC_MODE: number;
  16022. /** Projection coordinates mode */
  16023. static readonly PROJECTION_MODE: number;
  16024. /** Inverse Cubic coordinates mode */
  16025. static readonly SKYBOX_MODE: number;
  16026. /** Inverse Cubic coordinates mode */
  16027. static readonly INVCUBIC_MODE: number;
  16028. /** Equirectangular coordinates mode */
  16029. static readonly EQUIRECTANGULAR_MODE: number;
  16030. /** Equirectangular Fixed coordinates mode */
  16031. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16032. /** Equirectangular Fixed Mirrored coordinates mode */
  16033. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16034. /** Texture is not repeating outside of 0..1 UVs */
  16035. static readonly CLAMP_ADDRESSMODE: number;
  16036. /** Texture is repeating outside of 0..1 UVs */
  16037. static readonly WRAP_ADDRESSMODE: number;
  16038. /** Texture is repeating and mirrored */
  16039. static readonly MIRROR_ADDRESSMODE: number;
  16040. /**
  16041. * 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
  16042. */
  16043. static UseSerializedUrlIfAny: boolean;
  16044. /**
  16045. * Define the url of the texture.
  16046. */
  16047. url: Nullable<string>;
  16048. /**
  16049. * Define an offset on the texture to offset the u coordinates of the UVs
  16050. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16051. */
  16052. uOffset: number;
  16053. /**
  16054. * Define an offset on the texture to offset the v coordinates of the UVs
  16055. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16056. */
  16057. vOffset: number;
  16058. /**
  16059. * Define an offset on the texture to scale the u coordinates of the UVs
  16060. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16061. */
  16062. uScale: number;
  16063. /**
  16064. * Define an offset on the texture to scale the v coordinates of the UVs
  16065. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16066. */
  16067. vScale: number;
  16068. /**
  16069. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16070. * @see http://doc.babylonjs.com/how_to/more_materials
  16071. */
  16072. uAng: number;
  16073. /**
  16074. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16075. * @see http://doc.babylonjs.com/how_to/more_materials
  16076. */
  16077. vAng: number;
  16078. /**
  16079. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16080. * @see http://doc.babylonjs.com/how_to/more_materials
  16081. */
  16082. wAng: number;
  16083. /**
  16084. * Defines the center of rotation (U)
  16085. */
  16086. uRotationCenter: number;
  16087. /**
  16088. * Defines the center of rotation (V)
  16089. */
  16090. vRotationCenter: number;
  16091. /**
  16092. * Defines the center of rotation (W)
  16093. */
  16094. wRotationCenter: number;
  16095. /**
  16096. * Are mip maps generated for this texture or not.
  16097. */
  16098. readonly noMipmap: boolean;
  16099. /**
  16100. * List of inspectable custom properties (used by the Inspector)
  16101. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16102. */
  16103. inspectableCustomProperties: Nullable<IInspectable[]>;
  16104. private _noMipmap;
  16105. /** @hidden */
  16106. _invertY: boolean;
  16107. private _rowGenerationMatrix;
  16108. private _cachedTextureMatrix;
  16109. private _projectionModeMatrix;
  16110. private _t0;
  16111. private _t1;
  16112. private _t2;
  16113. private _cachedUOffset;
  16114. private _cachedVOffset;
  16115. private _cachedUScale;
  16116. private _cachedVScale;
  16117. private _cachedUAng;
  16118. private _cachedVAng;
  16119. private _cachedWAng;
  16120. private _cachedProjectionMatrixId;
  16121. private _cachedCoordinatesMode;
  16122. /** @hidden */
  16123. protected _initialSamplingMode: number;
  16124. /** @hidden */
  16125. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16126. private _deleteBuffer;
  16127. protected _format: Nullable<number>;
  16128. private _delayedOnLoad;
  16129. private _delayedOnError;
  16130. /**
  16131. * Observable triggered once the texture has been loaded.
  16132. */
  16133. onLoadObservable: Observable<Texture>;
  16134. protected _isBlocking: boolean;
  16135. /**
  16136. * Is the texture preventing material to render while loading.
  16137. * If false, a default texture will be used instead of the loading one during the preparation step.
  16138. */
  16139. isBlocking: boolean;
  16140. /**
  16141. * Get the current sampling mode associated with the texture.
  16142. */
  16143. readonly samplingMode: number;
  16144. /**
  16145. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16146. */
  16147. readonly invertY: boolean;
  16148. /**
  16149. * Instantiates a new texture.
  16150. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16151. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16152. * @param url define the url of the picture to load as a texture
  16153. * @param scene define the scene or engine the texture will belong to
  16154. * @param noMipmap define if the texture will require mip maps or not
  16155. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16156. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16157. * @param onLoad define a callback triggered when the texture has been loaded
  16158. * @param onError define a callback triggered when an error occurred during the loading session
  16159. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16160. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16161. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16162. */
  16163. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16164. /**
  16165. * Update the url (and optional buffer) of this texture if url was null during construction.
  16166. * @param url the url of the texture
  16167. * @param buffer the buffer of the texture (defaults to null)
  16168. * @param onLoad callback called when the texture is loaded (defaults to null)
  16169. */
  16170. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16171. /**
  16172. * Finish the loading sequence of a texture flagged as delayed load.
  16173. * @hidden
  16174. */
  16175. delayLoad(): void;
  16176. private _prepareRowForTextureGeneration;
  16177. /**
  16178. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16179. * @returns the transform matrix of the texture.
  16180. */
  16181. getTextureMatrix(): Matrix;
  16182. /**
  16183. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16184. * @returns The reflection texture transform
  16185. */
  16186. getReflectionTextureMatrix(): Matrix;
  16187. /**
  16188. * Clones the texture.
  16189. * @returns the cloned texture
  16190. */
  16191. clone(): Texture;
  16192. /**
  16193. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16194. * @returns The JSON representation of the texture
  16195. */
  16196. serialize(): any;
  16197. /**
  16198. * Get the current class name of the texture useful for serialization or dynamic coding.
  16199. * @returns "Texture"
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Dispose the texture and release its associated resources.
  16204. */
  16205. dispose(): void;
  16206. /**
  16207. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16208. * @param parsedTexture Define the JSON representation of the texture
  16209. * @param scene Define the scene the parsed texture should be instantiated in
  16210. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16211. * @returns The parsed texture if successful
  16212. */
  16213. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16214. /**
  16215. * Creates a texture from its base 64 representation.
  16216. * @param data Define the base64 payload without the data: prefix
  16217. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16218. * @param scene Define the scene the texture should belong to
  16219. * @param noMipmap Forces the texture to not create mip map information if true
  16220. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16221. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16222. * @param onLoad define a callback triggered when the texture has been loaded
  16223. * @param onError define a callback triggered when an error occurred during the loading session
  16224. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16225. * @returns the created texture
  16226. */
  16227. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16228. /**
  16229. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16230. * @param data Define the base64 payload without the data: prefix
  16231. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16232. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16233. * @param scene Define the scene the texture should belong to
  16234. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16235. * @param noMipmap Forces the texture to not create mip map information if true
  16236. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16237. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16238. * @param onLoad define a callback triggered when the texture has been loaded
  16239. * @param onError define a callback triggered when an error occurred during the loading session
  16240. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16241. * @returns the created texture
  16242. */
  16243. 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;
  16244. }
  16245. }
  16246. declare module "babylonjs/PostProcesses/postProcessManager" {
  16247. import { Nullable } from "babylonjs/types";
  16248. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16250. import { Scene } from "babylonjs/scene";
  16251. /**
  16252. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16253. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16254. */
  16255. export class PostProcessManager {
  16256. private _scene;
  16257. private _indexBuffer;
  16258. private _vertexBuffers;
  16259. /**
  16260. * Creates a new instance PostProcess
  16261. * @param scene The scene that the post process is associated with.
  16262. */
  16263. constructor(scene: Scene);
  16264. private _prepareBuffers;
  16265. private _buildIndexBuffer;
  16266. /**
  16267. * Rebuilds the vertex buffers of the manager.
  16268. * @hidden
  16269. */
  16270. _rebuild(): void;
  16271. /**
  16272. * Prepares a frame to be run through a post process.
  16273. * @param sourceTexture The input texture to the post procesess. (default: null)
  16274. * @param postProcesses An array of post processes to be run. (default: null)
  16275. * @returns True if the post processes were able to be run.
  16276. * @hidden
  16277. */
  16278. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16279. /**
  16280. * Manually render a set of post processes to a texture.
  16281. * @param postProcesses An array of post processes to be run.
  16282. * @param targetTexture The target texture to render to.
  16283. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16284. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16285. * @param lodLevel defines which lod of the texture to render to
  16286. */
  16287. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16288. /**
  16289. * Finalize the result of the output of the postprocesses.
  16290. * @param doNotPresent If true the result will not be displayed to the screen.
  16291. * @param targetTexture The target texture to render to.
  16292. * @param faceIndex The index of the face to bind the target texture to.
  16293. * @param postProcesses The array of post processes to render.
  16294. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16295. * @hidden
  16296. */
  16297. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16298. /**
  16299. * Disposes of the post process manager.
  16300. */
  16301. dispose(): void;
  16302. }
  16303. }
  16304. declare module "babylonjs/Misc/gradients" {
  16305. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16306. /** Interface used by value gradients (color, factor, ...) */
  16307. export interface IValueGradient {
  16308. /**
  16309. * Gets or sets the gradient value (between 0 and 1)
  16310. */
  16311. gradient: number;
  16312. }
  16313. /** Class used to store color4 gradient */
  16314. export class ColorGradient implements IValueGradient {
  16315. /**
  16316. * Gets or sets the gradient value (between 0 and 1)
  16317. */
  16318. gradient: number;
  16319. /**
  16320. * Gets or sets first associated color
  16321. */
  16322. color1: Color4;
  16323. /**
  16324. * Gets or sets second associated color
  16325. */
  16326. color2?: Color4;
  16327. /**
  16328. * Will get a color picked randomly between color1 and color2.
  16329. * If color2 is undefined then color1 will be used
  16330. * @param result defines the target Color4 to store the result in
  16331. */
  16332. getColorToRef(result: Color4): void;
  16333. }
  16334. /** Class used to store color 3 gradient */
  16335. export class Color3Gradient implements IValueGradient {
  16336. /**
  16337. * Gets or sets the gradient value (between 0 and 1)
  16338. */
  16339. gradient: number;
  16340. /**
  16341. * Gets or sets the associated color
  16342. */
  16343. color: Color3;
  16344. }
  16345. /** Class used to store factor gradient */
  16346. export class FactorGradient implements IValueGradient {
  16347. /**
  16348. * Gets or sets the gradient value (between 0 and 1)
  16349. */
  16350. gradient: number;
  16351. /**
  16352. * Gets or sets first associated factor
  16353. */
  16354. factor1: number;
  16355. /**
  16356. * Gets or sets second associated factor
  16357. */
  16358. factor2?: number;
  16359. /**
  16360. * Will get a number picked randomly between factor1 and factor2.
  16361. * If factor2 is undefined then factor1 will be used
  16362. * @returns the picked number
  16363. */
  16364. getFactor(): number;
  16365. }
  16366. /**
  16367. * Helper used to simplify some generic gradient tasks
  16368. */
  16369. export class GradientHelper {
  16370. /**
  16371. * Gets the current gradient from an array of IValueGradient
  16372. * @param ratio defines the current ratio to get
  16373. * @param gradients defines the array of IValueGradient
  16374. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16375. */
  16376. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16377. }
  16378. }
  16379. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16381. import { Nullable } from "babylonjs/types";
  16382. module "babylonjs/Engines/thinEngine" {
  16383. interface ThinEngine {
  16384. /**
  16385. * Creates a dynamic texture
  16386. * @param width defines the width of the texture
  16387. * @param height defines the height of the texture
  16388. * @param generateMipMaps defines if the engine should generate the mip levels
  16389. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16390. * @returns the dynamic texture inside an InternalTexture
  16391. */
  16392. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16393. /**
  16394. * Update the content of a dynamic texture
  16395. * @param texture defines the texture to update
  16396. * @param canvas defines the canvas containing the source
  16397. * @param invertY defines if data must be stored with Y axis inverted
  16398. * @param premulAlpha defines if alpha is stored as premultiplied
  16399. * @param format defines the format of the data
  16400. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16401. */
  16402. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16403. }
  16404. }
  16405. }
  16406. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16407. import { Scene } from "babylonjs/scene";
  16408. import { Texture } from "babylonjs/Materials/Textures/texture";
  16409. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16410. /**
  16411. * A class extending Texture allowing drawing on a texture
  16412. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16413. */
  16414. export class DynamicTexture extends Texture {
  16415. private _generateMipMaps;
  16416. private _canvas;
  16417. private _context;
  16418. private _engine;
  16419. /**
  16420. * Creates a DynamicTexture
  16421. * @param name defines the name of the texture
  16422. * @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
  16423. * @param scene defines the scene where you want the texture
  16424. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16425. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16426. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16427. */
  16428. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16429. /**
  16430. * Get the current class name of the texture useful for serialization or dynamic coding.
  16431. * @returns "DynamicTexture"
  16432. */
  16433. getClassName(): string;
  16434. /**
  16435. * Gets the current state of canRescale
  16436. */
  16437. readonly canRescale: boolean;
  16438. private _recreate;
  16439. /**
  16440. * Scales the texture
  16441. * @param ratio the scale factor to apply to both width and height
  16442. */
  16443. scale(ratio: number): void;
  16444. /**
  16445. * Resizes the texture
  16446. * @param width the new width
  16447. * @param height the new height
  16448. */
  16449. scaleTo(width: number, height: number): void;
  16450. /**
  16451. * Gets the context of the canvas used by the texture
  16452. * @returns the canvas context of the dynamic texture
  16453. */
  16454. getContext(): CanvasRenderingContext2D;
  16455. /**
  16456. * Clears the texture
  16457. */
  16458. clear(): void;
  16459. /**
  16460. * Updates the texture
  16461. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16462. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16463. */
  16464. update(invertY?: boolean, premulAlpha?: boolean): void;
  16465. /**
  16466. * Draws text onto the texture
  16467. * @param text defines the text to be drawn
  16468. * @param x defines the placement of the text from the left
  16469. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16470. * @param font defines the font to be used with font-style, font-size, font-name
  16471. * @param color defines the color used for the text
  16472. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16473. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16474. * @param update defines whether texture is immediately update (default is true)
  16475. */
  16476. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16477. /**
  16478. * Clones the texture
  16479. * @returns the clone of the texture.
  16480. */
  16481. clone(): DynamicTexture;
  16482. /**
  16483. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16484. * @returns a serialized dynamic texture object
  16485. */
  16486. serialize(): any;
  16487. /** @hidden */
  16488. _rebuild(): void;
  16489. }
  16490. }
  16491. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16492. import { Scene } from "babylonjs/scene";
  16493. import { ISceneComponent } from "babylonjs/sceneComponent";
  16494. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16495. module "babylonjs/abstractScene" {
  16496. interface AbstractScene {
  16497. /**
  16498. * The list of procedural textures added to the scene
  16499. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16500. */
  16501. proceduralTextures: Array<ProceduralTexture>;
  16502. }
  16503. }
  16504. /**
  16505. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16506. * in a given scene.
  16507. */
  16508. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16509. /**
  16510. * The component name helpfull to identify the component in the list of scene components.
  16511. */
  16512. readonly name: string;
  16513. /**
  16514. * The scene the component belongs to.
  16515. */
  16516. scene: Scene;
  16517. /**
  16518. * Creates a new instance of the component for the given scene
  16519. * @param scene Defines the scene to register the component in
  16520. */
  16521. constructor(scene: Scene);
  16522. /**
  16523. * Registers the component in a given scene
  16524. */
  16525. register(): void;
  16526. /**
  16527. * Rebuilds the elements related to this component in case of
  16528. * context lost for instance.
  16529. */
  16530. rebuild(): void;
  16531. /**
  16532. * Disposes the component and the associated ressources.
  16533. */
  16534. dispose(): void;
  16535. private _beforeClear;
  16536. }
  16537. }
  16538. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16539. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16540. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16541. module "babylonjs/Engines/thinEngine" {
  16542. interface ThinEngine {
  16543. /**
  16544. * Creates a new render target cube texture
  16545. * @param size defines the size of the texture
  16546. * @param options defines the options used to create the texture
  16547. * @returns a new render target cube texture stored in an InternalTexture
  16548. */
  16549. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16550. }
  16551. }
  16552. }
  16553. declare module "babylonjs/Shaders/procedural.vertex" {
  16554. /** @hidden */
  16555. export var proceduralVertexShader: {
  16556. name: string;
  16557. shader: string;
  16558. };
  16559. }
  16560. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16561. import { Observable } from "babylonjs/Misc/observable";
  16562. import { Nullable } from "babylonjs/types";
  16563. import { Scene } from "babylonjs/scene";
  16564. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16565. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16566. import { Effect } from "babylonjs/Materials/effect";
  16567. import { Texture } from "babylonjs/Materials/Textures/texture";
  16568. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16569. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16570. import "babylonjs/Shaders/procedural.vertex";
  16571. /**
  16572. * 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.
  16573. * This is the base class of any Procedural texture and contains most of the shareable code.
  16574. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16575. */
  16576. export class ProceduralTexture extends Texture {
  16577. isCube: boolean;
  16578. /**
  16579. * Define if the texture is enabled or not (disabled texture will not render)
  16580. */
  16581. isEnabled: boolean;
  16582. /**
  16583. * Define if the texture must be cleared before rendering (default is true)
  16584. */
  16585. autoClear: boolean;
  16586. /**
  16587. * Callback called when the texture is generated
  16588. */
  16589. onGenerated: () => void;
  16590. /**
  16591. * Event raised when the texture is generated
  16592. */
  16593. onGeneratedObservable: Observable<ProceduralTexture>;
  16594. /** @hidden */
  16595. _generateMipMaps: boolean;
  16596. /** @hidden **/
  16597. _effect: Effect;
  16598. /** @hidden */
  16599. _textures: {
  16600. [key: string]: Texture;
  16601. };
  16602. private _size;
  16603. private _currentRefreshId;
  16604. private _refreshRate;
  16605. private _vertexBuffers;
  16606. private _indexBuffer;
  16607. private _uniforms;
  16608. private _samplers;
  16609. private _fragment;
  16610. private _floats;
  16611. private _ints;
  16612. private _floatsArrays;
  16613. private _colors3;
  16614. private _colors4;
  16615. private _vectors2;
  16616. private _vectors3;
  16617. private _matrices;
  16618. private _fallbackTexture;
  16619. private _fallbackTextureUsed;
  16620. private _engine;
  16621. private _cachedDefines;
  16622. private _contentUpdateId;
  16623. private _contentData;
  16624. /**
  16625. * Instantiates a new procedural texture.
  16626. * 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.
  16627. * This is the base class of any Procedural texture and contains most of the shareable code.
  16628. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16629. * @param name Define the name of the texture
  16630. * @param size Define the size of the texture to create
  16631. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16632. * @param scene Define the scene the texture belongs to
  16633. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16634. * @param generateMipMaps Define if the texture should creates mip maps or not
  16635. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16636. */
  16637. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16638. /**
  16639. * The effect that is created when initializing the post process.
  16640. * @returns The created effect corresponding the the postprocess.
  16641. */
  16642. getEffect(): Effect;
  16643. /**
  16644. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16645. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16646. */
  16647. getContent(): Nullable<ArrayBufferView>;
  16648. private _createIndexBuffer;
  16649. /** @hidden */
  16650. _rebuild(): void;
  16651. /**
  16652. * Resets the texture in order to recreate its associated resources.
  16653. * This can be called in case of context loss
  16654. */
  16655. reset(): void;
  16656. protected _getDefines(): string;
  16657. /**
  16658. * Is the texture ready to be used ? (rendered at least once)
  16659. * @returns true if ready, otherwise, false.
  16660. */
  16661. isReady(): boolean;
  16662. /**
  16663. * Resets the refresh counter of the texture and start bak from scratch.
  16664. * Could be useful to regenerate the texture if it is setup to render only once.
  16665. */
  16666. resetRefreshCounter(): void;
  16667. /**
  16668. * Set the fragment shader to use in order to render the texture.
  16669. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16670. */
  16671. setFragment(fragment: any): void;
  16672. /**
  16673. * Define the refresh rate of the texture or the rendering frequency.
  16674. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16675. */
  16676. refreshRate: number;
  16677. /** @hidden */
  16678. _shouldRender(): boolean;
  16679. /**
  16680. * Get the size the texture is rendering at.
  16681. * @returns the size (texture is always squared)
  16682. */
  16683. getRenderSize(): number;
  16684. /**
  16685. * Resize the texture to new value.
  16686. * @param size Define the new size the texture should have
  16687. * @param generateMipMaps Define whether the new texture should create mip maps
  16688. */
  16689. resize(size: number, generateMipMaps: boolean): void;
  16690. private _checkUniform;
  16691. /**
  16692. * Set a texture in the shader program used to render.
  16693. * @param name Define the name of the uniform samplers as defined in the shader
  16694. * @param texture Define the texture to bind to this sampler
  16695. * @return the texture itself allowing "fluent" like uniform updates
  16696. */
  16697. setTexture(name: string, texture: Texture): ProceduralTexture;
  16698. /**
  16699. * Set a float in the shader.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the texture itself allowing "fluent" like uniform updates
  16703. */
  16704. setFloat(name: string, value: number): ProceduralTexture;
  16705. /**
  16706. * Set a int in the shader.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the texture itself allowing "fluent" like uniform updates
  16710. */
  16711. setInt(name: string, value: number): ProceduralTexture;
  16712. /**
  16713. * Set an array of floats in the shader.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the texture itself allowing "fluent" like uniform updates
  16717. */
  16718. setFloats(name: string, value: number[]): ProceduralTexture;
  16719. /**
  16720. * Set a vec3 in the shader from a Color3.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the texture itself allowing "fluent" like uniform updates
  16724. */
  16725. setColor3(name: string, value: Color3): ProceduralTexture;
  16726. /**
  16727. * Set a vec4 in the shader from a Color4.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the texture itself allowing "fluent" like uniform updates
  16731. */
  16732. setColor4(name: string, value: Color4): ProceduralTexture;
  16733. /**
  16734. * Set a vec2 in the shader from a Vector2.
  16735. * @param name Define the name of the uniform as defined in the shader
  16736. * @param value Define the value to give to the uniform
  16737. * @return the texture itself allowing "fluent" like uniform updates
  16738. */
  16739. setVector2(name: string, value: Vector2): ProceduralTexture;
  16740. /**
  16741. * Set a vec3 in the shader from a Vector3.
  16742. * @param name Define the name of the uniform as defined in the shader
  16743. * @param value Define the value to give to the uniform
  16744. * @return the texture itself allowing "fluent" like uniform updates
  16745. */
  16746. setVector3(name: string, value: Vector3): ProceduralTexture;
  16747. /**
  16748. * Set a mat4 in the shader from a MAtrix.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the texture itself allowing "fluent" like uniform updates
  16752. */
  16753. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16754. /**
  16755. * Render the texture to its associated render target.
  16756. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16757. */
  16758. render(useCameraPostProcess?: boolean): void;
  16759. /**
  16760. * Clone the texture.
  16761. * @returns the cloned texture
  16762. */
  16763. clone(): ProceduralTexture;
  16764. /**
  16765. * Dispose the texture and release its asoociated resources.
  16766. */
  16767. dispose(): void;
  16768. }
  16769. }
  16770. declare module "babylonjs/Particles/baseParticleSystem" {
  16771. import { Nullable } from "babylonjs/types";
  16772. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16774. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16775. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16776. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16777. import { Scene } from "babylonjs/scene";
  16778. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16779. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16780. import { Texture } from "babylonjs/Materials/Textures/texture";
  16781. import { Color4 } from "babylonjs/Maths/math.color";
  16782. import { Animation } from "babylonjs/Animations/animation";
  16783. /**
  16784. * This represents the base class for particle system in Babylon.
  16785. * 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.
  16786. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16787. * @example https://doc.babylonjs.com/babylon101/particles
  16788. */
  16789. export class BaseParticleSystem {
  16790. /**
  16791. * Source color is added to the destination color without alpha affecting the result
  16792. */
  16793. static BLENDMODE_ONEONE: number;
  16794. /**
  16795. * Blend current color and particle color using particle’s alpha
  16796. */
  16797. static BLENDMODE_STANDARD: number;
  16798. /**
  16799. * Add current color and particle color multiplied by particle’s alpha
  16800. */
  16801. static BLENDMODE_ADD: number;
  16802. /**
  16803. * Multiply current color with particle color
  16804. */
  16805. static BLENDMODE_MULTIPLY: number;
  16806. /**
  16807. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16808. */
  16809. static BLENDMODE_MULTIPLYADD: number;
  16810. /**
  16811. * List of animations used by the particle system.
  16812. */
  16813. animations: Animation[];
  16814. /**
  16815. * The id of the Particle system.
  16816. */
  16817. id: string;
  16818. /**
  16819. * The friendly name of the Particle system.
  16820. */
  16821. name: string;
  16822. /**
  16823. * The rendering group used by the Particle system to chose when to render.
  16824. */
  16825. renderingGroupId: number;
  16826. /**
  16827. * The emitter represents the Mesh or position we are attaching the particle system to.
  16828. */
  16829. emitter: Nullable<AbstractMesh | Vector3>;
  16830. /**
  16831. * The maximum number of particles to emit per frame
  16832. */
  16833. emitRate: number;
  16834. /**
  16835. * If you want to launch only a few particles at once, that can be done, as well.
  16836. */
  16837. manualEmitCount: number;
  16838. /**
  16839. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16840. */
  16841. updateSpeed: number;
  16842. /**
  16843. * The amount of time the particle system is running (depends of the overall update speed).
  16844. */
  16845. targetStopDuration: number;
  16846. /**
  16847. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16848. */
  16849. disposeOnStop: boolean;
  16850. /**
  16851. * Minimum power of emitting particles.
  16852. */
  16853. minEmitPower: number;
  16854. /**
  16855. * Maximum power of emitting particles.
  16856. */
  16857. maxEmitPower: number;
  16858. /**
  16859. * Minimum life time of emitting particles.
  16860. */
  16861. minLifeTime: number;
  16862. /**
  16863. * Maximum life time of emitting particles.
  16864. */
  16865. maxLifeTime: number;
  16866. /**
  16867. * Minimum Size of emitting particles.
  16868. */
  16869. minSize: number;
  16870. /**
  16871. * Maximum Size of emitting particles.
  16872. */
  16873. maxSize: number;
  16874. /**
  16875. * Minimum scale of emitting particles on X axis.
  16876. */
  16877. minScaleX: number;
  16878. /**
  16879. * Maximum scale of emitting particles on X axis.
  16880. */
  16881. maxScaleX: number;
  16882. /**
  16883. * Minimum scale of emitting particles on Y axis.
  16884. */
  16885. minScaleY: number;
  16886. /**
  16887. * Maximum scale of emitting particles on Y axis.
  16888. */
  16889. maxScaleY: number;
  16890. /**
  16891. * Gets or sets the minimal initial rotation in radians.
  16892. */
  16893. minInitialRotation: number;
  16894. /**
  16895. * Gets or sets the maximal initial rotation in radians.
  16896. */
  16897. maxInitialRotation: number;
  16898. /**
  16899. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16900. */
  16901. minAngularSpeed: number;
  16902. /**
  16903. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16904. */
  16905. maxAngularSpeed: number;
  16906. /**
  16907. * The texture used to render each particle. (this can be a spritesheet)
  16908. */
  16909. particleTexture: Nullable<Texture>;
  16910. /**
  16911. * The layer mask we are rendering the particles through.
  16912. */
  16913. layerMask: number;
  16914. /**
  16915. * This can help using your own shader to render the particle system.
  16916. * The according effect will be created
  16917. */
  16918. customShader: any;
  16919. /**
  16920. * By default particle system starts as soon as they are created. This prevents the
  16921. * automatic start to happen and let you decide when to start emitting particles.
  16922. */
  16923. preventAutoStart: boolean;
  16924. private _noiseTexture;
  16925. /**
  16926. * Gets or sets a texture used to add random noise to particle positions
  16927. */
  16928. noiseTexture: Nullable<ProceduralTexture>;
  16929. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16930. noiseStrength: Vector3;
  16931. /**
  16932. * Callback triggered when the particle animation is ending.
  16933. */
  16934. onAnimationEnd: Nullable<() => void>;
  16935. /**
  16936. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16937. */
  16938. blendMode: number;
  16939. /**
  16940. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16941. * to override the particles.
  16942. */
  16943. forceDepthWrite: boolean;
  16944. /** 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 */
  16945. preWarmCycles: number;
  16946. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16947. preWarmStepOffset: number;
  16948. /**
  16949. * 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)
  16950. */
  16951. spriteCellChangeSpeed: number;
  16952. /**
  16953. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16954. */
  16955. startSpriteCellID: number;
  16956. /**
  16957. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16958. */
  16959. endSpriteCellID: number;
  16960. /**
  16961. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16962. */
  16963. spriteCellWidth: number;
  16964. /**
  16965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16966. */
  16967. spriteCellHeight: number;
  16968. /**
  16969. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16970. */
  16971. spriteRandomStartCell: boolean;
  16972. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16973. translationPivot: Vector2;
  16974. /** @hidden */
  16975. protected _isAnimationSheetEnabled: boolean;
  16976. /**
  16977. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16978. */
  16979. beginAnimationOnStart: boolean;
  16980. /**
  16981. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16982. */
  16983. beginAnimationFrom: number;
  16984. /**
  16985. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16986. */
  16987. beginAnimationTo: number;
  16988. /**
  16989. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16990. */
  16991. beginAnimationLoop: boolean;
  16992. /**
  16993. * Gets or sets a world offset applied to all particles
  16994. */
  16995. worldOffset: Vector3;
  16996. /**
  16997. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16998. */
  16999. isAnimationSheetEnabled: boolean;
  17000. /**
  17001. * Get hosting scene
  17002. * @returns the scene
  17003. */
  17004. getScene(): Scene;
  17005. /**
  17006. * You can use gravity if you want to give an orientation to your particles.
  17007. */
  17008. gravity: Vector3;
  17009. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17010. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17011. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17012. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17013. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17014. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17015. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17016. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17017. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17018. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17019. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17020. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17021. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17022. /**
  17023. * Defines the delay in milliseconds before starting the system (0 by default)
  17024. */
  17025. startDelay: number;
  17026. /**
  17027. * Gets the current list of drag gradients.
  17028. * You must use addDragGradient and removeDragGradient to udpate this list
  17029. * @returns the list of drag gradients
  17030. */
  17031. getDragGradients(): Nullable<Array<FactorGradient>>;
  17032. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17033. limitVelocityDamping: number;
  17034. /**
  17035. * Gets the current list of limit velocity gradients.
  17036. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17037. * @returns the list of limit velocity gradients
  17038. */
  17039. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17040. /**
  17041. * Gets the current list of color gradients.
  17042. * You must use addColorGradient and removeColorGradient to udpate this list
  17043. * @returns the list of color gradients
  17044. */
  17045. getColorGradients(): Nullable<Array<ColorGradient>>;
  17046. /**
  17047. * Gets the current list of size gradients.
  17048. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17049. * @returns the list of size gradients
  17050. */
  17051. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17052. /**
  17053. * Gets the current list of color remap gradients.
  17054. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17055. * @returns the list of color remap gradients
  17056. */
  17057. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17058. /**
  17059. * Gets the current list of alpha remap gradients.
  17060. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17061. * @returns the list of alpha remap gradients
  17062. */
  17063. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17064. /**
  17065. * Gets the current list of life time gradients.
  17066. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17067. * @returns the list of life time gradients
  17068. */
  17069. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17070. /**
  17071. * Gets the current list of angular speed gradients.
  17072. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17073. * @returns the list of angular speed gradients
  17074. */
  17075. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17076. /**
  17077. * Gets the current list of velocity gradients.
  17078. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17079. * @returns the list of velocity gradients
  17080. */
  17081. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17082. /**
  17083. * Gets the current list of start size gradients.
  17084. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17085. * @returns the list of start size gradients
  17086. */
  17087. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17088. /**
  17089. * Gets the current list of emit rate gradients.
  17090. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17091. * @returns the list of emit rate gradients
  17092. */
  17093. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17094. /**
  17095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17096. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17097. */
  17098. direction1: Vector3;
  17099. /**
  17100. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17101. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17102. */
  17103. direction2: Vector3;
  17104. /**
  17105. * 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.
  17106. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17107. */
  17108. minEmitBox: Vector3;
  17109. /**
  17110. * 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.
  17111. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17112. */
  17113. maxEmitBox: Vector3;
  17114. /**
  17115. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17116. */
  17117. color1: Color4;
  17118. /**
  17119. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17120. */
  17121. color2: Color4;
  17122. /**
  17123. * Color the particle will have at the end of its lifetime
  17124. */
  17125. colorDead: Color4;
  17126. /**
  17127. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17128. */
  17129. textureMask: Color4;
  17130. /**
  17131. * The particle emitter type defines the emitter used by the particle system.
  17132. * It can be for example box, sphere, or cone...
  17133. */
  17134. particleEmitterType: IParticleEmitterType;
  17135. /** @hidden */
  17136. _isSubEmitter: boolean;
  17137. /**
  17138. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17139. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17140. */
  17141. billboardMode: number;
  17142. protected _isBillboardBased: boolean;
  17143. /**
  17144. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17145. */
  17146. isBillboardBased: boolean;
  17147. /**
  17148. * The scene the particle system belongs to.
  17149. */
  17150. protected _scene: Scene;
  17151. /**
  17152. * Local cache of defines for image processing.
  17153. */
  17154. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17155. /**
  17156. * Default configuration related to image processing available in the standard Material.
  17157. */
  17158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17159. /**
  17160. * Gets the image processing configuration used either in this material.
  17161. */
  17162. /**
  17163. * Sets the Default image processing configuration used either in the this material.
  17164. *
  17165. * If sets to null, the scene one is in use.
  17166. */
  17167. imageProcessingConfiguration: ImageProcessingConfiguration;
  17168. /**
  17169. * Attaches a new image processing configuration to the Standard Material.
  17170. * @param configuration
  17171. */
  17172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17173. /** @hidden */
  17174. protected _reset(): void;
  17175. /** @hidden */
  17176. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17177. /**
  17178. * Instantiates a particle system.
  17179. * 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.
  17180. * @param name The name of the particle system
  17181. */
  17182. constructor(name: string);
  17183. /**
  17184. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17187. * @returns the emitter
  17188. */
  17189. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17190. /**
  17191. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17192. * @param radius The radius of the hemisphere to emit from
  17193. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17194. * @returns the emitter
  17195. */
  17196. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17197. /**
  17198. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17199. * @param radius The radius of the sphere to emit from
  17200. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17201. * @returns the emitter
  17202. */
  17203. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17204. /**
  17205. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17206. * @param radius The radius of the sphere to emit from
  17207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17209. * @returns the emitter
  17210. */
  17211. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17212. /**
  17213. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17214. * @param radius The radius of the emission cylinder
  17215. * @param height The height of the emission cylinder
  17216. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17217. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17218. * @returns the emitter
  17219. */
  17220. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17221. /**
  17222. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17223. * @param radius The radius of the cylinder to emit from
  17224. * @param height The height of the emission cylinder
  17225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17228. * @returns the emitter
  17229. */
  17230. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17231. /**
  17232. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17233. * @param radius The radius of the cone to emit from
  17234. * @param angle The base angle of the cone
  17235. * @returns the emitter
  17236. */
  17237. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17238. /**
  17239. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17240. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17241. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17242. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17243. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17244. * @returns the emitter
  17245. */
  17246. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17247. }
  17248. }
  17249. declare module "babylonjs/Particles/subEmitter" {
  17250. import { Scene } from "babylonjs/scene";
  17251. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17252. /**
  17253. * Type of sub emitter
  17254. */
  17255. export enum SubEmitterType {
  17256. /**
  17257. * Attached to the particle over it's lifetime
  17258. */
  17259. ATTACHED = 0,
  17260. /**
  17261. * Created when the particle dies
  17262. */
  17263. END = 1
  17264. }
  17265. /**
  17266. * Sub emitter class used to emit particles from an existing particle
  17267. */
  17268. export class SubEmitter {
  17269. /**
  17270. * the particle system to be used by the sub emitter
  17271. */
  17272. particleSystem: ParticleSystem;
  17273. /**
  17274. * Type of the submitter (Default: END)
  17275. */
  17276. type: SubEmitterType;
  17277. /**
  17278. * 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)
  17279. * Note: This only is supported when using an emitter of type Mesh
  17280. */
  17281. inheritDirection: boolean;
  17282. /**
  17283. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17284. */
  17285. inheritedVelocityAmount: number;
  17286. /**
  17287. * Creates a sub emitter
  17288. * @param particleSystem the particle system to be used by the sub emitter
  17289. */
  17290. constructor(
  17291. /**
  17292. * the particle system to be used by the sub emitter
  17293. */
  17294. particleSystem: ParticleSystem);
  17295. /**
  17296. * Clones the sub emitter
  17297. * @returns the cloned sub emitter
  17298. */
  17299. clone(): SubEmitter;
  17300. /**
  17301. * Serialize current object to a JSON object
  17302. * @returns the serialized object
  17303. */
  17304. serialize(): any;
  17305. /** @hidden */
  17306. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17307. /**
  17308. * Creates a new SubEmitter from a serialized JSON version
  17309. * @param serializationObject defines the JSON object to read from
  17310. * @param scene defines the hosting scene
  17311. * @param rootUrl defines the rootUrl for data loading
  17312. * @returns a new SubEmitter
  17313. */
  17314. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17315. /** Release associated resources */
  17316. dispose(): void;
  17317. }
  17318. }
  17319. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17320. /** @hidden */
  17321. export var clipPlaneFragmentDeclaration: {
  17322. name: string;
  17323. shader: string;
  17324. };
  17325. }
  17326. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17327. /** @hidden */
  17328. export var imageProcessingDeclaration: {
  17329. name: string;
  17330. shader: string;
  17331. };
  17332. }
  17333. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17334. /** @hidden */
  17335. export var imageProcessingFunctions: {
  17336. name: string;
  17337. shader: string;
  17338. };
  17339. }
  17340. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17341. /** @hidden */
  17342. export var clipPlaneFragment: {
  17343. name: string;
  17344. shader: string;
  17345. };
  17346. }
  17347. declare module "babylonjs/Shaders/particles.fragment" {
  17348. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17349. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17350. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17351. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17352. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17353. /** @hidden */
  17354. export var particlesPixelShader: {
  17355. name: string;
  17356. shader: string;
  17357. };
  17358. }
  17359. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17360. /** @hidden */
  17361. export var clipPlaneVertexDeclaration: {
  17362. name: string;
  17363. shader: string;
  17364. };
  17365. }
  17366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17367. /** @hidden */
  17368. export var clipPlaneVertex: {
  17369. name: string;
  17370. shader: string;
  17371. };
  17372. }
  17373. declare module "babylonjs/Shaders/particles.vertex" {
  17374. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17375. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17376. /** @hidden */
  17377. export var particlesVertexShader: {
  17378. name: string;
  17379. shader: string;
  17380. };
  17381. }
  17382. declare module "babylonjs/Particles/particleSystem" {
  17383. import { Nullable } from "babylonjs/types";
  17384. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17385. import { Observable } from "babylonjs/Misc/observable";
  17386. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17387. import { Effect } from "babylonjs/Materials/effect";
  17388. import { Scene, IDisposable } from "babylonjs/scene";
  17389. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17390. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17391. import { Particle } from "babylonjs/Particles/particle";
  17392. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17394. import "babylonjs/Shaders/particles.fragment";
  17395. import "babylonjs/Shaders/particles.vertex";
  17396. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17397. /**
  17398. * This represents a particle system in Babylon.
  17399. * 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.
  17400. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17401. * @example https://doc.babylonjs.com/babylon101/particles
  17402. */
  17403. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17404. /**
  17405. * Billboard mode will only apply to Y axis
  17406. */
  17407. static readonly BILLBOARDMODE_Y: number;
  17408. /**
  17409. * Billboard mode will apply to all axes
  17410. */
  17411. static readonly BILLBOARDMODE_ALL: number;
  17412. /**
  17413. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17414. */
  17415. static readonly BILLBOARDMODE_STRETCHED: number;
  17416. /**
  17417. * This function can be defined to provide custom update for active particles.
  17418. * This function will be called instead of regular update (age, position, color, etc.).
  17419. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17420. */
  17421. updateFunction: (particles: Particle[]) => void;
  17422. private _emitterWorldMatrix;
  17423. /**
  17424. * This function can be defined to specify initial direction for every new particle.
  17425. * It by default use the emitterType defined function
  17426. */
  17427. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17428. /**
  17429. * This function can be defined to specify initial position for every new particle.
  17430. * It by default use the emitterType defined function
  17431. */
  17432. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17433. /**
  17434. * @hidden
  17435. */
  17436. _inheritedVelocityOffset: Vector3;
  17437. /**
  17438. * An event triggered when the system is disposed
  17439. */
  17440. onDisposeObservable: Observable<ParticleSystem>;
  17441. private _onDisposeObserver;
  17442. /**
  17443. * Sets a callback that will be triggered when the system is disposed
  17444. */
  17445. onDispose: () => void;
  17446. private _particles;
  17447. private _epsilon;
  17448. private _capacity;
  17449. private _stockParticles;
  17450. private _newPartsExcess;
  17451. private _vertexData;
  17452. private _vertexBuffer;
  17453. private _vertexBuffers;
  17454. private _spriteBuffer;
  17455. private _indexBuffer;
  17456. private _effect;
  17457. private _customEffect;
  17458. private _cachedDefines;
  17459. private _scaledColorStep;
  17460. private _colorDiff;
  17461. private _scaledDirection;
  17462. private _scaledGravity;
  17463. private _currentRenderId;
  17464. private _alive;
  17465. private _useInstancing;
  17466. private _started;
  17467. private _stopped;
  17468. private _actualFrame;
  17469. private _scaledUpdateSpeed;
  17470. private _vertexBufferSize;
  17471. /** @hidden */
  17472. _currentEmitRateGradient: Nullable<FactorGradient>;
  17473. /** @hidden */
  17474. _currentEmitRate1: number;
  17475. /** @hidden */
  17476. _currentEmitRate2: number;
  17477. /** @hidden */
  17478. _currentStartSizeGradient: Nullable<FactorGradient>;
  17479. /** @hidden */
  17480. _currentStartSize1: number;
  17481. /** @hidden */
  17482. _currentStartSize2: number;
  17483. private readonly _rawTextureWidth;
  17484. private _rampGradientsTexture;
  17485. private _useRampGradients;
  17486. /** Gets or sets a boolean indicating that ramp gradients must be used
  17487. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17488. */
  17489. useRampGradients: boolean;
  17490. /**
  17491. * 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.
  17492. * 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: [])
  17493. */
  17494. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17495. private _subEmitters;
  17496. /**
  17497. * @hidden
  17498. * If the particle systems emitter should be disposed when the particle system is disposed
  17499. */
  17500. _disposeEmitterOnDispose: boolean;
  17501. /**
  17502. * The current active Sub-systems, this property is used by the root particle system only.
  17503. */
  17504. activeSubSystems: Array<ParticleSystem>;
  17505. private _rootParticleSystem;
  17506. /**
  17507. * Gets the current list of active particles
  17508. */
  17509. readonly particles: Particle[];
  17510. /**
  17511. * Returns the string "ParticleSystem"
  17512. * @returns a string containing the class name
  17513. */
  17514. getClassName(): string;
  17515. /**
  17516. * Instantiates a particle system.
  17517. * 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.
  17518. * @param name The name of the particle system
  17519. * @param capacity The max number of particles alive at the same time
  17520. * @param scene The scene the particle system belongs to
  17521. * @param customEffect a custom effect used to change the way particles are rendered by default
  17522. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17523. * @param epsilon Offset used to render the particles
  17524. */
  17525. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17526. private _addFactorGradient;
  17527. private _removeFactorGradient;
  17528. /**
  17529. * Adds a new life time gradient
  17530. * @param gradient defines the gradient to use (between 0 and 1)
  17531. * @param factor defines the life time factor to affect to the specified gradient
  17532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17533. * @returns the current particle system
  17534. */
  17535. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17536. /**
  17537. * Remove a specific life time gradient
  17538. * @param gradient defines the gradient to remove
  17539. * @returns the current particle system
  17540. */
  17541. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17542. /**
  17543. * Adds a new size gradient
  17544. * @param gradient defines the gradient to use (between 0 and 1)
  17545. * @param factor defines the size factor to affect to the specified gradient
  17546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17547. * @returns the current particle system
  17548. */
  17549. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17550. /**
  17551. * Remove a specific size gradient
  17552. * @param gradient defines the gradient to remove
  17553. * @returns the current particle system
  17554. */
  17555. removeSizeGradient(gradient: number): IParticleSystem;
  17556. /**
  17557. * Adds a new color remap gradient
  17558. * @param gradient defines the gradient to use (between 0 and 1)
  17559. * @param min defines the color remap minimal range
  17560. * @param max defines the color remap maximal range
  17561. * @returns the current particle system
  17562. */
  17563. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17564. /**
  17565. * Remove a specific color remap gradient
  17566. * @param gradient defines the gradient to remove
  17567. * @returns the current particle system
  17568. */
  17569. removeColorRemapGradient(gradient: number): IParticleSystem;
  17570. /**
  17571. * Adds a new alpha remap gradient
  17572. * @param gradient defines the gradient to use (between 0 and 1)
  17573. * @param min defines the alpha remap minimal range
  17574. * @param max defines the alpha remap maximal range
  17575. * @returns the current particle system
  17576. */
  17577. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17578. /**
  17579. * Remove a specific alpha remap gradient
  17580. * @param gradient defines the gradient to remove
  17581. * @returns the current particle system
  17582. */
  17583. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17584. /**
  17585. * Adds a new angular speed gradient
  17586. * @param gradient defines the gradient to use (between 0 and 1)
  17587. * @param factor defines the angular speed to affect to the specified gradient
  17588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17589. * @returns the current particle system
  17590. */
  17591. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17592. /**
  17593. * Remove a specific angular speed gradient
  17594. * @param gradient defines the gradient to remove
  17595. * @returns the current particle system
  17596. */
  17597. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17598. /**
  17599. * Adds a new velocity gradient
  17600. * @param gradient defines the gradient to use (between 0 and 1)
  17601. * @param factor defines the velocity to affect to the specified gradient
  17602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17603. * @returns the current particle system
  17604. */
  17605. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17606. /**
  17607. * Remove a specific velocity gradient
  17608. * @param gradient defines the gradient to remove
  17609. * @returns the current particle system
  17610. */
  17611. removeVelocityGradient(gradient: number): IParticleSystem;
  17612. /**
  17613. * Adds a new limit velocity gradient
  17614. * @param gradient defines the gradient to use (between 0 and 1)
  17615. * @param factor defines the limit velocity value to affect to the specified gradient
  17616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17617. * @returns the current particle system
  17618. */
  17619. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17620. /**
  17621. * Remove a specific limit velocity gradient
  17622. * @param gradient defines the gradient to remove
  17623. * @returns the current particle system
  17624. */
  17625. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17626. /**
  17627. * Adds a new drag gradient
  17628. * @param gradient defines the gradient to use (between 0 and 1)
  17629. * @param factor defines the drag value to affect to the specified gradient
  17630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17631. * @returns the current particle system
  17632. */
  17633. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17634. /**
  17635. * Remove a specific drag gradient
  17636. * @param gradient defines the gradient to remove
  17637. * @returns the current particle system
  17638. */
  17639. removeDragGradient(gradient: number): IParticleSystem;
  17640. /**
  17641. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17642. * @param gradient defines the gradient to use (between 0 and 1)
  17643. * @param factor defines the emit rate value to affect to the specified gradient
  17644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17645. * @returns the current particle system
  17646. */
  17647. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17648. /**
  17649. * Remove a specific emit rate gradient
  17650. * @param gradient defines the gradient to remove
  17651. * @returns the current particle system
  17652. */
  17653. removeEmitRateGradient(gradient: number): IParticleSystem;
  17654. /**
  17655. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17656. * @param gradient defines the gradient to use (between 0 and 1)
  17657. * @param factor defines the start size value to affect to the specified gradient
  17658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17659. * @returns the current particle system
  17660. */
  17661. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17662. /**
  17663. * Remove a specific start size gradient
  17664. * @param gradient defines the gradient to remove
  17665. * @returns the current particle system
  17666. */
  17667. removeStartSizeGradient(gradient: number): IParticleSystem;
  17668. private _createRampGradientTexture;
  17669. /**
  17670. * Gets the current list of ramp gradients.
  17671. * You must use addRampGradient and removeRampGradient to udpate this list
  17672. * @returns the list of ramp gradients
  17673. */
  17674. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17675. /**
  17676. * Adds a new ramp gradient used to remap particle colors
  17677. * @param gradient defines the gradient to use (between 0 and 1)
  17678. * @param color defines the color to affect to the specified gradient
  17679. * @returns the current particle system
  17680. */
  17681. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17682. /**
  17683. * Remove a specific ramp gradient
  17684. * @param gradient defines the gradient to remove
  17685. * @returns the current particle system
  17686. */
  17687. removeRampGradient(gradient: number): ParticleSystem;
  17688. /**
  17689. * Adds a new color gradient
  17690. * @param gradient defines the gradient to use (between 0 and 1)
  17691. * @param color1 defines the color to affect to the specified gradient
  17692. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17693. * @returns this particle system
  17694. */
  17695. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17696. /**
  17697. * Remove a specific color gradient
  17698. * @param gradient defines the gradient to remove
  17699. * @returns this particle system
  17700. */
  17701. removeColorGradient(gradient: number): IParticleSystem;
  17702. private _fetchR;
  17703. protected _reset(): void;
  17704. private _resetEffect;
  17705. private _createVertexBuffers;
  17706. private _createIndexBuffer;
  17707. /**
  17708. * Gets the maximum number of particles active at the same time.
  17709. * @returns The max number of active particles.
  17710. */
  17711. getCapacity(): number;
  17712. /**
  17713. * Gets whether there are still active particles in the system.
  17714. * @returns True if it is alive, otherwise false.
  17715. */
  17716. isAlive(): boolean;
  17717. /**
  17718. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17719. * @returns True if it has been started, otherwise false.
  17720. */
  17721. isStarted(): boolean;
  17722. private _prepareSubEmitterInternalArray;
  17723. /**
  17724. * Starts the particle system and begins to emit
  17725. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17726. */
  17727. start(delay?: number): void;
  17728. /**
  17729. * Stops the particle system.
  17730. * @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.
  17731. */
  17732. stop(stopSubEmitters?: boolean): void;
  17733. /**
  17734. * Remove all active particles
  17735. */
  17736. reset(): void;
  17737. /**
  17738. * @hidden (for internal use only)
  17739. */
  17740. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17741. /**
  17742. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17743. * Its lifetime will start back at 0.
  17744. */
  17745. recycleParticle: (particle: Particle) => void;
  17746. private _stopSubEmitters;
  17747. private _createParticle;
  17748. private _removeFromRoot;
  17749. private _emitFromParticle;
  17750. private _update;
  17751. /** @hidden */
  17752. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17753. /** @hidden */
  17754. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17755. /** @hidden */
  17756. private _getEffect;
  17757. /**
  17758. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17759. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17760. */
  17761. animate(preWarmOnly?: boolean): void;
  17762. private _appendParticleVertices;
  17763. /**
  17764. * Rebuilds the particle system.
  17765. */
  17766. rebuild(): void;
  17767. /**
  17768. * Is this system ready to be used/rendered
  17769. * @return true if the system is ready
  17770. */
  17771. isReady(): boolean;
  17772. private _render;
  17773. /**
  17774. * Renders the particle system in its current state.
  17775. * @returns the current number of particles
  17776. */
  17777. render(): number;
  17778. /**
  17779. * Disposes the particle system and free the associated resources
  17780. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17781. */
  17782. dispose(disposeTexture?: boolean): void;
  17783. /**
  17784. * Clones the particle system.
  17785. * @param name The name of the cloned object
  17786. * @param newEmitter The new emitter to use
  17787. * @returns the cloned particle system
  17788. */
  17789. clone(name: string, newEmitter: any): ParticleSystem;
  17790. /**
  17791. * Serializes the particle system to a JSON object.
  17792. * @returns the JSON object
  17793. */
  17794. serialize(): any;
  17795. /** @hidden */
  17796. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17797. /** @hidden */
  17798. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17799. /**
  17800. * Parses a JSON object to create a particle system.
  17801. * @param parsedParticleSystem The JSON object to parse
  17802. * @param scene The scene to create the particle system in
  17803. * @param rootUrl The root url to use to load external dependencies like texture
  17804. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17805. * @returns the Parsed particle system
  17806. */
  17807. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17808. }
  17809. }
  17810. declare module "babylonjs/Particles/particle" {
  17811. import { Nullable } from "babylonjs/types";
  17812. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17813. import { Color4 } from "babylonjs/Maths/math.color";
  17814. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17815. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17816. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17817. /**
  17818. * A particle represents one of the element emitted by a particle system.
  17819. * This is mainly define by its coordinates, direction, velocity and age.
  17820. */
  17821. export class Particle {
  17822. /**
  17823. * The particle system the particle belongs to.
  17824. */
  17825. particleSystem: ParticleSystem;
  17826. private static _Count;
  17827. /**
  17828. * Unique ID of the particle
  17829. */
  17830. id: number;
  17831. /**
  17832. * The world position of the particle in the scene.
  17833. */
  17834. position: Vector3;
  17835. /**
  17836. * The world direction of the particle in the scene.
  17837. */
  17838. direction: Vector3;
  17839. /**
  17840. * The color of the particle.
  17841. */
  17842. color: Color4;
  17843. /**
  17844. * The color change of the particle per step.
  17845. */
  17846. colorStep: Color4;
  17847. /**
  17848. * Defines how long will the life of the particle be.
  17849. */
  17850. lifeTime: number;
  17851. /**
  17852. * The current age of the particle.
  17853. */
  17854. age: number;
  17855. /**
  17856. * The current size of the particle.
  17857. */
  17858. size: number;
  17859. /**
  17860. * The current scale of the particle.
  17861. */
  17862. scale: Vector2;
  17863. /**
  17864. * The current angle of the particle.
  17865. */
  17866. angle: number;
  17867. /**
  17868. * Defines how fast is the angle changing.
  17869. */
  17870. angularSpeed: number;
  17871. /**
  17872. * Defines the cell index used by the particle to be rendered from a sprite.
  17873. */
  17874. cellIndex: number;
  17875. /**
  17876. * The information required to support color remapping
  17877. */
  17878. remapData: Vector4;
  17879. /** @hidden */
  17880. _randomCellOffset?: number;
  17881. /** @hidden */
  17882. _initialDirection: Nullable<Vector3>;
  17883. /** @hidden */
  17884. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17885. /** @hidden */
  17886. _initialStartSpriteCellID: number;
  17887. /** @hidden */
  17888. _initialEndSpriteCellID: number;
  17889. /** @hidden */
  17890. _currentColorGradient: Nullable<ColorGradient>;
  17891. /** @hidden */
  17892. _currentColor1: Color4;
  17893. /** @hidden */
  17894. _currentColor2: Color4;
  17895. /** @hidden */
  17896. _currentSizeGradient: Nullable<FactorGradient>;
  17897. /** @hidden */
  17898. _currentSize1: number;
  17899. /** @hidden */
  17900. _currentSize2: number;
  17901. /** @hidden */
  17902. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17903. /** @hidden */
  17904. _currentAngularSpeed1: number;
  17905. /** @hidden */
  17906. _currentAngularSpeed2: number;
  17907. /** @hidden */
  17908. _currentVelocityGradient: Nullable<FactorGradient>;
  17909. /** @hidden */
  17910. _currentVelocity1: number;
  17911. /** @hidden */
  17912. _currentVelocity2: number;
  17913. /** @hidden */
  17914. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17915. /** @hidden */
  17916. _currentLimitVelocity1: number;
  17917. /** @hidden */
  17918. _currentLimitVelocity2: number;
  17919. /** @hidden */
  17920. _currentDragGradient: Nullable<FactorGradient>;
  17921. /** @hidden */
  17922. _currentDrag1: number;
  17923. /** @hidden */
  17924. _currentDrag2: number;
  17925. /** @hidden */
  17926. _randomNoiseCoordinates1: Vector3;
  17927. /** @hidden */
  17928. _randomNoiseCoordinates2: Vector3;
  17929. /**
  17930. * Creates a new instance Particle
  17931. * @param particleSystem the particle system the particle belongs to
  17932. */
  17933. constructor(
  17934. /**
  17935. * The particle system the particle belongs to.
  17936. */
  17937. particleSystem: ParticleSystem);
  17938. private updateCellInfoFromSystem;
  17939. /**
  17940. * Defines how the sprite cell index is updated for the particle
  17941. */
  17942. updateCellIndex(): void;
  17943. /** @hidden */
  17944. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17945. /** @hidden */
  17946. _inheritParticleInfoToSubEmitters(): void;
  17947. /** @hidden */
  17948. _reset(): void;
  17949. /**
  17950. * Copy the properties of particle to another one.
  17951. * @param other the particle to copy the information to.
  17952. */
  17953. copyTo(other: Particle): void;
  17954. }
  17955. }
  17956. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17957. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17958. import { Effect } from "babylonjs/Materials/effect";
  17959. import { Particle } from "babylonjs/Particles/particle";
  17960. /**
  17961. * Particle emitter represents a volume emitting particles.
  17962. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17963. */
  17964. export interface IParticleEmitterType {
  17965. /**
  17966. * Called by the particle System when the direction is computed for the created particle.
  17967. * @param worldMatrix is the world matrix of the particle system
  17968. * @param directionToUpdate is the direction vector to update with the result
  17969. * @param particle is the particle we are computed the direction for
  17970. */
  17971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17972. /**
  17973. * Called by the particle System when the position is computed for the created particle.
  17974. * @param worldMatrix is the world matrix of the particle system
  17975. * @param positionToUpdate is the position vector to update with the result
  17976. * @param particle is the particle we are computed the position for
  17977. */
  17978. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17979. /**
  17980. * Clones the current emitter and returns a copy of it
  17981. * @returns the new emitter
  17982. */
  17983. clone(): IParticleEmitterType;
  17984. /**
  17985. * Called by the GPUParticleSystem to setup the update shader
  17986. * @param effect defines the update shader
  17987. */
  17988. applyToShader(effect: Effect): void;
  17989. /**
  17990. * Returns a string to use to update the GPU particles update shader
  17991. * @returns the effect defines string
  17992. */
  17993. getEffectDefines(): string;
  17994. /**
  17995. * Returns a string representing the class name
  17996. * @returns a string containing the class name
  17997. */
  17998. getClassName(): string;
  17999. /**
  18000. * Serializes the particle system to a JSON object.
  18001. * @returns the JSON object
  18002. */
  18003. serialize(): any;
  18004. /**
  18005. * Parse properties from a JSON object
  18006. * @param serializationObject defines the JSON object
  18007. */
  18008. parse(serializationObject: any): void;
  18009. }
  18010. }
  18011. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18012. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18013. import { Effect } from "babylonjs/Materials/effect";
  18014. import { Particle } from "babylonjs/Particles/particle";
  18015. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18016. /**
  18017. * Particle emitter emitting particles from the inside of a box.
  18018. * It emits the particles randomly between 2 given directions.
  18019. */
  18020. export class BoxParticleEmitter implements IParticleEmitterType {
  18021. /**
  18022. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18023. */
  18024. direction1: Vector3;
  18025. /**
  18026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18027. */
  18028. direction2: Vector3;
  18029. /**
  18030. * 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.
  18031. */
  18032. minEmitBox: Vector3;
  18033. /**
  18034. * 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.
  18035. */
  18036. maxEmitBox: Vector3;
  18037. /**
  18038. * Creates a new instance BoxParticleEmitter
  18039. */
  18040. constructor();
  18041. /**
  18042. * Called by the particle System when the direction is computed for the created particle.
  18043. * @param worldMatrix is the world matrix of the particle system
  18044. * @param directionToUpdate is the direction vector to update with the result
  18045. * @param particle is the particle we are computed the direction for
  18046. */
  18047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18048. /**
  18049. * Called by the particle System when the position is computed for the created particle.
  18050. * @param worldMatrix is the world matrix of the particle system
  18051. * @param positionToUpdate is the position vector to update with the result
  18052. * @param particle is the particle we are computed the position for
  18053. */
  18054. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18055. /**
  18056. * Clones the current emitter and returns a copy of it
  18057. * @returns the new emitter
  18058. */
  18059. clone(): BoxParticleEmitter;
  18060. /**
  18061. * Called by the GPUParticleSystem to setup the update shader
  18062. * @param effect defines the update shader
  18063. */
  18064. applyToShader(effect: Effect): void;
  18065. /**
  18066. * Returns a string to use to update the GPU particles update shader
  18067. * @returns a string containng the defines string
  18068. */
  18069. getEffectDefines(): string;
  18070. /**
  18071. * Returns the string "BoxParticleEmitter"
  18072. * @returns a string containing the class name
  18073. */
  18074. getClassName(): string;
  18075. /**
  18076. * Serializes the particle system to a JSON object.
  18077. * @returns the JSON object
  18078. */
  18079. serialize(): any;
  18080. /**
  18081. * Parse properties from a JSON object
  18082. * @param serializationObject defines the JSON object
  18083. */
  18084. parse(serializationObject: any): void;
  18085. }
  18086. }
  18087. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18088. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18089. import { Effect } from "babylonjs/Materials/effect";
  18090. import { Particle } from "babylonjs/Particles/particle";
  18091. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18092. /**
  18093. * Particle emitter emitting particles from the inside of a cone.
  18094. * It emits the particles alongside the cone volume from the base to the particle.
  18095. * The emission direction might be randomized.
  18096. */
  18097. export class ConeParticleEmitter implements IParticleEmitterType {
  18098. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18099. directionRandomizer: number;
  18100. private _radius;
  18101. private _angle;
  18102. private _height;
  18103. /**
  18104. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18105. */
  18106. radiusRange: number;
  18107. /**
  18108. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18109. */
  18110. heightRange: number;
  18111. /**
  18112. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18113. */
  18114. emitFromSpawnPointOnly: boolean;
  18115. /**
  18116. * Gets or sets the radius of the emission cone
  18117. */
  18118. radius: number;
  18119. /**
  18120. * Gets or sets the angle of the emission cone
  18121. */
  18122. angle: number;
  18123. private _buildHeight;
  18124. /**
  18125. * Creates a new instance ConeParticleEmitter
  18126. * @param radius the radius of the emission cone (1 by default)
  18127. * @param angle the cone base angle (PI by default)
  18128. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18129. */
  18130. constructor(radius?: number, angle?: number,
  18131. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18132. directionRandomizer?: number);
  18133. /**
  18134. * Called by the particle System when the direction is computed for the created particle.
  18135. * @param worldMatrix is the world matrix of the particle system
  18136. * @param directionToUpdate is the direction vector to update with the result
  18137. * @param particle is the particle we are computed the direction for
  18138. */
  18139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18140. /**
  18141. * Called by the particle System when the position is computed for the created particle.
  18142. * @param worldMatrix is the world matrix of the particle system
  18143. * @param positionToUpdate is the position vector to update with the result
  18144. * @param particle is the particle we are computed the position for
  18145. */
  18146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18147. /**
  18148. * Clones the current emitter and returns a copy of it
  18149. * @returns the new emitter
  18150. */
  18151. clone(): ConeParticleEmitter;
  18152. /**
  18153. * Called by the GPUParticleSystem to setup the update shader
  18154. * @param effect defines the update shader
  18155. */
  18156. applyToShader(effect: Effect): void;
  18157. /**
  18158. * Returns a string to use to update the GPU particles update shader
  18159. * @returns a string containng the defines string
  18160. */
  18161. getEffectDefines(): string;
  18162. /**
  18163. * Returns the string "ConeParticleEmitter"
  18164. * @returns a string containing the class name
  18165. */
  18166. getClassName(): string;
  18167. /**
  18168. * Serializes the particle system to a JSON object.
  18169. * @returns the JSON object
  18170. */
  18171. serialize(): any;
  18172. /**
  18173. * Parse properties from a JSON object
  18174. * @param serializationObject defines the JSON object
  18175. */
  18176. parse(serializationObject: any): void;
  18177. }
  18178. }
  18179. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18180. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18181. import { Effect } from "babylonjs/Materials/effect";
  18182. import { Particle } from "babylonjs/Particles/particle";
  18183. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18184. /**
  18185. * Particle emitter emitting particles from the inside of a cylinder.
  18186. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18187. */
  18188. export class CylinderParticleEmitter implements IParticleEmitterType {
  18189. /**
  18190. * The radius of the emission cylinder.
  18191. */
  18192. radius: number;
  18193. /**
  18194. * The height of the emission cylinder.
  18195. */
  18196. height: number;
  18197. /**
  18198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18199. */
  18200. radiusRange: number;
  18201. /**
  18202. * How much to randomize the particle direction [0-1].
  18203. */
  18204. directionRandomizer: number;
  18205. /**
  18206. * Creates a new instance CylinderParticleEmitter
  18207. * @param radius the radius of the emission cylinder (1 by default)
  18208. * @param height the height of the emission cylinder (1 by default)
  18209. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18210. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18211. */
  18212. constructor(
  18213. /**
  18214. * The radius of the emission cylinder.
  18215. */
  18216. radius?: number,
  18217. /**
  18218. * The height of the emission cylinder.
  18219. */
  18220. height?: number,
  18221. /**
  18222. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18223. */
  18224. radiusRange?: number,
  18225. /**
  18226. * How much to randomize the particle direction [0-1].
  18227. */
  18228. directionRandomizer?: number);
  18229. /**
  18230. * Called by the particle System when the direction is computed for the created particle.
  18231. * @param worldMatrix is the world matrix of the particle system
  18232. * @param directionToUpdate is the direction vector to update with the result
  18233. * @param particle is the particle we are computed the direction for
  18234. */
  18235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18236. /**
  18237. * Called by the particle System when the position is computed for the created particle.
  18238. * @param worldMatrix is the world matrix of the particle system
  18239. * @param positionToUpdate is the position vector to update with the result
  18240. * @param particle is the particle we are computed the position for
  18241. */
  18242. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18243. /**
  18244. * Clones the current emitter and returns a copy of it
  18245. * @returns the new emitter
  18246. */
  18247. clone(): CylinderParticleEmitter;
  18248. /**
  18249. * Called by the GPUParticleSystem to setup the update shader
  18250. * @param effect defines the update shader
  18251. */
  18252. applyToShader(effect: Effect): void;
  18253. /**
  18254. * Returns a string to use to update the GPU particles update shader
  18255. * @returns a string containng the defines string
  18256. */
  18257. getEffectDefines(): string;
  18258. /**
  18259. * Returns the string "CylinderParticleEmitter"
  18260. * @returns a string containing the class name
  18261. */
  18262. getClassName(): string;
  18263. /**
  18264. * Serializes the particle system to a JSON object.
  18265. * @returns the JSON object
  18266. */
  18267. serialize(): any;
  18268. /**
  18269. * Parse properties from a JSON object
  18270. * @param serializationObject defines the JSON object
  18271. */
  18272. parse(serializationObject: any): void;
  18273. }
  18274. /**
  18275. * Particle emitter emitting particles from the inside of a cylinder.
  18276. * It emits the particles randomly between two vectors.
  18277. */
  18278. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18279. /**
  18280. * The min limit of the emission direction.
  18281. */
  18282. direction1: Vector3;
  18283. /**
  18284. * The max limit of the emission direction.
  18285. */
  18286. direction2: Vector3;
  18287. /**
  18288. * Creates a new instance CylinderDirectedParticleEmitter
  18289. * @param radius the radius of the emission cylinder (1 by default)
  18290. * @param height the height of the emission cylinder (1 by default)
  18291. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18292. * @param direction1 the min limit of the emission direction (up vector by default)
  18293. * @param direction2 the max limit of the emission direction (up vector by default)
  18294. */
  18295. constructor(radius?: number, height?: number, radiusRange?: number,
  18296. /**
  18297. * The min limit of the emission direction.
  18298. */
  18299. direction1?: Vector3,
  18300. /**
  18301. * The max limit of the emission direction.
  18302. */
  18303. direction2?: Vector3);
  18304. /**
  18305. * Called by the particle System when the direction is computed for the created particle.
  18306. * @param worldMatrix is the world matrix of the particle system
  18307. * @param directionToUpdate is the direction vector to update with the result
  18308. * @param particle is the particle we are computed the direction for
  18309. */
  18310. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18311. /**
  18312. * Clones the current emitter and returns a copy of it
  18313. * @returns the new emitter
  18314. */
  18315. clone(): CylinderDirectedParticleEmitter;
  18316. /**
  18317. * Called by the GPUParticleSystem to setup the update shader
  18318. * @param effect defines the update shader
  18319. */
  18320. applyToShader(effect: Effect): void;
  18321. /**
  18322. * Returns a string to use to update the GPU particles update shader
  18323. * @returns a string containng the defines string
  18324. */
  18325. getEffectDefines(): string;
  18326. /**
  18327. * Returns the string "CylinderDirectedParticleEmitter"
  18328. * @returns a string containing the class name
  18329. */
  18330. getClassName(): string;
  18331. /**
  18332. * Serializes the particle system to a JSON object.
  18333. * @returns the JSON object
  18334. */
  18335. serialize(): any;
  18336. /**
  18337. * Parse properties from a JSON object
  18338. * @param serializationObject defines the JSON object
  18339. */
  18340. parse(serializationObject: any): void;
  18341. }
  18342. }
  18343. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18344. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18345. import { Effect } from "babylonjs/Materials/effect";
  18346. import { Particle } from "babylonjs/Particles/particle";
  18347. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18348. /**
  18349. * Particle emitter emitting particles from the inside of a hemisphere.
  18350. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18351. */
  18352. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18353. /**
  18354. * The radius of the emission hemisphere.
  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. * Creates a new instance HemisphericParticleEmitter
  18367. * @param radius the radius of the emission hemisphere (1 by default)
  18368. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18369. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18370. */
  18371. constructor(
  18372. /**
  18373. * The radius of the emission hemisphere.
  18374. */
  18375. radius?: number,
  18376. /**
  18377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18378. */
  18379. radiusRange?: number,
  18380. /**
  18381. * How much to randomize the particle direction [0-1].
  18382. */
  18383. directionRandomizer?: number);
  18384. /**
  18385. * Called by the particle System when the direction is computed for the created particle.
  18386. * @param worldMatrix is the world matrix of the particle system
  18387. * @param directionToUpdate is the direction vector to update with the result
  18388. * @param particle is the particle we are computed the direction for
  18389. */
  18390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18391. /**
  18392. * Called by the particle System when the position is computed for the created particle.
  18393. * @param worldMatrix is the world matrix of the particle system
  18394. * @param positionToUpdate is the position vector to update with the result
  18395. * @param particle is the particle we are computed the position for
  18396. */
  18397. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18398. /**
  18399. * Clones the current emitter and returns a copy of it
  18400. * @returns the new emitter
  18401. */
  18402. clone(): HemisphericParticleEmitter;
  18403. /**
  18404. * Called by the GPUParticleSystem to setup the update shader
  18405. * @param effect defines the update shader
  18406. */
  18407. applyToShader(effect: Effect): void;
  18408. /**
  18409. * Returns a string to use to update the GPU particles update shader
  18410. * @returns a string containng the defines string
  18411. */
  18412. getEffectDefines(): string;
  18413. /**
  18414. * Returns the string "HemisphericParticleEmitter"
  18415. * @returns a string containing the class name
  18416. */
  18417. getClassName(): string;
  18418. /**
  18419. * Serializes the particle system to a JSON object.
  18420. * @returns the JSON object
  18421. */
  18422. serialize(): any;
  18423. /**
  18424. * Parse properties from a JSON object
  18425. * @param serializationObject defines the JSON object
  18426. */
  18427. parse(serializationObject: any): void;
  18428. }
  18429. }
  18430. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18431. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18432. import { Effect } from "babylonjs/Materials/effect";
  18433. import { Particle } from "babylonjs/Particles/particle";
  18434. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18435. /**
  18436. * Particle emitter emitting particles from a point.
  18437. * It emits the particles randomly between 2 given directions.
  18438. */
  18439. export class PointParticleEmitter implements IParticleEmitterType {
  18440. /**
  18441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18442. */
  18443. direction1: Vector3;
  18444. /**
  18445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18446. */
  18447. direction2: Vector3;
  18448. /**
  18449. * Creates a new instance PointParticleEmitter
  18450. */
  18451. constructor();
  18452. /**
  18453. * Called by the particle System when the direction is computed for the created particle.
  18454. * @param worldMatrix is the world matrix of the particle system
  18455. * @param directionToUpdate is the direction vector to update with the result
  18456. * @param particle is the particle we are computed the direction for
  18457. */
  18458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18459. /**
  18460. * Called by the particle System when the position is computed for the created particle.
  18461. * @param worldMatrix is the world matrix of the particle system
  18462. * @param positionToUpdate is the position vector to update with the result
  18463. * @param particle is the particle we are computed the position for
  18464. */
  18465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18466. /**
  18467. * Clones the current emitter and returns a copy of it
  18468. * @returns the new emitter
  18469. */
  18470. clone(): PointParticleEmitter;
  18471. /**
  18472. * Called by the GPUParticleSystem to setup the update shader
  18473. * @param effect defines the update shader
  18474. */
  18475. applyToShader(effect: Effect): void;
  18476. /**
  18477. * Returns a string to use to update the GPU particles update shader
  18478. * @returns a string containng the defines string
  18479. */
  18480. getEffectDefines(): string;
  18481. /**
  18482. * Returns the string "PointParticleEmitter"
  18483. * @returns a string containing the class name
  18484. */
  18485. getClassName(): string;
  18486. /**
  18487. * Serializes the particle system to a JSON object.
  18488. * @returns the JSON object
  18489. */
  18490. serialize(): any;
  18491. /**
  18492. * Parse properties from a JSON object
  18493. * @param serializationObject defines the JSON object
  18494. */
  18495. parse(serializationObject: any): void;
  18496. }
  18497. }
  18498. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18499. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18500. import { Effect } from "babylonjs/Materials/effect";
  18501. import { Particle } from "babylonjs/Particles/particle";
  18502. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18503. /**
  18504. * Particle emitter emitting particles from the inside of a sphere.
  18505. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18506. */
  18507. export class SphereParticleEmitter implements IParticleEmitterType {
  18508. /**
  18509. * The radius of the emission sphere.
  18510. */
  18511. radius: number;
  18512. /**
  18513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18514. */
  18515. radiusRange: number;
  18516. /**
  18517. * How much to randomize the particle direction [0-1].
  18518. */
  18519. directionRandomizer: number;
  18520. /**
  18521. * Creates a new instance SphereParticleEmitter
  18522. * @param radius the radius of the emission sphere (1 by default)
  18523. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18524. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18525. */
  18526. constructor(
  18527. /**
  18528. * The radius of the emission sphere.
  18529. */
  18530. radius?: number,
  18531. /**
  18532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18533. */
  18534. radiusRange?: number,
  18535. /**
  18536. * How much to randomize the particle direction [0-1].
  18537. */
  18538. directionRandomizer?: number);
  18539. /**
  18540. * Called by the particle System when the direction is computed for the created particle.
  18541. * @param worldMatrix is the world matrix of the particle system
  18542. * @param directionToUpdate is the direction vector to update with the result
  18543. * @param particle is the particle we are computed the direction for
  18544. */
  18545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18546. /**
  18547. * Called by the particle System when the position is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param positionToUpdate is the position vector to update with the result
  18550. * @param particle is the particle we are computed the position for
  18551. */
  18552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): SphereParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "SphereParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. /**
  18585. * Particle emitter emitting particles from the inside of a sphere.
  18586. * It emits the particles randomly between two vectors.
  18587. */
  18588. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18589. /**
  18590. * The min limit of the emission direction.
  18591. */
  18592. direction1: Vector3;
  18593. /**
  18594. * The max limit of the emission direction.
  18595. */
  18596. direction2: Vector3;
  18597. /**
  18598. * Creates a new instance SphereDirectedParticleEmitter
  18599. * @param radius the radius of the emission sphere (1 by default)
  18600. * @param direction1 the min limit of the emission direction (up vector by default)
  18601. * @param direction2 the max limit of the emission direction (up vector by default)
  18602. */
  18603. constructor(radius?: number,
  18604. /**
  18605. * The min limit of the emission direction.
  18606. */
  18607. direction1?: Vector3,
  18608. /**
  18609. * The max limit of the emission direction.
  18610. */
  18611. direction2?: Vector3);
  18612. /**
  18613. * Called by the particle System when the direction is computed for the created particle.
  18614. * @param worldMatrix is the world matrix of the particle system
  18615. * @param directionToUpdate is the direction vector to update with the result
  18616. * @param particle is the particle we are computed the direction for
  18617. */
  18618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18619. /**
  18620. * Clones the current emitter and returns a copy of it
  18621. * @returns the new emitter
  18622. */
  18623. clone(): SphereDirectedParticleEmitter;
  18624. /**
  18625. * Called by the GPUParticleSystem to setup the update shader
  18626. * @param effect defines the update shader
  18627. */
  18628. applyToShader(effect: Effect): void;
  18629. /**
  18630. * Returns a string to use to update the GPU particles update shader
  18631. * @returns a string containng the defines string
  18632. */
  18633. getEffectDefines(): string;
  18634. /**
  18635. * Returns the string "SphereDirectedParticleEmitter"
  18636. * @returns a string containing the class name
  18637. */
  18638. getClassName(): string;
  18639. /**
  18640. * Serializes the particle system to a JSON object.
  18641. * @returns the JSON object
  18642. */
  18643. serialize(): any;
  18644. /**
  18645. * Parse properties from a JSON object
  18646. * @param serializationObject defines the JSON object
  18647. */
  18648. parse(serializationObject: any): void;
  18649. }
  18650. }
  18651. declare module "babylonjs/Particles/EmitterTypes/index" {
  18652. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18653. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18654. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18655. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18656. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18657. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18658. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18659. }
  18660. declare module "babylonjs/Particles/IParticleSystem" {
  18661. import { Nullable } from "babylonjs/types";
  18662. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18663. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18666. import { Texture } from "babylonjs/Materials/Textures/texture";
  18667. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18668. import { Scene } from "babylonjs/scene";
  18669. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18670. import { Animation } from "babylonjs/Animations/animation";
  18671. /**
  18672. * Interface representing a particle system in Babylon.js.
  18673. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18674. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18675. */
  18676. export interface IParticleSystem {
  18677. /**
  18678. * List of animations used by the particle system.
  18679. */
  18680. animations: Animation[];
  18681. /**
  18682. * The id of the Particle system.
  18683. */
  18684. id: string;
  18685. /**
  18686. * The name of the Particle system.
  18687. */
  18688. name: string;
  18689. /**
  18690. * The emitter represents the Mesh or position we are attaching the particle system to.
  18691. */
  18692. emitter: Nullable<AbstractMesh | Vector3>;
  18693. /**
  18694. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18695. */
  18696. isBillboardBased: boolean;
  18697. /**
  18698. * The rendering group used by the Particle system to chose when to render.
  18699. */
  18700. renderingGroupId: number;
  18701. /**
  18702. * The layer mask we are rendering the particles through.
  18703. */
  18704. layerMask: number;
  18705. /**
  18706. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18707. */
  18708. updateSpeed: number;
  18709. /**
  18710. * The amount of time the particle system is running (depends of the overall update speed).
  18711. */
  18712. targetStopDuration: number;
  18713. /**
  18714. * The texture used to render each particle. (this can be a spritesheet)
  18715. */
  18716. particleTexture: Nullable<Texture>;
  18717. /**
  18718. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18719. */
  18720. blendMode: number;
  18721. /**
  18722. * Minimum life time of emitting particles.
  18723. */
  18724. minLifeTime: number;
  18725. /**
  18726. * Maximum life time of emitting particles.
  18727. */
  18728. maxLifeTime: number;
  18729. /**
  18730. * Minimum Size of emitting particles.
  18731. */
  18732. minSize: number;
  18733. /**
  18734. * Maximum Size of emitting particles.
  18735. */
  18736. maxSize: number;
  18737. /**
  18738. * Minimum scale of emitting particles on X axis.
  18739. */
  18740. minScaleX: number;
  18741. /**
  18742. * Maximum scale of emitting particles on X axis.
  18743. */
  18744. maxScaleX: number;
  18745. /**
  18746. * Minimum scale of emitting particles on Y axis.
  18747. */
  18748. minScaleY: number;
  18749. /**
  18750. * Maximum scale of emitting particles on Y axis.
  18751. */
  18752. maxScaleY: number;
  18753. /**
  18754. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18755. */
  18756. color1: Color4;
  18757. /**
  18758. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18759. */
  18760. color2: Color4;
  18761. /**
  18762. * Color the particle will have at the end of its lifetime.
  18763. */
  18764. colorDead: Color4;
  18765. /**
  18766. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18767. */
  18768. emitRate: number;
  18769. /**
  18770. * You can use gravity if you want to give an orientation to your particles.
  18771. */
  18772. gravity: Vector3;
  18773. /**
  18774. * Minimum power of emitting particles.
  18775. */
  18776. minEmitPower: number;
  18777. /**
  18778. * Maximum power of emitting particles.
  18779. */
  18780. maxEmitPower: number;
  18781. /**
  18782. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18783. */
  18784. minAngularSpeed: number;
  18785. /**
  18786. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18787. */
  18788. maxAngularSpeed: number;
  18789. /**
  18790. * Gets or sets the minimal initial rotation in radians.
  18791. */
  18792. minInitialRotation: number;
  18793. /**
  18794. * Gets or sets the maximal initial rotation in radians.
  18795. */
  18796. maxInitialRotation: number;
  18797. /**
  18798. * The particle emitter type defines the emitter used by the particle system.
  18799. * It can be for example box, sphere, or cone...
  18800. */
  18801. particleEmitterType: Nullable<IParticleEmitterType>;
  18802. /**
  18803. * Defines the delay in milliseconds before starting the system (0 by default)
  18804. */
  18805. startDelay: number;
  18806. /**
  18807. * 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
  18808. */
  18809. preWarmCycles: number;
  18810. /**
  18811. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18812. */
  18813. preWarmStepOffset: number;
  18814. /**
  18815. * 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)
  18816. */
  18817. spriteCellChangeSpeed: number;
  18818. /**
  18819. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18820. */
  18821. startSpriteCellID: number;
  18822. /**
  18823. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18824. */
  18825. endSpriteCellID: number;
  18826. /**
  18827. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18828. */
  18829. spriteCellWidth: number;
  18830. /**
  18831. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18832. */
  18833. spriteCellHeight: number;
  18834. /**
  18835. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18836. */
  18837. spriteRandomStartCell: boolean;
  18838. /**
  18839. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18840. */
  18841. isAnimationSheetEnabled: boolean;
  18842. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18843. translationPivot: Vector2;
  18844. /**
  18845. * Gets or sets a texture used to add random noise to particle positions
  18846. */
  18847. noiseTexture: Nullable<BaseTexture>;
  18848. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18849. noiseStrength: Vector3;
  18850. /**
  18851. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18852. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18853. */
  18854. billboardMode: number;
  18855. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18856. limitVelocityDamping: number;
  18857. /**
  18858. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18859. */
  18860. beginAnimationOnStart: boolean;
  18861. /**
  18862. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18863. */
  18864. beginAnimationFrom: number;
  18865. /**
  18866. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18867. */
  18868. beginAnimationTo: number;
  18869. /**
  18870. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18871. */
  18872. beginAnimationLoop: boolean;
  18873. /**
  18874. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18875. */
  18876. disposeOnStop: boolean;
  18877. /**
  18878. * Gets the maximum number of particles active at the same time.
  18879. * @returns The max number of active particles.
  18880. */
  18881. getCapacity(): number;
  18882. /**
  18883. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18884. * @returns True if it has been started, otherwise false.
  18885. */
  18886. isStarted(): boolean;
  18887. /**
  18888. * Animates the particle system for this frame.
  18889. */
  18890. animate(): void;
  18891. /**
  18892. * Renders the particle system in its current state.
  18893. * @returns the current number of particles
  18894. */
  18895. render(): number;
  18896. /**
  18897. * Dispose the particle system and frees its associated resources.
  18898. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18899. */
  18900. dispose(disposeTexture?: boolean): void;
  18901. /**
  18902. * Clones the particle system.
  18903. * @param name The name of the cloned object
  18904. * @param newEmitter The new emitter to use
  18905. * @returns the cloned particle system
  18906. */
  18907. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18908. /**
  18909. * Serializes the particle system to a JSON object.
  18910. * @returns the JSON object
  18911. */
  18912. serialize(): any;
  18913. /**
  18914. * Rebuild the particle system
  18915. */
  18916. rebuild(): void;
  18917. /**
  18918. * Starts the particle system and begins to emit
  18919. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18920. */
  18921. start(delay?: number): void;
  18922. /**
  18923. * Stops the particle system.
  18924. */
  18925. stop(): void;
  18926. /**
  18927. * Remove all active particles
  18928. */
  18929. reset(): void;
  18930. /**
  18931. * Is this system ready to be used/rendered
  18932. * @return true if the system is ready
  18933. */
  18934. isReady(): boolean;
  18935. /**
  18936. * Adds a new color gradient
  18937. * @param gradient defines the gradient to use (between 0 and 1)
  18938. * @param color1 defines the color to affect to the specified gradient
  18939. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18940. * @returns the current particle system
  18941. */
  18942. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18943. /**
  18944. * Remove a specific color gradient
  18945. * @param gradient defines the gradient to remove
  18946. * @returns the current particle system
  18947. */
  18948. removeColorGradient(gradient: number): IParticleSystem;
  18949. /**
  18950. * Adds a new size gradient
  18951. * @param gradient defines the gradient to use (between 0 and 1)
  18952. * @param factor defines the size factor to affect to the specified gradient
  18953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18954. * @returns the current particle system
  18955. */
  18956. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18957. /**
  18958. * Remove a specific size gradient
  18959. * @param gradient defines the gradient to remove
  18960. * @returns the current particle system
  18961. */
  18962. removeSizeGradient(gradient: number): IParticleSystem;
  18963. /**
  18964. * Gets the current list of color gradients.
  18965. * You must use addColorGradient and removeColorGradient to udpate this list
  18966. * @returns the list of color gradients
  18967. */
  18968. getColorGradients(): Nullable<Array<ColorGradient>>;
  18969. /**
  18970. * Gets the current list of size gradients.
  18971. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18972. * @returns the list of size gradients
  18973. */
  18974. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18975. /**
  18976. * Gets the current list of angular speed gradients.
  18977. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18978. * @returns the list of angular speed gradients
  18979. */
  18980. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18981. /**
  18982. * Adds a new angular speed gradient
  18983. * @param gradient defines the gradient to use (between 0 and 1)
  18984. * @param factor defines the angular speed to affect to the specified gradient
  18985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18986. * @returns the current particle system
  18987. */
  18988. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18989. /**
  18990. * Remove a specific angular speed gradient
  18991. * @param gradient defines the gradient to remove
  18992. * @returns the current particle system
  18993. */
  18994. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18995. /**
  18996. * Gets the current list of velocity gradients.
  18997. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18998. * @returns the list of velocity gradients
  18999. */
  19000. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19001. /**
  19002. * Adds a new velocity gradient
  19003. * @param gradient defines the gradient to use (between 0 and 1)
  19004. * @param factor defines the velocity to affect to the specified gradient
  19005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19006. * @returns the current particle system
  19007. */
  19008. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19009. /**
  19010. * Remove a specific velocity gradient
  19011. * @param gradient defines the gradient to remove
  19012. * @returns the current particle system
  19013. */
  19014. removeVelocityGradient(gradient: number): IParticleSystem;
  19015. /**
  19016. * Gets the current list of limit velocity gradients.
  19017. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19018. * @returns the list of limit velocity gradients
  19019. */
  19020. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19021. /**
  19022. * Adds a new limit velocity gradient
  19023. * @param gradient defines the gradient to use (between 0 and 1)
  19024. * @param factor defines the limit velocity to affect to the specified gradient
  19025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19026. * @returns the current particle system
  19027. */
  19028. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19029. /**
  19030. * Remove a specific limit velocity gradient
  19031. * @param gradient defines the gradient to remove
  19032. * @returns the current particle system
  19033. */
  19034. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19035. /**
  19036. * Adds a new drag gradient
  19037. * @param gradient defines the gradient to use (between 0 and 1)
  19038. * @param factor defines the drag to affect to the specified gradient
  19039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19040. * @returns the current particle system
  19041. */
  19042. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19043. /**
  19044. * Remove a specific drag gradient
  19045. * @param gradient defines the gradient to remove
  19046. * @returns the current particle system
  19047. */
  19048. removeDragGradient(gradient: number): IParticleSystem;
  19049. /**
  19050. * Gets the current list of drag gradients.
  19051. * You must use addDragGradient and removeDragGradient to udpate this list
  19052. * @returns the list of drag gradients
  19053. */
  19054. getDragGradients(): Nullable<Array<FactorGradient>>;
  19055. /**
  19056. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19057. * @param gradient defines the gradient to use (between 0 and 1)
  19058. * @param factor defines the emit rate to affect to the specified gradient
  19059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19060. * @returns the current particle system
  19061. */
  19062. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19063. /**
  19064. * Remove a specific emit rate gradient
  19065. * @param gradient defines the gradient to remove
  19066. * @returns the current particle system
  19067. */
  19068. removeEmitRateGradient(gradient: number): IParticleSystem;
  19069. /**
  19070. * Gets the current list of emit rate gradients.
  19071. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19072. * @returns the list of emit rate gradients
  19073. */
  19074. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19075. /**
  19076. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19077. * @param gradient defines the gradient to use (between 0 and 1)
  19078. * @param factor defines the start size to affect to the specified gradient
  19079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19080. * @returns the current particle system
  19081. */
  19082. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19083. /**
  19084. * Remove a specific start size gradient
  19085. * @param gradient defines the gradient to remove
  19086. * @returns the current particle system
  19087. */
  19088. removeStartSizeGradient(gradient: number): IParticleSystem;
  19089. /**
  19090. * Gets the current list of start size gradients.
  19091. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19092. * @returns the list of start size gradients
  19093. */
  19094. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19095. /**
  19096. * Adds a new life time gradient
  19097. * @param gradient defines the gradient to use (between 0 and 1)
  19098. * @param factor defines the life time factor to affect to the specified gradient
  19099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19100. * @returns the current particle system
  19101. */
  19102. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19103. /**
  19104. * Remove a specific life time gradient
  19105. * @param gradient defines the gradient to remove
  19106. * @returns the current particle system
  19107. */
  19108. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19109. /**
  19110. * Gets the current list of life time gradients.
  19111. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19112. * @returns the list of life time gradients
  19113. */
  19114. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19115. /**
  19116. * Gets the current list of color gradients.
  19117. * You must use addColorGradient and removeColorGradient to udpate this list
  19118. * @returns the list of color gradients
  19119. */
  19120. getColorGradients(): Nullable<Array<ColorGradient>>;
  19121. /**
  19122. * Adds a new ramp gradient used to remap particle colors
  19123. * @param gradient defines the gradient to use (between 0 and 1)
  19124. * @param color defines the color to affect to the specified gradient
  19125. * @returns the current particle system
  19126. */
  19127. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19128. /**
  19129. * Gets the current list of ramp gradients.
  19130. * You must use addRampGradient and removeRampGradient to udpate this list
  19131. * @returns the list of ramp gradients
  19132. */
  19133. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19134. /** Gets or sets a boolean indicating that ramp gradients must be used
  19135. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19136. */
  19137. useRampGradients: boolean;
  19138. /**
  19139. * Adds a new color remap gradient
  19140. * @param gradient defines the gradient to use (between 0 and 1)
  19141. * @param min defines the color remap minimal range
  19142. * @param max defines the color remap maximal range
  19143. * @returns the current particle system
  19144. */
  19145. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19146. /**
  19147. * Gets the current list of color remap gradients.
  19148. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19149. * @returns the list of color remap gradients
  19150. */
  19151. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new alpha remap gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param min defines the alpha remap minimal range
  19156. * @param max defines the alpha remap maximal range
  19157. * @returns the current particle system
  19158. */
  19159. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19160. /**
  19161. * Gets the current list of alpha remap gradients.
  19162. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19163. * @returns the list of alpha remap gradients
  19164. */
  19165. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19166. /**
  19167. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19168. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19169. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19170. * @returns the emitter
  19171. */
  19172. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19173. /**
  19174. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19175. * @param radius The radius of the hemisphere to emit from
  19176. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19177. * @returns the emitter
  19178. */
  19179. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19180. /**
  19181. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19182. * @param radius The radius of the sphere to emit from
  19183. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19184. * @returns the emitter
  19185. */
  19186. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19187. /**
  19188. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19189. * @param radius The radius of the sphere to emit from
  19190. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19191. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19192. * @returns the emitter
  19193. */
  19194. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19195. /**
  19196. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19197. * @param radius The radius of the emission cylinder
  19198. * @param height The height of the emission cylinder
  19199. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19200. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19201. * @returns the emitter
  19202. */
  19203. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19204. /**
  19205. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19206. * @param radius The radius of the cylinder to emit from
  19207. * @param height The height of the emission cylinder
  19208. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19209. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19210. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19211. * @returns the emitter
  19212. */
  19213. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19214. /**
  19215. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19216. * @param radius The radius of the cone to emit from
  19217. * @param angle The base angle of the cone
  19218. * @returns the emitter
  19219. */
  19220. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19221. /**
  19222. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19223. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19224. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19225. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19226. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19227. * @returns the emitter
  19228. */
  19229. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19230. /**
  19231. * Get hosting scene
  19232. * @returns the scene
  19233. */
  19234. getScene(): Scene;
  19235. }
  19236. }
  19237. declare module "babylonjs/Meshes/instancedMesh" {
  19238. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19240. import { Camera } from "babylonjs/Cameras/camera";
  19241. import { Node } from "babylonjs/node";
  19242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19243. import { Mesh } from "babylonjs/Meshes/mesh";
  19244. import { Material } from "babylonjs/Materials/material";
  19245. import { Skeleton } from "babylonjs/Bones/skeleton";
  19246. import { Light } from "babylonjs/Lights/light";
  19247. /**
  19248. * Creates an instance based on a source mesh.
  19249. */
  19250. export class InstancedMesh extends AbstractMesh {
  19251. private _sourceMesh;
  19252. private _currentLOD;
  19253. /** @hidden */
  19254. _indexInSourceMeshInstanceArray: number;
  19255. constructor(name: string, source: Mesh);
  19256. /**
  19257. * Returns the string "InstancedMesh".
  19258. */
  19259. getClassName(): string;
  19260. /** Gets the list of lights affecting that mesh */
  19261. readonly lightSources: Light[];
  19262. _resyncLightSources(): void;
  19263. _resyncLighSource(light: Light): void;
  19264. _removeLightSource(light: Light, dispose: boolean): void;
  19265. /**
  19266. * If the source mesh receives shadows
  19267. */
  19268. readonly receiveShadows: boolean;
  19269. /**
  19270. * The material of the source mesh
  19271. */
  19272. readonly material: Nullable<Material>;
  19273. /**
  19274. * Visibility of the source mesh
  19275. */
  19276. readonly visibility: number;
  19277. /**
  19278. * Skeleton of the source mesh
  19279. */
  19280. readonly skeleton: Nullable<Skeleton>;
  19281. /**
  19282. * Rendering ground id of the source mesh
  19283. */
  19284. renderingGroupId: number;
  19285. /**
  19286. * Returns the total number of vertices (integer).
  19287. */
  19288. getTotalVertices(): number;
  19289. /**
  19290. * Returns a positive integer : the total number of indices in this mesh geometry.
  19291. * @returns the numner of indices or zero if the mesh has no geometry.
  19292. */
  19293. getTotalIndices(): number;
  19294. /**
  19295. * The source mesh of the instance
  19296. */
  19297. readonly sourceMesh: Mesh;
  19298. /**
  19299. * Is this node ready to be used/rendered
  19300. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19301. * @return {boolean} is it ready
  19302. */
  19303. isReady(completeCheck?: boolean): boolean;
  19304. /**
  19305. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19306. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19307. * @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.
  19308. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19309. */
  19310. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19311. /**
  19312. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19313. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19314. * The `data` are either a numeric array either a Float32Array.
  19315. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19316. * 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).
  19317. * Note that a new underlying VertexBuffer object is created each call.
  19318. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19319. *
  19320. * Possible `kind` values :
  19321. * - VertexBuffer.PositionKind
  19322. * - VertexBuffer.UVKind
  19323. * - VertexBuffer.UV2Kind
  19324. * - VertexBuffer.UV3Kind
  19325. * - VertexBuffer.UV4Kind
  19326. * - VertexBuffer.UV5Kind
  19327. * - VertexBuffer.UV6Kind
  19328. * - VertexBuffer.ColorKind
  19329. * - VertexBuffer.MatricesIndicesKind
  19330. * - VertexBuffer.MatricesIndicesExtraKind
  19331. * - VertexBuffer.MatricesWeightsKind
  19332. * - VertexBuffer.MatricesWeightsExtraKind
  19333. *
  19334. * Returns the Mesh.
  19335. */
  19336. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19337. /**
  19338. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19339. * If the mesh has no geometry, it is simply returned as it is.
  19340. * The `data` are either a numeric array either a Float32Array.
  19341. * No new underlying VertexBuffer object is created.
  19342. * 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.
  19343. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19344. *
  19345. * Possible `kind` values :
  19346. * - VertexBuffer.PositionKind
  19347. * - VertexBuffer.UVKind
  19348. * - VertexBuffer.UV2Kind
  19349. * - VertexBuffer.UV3Kind
  19350. * - VertexBuffer.UV4Kind
  19351. * - VertexBuffer.UV5Kind
  19352. * - VertexBuffer.UV6Kind
  19353. * - VertexBuffer.ColorKind
  19354. * - VertexBuffer.MatricesIndicesKind
  19355. * - VertexBuffer.MatricesIndicesExtraKind
  19356. * - VertexBuffer.MatricesWeightsKind
  19357. * - VertexBuffer.MatricesWeightsExtraKind
  19358. *
  19359. * Returns the Mesh.
  19360. */
  19361. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19362. /**
  19363. * Sets the mesh indices.
  19364. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19365. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19366. * This method creates a new index buffer each call.
  19367. * Returns the Mesh.
  19368. */
  19369. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19370. /**
  19371. * Boolean : True if the mesh owns the requested kind of data.
  19372. */
  19373. isVerticesDataPresent(kind: string): boolean;
  19374. /**
  19375. * Returns an array of indices (IndicesArray).
  19376. */
  19377. getIndices(): Nullable<IndicesArray>;
  19378. readonly _positions: Nullable<Vector3[]>;
  19379. /**
  19380. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19381. * This means the mesh underlying bounding box and sphere are recomputed.
  19382. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19383. * @returns the current mesh
  19384. */
  19385. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19386. /** @hidden */
  19387. _preActivate(): InstancedMesh;
  19388. /** @hidden */
  19389. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19390. /** @hidden */
  19391. _postActivate(): void;
  19392. getWorldMatrix(): Matrix;
  19393. readonly isAnInstance: boolean;
  19394. /**
  19395. * Returns the current associated LOD AbstractMesh.
  19396. */
  19397. getLOD(camera: Camera): AbstractMesh;
  19398. /** @hidden */
  19399. _syncSubMeshes(): InstancedMesh;
  19400. /** @hidden */
  19401. _generatePointsArray(): boolean;
  19402. /**
  19403. * Creates a new InstancedMesh from the current mesh.
  19404. * - name (string) : the cloned mesh name
  19405. * - newParent (optional Node) : the optional Node to parent the clone to.
  19406. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19407. *
  19408. * Returns the clone.
  19409. */
  19410. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19411. /**
  19412. * Disposes the InstancedMesh.
  19413. * Returns nothing.
  19414. */
  19415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19416. }
  19417. }
  19418. declare module "babylonjs/Materials/shaderMaterial" {
  19419. import { Scene } from "babylonjs/scene";
  19420. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19422. import { Mesh } from "babylonjs/Meshes/mesh";
  19423. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19425. import { Texture } from "babylonjs/Materials/Textures/texture";
  19426. import { Material } from "babylonjs/Materials/material";
  19427. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19428. /**
  19429. * Defines the options associated with the creation of a shader material.
  19430. */
  19431. export interface IShaderMaterialOptions {
  19432. /**
  19433. * Does the material work in alpha blend mode
  19434. */
  19435. needAlphaBlending: boolean;
  19436. /**
  19437. * Does the material work in alpha test mode
  19438. */
  19439. needAlphaTesting: boolean;
  19440. /**
  19441. * The list of attribute names used in the shader
  19442. */
  19443. attributes: string[];
  19444. /**
  19445. * The list of unifrom names used in the shader
  19446. */
  19447. uniforms: string[];
  19448. /**
  19449. * The list of UBO names used in the shader
  19450. */
  19451. uniformBuffers: string[];
  19452. /**
  19453. * The list of sampler names used in the shader
  19454. */
  19455. samplers: string[];
  19456. /**
  19457. * The list of defines used in the shader
  19458. */
  19459. defines: string[];
  19460. }
  19461. /**
  19462. * 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.
  19463. *
  19464. * This returned material effects how the mesh will look based on the code in the shaders.
  19465. *
  19466. * @see http://doc.babylonjs.com/how_to/shader_material
  19467. */
  19468. export class ShaderMaterial extends Material {
  19469. private _shaderPath;
  19470. private _options;
  19471. private _textures;
  19472. private _textureArrays;
  19473. private _floats;
  19474. private _ints;
  19475. private _floatsArrays;
  19476. private _colors3;
  19477. private _colors3Arrays;
  19478. private _colors4;
  19479. private _colors4Arrays;
  19480. private _vectors2;
  19481. private _vectors3;
  19482. private _vectors4;
  19483. private _matrices;
  19484. private _matrices3x3;
  19485. private _matrices2x2;
  19486. private _vectors2Arrays;
  19487. private _vectors3Arrays;
  19488. private _vectors4Arrays;
  19489. private _cachedWorldViewMatrix;
  19490. private _cachedWorldViewProjectionMatrix;
  19491. private _renderId;
  19492. /**
  19493. * Instantiate a new shader material.
  19494. * 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.
  19495. * This returned material effects how the mesh will look based on the code in the shaders.
  19496. * @see http://doc.babylonjs.com/how_to/shader_material
  19497. * @param name Define the name of the material in the scene
  19498. * @param scene Define the scene the material belongs to
  19499. * @param shaderPath Defines the route to the shader code in one of three ways:
  19500. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19501. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19502. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19503. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19504. * @param options Define the options used to create the shader
  19505. */
  19506. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19507. /**
  19508. * Gets the options used to compile the shader.
  19509. * They can be modified to trigger a new compilation
  19510. */
  19511. readonly options: IShaderMaterialOptions;
  19512. /**
  19513. * Gets the current class name of the material e.g. "ShaderMaterial"
  19514. * Mainly use in serialization.
  19515. * @returns the class name
  19516. */
  19517. getClassName(): string;
  19518. /**
  19519. * Specifies if the material will require alpha blending
  19520. * @returns a boolean specifying if alpha blending is needed
  19521. */
  19522. needAlphaBlending(): boolean;
  19523. /**
  19524. * Specifies if this material should be rendered in alpha test mode
  19525. * @returns a boolean specifying if an alpha test is needed.
  19526. */
  19527. needAlphaTesting(): boolean;
  19528. private _checkUniform;
  19529. /**
  19530. * Set a texture in the shader.
  19531. * @param name Define the name of the uniform samplers as defined in the shader
  19532. * @param texture Define the texture to bind to this sampler
  19533. * @return the material itself allowing "fluent" like uniform updates
  19534. */
  19535. setTexture(name: string, texture: Texture): ShaderMaterial;
  19536. /**
  19537. * Set a texture array in the shader.
  19538. * @param name Define the name of the uniform sampler array as defined in the shader
  19539. * @param textures Define the list of textures to bind to this sampler
  19540. * @return the material itself allowing "fluent" like uniform updates
  19541. */
  19542. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19543. /**
  19544. * Set a float in the shader.
  19545. * @param name Define the name of the uniform as defined in the shader
  19546. * @param value Define the value to give to the uniform
  19547. * @return the material itself allowing "fluent" like uniform updates
  19548. */
  19549. setFloat(name: string, value: number): ShaderMaterial;
  19550. /**
  19551. * Set a int in the shader.
  19552. * @param name Define the name of the uniform as defined in the shader
  19553. * @param value Define the value to give to the uniform
  19554. * @return the material itself allowing "fluent" like uniform updates
  19555. */
  19556. setInt(name: string, value: number): ShaderMaterial;
  19557. /**
  19558. * Set an array of floats in the shader.
  19559. * @param name Define the name of the uniform as defined in the shader
  19560. * @param value Define the value to give to the uniform
  19561. * @return the material itself allowing "fluent" like uniform updates
  19562. */
  19563. setFloats(name: string, value: number[]): ShaderMaterial;
  19564. /**
  19565. * Set a vec3 in the shader from a Color3.
  19566. * @param name Define the name of the uniform as defined in the shader
  19567. * @param value Define the value to give to the uniform
  19568. * @return the material itself allowing "fluent" like uniform updates
  19569. */
  19570. setColor3(name: string, value: Color3): ShaderMaterial;
  19571. /**
  19572. * Set a vec3 array in the shader from a Color3 array.
  19573. * @param name Define the name of the uniform as defined in the shader
  19574. * @param value Define the value to give to the uniform
  19575. * @return the material itself allowing "fluent" like uniform updates
  19576. */
  19577. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19578. /**
  19579. * Set a vec4 in the shader from a Color4.
  19580. * @param name Define the name of the uniform as defined in the shader
  19581. * @param value Define the value to give to the uniform
  19582. * @return the material itself allowing "fluent" like uniform updates
  19583. */
  19584. setColor4(name: string, value: Color4): ShaderMaterial;
  19585. /**
  19586. * Set a vec4 array in the shader from a Color4 array.
  19587. * @param name Define the name of the uniform as defined in the shader
  19588. * @param value Define the value to give to the uniform
  19589. * @return the material itself allowing "fluent" like uniform updates
  19590. */
  19591. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19592. /**
  19593. * Set a vec2 in the shader from a Vector2.
  19594. * @param name Define the name of the uniform as defined in the shader
  19595. * @param value Define the value to give to the uniform
  19596. * @return the material itself allowing "fluent" like uniform updates
  19597. */
  19598. setVector2(name: string, value: Vector2): ShaderMaterial;
  19599. /**
  19600. * Set a vec3 in the shader from a Vector3.
  19601. * @param name Define the name of the uniform as defined in the shader
  19602. * @param value Define the value to give to the uniform
  19603. * @return the material itself allowing "fluent" like uniform updates
  19604. */
  19605. setVector3(name: string, value: Vector3): ShaderMaterial;
  19606. /**
  19607. * Set a vec4 in the shader from a Vector4.
  19608. * @param name Define the name of the uniform as defined in the shader
  19609. * @param value Define the value to give to the uniform
  19610. * @return the material itself allowing "fluent" like uniform updates
  19611. */
  19612. setVector4(name: string, value: Vector4): ShaderMaterial;
  19613. /**
  19614. * Set a mat4 in the shader from a Matrix.
  19615. * @param name Define the name of the uniform as defined in the shader
  19616. * @param value Define the value to give to the uniform
  19617. * @return the material itself allowing "fluent" like uniform updates
  19618. */
  19619. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19620. /**
  19621. * Set a mat3 in the shader from a Float32Array.
  19622. * @param name Define the name of the uniform as defined in the shader
  19623. * @param value Define the value to give to the uniform
  19624. * @return the material itself allowing "fluent" like uniform updates
  19625. */
  19626. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19627. /**
  19628. * Set a mat2 in the shader from a Float32Array.
  19629. * @param name Define the name of the uniform as defined in the shader
  19630. * @param value Define the value to give to the uniform
  19631. * @return the material itself allowing "fluent" like uniform updates
  19632. */
  19633. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19634. /**
  19635. * Set a vec2 array in the shader from a number array.
  19636. * @param name Define the name of the uniform as defined in the shader
  19637. * @param value Define the value to give to the uniform
  19638. * @return the material itself allowing "fluent" like uniform updates
  19639. */
  19640. setArray2(name: string, value: number[]): ShaderMaterial;
  19641. /**
  19642. * Set a vec3 array in the shader from a number array.
  19643. * @param name Define the name of the uniform as defined in the shader
  19644. * @param value Define the value to give to the uniform
  19645. * @return the material itself allowing "fluent" like uniform updates
  19646. */
  19647. setArray3(name: string, value: number[]): ShaderMaterial;
  19648. /**
  19649. * Set a vec4 array in the shader from a number array.
  19650. * @param name Define the name of the uniform as defined in the shader
  19651. * @param value Define the value to give to the uniform
  19652. * @return the material itself allowing "fluent" like uniform updates
  19653. */
  19654. setArray4(name: string, value: number[]): ShaderMaterial;
  19655. private _checkCache;
  19656. /**
  19657. * Specifies that the submesh is ready to be used
  19658. * @param mesh defines the mesh to check
  19659. * @param subMesh defines which submesh to check
  19660. * @param useInstances specifies that instances should be used
  19661. * @returns a boolean indicating that the submesh is ready or not
  19662. */
  19663. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19664. /**
  19665. * Checks if the material is ready to render the requested mesh
  19666. * @param mesh Define the mesh to render
  19667. * @param useInstances Define whether or not the material is used with instances
  19668. * @returns true if ready, otherwise false
  19669. */
  19670. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19671. /**
  19672. * Binds the world matrix to the material
  19673. * @param world defines the world transformation matrix
  19674. */
  19675. bindOnlyWorldMatrix(world: Matrix): void;
  19676. /**
  19677. * Binds the material to the mesh
  19678. * @param world defines the world transformation matrix
  19679. * @param mesh defines the mesh to bind the material to
  19680. */
  19681. bind(world: Matrix, mesh?: Mesh): void;
  19682. /**
  19683. * Gets the active textures from the material
  19684. * @returns an array of textures
  19685. */
  19686. getActiveTextures(): BaseTexture[];
  19687. /**
  19688. * Specifies if the material uses a texture
  19689. * @param texture defines the texture to check against the material
  19690. * @returns a boolean specifying if the material uses the texture
  19691. */
  19692. hasTexture(texture: BaseTexture): boolean;
  19693. /**
  19694. * Makes a duplicate of the material, and gives it a new name
  19695. * @param name defines the new name for the duplicated material
  19696. * @returns the cloned material
  19697. */
  19698. clone(name: string): ShaderMaterial;
  19699. /**
  19700. * Disposes the material
  19701. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19702. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19703. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19704. */
  19705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19706. /**
  19707. * Serializes this material in a JSON representation
  19708. * @returns the serialized material object
  19709. */
  19710. serialize(): any;
  19711. /**
  19712. * Creates a shader material from parsed shader material data
  19713. * @param source defines the JSON represnetation of the material
  19714. * @param scene defines the hosting scene
  19715. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19716. * @returns a new material
  19717. */
  19718. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19719. }
  19720. }
  19721. declare module "babylonjs/Shaders/color.fragment" {
  19722. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19723. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19724. /** @hidden */
  19725. export var colorPixelShader: {
  19726. name: string;
  19727. shader: string;
  19728. };
  19729. }
  19730. declare module "babylonjs/Shaders/color.vertex" {
  19731. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19733. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19734. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19735. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19736. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19737. /** @hidden */
  19738. export var colorVertexShader: {
  19739. name: string;
  19740. shader: string;
  19741. };
  19742. }
  19743. declare module "babylonjs/Meshes/linesMesh" {
  19744. import { Nullable } from "babylonjs/types";
  19745. import { Scene } from "babylonjs/scene";
  19746. import { Color3 } from "babylonjs/Maths/math.color";
  19747. import { Node } from "babylonjs/node";
  19748. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19749. import { Mesh } from "babylonjs/Meshes/mesh";
  19750. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19751. import { Effect } from "babylonjs/Materials/effect";
  19752. import { Material } from "babylonjs/Materials/material";
  19753. import "babylonjs/Shaders/color.fragment";
  19754. import "babylonjs/Shaders/color.vertex";
  19755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19756. /**
  19757. * Line mesh
  19758. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19759. */
  19760. export class LinesMesh extends Mesh {
  19761. /**
  19762. * If vertex color should be applied to the mesh
  19763. */
  19764. readonly useVertexColor?: boolean | undefined;
  19765. /**
  19766. * If vertex alpha should be applied to the mesh
  19767. */
  19768. readonly useVertexAlpha?: boolean | undefined;
  19769. /**
  19770. * Color of the line (Default: White)
  19771. */
  19772. color: Color3;
  19773. /**
  19774. * Alpha of the line (Default: 1)
  19775. */
  19776. alpha: number;
  19777. /**
  19778. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19779. * This margin is expressed in world space coordinates, so its value may vary.
  19780. * Default value is 0.1
  19781. */
  19782. intersectionThreshold: number;
  19783. private _colorShader;
  19784. private color4;
  19785. /**
  19786. * Creates a new LinesMesh
  19787. * @param name defines the name
  19788. * @param scene defines the hosting scene
  19789. * @param parent defines the parent mesh if any
  19790. * @param source defines the optional source LinesMesh used to clone data from
  19791. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19792. * When false, achieved by calling a clone(), also passing False.
  19793. * This will make creation of children, recursive.
  19794. * @param useVertexColor defines if this LinesMesh supports vertex color
  19795. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19796. */
  19797. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19798. /**
  19799. * If vertex color should be applied to the mesh
  19800. */
  19801. useVertexColor?: boolean | undefined,
  19802. /**
  19803. * If vertex alpha should be applied to the mesh
  19804. */
  19805. useVertexAlpha?: boolean | undefined);
  19806. private _addClipPlaneDefine;
  19807. private _removeClipPlaneDefine;
  19808. isReady(): boolean;
  19809. /**
  19810. * Returns the string "LineMesh"
  19811. */
  19812. getClassName(): string;
  19813. /**
  19814. * @hidden
  19815. */
  19816. /**
  19817. * @hidden
  19818. */
  19819. material: Material;
  19820. /**
  19821. * @hidden
  19822. */
  19823. readonly checkCollisions: boolean;
  19824. /** @hidden */
  19825. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19826. /** @hidden */
  19827. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19828. /**
  19829. * Disposes of the line mesh
  19830. * @param doNotRecurse If children should be disposed
  19831. */
  19832. dispose(doNotRecurse?: boolean): void;
  19833. /**
  19834. * Returns a new LineMesh object cloned from the current one.
  19835. */
  19836. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19837. /**
  19838. * Creates a new InstancedLinesMesh object from the mesh model.
  19839. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19840. * @param name defines the name of the new instance
  19841. * @returns a new InstancedLinesMesh
  19842. */
  19843. createInstance(name: string): InstancedLinesMesh;
  19844. }
  19845. /**
  19846. * Creates an instance based on a source LinesMesh
  19847. */
  19848. export class InstancedLinesMesh extends InstancedMesh {
  19849. /**
  19850. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19851. * This margin is expressed in world space coordinates, so its value may vary.
  19852. * Initilized with the intersectionThreshold value of the source LinesMesh
  19853. */
  19854. intersectionThreshold: number;
  19855. constructor(name: string, source: LinesMesh);
  19856. /**
  19857. * Returns the string "InstancedLinesMesh".
  19858. */
  19859. getClassName(): string;
  19860. }
  19861. }
  19862. declare module "babylonjs/Shaders/line.fragment" {
  19863. /** @hidden */
  19864. export var linePixelShader: {
  19865. name: string;
  19866. shader: string;
  19867. };
  19868. }
  19869. declare module "babylonjs/Shaders/line.vertex" {
  19870. /** @hidden */
  19871. export var lineVertexShader: {
  19872. name: string;
  19873. shader: string;
  19874. };
  19875. }
  19876. declare module "babylonjs/Rendering/edgesRenderer" {
  19877. import { Nullable } from "babylonjs/types";
  19878. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19880. import { Vector3 } from "babylonjs/Maths/math.vector";
  19881. import { IDisposable } from "babylonjs/scene";
  19882. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19883. import "babylonjs/Shaders/line.fragment";
  19884. import "babylonjs/Shaders/line.vertex";
  19885. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19886. module "babylonjs/Meshes/abstractMesh" {
  19887. interface AbstractMesh {
  19888. /**
  19889. * Gets the edgesRenderer associated with the mesh
  19890. */
  19891. edgesRenderer: Nullable<EdgesRenderer>;
  19892. }
  19893. }
  19894. module "babylonjs/Meshes/linesMesh" {
  19895. interface LinesMesh {
  19896. /**
  19897. * Enables the edge rendering mode on the mesh.
  19898. * This mode makes the mesh edges visible
  19899. * @param epsilon defines the maximal distance between two angles to detect a face
  19900. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19901. * @returns the currentAbstractMesh
  19902. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19903. */
  19904. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19905. }
  19906. }
  19907. module "babylonjs/Meshes/linesMesh" {
  19908. interface InstancedLinesMesh {
  19909. /**
  19910. * Enables the edge rendering mode on the mesh.
  19911. * This mode makes the mesh edges visible
  19912. * @param epsilon defines the maximal distance between two angles to detect a face
  19913. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19914. * @returns the current InstancedLinesMesh
  19915. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19916. */
  19917. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19918. }
  19919. }
  19920. /**
  19921. * Defines the minimum contract an Edges renderer should follow.
  19922. */
  19923. export interface IEdgesRenderer extends IDisposable {
  19924. /**
  19925. * Gets or sets a boolean indicating if the edgesRenderer is active
  19926. */
  19927. isEnabled: boolean;
  19928. /**
  19929. * Renders the edges of the attached mesh,
  19930. */
  19931. render(): void;
  19932. /**
  19933. * Checks wether or not the edges renderer is ready to render.
  19934. * @return true if ready, otherwise false.
  19935. */
  19936. isReady(): boolean;
  19937. }
  19938. /**
  19939. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19940. */
  19941. export class EdgesRenderer implements IEdgesRenderer {
  19942. /**
  19943. * Define the size of the edges with an orthographic camera
  19944. */
  19945. edgesWidthScalerForOrthographic: number;
  19946. /**
  19947. * Define the size of the edges with a perspective camera
  19948. */
  19949. edgesWidthScalerForPerspective: number;
  19950. protected _source: AbstractMesh;
  19951. protected _linesPositions: number[];
  19952. protected _linesNormals: number[];
  19953. protected _linesIndices: number[];
  19954. protected _epsilon: number;
  19955. protected _indicesCount: number;
  19956. protected _lineShader: ShaderMaterial;
  19957. protected _ib: DataBuffer;
  19958. protected _buffers: {
  19959. [key: string]: Nullable<VertexBuffer>;
  19960. };
  19961. protected _checkVerticesInsteadOfIndices: boolean;
  19962. private _meshRebuildObserver;
  19963. private _meshDisposeObserver;
  19964. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19965. isEnabled: boolean;
  19966. /**
  19967. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19968. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19969. * @param source Mesh used to create edges
  19970. * @param epsilon sum of angles in adjacency to check for edge
  19971. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19972. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19973. */
  19974. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19975. protected _prepareRessources(): void;
  19976. /** @hidden */
  19977. _rebuild(): void;
  19978. /**
  19979. * Releases the required resources for the edges renderer
  19980. */
  19981. dispose(): void;
  19982. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19983. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19984. /**
  19985. * Checks if the pair of p0 and p1 is en edge
  19986. * @param faceIndex
  19987. * @param edge
  19988. * @param faceNormals
  19989. * @param p0
  19990. * @param p1
  19991. * @private
  19992. */
  19993. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19994. /**
  19995. * push line into the position, normal and index buffer
  19996. * @protected
  19997. */
  19998. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19999. /**
  20000. * Generates lines edges from adjacencjes
  20001. * @private
  20002. */
  20003. _generateEdgesLines(): void;
  20004. /**
  20005. * Checks wether or not the edges renderer is ready to render.
  20006. * @return true if ready, otherwise false.
  20007. */
  20008. isReady(): boolean;
  20009. /**
  20010. * Renders the edges of the attached mesh,
  20011. */
  20012. render(): void;
  20013. }
  20014. /**
  20015. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20016. */
  20017. export class LineEdgesRenderer extends EdgesRenderer {
  20018. /**
  20019. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20020. * @param source LineMesh used to generate edges
  20021. * @param epsilon not important (specified angle for edge detection)
  20022. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20023. */
  20024. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20025. /**
  20026. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20027. */
  20028. _generateEdgesLines(): void;
  20029. }
  20030. }
  20031. declare module "babylonjs/Rendering/renderingGroup" {
  20032. import { SmartArray } from "babylonjs/Misc/smartArray";
  20033. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20035. import { Nullable } from "babylonjs/types";
  20036. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20037. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20038. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20039. import { Material } from "babylonjs/Materials/material";
  20040. import { Scene } from "babylonjs/scene";
  20041. /**
  20042. * This represents the object necessary to create a rendering group.
  20043. * This is exclusively used and created by the rendering manager.
  20044. * To modify the behavior, you use the available helpers in your scene or meshes.
  20045. * @hidden
  20046. */
  20047. export class RenderingGroup {
  20048. index: number;
  20049. private static _zeroVector;
  20050. private _scene;
  20051. private _opaqueSubMeshes;
  20052. private _transparentSubMeshes;
  20053. private _alphaTestSubMeshes;
  20054. private _depthOnlySubMeshes;
  20055. private _particleSystems;
  20056. private _spriteManagers;
  20057. private _opaqueSortCompareFn;
  20058. private _alphaTestSortCompareFn;
  20059. private _transparentSortCompareFn;
  20060. private _renderOpaque;
  20061. private _renderAlphaTest;
  20062. private _renderTransparent;
  20063. /** @hidden */
  20064. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20065. onBeforeTransparentRendering: () => void;
  20066. /**
  20067. * Set the opaque sort comparison function.
  20068. * If null the sub meshes will be render in the order they were created
  20069. */
  20070. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20071. /**
  20072. * Set the alpha test sort comparison function.
  20073. * If null the sub meshes will be render in the order they were created
  20074. */
  20075. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20076. /**
  20077. * Set the transparent sort comparison function.
  20078. * If null the sub meshes will be render in the order they were created
  20079. */
  20080. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20081. /**
  20082. * Creates a new rendering group.
  20083. * @param index The rendering group index
  20084. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20085. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20086. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20087. */
  20088. 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>);
  20089. /**
  20090. * Render all the sub meshes contained in the group.
  20091. * @param customRenderFunction Used to override the default render behaviour of the group.
  20092. * @returns true if rendered some submeshes.
  20093. */
  20094. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20095. /**
  20096. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20097. * @param subMeshes The submeshes to render
  20098. */
  20099. private renderOpaqueSorted;
  20100. /**
  20101. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20102. * @param subMeshes The submeshes to render
  20103. */
  20104. private renderAlphaTestSorted;
  20105. /**
  20106. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20107. * @param subMeshes The submeshes to render
  20108. */
  20109. private renderTransparentSorted;
  20110. /**
  20111. * Renders the submeshes in a specified order.
  20112. * @param subMeshes The submeshes to sort before render
  20113. * @param sortCompareFn The comparison function use to sort
  20114. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20115. * @param transparent Specifies to activate blending if true
  20116. */
  20117. private static renderSorted;
  20118. /**
  20119. * Renders the submeshes in the order they were dispatched (no sort applied).
  20120. * @param subMeshes The submeshes to render
  20121. */
  20122. private static renderUnsorted;
  20123. /**
  20124. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20125. * are rendered back to front if in the same alpha index.
  20126. *
  20127. * @param a The first submesh
  20128. * @param b The second submesh
  20129. * @returns The result of the comparison
  20130. */
  20131. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20132. /**
  20133. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20134. * are rendered back to front.
  20135. *
  20136. * @param a The first submesh
  20137. * @param b The second submesh
  20138. * @returns The result of the comparison
  20139. */
  20140. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20141. /**
  20142. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20143. * are rendered front to back (prevent overdraw).
  20144. *
  20145. * @param a The first submesh
  20146. * @param b The second submesh
  20147. * @returns The result of the comparison
  20148. */
  20149. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20150. /**
  20151. * Resets the different lists of submeshes to prepare a new frame.
  20152. */
  20153. prepare(): void;
  20154. dispose(): void;
  20155. /**
  20156. * Inserts the submesh in its correct queue depending on its material.
  20157. * @param subMesh The submesh to dispatch
  20158. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20159. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20160. */
  20161. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20162. dispatchSprites(spriteManager: ISpriteManager): void;
  20163. dispatchParticles(particleSystem: IParticleSystem): void;
  20164. private _renderParticles;
  20165. private _renderSprites;
  20166. }
  20167. }
  20168. declare module "babylonjs/Rendering/renderingManager" {
  20169. import { Nullable } from "babylonjs/types";
  20170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20172. import { SmartArray } from "babylonjs/Misc/smartArray";
  20173. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20174. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20175. import { Material } from "babylonjs/Materials/material";
  20176. import { Scene } from "babylonjs/scene";
  20177. import { Camera } from "babylonjs/Cameras/camera";
  20178. /**
  20179. * Interface describing the different options available in the rendering manager
  20180. * regarding Auto Clear between groups.
  20181. */
  20182. export interface IRenderingManagerAutoClearSetup {
  20183. /**
  20184. * Defines whether or not autoclear is enable.
  20185. */
  20186. autoClear: boolean;
  20187. /**
  20188. * Defines whether or not to autoclear the depth buffer.
  20189. */
  20190. depth: boolean;
  20191. /**
  20192. * Defines whether or not to autoclear the stencil buffer.
  20193. */
  20194. stencil: boolean;
  20195. }
  20196. /**
  20197. * This class is used by the onRenderingGroupObservable
  20198. */
  20199. export class RenderingGroupInfo {
  20200. /**
  20201. * The Scene that being rendered
  20202. */
  20203. scene: Scene;
  20204. /**
  20205. * The camera currently used for the rendering pass
  20206. */
  20207. camera: Nullable<Camera>;
  20208. /**
  20209. * The ID of the renderingGroup being processed
  20210. */
  20211. renderingGroupId: number;
  20212. }
  20213. /**
  20214. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20215. * It is enable to manage the different groups as well as the different necessary sort functions.
  20216. * This should not be used directly aside of the few static configurations
  20217. */
  20218. export class RenderingManager {
  20219. /**
  20220. * The max id used for rendering groups (not included)
  20221. */
  20222. static MAX_RENDERINGGROUPS: number;
  20223. /**
  20224. * The min id used for rendering groups (included)
  20225. */
  20226. static MIN_RENDERINGGROUPS: number;
  20227. /**
  20228. * Used to globally prevent autoclearing scenes.
  20229. */
  20230. static AUTOCLEAR: boolean;
  20231. /**
  20232. * @hidden
  20233. */
  20234. _useSceneAutoClearSetup: boolean;
  20235. private _scene;
  20236. private _renderingGroups;
  20237. private _depthStencilBufferAlreadyCleaned;
  20238. private _autoClearDepthStencil;
  20239. private _customOpaqueSortCompareFn;
  20240. private _customAlphaTestSortCompareFn;
  20241. private _customTransparentSortCompareFn;
  20242. private _renderingGroupInfo;
  20243. /**
  20244. * Instantiates a new rendering group for a particular scene
  20245. * @param scene Defines the scene the groups belongs to
  20246. */
  20247. constructor(scene: Scene);
  20248. private _clearDepthStencilBuffer;
  20249. /**
  20250. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20251. * @hidden
  20252. */
  20253. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20254. /**
  20255. * Resets the different information of the group to prepare a new frame
  20256. * @hidden
  20257. */
  20258. reset(): void;
  20259. /**
  20260. * Dispose and release the group and its associated resources.
  20261. * @hidden
  20262. */
  20263. dispose(): void;
  20264. /**
  20265. * Clear the info related to rendering groups preventing retention points during dispose.
  20266. */
  20267. freeRenderingGroups(): void;
  20268. private _prepareRenderingGroup;
  20269. /**
  20270. * Add a sprite manager to the rendering manager in order to render it this frame.
  20271. * @param spriteManager Define the sprite manager to render
  20272. */
  20273. dispatchSprites(spriteManager: ISpriteManager): void;
  20274. /**
  20275. * Add a particle system to the rendering manager in order to render it this frame.
  20276. * @param particleSystem Define the particle system to render
  20277. */
  20278. dispatchParticles(particleSystem: IParticleSystem): void;
  20279. /**
  20280. * Add a submesh to the manager in order to render it this frame
  20281. * @param subMesh The submesh to dispatch
  20282. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20283. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20284. */
  20285. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20286. /**
  20287. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20288. * This allowed control for front to back rendering or reversly depending of the special needs.
  20289. *
  20290. * @param renderingGroupId The rendering group id corresponding to its index
  20291. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20292. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20293. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20294. */
  20295. 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;
  20296. /**
  20297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20298. *
  20299. * @param renderingGroupId The rendering group id corresponding to its index
  20300. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20301. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20302. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20303. */
  20304. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20305. /**
  20306. * Gets the current auto clear configuration for one rendering group of the rendering
  20307. * manager.
  20308. * @param index the rendering group index to get the information for
  20309. * @returns The auto clear setup for the requested rendering group
  20310. */
  20311. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20312. }
  20313. }
  20314. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20315. import { Observable } from "babylonjs/Misc/observable";
  20316. import { SmartArray } from "babylonjs/Misc/smartArray";
  20317. import { Nullable } from "babylonjs/types";
  20318. import { Camera } from "babylonjs/Cameras/camera";
  20319. import { Scene } from "babylonjs/scene";
  20320. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20321. import { Color4 } from "babylonjs/Maths/math.color";
  20322. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20326. import { Texture } from "babylonjs/Materials/Textures/texture";
  20327. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20328. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20329. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20330. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20331. import { Engine } from "babylonjs/Engines/engine";
  20332. /**
  20333. * This Helps creating a texture that will be created from a camera in your scene.
  20334. * It is basically a dynamic texture that could be used to create special effects for instance.
  20335. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20336. */
  20337. export class RenderTargetTexture extends Texture {
  20338. isCube: boolean;
  20339. /**
  20340. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20341. */
  20342. static readonly REFRESHRATE_RENDER_ONCE: number;
  20343. /**
  20344. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20345. */
  20346. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20347. /**
  20348. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20349. * the central point of your effect and can save a lot of performances.
  20350. */
  20351. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20352. /**
  20353. * Use this predicate to dynamically define the list of mesh you want to render.
  20354. * If set, the renderList property will be overwritten.
  20355. */
  20356. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20357. private _renderList;
  20358. /**
  20359. * Use this list to define the list of mesh you want to render.
  20360. */
  20361. renderList: Nullable<Array<AbstractMesh>>;
  20362. private _hookArray;
  20363. /**
  20364. * Define if particles should be rendered in your texture.
  20365. */
  20366. renderParticles: boolean;
  20367. /**
  20368. * Define if sprites should be rendered in your texture.
  20369. */
  20370. renderSprites: boolean;
  20371. /**
  20372. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20373. */
  20374. coordinatesMode: number;
  20375. /**
  20376. * Define the camera used to render the texture.
  20377. */
  20378. activeCamera: Nullable<Camera>;
  20379. /**
  20380. * Override the render function of the texture with your own one.
  20381. */
  20382. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20383. /**
  20384. * Define if camera post processes should be use while rendering the texture.
  20385. */
  20386. useCameraPostProcesses: boolean;
  20387. /**
  20388. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20389. */
  20390. ignoreCameraViewport: boolean;
  20391. private _postProcessManager;
  20392. private _postProcesses;
  20393. private _resizeObserver;
  20394. /**
  20395. * An event triggered when the texture is unbind.
  20396. */
  20397. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20398. /**
  20399. * An event triggered when the texture is unbind.
  20400. */
  20401. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20402. private _onAfterUnbindObserver;
  20403. /**
  20404. * Set a after unbind callback in the texture.
  20405. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20406. */
  20407. onAfterUnbind: () => void;
  20408. /**
  20409. * An event triggered before rendering the texture
  20410. */
  20411. onBeforeRenderObservable: Observable<number>;
  20412. private _onBeforeRenderObserver;
  20413. /**
  20414. * Set a before render callback in the texture.
  20415. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20416. */
  20417. onBeforeRender: (faceIndex: number) => void;
  20418. /**
  20419. * An event triggered after rendering the texture
  20420. */
  20421. onAfterRenderObservable: Observable<number>;
  20422. private _onAfterRenderObserver;
  20423. /**
  20424. * Set a after render callback in the texture.
  20425. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20426. */
  20427. onAfterRender: (faceIndex: number) => void;
  20428. /**
  20429. * An event triggered after the texture clear
  20430. */
  20431. onClearObservable: Observable<Engine>;
  20432. private _onClearObserver;
  20433. /**
  20434. * Set a clear callback in the texture.
  20435. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20436. */
  20437. onClear: (Engine: Engine) => void;
  20438. /**
  20439. * An event triggered when the texture is resized.
  20440. */
  20441. onResizeObservable: Observable<RenderTargetTexture>;
  20442. /**
  20443. * Define the clear color of the Render Target if it should be different from the scene.
  20444. */
  20445. clearColor: Color4;
  20446. protected _size: number | {
  20447. width: number;
  20448. height: number;
  20449. };
  20450. protected _initialSizeParameter: number | {
  20451. width: number;
  20452. height: number;
  20453. } | {
  20454. ratio: number;
  20455. };
  20456. protected _sizeRatio: Nullable<number>;
  20457. /** @hidden */
  20458. _generateMipMaps: boolean;
  20459. protected _renderingManager: RenderingManager;
  20460. /** @hidden */
  20461. _waitingRenderList: string[];
  20462. protected _doNotChangeAspectRatio: boolean;
  20463. protected _currentRefreshId: number;
  20464. protected _refreshRate: number;
  20465. protected _textureMatrix: Matrix;
  20466. protected _samples: number;
  20467. protected _renderTargetOptions: RenderTargetCreationOptions;
  20468. /**
  20469. * Gets render target creation options that were used.
  20470. */
  20471. readonly renderTargetOptions: RenderTargetCreationOptions;
  20472. protected _engine: Engine;
  20473. protected _onRatioRescale(): void;
  20474. /**
  20475. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20476. * It must define where the camera used to render the texture is set
  20477. */
  20478. boundingBoxPosition: Vector3;
  20479. private _boundingBoxSize;
  20480. /**
  20481. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20482. * When defined, the cubemap will switch to local mode
  20483. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20484. * @example https://www.babylonjs-playground.com/#RNASML
  20485. */
  20486. boundingBoxSize: Vector3;
  20487. /**
  20488. * In case the RTT has been created with a depth texture, get the associated
  20489. * depth texture.
  20490. * Otherwise, return null.
  20491. */
  20492. depthStencilTexture: Nullable<InternalTexture>;
  20493. /**
  20494. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20495. * or used a shadow, depth texture...
  20496. * @param name The friendly name of the texture
  20497. * @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)
  20498. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20499. * @param generateMipMaps True if mip maps need to be generated after render.
  20500. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20501. * @param type The type of the buffer in the RTT (int, half float, float...)
  20502. * @param isCube True if a cube texture needs to be created
  20503. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20504. * @param generateDepthBuffer True to generate a depth buffer
  20505. * @param generateStencilBuffer True to generate a stencil buffer
  20506. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20507. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20508. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20509. */
  20510. constructor(name: string, size: number | {
  20511. width: number;
  20512. height: number;
  20513. } | {
  20514. ratio: number;
  20515. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20516. /**
  20517. * Creates a depth stencil texture.
  20518. * This is only available in WebGL 2 or with the depth texture extension available.
  20519. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20520. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20521. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20522. */
  20523. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20524. private _processSizeParameter;
  20525. /**
  20526. * Define the number of samples to use in case of MSAA.
  20527. * It defaults to one meaning no MSAA has been enabled.
  20528. */
  20529. samples: number;
  20530. /**
  20531. * Resets the refresh counter of the texture and start bak from scratch.
  20532. * Could be useful to regenerate the texture if it is setup to render only once.
  20533. */
  20534. resetRefreshCounter(): void;
  20535. /**
  20536. * Define the refresh rate of the texture or the rendering frequency.
  20537. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20538. */
  20539. refreshRate: number;
  20540. /**
  20541. * Adds a post process to the render target rendering passes.
  20542. * @param postProcess define the post process to add
  20543. */
  20544. addPostProcess(postProcess: PostProcess): void;
  20545. /**
  20546. * Clear all the post processes attached to the render target
  20547. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20548. */
  20549. clearPostProcesses(dispose?: boolean): void;
  20550. /**
  20551. * Remove one of the post process from the list of attached post processes to the texture
  20552. * @param postProcess define the post process to remove from the list
  20553. */
  20554. removePostProcess(postProcess: PostProcess): void;
  20555. /** @hidden */
  20556. _shouldRender(): boolean;
  20557. /**
  20558. * Gets the actual render size of the texture.
  20559. * @returns the width of the render size
  20560. */
  20561. getRenderSize(): number;
  20562. /**
  20563. * Gets the actual render width of the texture.
  20564. * @returns the width of the render size
  20565. */
  20566. getRenderWidth(): number;
  20567. /**
  20568. * Gets the actual render height of the texture.
  20569. * @returns the height of the render size
  20570. */
  20571. getRenderHeight(): number;
  20572. /**
  20573. * Get if the texture can be rescaled or not.
  20574. */
  20575. readonly canRescale: boolean;
  20576. /**
  20577. * Resize the texture using a ratio.
  20578. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20579. */
  20580. scale(ratio: number): void;
  20581. /**
  20582. * Get the texture reflection matrix used to rotate/transform the reflection.
  20583. * @returns the reflection matrix
  20584. */
  20585. getReflectionTextureMatrix(): Matrix;
  20586. /**
  20587. * Resize the texture to a new desired size.
  20588. * Be carrefull as it will recreate all the data in the new texture.
  20589. * @param size Define the new size. It can be:
  20590. * - a number for squared texture,
  20591. * - an object containing { width: number, height: number }
  20592. * - or an object containing a ratio { ratio: number }
  20593. */
  20594. resize(size: number | {
  20595. width: number;
  20596. height: number;
  20597. } | {
  20598. ratio: number;
  20599. }): void;
  20600. /**
  20601. * Renders all the objects from the render list into the texture.
  20602. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20603. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20604. */
  20605. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20606. private _bestReflectionRenderTargetDimension;
  20607. /**
  20608. * @hidden
  20609. * @param faceIndex face index to bind to if this is a cubetexture
  20610. */
  20611. _bindFrameBuffer(faceIndex?: number): void;
  20612. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20613. private renderToTarget;
  20614. /**
  20615. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20616. * This allowed control for front to back rendering or reversly depending of the special needs.
  20617. *
  20618. * @param renderingGroupId The rendering group id corresponding to its index
  20619. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20620. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20621. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20622. */
  20623. 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;
  20624. /**
  20625. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20626. *
  20627. * @param renderingGroupId The rendering group id corresponding to its index
  20628. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20629. */
  20630. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20631. /**
  20632. * Clones the texture.
  20633. * @returns the cloned texture
  20634. */
  20635. clone(): RenderTargetTexture;
  20636. /**
  20637. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20638. * @returns The JSON representation of the texture
  20639. */
  20640. serialize(): any;
  20641. /**
  20642. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20643. */
  20644. disposeFramebufferObjects(): void;
  20645. /**
  20646. * Dispose the texture and release its associated resources.
  20647. */
  20648. dispose(): void;
  20649. /** @hidden */
  20650. _rebuild(): void;
  20651. /**
  20652. * Clear the info related to rendering groups preventing retention point in material dispose.
  20653. */
  20654. freeRenderingGroups(): void;
  20655. /**
  20656. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20657. * @returns the view count
  20658. */
  20659. getViewCount(): number;
  20660. }
  20661. }
  20662. declare module "babylonjs/Materials/material" {
  20663. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20664. import { SmartArray } from "babylonjs/Misc/smartArray";
  20665. import { Observable } from "babylonjs/Misc/observable";
  20666. import { Nullable } from "babylonjs/types";
  20667. import { Scene } from "babylonjs/scene";
  20668. import { Matrix } from "babylonjs/Maths/math.vector";
  20669. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20671. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20672. import { Effect } from "babylonjs/Materials/effect";
  20673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20674. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20675. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20676. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20677. import { Mesh } from "babylonjs/Meshes/mesh";
  20678. import { Animation } from "babylonjs/Animations/animation";
  20679. /**
  20680. * Base class for the main features of a material in Babylon.js
  20681. */
  20682. export class Material implements IAnimatable {
  20683. /**
  20684. * Returns the triangle fill mode
  20685. */
  20686. static readonly TriangleFillMode: number;
  20687. /**
  20688. * Returns the wireframe mode
  20689. */
  20690. static readonly WireFrameFillMode: number;
  20691. /**
  20692. * Returns the point fill mode
  20693. */
  20694. static readonly PointFillMode: number;
  20695. /**
  20696. * Returns the point list draw mode
  20697. */
  20698. static readonly PointListDrawMode: number;
  20699. /**
  20700. * Returns the line list draw mode
  20701. */
  20702. static readonly LineListDrawMode: number;
  20703. /**
  20704. * Returns the line loop draw mode
  20705. */
  20706. static readonly LineLoopDrawMode: number;
  20707. /**
  20708. * Returns the line strip draw mode
  20709. */
  20710. static readonly LineStripDrawMode: number;
  20711. /**
  20712. * Returns the triangle strip draw mode
  20713. */
  20714. static readonly TriangleStripDrawMode: number;
  20715. /**
  20716. * Returns the triangle fan draw mode
  20717. */
  20718. static readonly TriangleFanDrawMode: number;
  20719. /**
  20720. * Stores the clock-wise side orientation
  20721. */
  20722. static readonly ClockWiseSideOrientation: number;
  20723. /**
  20724. * Stores the counter clock-wise side orientation
  20725. */
  20726. static readonly CounterClockWiseSideOrientation: number;
  20727. /**
  20728. * The dirty texture flag value
  20729. */
  20730. static readonly TextureDirtyFlag: number;
  20731. /**
  20732. * The dirty light flag value
  20733. */
  20734. static readonly LightDirtyFlag: number;
  20735. /**
  20736. * The dirty fresnel flag value
  20737. */
  20738. static readonly FresnelDirtyFlag: number;
  20739. /**
  20740. * The dirty attribute flag value
  20741. */
  20742. static readonly AttributesDirtyFlag: number;
  20743. /**
  20744. * The dirty misc flag value
  20745. */
  20746. static readonly MiscDirtyFlag: number;
  20747. /**
  20748. * The all dirty flag value
  20749. */
  20750. static readonly AllDirtyFlag: number;
  20751. /**
  20752. * The ID of the material
  20753. */
  20754. id: string;
  20755. /**
  20756. * Gets or sets the unique id of the material
  20757. */
  20758. uniqueId: number;
  20759. /**
  20760. * The name of the material
  20761. */
  20762. name: string;
  20763. /**
  20764. * Gets or sets user defined metadata
  20765. */
  20766. metadata: any;
  20767. /**
  20768. * For internal use only. Please do not use.
  20769. */
  20770. reservedDataStore: any;
  20771. /**
  20772. * Specifies if the ready state should be checked on each call
  20773. */
  20774. checkReadyOnEveryCall: boolean;
  20775. /**
  20776. * Specifies if the ready state should be checked once
  20777. */
  20778. checkReadyOnlyOnce: boolean;
  20779. /**
  20780. * The state of the material
  20781. */
  20782. state: string;
  20783. /**
  20784. * The alpha value of the material
  20785. */
  20786. protected _alpha: number;
  20787. /**
  20788. * List of inspectable custom properties (used by the Inspector)
  20789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20790. */
  20791. inspectableCustomProperties: IInspectable[];
  20792. /**
  20793. * Sets the alpha value of the material
  20794. */
  20795. /**
  20796. * Gets the alpha value of the material
  20797. */
  20798. alpha: number;
  20799. /**
  20800. * Specifies if back face culling is enabled
  20801. */
  20802. protected _backFaceCulling: boolean;
  20803. /**
  20804. * Sets the back-face culling state
  20805. */
  20806. /**
  20807. * Gets the back-face culling state
  20808. */
  20809. backFaceCulling: boolean;
  20810. /**
  20811. * Stores the value for side orientation
  20812. */
  20813. sideOrientation: number;
  20814. /**
  20815. * Callback triggered when the material is compiled
  20816. */
  20817. onCompiled: Nullable<(effect: Effect) => void>;
  20818. /**
  20819. * Callback triggered when an error occurs
  20820. */
  20821. onError: Nullable<(effect: Effect, errors: string) => void>;
  20822. /**
  20823. * Callback triggered to get the render target textures
  20824. */
  20825. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20826. /**
  20827. * Gets a boolean indicating that current material needs to register RTT
  20828. */
  20829. readonly hasRenderTargetTextures: boolean;
  20830. /**
  20831. * Specifies if the material should be serialized
  20832. */
  20833. doNotSerialize: boolean;
  20834. /**
  20835. * @hidden
  20836. */
  20837. _storeEffectOnSubMeshes: boolean;
  20838. /**
  20839. * Stores the animations for the material
  20840. */
  20841. animations: Nullable<Array<Animation>>;
  20842. /**
  20843. * An event triggered when the material is disposed
  20844. */
  20845. onDisposeObservable: Observable<Material>;
  20846. /**
  20847. * An observer which watches for dispose events
  20848. */
  20849. private _onDisposeObserver;
  20850. private _onUnBindObservable;
  20851. /**
  20852. * Called during a dispose event
  20853. */
  20854. onDispose: () => void;
  20855. private _onBindObservable;
  20856. /**
  20857. * An event triggered when the material is bound
  20858. */
  20859. readonly onBindObservable: Observable<AbstractMesh>;
  20860. /**
  20861. * An observer which watches for bind events
  20862. */
  20863. private _onBindObserver;
  20864. /**
  20865. * Called during a bind event
  20866. */
  20867. onBind: (Mesh: AbstractMesh) => void;
  20868. /**
  20869. * An event triggered when the material is unbound
  20870. */
  20871. readonly onUnBindObservable: Observable<Material>;
  20872. /**
  20873. * Stores the value of the alpha mode
  20874. */
  20875. private _alphaMode;
  20876. /**
  20877. * Sets the value of the alpha mode.
  20878. *
  20879. * | Value | Type | Description |
  20880. * | --- | --- | --- |
  20881. * | 0 | ALPHA_DISABLE | |
  20882. * | 1 | ALPHA_ADD | |
  20883. * | 2 | ALPHA_COMBINE | |
  20884. * | 3 | ALPHA_SUBTRACT | |
  20885. * | 4 | ALPHA_MULTIPLY | |
  20886. * | 5 | ALPHA_MAXIMIZED | |
  20887. * | 6 | ALPHA_ONEONE | |
  20888. * | 7 | ALPHA_PREMULTIPLIED | |
  20889. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20890. * | 9 | ALPHA_INTERPOLATE | |
  20891. * | 10 | ALPHA_SCREENMODE | |
  20892. *
  20893. */
  20894. /**
  20895. * Gets the value of the alpha mode
  20896. */
  20897. alphaMode: number;
  20898. /**
  20899. * Stores the state of the need depth pre-pass value
  20900. */
  20901. private _needDepthPrePass;
  20902. /**
  20903. * Sets the need depth pre-pass value
  20904. */
  20905. /**
  20906. * Gets the depth pre-pass value
  20907. */
  20908. needDepthPrePass: boolean;
  20909. /**
  20910. * Specifies if depth writing should be disabled
  20911. */
  20912. disableDepthWrite: boolean;
  20913. /**
  20914. * Specifies if depth writing should be forced
  20915. */
  20916. forceDepthWrite: boolean;
  20917. /**
  20918. * Specifies if there should be a separate pass for culling
  20919. */
  20920. separateCullingPass: boolean;
  20921. /**
  20922. * Stores the state specifing if fog should be enabled
  20923. */
  20924. private _fogEnabled;
  20925. /**
  20926. * Sets the state for enabling fog
  20927. */
  20928. /**
  20929. * Gets the value of the fog enabled state
  20930. */
  20931. fogEnabled: boolean;
  20932. /**
  20933. * Stores the size of points
  20934. */
  20935. pointSize: number;
  20936. /**
  20937. * Stores the z offset value
  20938. */
  20939. zOffset: number;
  20940. /**
  20941. * Gets a value specifying if wireframe mode is enabled
  20942. */
  20943. /**
  20944. * Sets the state of wireframe mode
  20945. */
  20946. wireframe: boolean;
  20947. /**
  20948. * Gets the value specifying if point clouds are enabled
  20949. */
  20950. /**
  20951. * Sets the state of point cloud mode
  20952. */
  20953. pointsCloud: boolean;
  20954. /**
  20955. * Gets the material fill mode
  20956. */
  20957. /**
  20958. * Sets the material fill mode
  20959. */
  20960. fillMode: number;
  20961. /**
  20962. * @hidden
  20963. * Stores the effects for the material
  20964. */
  20965. _effect: Nullable<Effect>;
  20966. /**
  20967. * @hidden
  20968. * Specifies if the material was previously ready
  20969. */
  20970. _wasPreviouslyReady: boolean;
  20971. /**
  20972. * Specifies if uniform buffers should be used
  20973. */
  20974. private _useUBO;
  20975. /**
  20976. * Stores a reference to the scene
  20977. */
  20978. private _scene;
  20979. /**
  20980. * Stores the fill mode state
  20981. */
  20982. private _fillMode;
  20983. /**
  20984. * Specifies if the depth write state should be cached
  20985. */
  20986. private _cachedDepthWriteState;
  20987. /**
  20988. * Stores the uniform buffer
  20989. */
  20990. protected _uniformBuffer: UniformBuffer;
  20991. /** @hidden */
  20992. _indexInSceneMaterialArray: number;
  20993. /** @hidden */
  20994. meshMap: Nullable<{
  20995. [id: string]: AbstractMesh | undefined;
  20996. }>;
  20997. /**
  20998. * Creates a material instance
  20999. * @param name defines the name of the material
  21000. * @param scene defines the scene to reference
  21001. * @param doNotAdd specifies if the material should be added to the scene
  21002. */
  21003. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21004. /**
  21005. * Returns a string representation of the current material
  21006. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21007. * @returns a string with material information
  21008. */
  21009. toString(fullDetails?: boolean): string;
  21010. /**
  21011. * Gets the class name of the material
  21012. * @returns a string with the class name of the material
  21013. */
  21014. getClassName(): string;
  21015. /**
  21016. * Specifies if updates for the material been locked
  21017. */
  21018. readonly isFrozen: boolean;
  21019. /**
  21020. * Locks updates for the material
  21021. */
  21022. freeze(): void;
  21023. /**
  21024. * Unlocks updates for the material
  21025. */
  21026. unfreeze(): void;
  21027. /**
  21028. * Specifies if the material is ready to be used
  21029. * @param mesh defines the mesh to check
  21030. * @param useInstances specifies if instances should be used
  21031. * @returns a boolean indicating if the material is ready to be used
  21032. */
  21033. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21034. /**
  21035. * Specifies that the submesh is ready to be used
  21036. * @param mesh defines the mesh to check
  21037. * @param subMesh defines which submesh to check
  21038. * @param useInstances specifies that instances should be used
  21039. * @returns a boolean indicating that the submesh is ready or not
  21040. */
  21041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21042. /**
  21043. * Returns the material effect
  21044. * @returns the effect associated with the material
  21045. */
  21046. getEffect(): Nullable<Effect>;
  21047. /**
  21048. * Returns the current scene
  21049. * @returns a Scene
  21050. */
  21051. getScene(): Scene;
  21052. /**
  21053. * Specifies if the material will require alpha blending
  21054. * @returns a boolean specifying if alpha blending is needed
  21055. */
  21056. needAlphaBlending(): boolean;
  21057. /**
  21058. * Specifies if the mesh will require alpha blending
  21059. * @param mesh defines the mesh to check
  21060. * @returns a boolean specifying if alpha blending is needed for the mesh
  21061. */
  21062. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21063. /**
  21064. * Specifies if this material should be rendered in alpha test mode
  21065. * @returns a boolean specifying if an alpha test is needed.
  21066. */
  21067. needAlphaTesting(): boolean;
  21068. /**
  21069. * Gets the texture used for the alpha test
  21070. * @returns the texture to use for alpha testing
  21071. */
  21072. getAlphaTestTexture(): Nullable<BaseTexture>;
  21073. /**
  21074. * Marks the material to indicate that it needs to be re-calculated
  21075. */
  21076. markDirty(): void;
  21077. /** @hidden */
  21078. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21079. /**
  21080. * Binds the material to the mesh
  21081. * @param world defines the world transformation matrix
  21082. * @param mesh defines the mesh to bind the material to
  21083. */
  21084. bind(world: Matrix, mesh?: Mesh): void;
  21085. /**
  21086. * Binds the submesh to the material
  21087. * @param world defines the world transformation matrix
  21088. * @param mesh defines the mesh containing the submesh
  21089. * @param subMesh defines the submesh to bind the material to
  21090. */
  21091. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21092. /**
  21093. * Binds the world matrix to the material
  21094. * @param world defines the world transformation matrix
  21095. */
  21096. bindOnlyWorldMatrix(world: Matrix): void;
  21097. /**
  21098. * Binds the scene's uniform buffer to the effect.
  21099. * @param effect defines the effect to bind to the scene uniform buffer
  21100. * @param sceneUbo defines the uniform buffer storing scene data
  21101. */
  21102. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21103. /**
  21104. * Binds the view matrix to the effect
  21105. * @param effect defines the effect to bind the view matrix to
  21106. */
  21107. bindView(effect: Effect): void;
  21108. /**
  21109. * Binds the view projection matrix to the effect
  21110. * @param effect defines the effect to bind the view projection matrix to
  21111. */
  21112. bindViewProjection(effect: Effect): void;
  21113. /**
  21114. * Specifies if material alpha testing should be turned on for the mesh
  21115. * @param mesh defines the mesh to check
  21116. */
  21117. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21118. /**
  21119. * Processes to execute after binding the material to a mesh
  21120. * @param mesh defines the rendered mesh
  21121. */
  21122. protected _afterBind(mesh?: Mesh): void;
  21123. /**
  21124. * Unbinds the material from the mesh
  21125. */
  21126. unbind(): void;
  21127. /**
  21128. * Gets the active textures from the material
  21129. * @returns an array of textures
  21130. */
  21131. getActiveTextures(): BaseTexture[];
  21132. /**
  21133. * Specifies if the material uses a texture
  21134. * @param texture defines the texture to check against the material
  21135. * @returns a boolean specifying if the material uses the texture
  21136. */
  21137. hasTexture(texture: BaseTexture): boolean;
  21138. /**
  21139. * Makes a duplicate of the material, and gives it a new name
  21140. * @param name defines the new name for the duplicated material
  21141. * @returns the cloned material
  21142. */
  21143. clone(name: string): Nullable<Material>;
  21144. /**
  21145. * Gets the meshes bound to the material
  21146. * @returns an array of meshes bound to the material
  21147. */
  21148. getBindedMeshes(): AbstractMesh[];
  21149. /**
  21150. * Force shader compilation
  21151. * @param mesh defines the mesh associated with this material
  21152. * @param onCompiled defines a function to execute once the material is compiled
  21153. * @param options defines the options to configure the compilation
  21154. * @param onError defines a function to execute if the material fails compiling
  21155. */
  21156. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21157. clipPlane: boolean;
  21158. }>, onError?: (reason: string) => void): void;
  21159. /**
  21160. * Force shader compilation
  21161. * @param mesh defines the mesh that will use this material
  21162. * @param options defines additional options for compiling the shaders
  21163. * @returns a promise that resolves when the compilation completes
  21164. */
  21165. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21166. clipPlane: boolean;
  21167. }>): Promise<void>;
  21168. private static readonly _AllDirtyCallBack;
  21169. private static readonly _ImageProcessingDirtyCallBack;
  21170. private static readonly _TextureDirtyCallBack;
  21171. private static readonly _FresnelDirtyCallBack;
  21172. private static readonly _MiscDirtyCallBack;
  21173. private static readonly _LightsDirtyCallBack;
  21174. private static readonly _AttributeDirtyCallBack;
  21175. private static _FresnelAndMiscDirtyCallBack;
  21176. private static _TextureAndMiscDirtyCallBack;
  21177. private static readonly _DirtyCallbackArray;
  21178. private static readonly _RunDirtyCallBacks;
  21179. /**
  21180. * Marks a define in the material to indicate that it needs to be re-computed
  21181. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21182. */
  21183. markAsDirty(flag: number): void;
  21184. /**
  21185. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21186. * @param func defines a function which checks material defines against the submeshes
  21187. */
  21188. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21189. /**
  21190. * Indicates that we need to re-calculated for all submeshes
  21191. */
  21192. protected _markAllSubMeshesAsAllDirty(): void;
  21193. /**
  21194. * Indicates that image processing needs to be re-calculated for all submeshes
  21195. */
  21196. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21197. /**
  21198. * Indicates that textures need to be re-calculated for all submeshes
  21199. */
  21200. protected _markAllSubMeshesAsTexturesDirty(): void;
  21201. /**
  21202. * Indicates that fresnel needs to be re-calculated for all submeshes
  21203. */
  21204. protected _markAllSubMeshesAsFresnelDirty(): void;
  21205. /**
  21206. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21207. */
  21208. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21209. /**
  21210. * Indicates that lights need to be re-calculated for all submeshes
  21211. */
  21212. protected _markAllSubMeshesAsLightsDirty(): void;
  21213. /**
  21214. * Indicates that attributes need to be re-calculated for all submeshes
  21215. */
  21216. protected _markAllSubMeshesAsAttributesDirty(): void;
  21217. /**
  21218. * Indicates that misc needs to be re-calculated for all submeshes
  21219. */
  21220. protected _markAllSubMeshesAsMiscDirty(): void;
  21221. /**
  21222. * Indicates that textures and misc need to be re-calculated for all submeshes
  21223. */
  21224. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21225. /**
  21226. * Disposes the material
  21227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21229. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21230. */
  21231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21232. /** @hidden */
  21233. private releaseVertexArrayObject;
  21234. /**
  21235. * Serializes this material
  21236. * @returns the serialized material object
  21237. */
  21238. serialize(): any;
  21239. /**
  21240. * Creates a material from parsed material data
  21241. * @param parsedMaterial defines parsed material data
  21242. * @param scene defines the hosting scene
  21243. * @param rootUrl defines the root URL to use to load textures
  21244. * @returns a new material
  21245. */
  21246. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21247. }
  21248. }
  21249. declare module "babylonjs/Materials/multiMaterial" {
  21250. import { Nullable } from "babylonjs/types";
  21251. import { Scene } from "babylonjs/scene";
  21252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21253. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21255. import { Material } from "babylonjs/Materials/material";
  21256. /**
  21257. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21258. * separate meshes. This can be use to improve performances.
  21259. * @see http://doc.babylonjs.com/how_to/multi_materials
  21260. */
  21261. export class MultiMaterial extends Material {
  21262. private _subMaterials;
  21263. /**
  21264. * Gets or Sets the list of Materials used within the multi material.
  21265. * They need to be ordered according to the submeshes order in the associated mesh
  21266. */
  21267. subMaterials: Nullable<Material>[];
  21268. /**
  21269. * Function used to align with Node.getChildren()
  21270. * @returns the list of Materials used within the multi material
  21271. */
  21272. getChildren(): Nullable<Material>[];
  21273. /**
  21274. * Instantiates a new Multi Material
  21275. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21276. * separate meshes. This can be use to improve performances.
  21277. * @see http://doc.babylonjs.com/how_to/multi_materials
  21278. * @param name Define the name in the scene
  21279. * @param scene Define the scene the material belongs to
  21280. */
  21281. constructor(name: string, scene: Scene);
  21282. private _hookArray;
  21283. /**
  21284. * Get one of the submaterial by its index in the submaterials array
  21285. * @param index The index to look the sub material at
  21286. * @returns The Material if the index has been defined
  21287. */
  21288. getSubMaterial(index: number): Nullable<Material>;
  21289. /**
  21290. * Get the list of active textures for the whole sub materials list.
  21291. * @returns All the textures that will be used during the rendering
  21292. */
  21293. getActiveTextures(): BaseTexture[];
  21294. /**
  21295. * Gets the current class name of the material e.g. "MultiMaterial"
  21296. * Mainly use in serialization.
  21297. * @returns the class name
  21298. */
  21299. getClassName(): string;
  21300. /**
  21301. * Checks if the material is ready to render the requested sub mesh
  21302. * @param mesh Define the mesh the submesh belongs to
  21303. * @param subMesh Define the sub mesh to look readyness for
  21304. * @param useInstances Define whether or not the material is used with instances
  21305. * @returns true if ready, otherwise false
  21306. */
  21307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21308. /**
  21309. * Clones the current material and its related sub materials
  21310. * @param name Define the name of the newly cloned material
  21311. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21312. * @returns the cloned material
  21313. */
  21314. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21315. /**
  21316. * Serializes the materials into a JSON representation.
  21317. * @returns the JSON representation
  21318. */
  21319. serialize(): any;
  21320. /**
  21321. * Dispose the material and release its associated resources
  21322. * @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)
  21323. * @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)
  21324. * @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)
  21325. */
  21326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21327. /**
  21328. * Creates a MultiMaterial from parsed MultiMaterial data.
  21329. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21330. * @param scene defines the hosting scene
  21331. * @returns a new MultiMaterial
  21332. */
  21333. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21334. }
  21335. }
  21336. declare module "babylonjs/Meshes/subMesh" {
  21337. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21338. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21339. import { Engine } from "babylonjs/Engines/engine";
  21340. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21341. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21342. import { Effect } from "babylonjs/Materials/effect";
  21343. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21344. import { Plane } from "babylonjs/Maths/math.plane";
  21345. import { Collider } from "babylonjs/Collisions/collider";
  21346. import { Material } from "babylonjs/Materials/material";
  21347. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21349. import { Mesh } from "babylonjs/Meshes/mesh";
  21350. import { Ray } from "babylonjs/Culling/ray";
  21351. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21352. /**
  21353. * Base class for submeshes
  21354. */
  21355. export class BaseSubMesh {
  21356. /** @hidden */
  21357. _materialDefines: Nullable<MaterialDefines>;
  21358. /** @hidden */
  21359. _materialEffect: Nullable<Effect>;
  21360. /**
  21361. * Gets associated effect
  21362. */
  21363. readonly effect: Nullable<Effect>;
  21364. /**
  21365. * Sets associated effect (effect used to render this submesh)
  21366. * @param effect defines the effect to associate with
  21367. * @param defines defines the set of defines used to compile this effect
  21368. */
  21369. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21370. }
  21371. /**
  21372. * Defines a subdivision inside a mesh
  21373. */
  21374. export class SubMesh extends BaseSubMesh implements ICullable {
  21375. /** the material index to use */
  21376. materialIndex: number;
  21377. /** vertex index start */
  21378. verticesStart: number;
  21379. /** vertices count */
  21380. verticesCount: number;
  21381. /** index start */
  21382. indexStart: number;
  21383. /** indices count */
  21384. indexCount: number;
  21385. /** @hidden */
  21386. _linesIndexCount: number;
  21387. private _mesh;
  21388. private _renderingMesh;
  21389. private _boundingInfo;
  21390. private _linesIndexBuffer;
  21391. /** @hidden */
  21392. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21393. /** @hidden */
  21394. _trianglePlanes: Plane[];
  21395. /** @hidden */
  21396. _lastColliderTransformMatrix: Nullable<Matrix>;
  21397. /** @hidden */
  21398. _renderId: number;
  21399. /** @hidden */
  21400. _alphaIndex: number;
  21401. /** @hidden */
  21402. _distanceToCamera: number;
  21403. /** @hidden */
  21404. _id: number;
  21405. private _currentMaterial;
  21406. /**
  21407. * Add a new submesh to a mesh
  21408. * @param materialIndex defines the material index to use
  21409. * @param verticesStart defines vertex index start
  21410. * @param verticesCount defines vertices count
  21411. * @param indexStart defines index start
  21412. * @param indexCount defines indices count
  21413. * @param mesh defines the parent mesh
  21414. * @param renderingMesh defines an optional rendering mesh
  21415. * @param createBoundingBox defines if bounding box should be created for this submesh
  21416. * @returns the new submesh
  21417. */
  21418. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21419. /**
  21420. * Creates a new submesh
  21421. * @param materialIndex defines the material index to use
  21422. * @param verticesStart defines vertex index start
  21423. * @param verticesCount defines vertices count
  21424. * @param indexStart defines index start
  21425. * @param indexCount defines indices count
  21426. * @param mesh defines the parent mesh
  21427. * @param renderingMesh defines an optional rendering mesh
  21428. * @param createBoundingBox defines if bounding box should be created for this submesh
  21429. */
  21430. constructor(
  21431. /** the material index to use */
  21432. materialIndex: number,
  21433. /** vertex index start */
  21434. verticesStart: number,
  21435. /** vertices count */
  21436. verticesCount: number,
  21437. /** index start */
  21438. indexStart: number,
  21439. /** indices count */
  21440. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21441. /**
  21442. * Returns true if this submesh covers the entire parent mesh
  21443. * @ignorenaming
  21444. */
  21445. readonly IsGlobal: boolean;
  21446. /**
  21447. * Returns the submesh BoudingInfo object
  21448. * @returns current bounding info (or mesh's one if the submesh is global)
  21449. */
  21450. getBoundingInfo(): BoundingInfo;
  21451. /**
  21452. * Sets the submesh BoundingInfo
  21453. * @param boundingInfo defines the new bounding info to use
  21454. * @returns the SubMesh
  21455. */
  21456. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21457. /**
  21458. * Returns the mesh of the current submesh
  21459. * @return the parent mesh
  21460. */
  21461. getMesh(): AbstractMesh;
  21462. /**
  21463. * Returns the rendering mesh of the submesh
  21464. * @returns the rendering mesh (could be different from parent mesh)
  21465. */
  21466. getRenderingMesh(): Mesh;
  21467. /**
  21468. * Returns the submesh material
  21469. * @returns null or the current material
  21470. */
  21471. getMaterial(): Nullable<Material>;
  21472. /**
  21473. * Sets a new updated BoundingInfo object to the submesh
  21474. * @param data defines an optional position array to use to determine the bounding info
  21475. * @returns the SubMesh
  21476. */
  21477. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21478. /** @hidden */
  21479. _checkCollision(collider: Collider): boolean;
  21480. /**
  21481. * Updates the submesh BoundingInfo
  21482. * @param world defines the world matrix to use to update the bounding info
  21483. * @returns the submesh
  21484. */
  21485. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21486. /**
  21487. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21488. * @param frustumPlanes defines the frustum planes
  21489. * @returns true if the submesh is intersecting with the frustum
  21490. */
  21491. isInFrustum(frustumPlanes: Plane[]): boolean;
  21492. /**
  21493. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21494. * @param frustumPlanes defines the frustum planes
  21495. * @returns true if the submesh is inside the frustum
  21496. */
  21497. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21498. /**
  21499. * Renders the submesh
  21500. * @param enableAlphaMode defines if alpha needs to be used
  21501. * @returns the submesh
  21502. */
  21503. render(enableAlphaMode: boolean): SubMesh;
  21504. /**
  21505. * @hidden
  21506. */
  21507. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21508. /**
  21509. * Checks if the submesh intersects with a ray
  21510. * @param ray defines the ray to test
  21511. * @returns true is the passed ray intersects the submesh bounding box
  21512. */
  21513. canIntersects(ray: Ray): boolean;
  21514. /**
  21515. * Intersects current submesh with a ray
  21516. * @param ray defines the ray to test
  21517. * @param positions defines mesh's positions array
  21518. * @param indices defines mesh's indices array
  21519. * @param fastCheck defines if only bounding info should be used
  21520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21521. * @returns intersection info or null if no intersection
  21522. */
  21523. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21524. /** @hidden */
  21525. private _intersectLines;
  21526. /** @hidden */
  21527. private _intersectUnIndexedLines;
  21528. /** @hidden */
  21529. private _intersectTriangles;
  21530. /** @hidden */
  21531. private _intersectUnIndexedTriangles;
  21532. /** @hidden */
  21533. _rebuild(): void;
  21534. /**
  21535. * Creates a new submesh from the passed mesh
  21536. * @param newMesh defines the new hosting mesh
  21537. * @param newRenderingMesh defines an optional rendering mesh
  21538. * @returns the new submesh
  21539. */
  21540. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21541. /**
  21542. * Release associated resources
  21543. */
  21544. dispose(): void;
  21545. /**
  21546. * Gets the class name
  21547. * @returns the string "SubMesh".
  21548. */
  21549. getClassName(): string;
  21550. /**
  21551. * Creates a new submesh from indices data
  21552. * @param materialIndex the index of the main mesh material
  21553. * @param startIndex the index where to start the copy in the mesh indices array
  21554. * @param indexCount the number of indices to copy then from the startIndex
  21555. * @param mesh the main mesh to create the submesh from
  21556. * @param renderingMesh the optional rendering mesh
  21557. * @returns a new submesh
  21558. */
  21559. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21560. }
  21561. }
  21562. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21563. /**
  21564. * Class used to represent data loading progression
  21565. */
  21566. export class SceneLoaderFlags {
  21567. private static _ForceFullSceneLoadingForIncremental;
  21568. private static _ShowLoadingScreen;
  21569. private static _CleanBoneMatrixWeights;
  21570. private static _loggingLevel;
  21571. /**
  21572. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21573. */
  21574. static ForceFullSceneLoadingForIncremental: boolean;
  21575. /**
  21576. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21577. */
  21578. static ShowLoadingScreen: boolean;
  21579. /**
  21580. * Defines the current logging level (while loading the scene)
  21581. * @ignorenaming
  21582. */
  21583. static loggingLevel: number;
  21584. /**
  21585. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21586. */
  21587. static CleanBoneMatrixWeights: boolean;
  21588. }
  21589. }
  21590. declare module "babylonjs/Meshes/geometry" {
  21591. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21592. import { Scene } from "babylonjs/scene";
  21593. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21594. import { Engine } from "babylonjs/Engines/engine";
  21595. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21596. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21597. import { Effect } from "babylonjs/Materials/effect";
  21598. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21599. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21600. import { Mesh } from "babylonjs/Meshes/mesh";
  21601. /**
  21602. * Class used to store geometry data (vertex buffers + index buffer)
  21603. */
  21604. export class Geometry implements IGetSetVerticesData {
  21605. /**
  21606. * Gets or sets the ID of the geometry
  21607. */
  21608. id: string;
  21609. /**
  21610. * Gets or sets the unique ID of the geometry
  21611. */
  21612. uniqueId: number;
  21613. /**
  21614. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21615. */
  21616. delayLoadState: number;
  21617. /**
  21618. * Gets the file containing the data to load when running in delay load state
  21619. */
  21620. delayLoadingFile: Nullable<string>;
  21621. /**
  21622. * Callback called when the geometry is updated
  21623. */
  21624. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21625. private _scene;
  21626. private _engine;
  21627. private _meshes;
  21628. private _totalVertices;
  21629. /** @hidden */
  21630. _indices: IndicesArray;
  21631. /** @hidden */
  21632. _vertexBuffers: {
  21633. [key: string]: VertexBuffer;
  21634. };
  21635. private _isDisposed;
  21636. private _extend;
  21637. private _boundingBias;
  21638. /** @hidden */
  21639. _delayInfo: Array<string>;
  21640. private _indexBuffer;
  21641. private _indexBufferIsUpdatable;
  21642. /** @hidden */
  21643. _boundingInfo: Nullable<BoundingInfo>;
  21644. /** @hidden */
  21645. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21646. /** @hidden */
  21647. _softwareSkinningFrameId: number;
  21648. private _vertexArrayObjects;
  21649. private _updatable;
  21650. /** @hidden */
  21651. _positions: Nullable<Vector3[]>;
  21652. /**
  21653. * 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
  21654. */
  21655. /**
  21656. * 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
  21657. */
  21658. boundingBias: Vector2;
  21659. /**
  21660. * Static function used to attach a new empty geometry to a mesh
  21661. * @param mesh defines the mesh to attach the geometry to
  21662. * @returns the new Geometry
  21663. */
  21664. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21665. /**
  21666. * Creates a new geometry
  21667. * @param id defines the unique ID
  21668. * @param scene defines the hosting scene
  21669. * @param vertexData defines the VertexData used to get geometry data
  21670. * @param updatable defines if geometry must be updatable (false by default)
  21671. * @param mesh defines the mesh that will be associated with the geometry
  21672. */
  21673. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21674. /**
  21675. * Gets the current extend of the geometry
  21676. */
  21677. readonly extend: {
  21678. minimum: Vector3;
  21679. maximum: Vector3;
  21680. };
  21681. /**
  21682. * Gets the hosting scene
  21683. * @returns the hosting Scene
  21684. */
  21685. getScene(): Scene;
  21686. /**
  21687. * Gets the hosting engine
  21688. * @returns the hosting Engine
  21689. */
  21690. getEngine(): Engine;
  21691. /**
  21692. * Defines if the geometry is ready to use
  21693. * @returns true if the geometry is ready to be used
  21694. */
  21695. isReady(): boolean;
  21696. /**
  21697. * Gets a value indicating that the geometry should not be serialized
  21698. */
  21699. readonly doNotSerialize: boolean;
  21700. /** @hidden */
  21701. _rebuild(): void;
  21702. /**
  21703. * Affects all geometry data in one call
  21704. * @param vertexData defines the geometry data
  21705. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21706. */
  21707. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21708. /**
  21709. * Set specific vertex data
  21710. * @param kind defines the data kind (Position, normal, etc...)
  21711. * @param data defines the vertex data to use
  21712. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21713. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21714. */
  21715. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21716. /**
  21717. * Removes a specific vertex data
  21718. * @param kind defines the data kind (Position, normal, etc...)
  21719. */
  21720. removeVerticesData(kind: string): void;
  21721. /**
  21722. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21723. * @param buffer defines the vertex buffer to use
  21724. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21725. */
  21726. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21727. /**
  21728. * Update a specific vertex buffer
  21729. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21730. * It will do nothing if the buffer is not updatable
  21731. * @param kind defines the data kind (Position, normal, etc...)
  21732. * @param data defines the data to use
  21733. * @param offset defines the offset in the target buffer where to store the data
  21734. * @param useBytes set to true if the offset is in bytes
  21735. */
  21736. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21737. /**
  21738. * Update a specific vertex buffer
  21739. * This function will create a new buffer if the current one is not updatable
  21740. * @param kind defines the data kind (Position, normal, etc...)
  21741. * @param data defines the data to use
  21742. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21743. */
  21744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21745. private _updateBoundingInfo;
  21746. /** @hidden */
  21747. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21748. /**
  21749. * Gets total number of vertices
  21750. * @returns the total number of vertices
  21751. */
  21752. getTotalVertices(): number;
  21753. /**
  21754. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21755. * @param kind defines the data kind (Position, normal, etc...)
  21756. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21757. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21758. * @returns a float array containing vertex data
  21759. */
  21760. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21761. /**
  21762. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21763. * @param kind defines the data kind (Position, normal, etc...)
  21764. * @returns true if the vertex buffer with the specified kind is updatable
  21765. */
  21766. isVertexBufferUpdatable(kind: string): boolean;
  21767. /**
  21768. * Gets a specific vertex buffer
  21769. * @param kind defines the data kind (Position, normal, etc...)
  21770. * @returns a VertexBuffer
  21771. */
  21772. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21773. /**
  21774. * Returns all vertex buffers
  21775. * @return an object holding all vertex buffers indexed by kind
  21776. */
  21777. getVertexBuffers(): Nullable<{
  21778. [key: string]: VertexBuffer;
  21779. }>;
  21780. /**
  21781. * Gets a boolean indicating if specific vertex buffer is present
  21782. * @param kind defines the data kind (Position, normal, etc...)
  21783. * @returns true if data is present
  21784. */
  21785. isVerticesDataPresent(kind: string): boolean;
  21786. /**
  21787. * Gets a list of all attached data kinds (Position, normal, etc...)
  21788. * @returns a list of string containing all kinds
  21789. */
  21790. getVerticesDataKinds(): string[];
  21791. /**
  21792. * Update index buffer
  21793. * @param indices defines the indices to store in the index buffer
  21794. * @param offset defines the offset in the target buffer where to store the data
  21795. * @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)
  21796. */
  21797. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21798. /**
  21799. * Creates a new index buffer
  21800. * @param indices defines the indices to store in the index buffer
  21801. * @param totalVertices defines the total number of vertices (could be null)
  21802. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21803. */
  21804. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21805. /**
  21806. * Return the total number of indices
  21807. * @returns the total number of indices
  21808. */
  21809. getTotalIndices(): number;
  21810. /**
  21811. * Gets the index buffer array
  21812. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21813. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21814. * @returns the index buffer array
  21815. */
  21816. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21817. /**
  21818. * Gets the index buffer
  21819. * @return the index buffer
  21820. */
  21821. getIndexBuffer(): Nullable<DataBuffer>;
  21822. /** @hidden */
  21823. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21824. /**
  21825. * Release the associated resources for a specific mesh
  21826. * @param mesh defines the source mesh
  21827. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21828. */
  21829. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21830. /**
  21831. * Apply current geometry to a given mesh
  21832. * @param mesh defines the mesh to apply geometry to
  21833. */
  21834. applyToMesh(mesh: Mesh): void;
  21835. private _updateExtend;
  21836. private _applyToMesh;
  21837. private notifyUpdate;
  21838. /**
  21839. * Load the geometry if it was flagged as delay loaded
  21840. * @param scene defines the hosting scene
  21841. * @param onLoaded defines a callback called when the geometry is loaded
  21842. */
  21843. load(scene: Scene, onLoaded?: () => void): void;
  21844. private _queueLoad;
  21845. /**
  21846. * Invert the geometry to move from a right handed system to a left handed one.
  21847. */
  21848. toLeftHanded(): void;
  21849. /** @hidden */
  21850. _resetPointsArrayCache(): void;
  21851. /** @hidden */
  21852. _generatePointsArray(): boolean;
  21853. /**
  21854. * Gets a value indicating if the geometry is disposed
  21855. * @returns true if the geometry was disposed
  21856. */
  21857. isDisposed(): boolean;
  21858. private _disposeVertexArrayObjects;
  21859. /**
  21860. * Free all associated resources
  21861. */
  21862. dispose(): void;
  21863. /**
  21864. * Clone the current geometry into a new geometry
  21865. * @param id defines the unique ID of the new geometry
  21866. * @returns a new geometry object
  21867. */
  21868. copy(id: string): Geometry;
  21869. /**
  21870. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21871. * @return a JSON representation of the current geometry data (without the vertices data)
  21872. */
  21873. serialize(): any;
  21874. private toNumberArray;
  21875. /**
  21876. * Serialize all vertices data into a JSON oject
  21877. * @returns a JSON representation of the current geometry data
  21878. */
  21879. serializeVerticeData(): any;
  21880. /**
  21881. * Extracts a clone of a mesh geometry
  21882. * @param mesh defines the source mesh
  21883. * @param id defines the unique ID of the new geometry object
  21884. * @returns the new geometry object
  21885. */
  21886. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21887. /**
  21888. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21889. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21890. * Be aware Math.random() could cause collisions, but:
  21891. * "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"
  21892. * @returns a string containing a new GUID
  21893. */
  21894. static RandomId(): string;
  21895. /** @hidden */
  21896. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21897. private static _CleanMatricesWeights;
  21898. /**
  21899. * Create a new geometry from persisted data (Using .babylon file format)
  21900. * @param parsedVertexData defines the persisted data
  21901. * @param scene defines the hosting scene
  21902. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21903. * @returns the new geometry object
  21904. */
  21905. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21906. }
  21907. }
  21908. declare module "babylonjs/Meshes/mesh.vertexData" {
  21909. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21910. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21911. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21912. import { Geometry } from "babylonjs/Meshes/geometry";
  21913. import { Mesh } from "babylonjs/Meshes/mesh";
  21914. /**
  21915. * Define an interface for all classes that will get and set the data on vertices
  21916. */
  21917. export interface IGetSetVerticesData {
  21918. /**
  21919. * Gets a boolean indicating if specific vertex data is present
  21920. * @param kind defines the vertex data kind to use
  21921. * @returns true is data kind is present
  21922. */
  21923. isVerticesDataPresent(kind: string): boolean;
  21924. /**
  21925. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21926. * @param kind defines the data kind (Position, normal, etc...)
  21927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21929. * @returns a float array containing vertex data
  21930. */
  21931. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21932. /**
  21933. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21934. * @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.
  21935. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21936. * @returns the indices array or an empty array if the mesh has no geometry
  21937. */
  21938. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21939. /**
  21940. * Set specific vertex data
  21941. * @param kind defines the data kind (Position, normal, etc...)
  21942. * @param data defines the vertex data to use
  21943. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21944. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21945. */
  21946. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21947. /**
  21948. * Update a specific associated vertex buffer
  21949. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21950. * - VertexBuffer.PositionKind
  21951. * - VertexBuffer.UVKind
  21952. * - VertexBuffer.UV2Kind
  21953. * - VertexBuffer.UV3Kind
  21954. * - VertexBuffer.UV4Kind
  21955. * - VertexBuffer.UV5Kind
  21956. * - VertexBuffer.UV6Kind
  21957. * - VertexBuffer.ColorKind
  21958. * - VertexBuffer.MatricesIndicesKind
  21959. * - VertexBuffer.MatricesIndicesExtraKind
  21960. * - VertexBuffer.MatricesWeightsKind
  21961. * - VertexBuffer.MatricesWeightsExtraKind
  21962. * @param data defines the data source
  21963. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21964. * @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)
  21965. */
  21966. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21967. /**
  21968. * Creates a new index buffer
  21969. * @param indices defines the indices to store in the index buffer
  21970. * @param totalVertices defines the total number of vertices (could be null)
  21971. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21972. */
  21973. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21974. }
  21975. /**
  21976. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21977. */
  21978. export class VertexData {
  21979. /**
  21980. * Mesh side orientation : usually the external or front surface
  21981. */
  21982. static readonly FRONTSIDE: number;
  21983. /**
  21984. * Mesh side orientation : usually the internal or back surface
  21985. */
  21986. static readonly BACKSIDE: number;
  21987. /**
  21988. * Mesh side orientation : both internal and external or front and back surfaces
  21989. */
  21990. static readonly DOUBLESIDE: number;
  21991. /**
  21992. * Mesh side orientation : by default, `FRONTSIDE`
  21993. */
  21994. static readonly DEFAULTSIDE: number;
  21995. /**
  21996. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21997. */
  21998. positions: Nullable<FloatArray>;
  21999. /**
  22000. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22001. */
  22002. normals: Nullable<FloatArray>;
  22003. /**
  22004. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22005. */
  22006. tangents: Nullable<FloatArray>;
  22007. /**
  22008. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22009. */
  22010. uvs: Nullable<FloatArray>;
  22011. /**
  22012. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22013. */
  22014. uvs2: Nullable<FloatArray>;
  22015. /**
  22016. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22017. */
  22018. uvs3: Nullable<FloatArray>;
  22019. /**
  22020. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22021. */
  22022. uvs4: Nullable<FloatArray>;
  22023. /**
  22024. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22025. */
  22026. uvs5: Nullable<FloatArray>;
  22027. /**
  22028. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22029. */
  22030. uvs6: Nullable<FloatArray>;
  22031. /**
  22032. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22033. */
  22034. colors: Nullable<FloatArray>;
  22035. /**
  22036. * 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).
  22037. */
  22038. matricesIndices: Nullable<FloatArray>;
  22039. /**
  22040. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22041. */
  22042. matricesWeights: Nullable<FloatArray>;
  22043. /**
  22044. * An array extending the number of possible indices
  22045. */
  22046. matricesIndicesExtra: Nullable<FloatArray>;
  22047. /**
  22048. * An array extending the number of possible weights when the number of indices is extended
  22049. */
  22050. matricesWeightsExtra: Nullable<FloatArray>;
  22051. /**
  22052. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22053. */
  22054. indices: Nullable<IndicesArray>;
  22055. /**
  22056. * Uses the passed data array to set the set the values for the specified kind of data
  22057. * @param data a linear array of floating numbers
  22058. * @param kind the type of data that is being set, eg positions, colors etc
  22059. */
  22060. set(data: FloatArray, kind: string): void;
  22061. /**
  22062. * Associates the vertexData to the passed Mesh.
  22063. * Sets it as updatable or not (default `false`)
  22064. * @param mesh the mesh the vertexData is applied to
  22065. * @param updatable when used and having the value true allows new data to update the vertexData
  22066. * @returns the VertexData
  22067. */
  22068. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22069. /**
  22070. * Associates the vertexData to the passed Geometry.
  22071. * Sets it as updatable or not (default `false`)
  22072. * @param geometry the geometry the vertexData is applied to
  22073. * @param updatable when used and having the value true allows new data to update the vertexData
  22074. * @returns VertexData
  22075. */
  22076. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22077. /**
  22078. * Updates the associated mesh
  22079. * @param mesh the mesh to be updated
  22080. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22081. * @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
  22082. * @returns VertexData
  22083. */
  22084. updateMesh(mesh: Mesh): VertexData;
  22085. /**
  22086. * Updates the associated geometry
  22087. * @param geometry the geometry to be updated
  22088. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22089. * @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
  22090. * @returns VertexData.
  22091. */
  22092. updateGeometry(geometry: Geometry): VertexData;
  22093. private _applyTo;
  22094. private _update;
  22095. /**
  22096. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22097. * @param matrix the transforming matrix
  22098. * @returns the VertexData
  22099. */
  22100. transform(matrix: Matrix): VertexData;
  22101. /**
  22102. * Merges the passed VertexData into the current one
  22103. * @param other the VertexData to be merged into the current one
  22104. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22105. * @returns the modified VertexData
  22106. */
  22107. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22108. private _mergeElement;
  22109. private _validate;
  22110. /**
  22111. * Serializes the VertexData
  22112. * @returns a serialized object
  22113. */
  22114. serialize(): any;
  22115. /**
  22116. * Extracts the vertexData from a mesh
  22117. * @param mesh the mesh from which to extract the VertexData
  22118. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22119. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22120. * @returns the object VertexData associated to the passed mesh
  22121. */
  22122. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22123. /**
  22124. * Extracts the vertexData from the geometry
  22125. * @param geometry the geometry from which to extract the VertexData
  22126. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22127. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22128. * @returns the object VertexData associated to the passed mesh
  22129. */
  22130. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22131. private static _ExtractFrom;
  22132. /**
  22133. * Creates the VertexData for a Ribbon
  22134. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22135. * * pathArray array of paths, each of which an array of successive Vector3
  22136. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22137. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22138. * * 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
  22139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22140. * * 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)
  22141. * * 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)
  22142. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22143. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22144. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22145. * @returns the VertexData of the ribbon
  22146. */
  22147. static CreateRibbon(options: {
  22148. pathArray: Vector3[][];
  22149. closeArray?: boolean;
  22150. closePath?: boolean;
  22151. offset?: number;
  22152. sideOrientation?: number;
  22153. frontUVs?: Vector4;
  22154. backUVs?: Vector4;
  22155. invertUV?: boolean;
  22156. uvs?: Vector2[];
  22157. colors?: Color4[];
  22158. }): VertexData;
  22159. /**
  22160. * Creates the VertexData for a box
  22161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22162. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22163. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22164. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22165. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22166. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22167. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22169. * * 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)
  22170. * * 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)
  22171. * @returns the VertexData of the box
  22172. */
  22173. static CreateBox(options: {
  22174. size?: number;
  22175. width?: number;
  22176. height?: number;
  22177. depth?: number;
  22178. faceUV?: Vector4[];
  22179. faceColors?: Color4[];
  22180. sideOrientation?: number;
  22181. frontUVs?: Vector4;
  22182. backUVs?: Vector4;
  22183. }): VertexData;
  22184. /**
  22185. * Creates the VertexData for a tiled box
  22186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22187. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22188. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22189. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22191. * @returns the VertexData of the box
  22192. */
  22193. static CreateTiledBox(options: {
  22194. pattern?: number;
  22195. width?: number;
  22196. height?: number;
  22197. depth?: number;
  22198. tileSize?: number;
  22199. tileWidth?: number;
  22200. tileHeight?: number;
  22201. alignHorizontal?: number;
  22202. alignVertical?: number;
  22203. faceUV?: Vector4[];
  22204. faceColors?: Color4[];
  22205. sideOrientation?: number;
  22206. }): VertexData;
  22207. /**
  22208. * Creates the VertexData for a tiled plane
  22209. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22210. * * pattern a limited pattern arrangement depending on the number
  22211. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22212. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22213. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22215. * * 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)
  22216. * * 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)
  22217. * @returns the VertexData of the tiled plane
  22218. */
  22219. static CreateTiledPlane(options: {
  22220. pattern?: number;
  22221. tileSize?: number;
  22222. tileWidth?: number;
  22223. tileHeight?: number;
  22224. size?: number;
  22225. width?: number;
  22226. height?: number;
  22227. alignHorizontal?: number;
  22228. alignVertical?: number;
  22229. sideOrientation?: number;
  22230. frontUVs?: Vector4;
  22231. backUVs?: Vector4;
  22232. }): VertexData;
  22233. /**
  22234. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22235. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22236. * * segments sets the number of horizontal strips optional, default 32
  22237. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22238. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22239. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22240. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22241. * * 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
  22242. * * 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
  22243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22244. * * 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)
  22245. * * 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)
  22246. * @returns the VertexData of the ellipsoid
  22247. */
  22248. static CreateSphere(options: {
  22249. segments?: number;
  22250. diameter?: number;
  22251. diameterX?: number;
  22252. diameterY?: number;
  22253. diameterZ?: number;
  22254. arc?: number;
  22255. slice?: number;
  22256. sideOrientation?: number;
  22257. frontUVs?: Vector4;
  22258. backUVs?: Vector4;
  22259. }): VertexData;
  22260. /**
  22261. * Creates the VertexData for a cylinder, cone or prism
  22262. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22263. * * height sets the height (y direction) of the cylinder, optional, default 2
  22264. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22265. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22266. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22267. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22268. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22269. * * 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
  22270. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22271. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22272. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22273. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22275. * * 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. * * 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 cylinder, cone or prism
  22278. */
  22279. static CreateCylinder(options: {
  22280. height?: number;
  22281. diameterTop?: number;
  22282. diameterBottom?: number;
  22283. diameter?: number;
  22284. tessellation?: number;
  22285. subdivisions?: number;
  22286. arc?: number;
  22287. faceColors?: Color4[];
  22288. faceUV?: Vector4[];
  22289. hasRings?: boolean;
  22290. enclose?: boolean;
  22291. sideOrientation?: number;
  22292. frontUVs?: Vector4;
  22293. backUVs?: Vector4;
  22294. }): VertexData;
  22295. /**
  22296. * Creates the VertexData for a torus
  22297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22298. * * diameter the diameter of the torus, optional default 1
  22299. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22300. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22302. * * 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)
  22303. * * 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)
  22304. * @returns the VertexData of the torus
  22305. */
  22306. static CreateTorus(options: {
  22307. diameter?: number;
  22308. thickness?: number;
  22309. tessellation?: number;
  22310. sideOrientation?: number;
  22311. frontUVs?: Vector4;
  22312. backUVs?: Vector4;
  22313. }): VertexData;
  22314. /**
  22315. * Creates the VertexData of the LineSystem
  22316. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22317. * - lines an array of lines, each line being an array of successive Vector3
  22318. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22319. * @returns the VertexData of the LineSystem
  22320. */
  22321. static CreateLineSystem(options: {
  22322. lines: Vector3[][];
  22323. colors?: Nullable<Color4[][]>;
  22324. }): VertexData;
  22325. /**
  22326. * Create the VertexData for a DashedLines
  22327. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22328. * - points an array successive Vector3
  22329. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22330. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22331. * - dashNb the intended total number of dashes, optional, default 200
  22332. * @returns the VertexData for the DashedLines
  22333. */
  22334. static CreateDashedLines(options: {
  22335. points: Vector3[];
  22336. dashSize?: number;
  22337. gapSize?: number;
  22338. dashNb?: number;
  22339. }): VertexData;
  22340. /**
  22341. * Creates the VertexData for a Ground
  22342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22343. * - width the width (x direction) of the ground, optional, default 1
  22344. * - height the height (z direction) of the ground, optional, default 1
  22345. * - subdivisions the number of subdivisions per side, optional, default 1
  22346. * @returns the VertexData of the Ground
  22347. */
  22348. static CreateGround(options: {
  22349. width?: number;
  22350. height?: number;
  22351. subdivisions?: number;
  22352. subdivisionsX?: number;
  22353. subdivisionsY?: number;
  22354. }): VertexData;
  22355. /**
  22356. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22357. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22358. * * xmin the ground minimum X coordinate, optional, default -1
  22359. * * zmin the ground minimum Z coordinate, optional, default -1
  22360. * * xmax the ground maximum X coordinate, optional, default 1
  22361. * * zmax the ground maximum Z coordinate, optional, default 1
  22362. * * 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}
  22363. * * 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}
  22364. * @returns the VertexData of the TiledGround
  22365. */
  22366. static CreateTiledGround(options: {
  22367. xmin: number;
  22368. zmin: number;
  22369. xmax: number;
  22370. zmax: number;
  22371. subdivisions?: {
  22372. w: number;
  22373. h: number;
  22374. };
  22375. precision?: {
  22376. w: number;
  22377. h: number;
  22378. };
  22379. }): VertexData;
  22380. /**
  22381. * Creates the VertexData of the Ground designed from a heightmap
  22382. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22383. * * width the width (x direction) of the ground
  22384. * * height the height (z direction) of the ground
  22385. * * subdivisions the number of subdivisions per side
  22386. * * minHeight the minimum altitude on the ground, optional, default 0
  22387. * * maxHeight the maximum altitude on the ground, optional default 1
  22388. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22389. * * buffer the array holding the image color data
  22390. * * bufferWidth the width of image
  22391. * * bufferHeight the height of image
  22392. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22393. * @returns the VertexData of the Ground designed from a heightmap
  22394. */
  22395. static CreateGroundFromHeightMap(options: {
  22396. width: number;
  22397. height: number;
  22398. subdivisions: number;
  22399. minHeight: number;
  22400. maxHeight: number;
  22401. colorFilter: Color3;
  22402. buffer: Uint8Array;
  22403. bufferWidth: number;
  22404. bufferHeight: number;
  22405. alphaFilter: number;
  22406. }): VertexData;
  22407. /**
  22408. * Creates the VertexData for a Plane
  22409. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22410. * * size sets the width and height of the plane to the value of size, optional default 1
  22411. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22412. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22414. * * 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)
  22415. * * 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)
  22416. * @returns the VertexData of the box
  22417. */
  22418. static CreatePlane(options: {
  22419. size?: number;
  22420. width?: number;
  22421. height?: number;
  22422. sideOrientation?: number;
  22423. frontUVs?: Vector4;
  22424. backUVs?: Vector4;
  22425. }): VertexData;
  22426. /**
  22427. * Creates the VertexData of the Disc or regular Polygon
  22428. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22429. * * radius the radius of the disc, optional default 0.5
  22430. * * tessellation the number of polygon sides, optional, default 64
  22431. * * 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
  22432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22433. * * 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)
  22434. * * 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)
  22435. * @returns the VertexData of the box
  22436. */
  22437. static CreateDisc(options: {
  22438. radius?: number;
  22439. tessellation?: number;
  22440. arc?: number;
  22441. sideOrientation?: number;
  22442. frontUVs?: Vector4;
  22443. backUVs?: Vector4;
  22444. }): VertexData;
  22445. /**
  22446. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22447. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22448. * @param polygon a mesh built from polygonTriangulation.build()
  22449. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22450. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22451. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22452. * @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)
  22453. * @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)
  22454. * @returns the VertexData of the Polygon
  22455. */
  22456. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22457. /**
  22458. * Creates the VertexData of the IcoSphere
  22459. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22460. * * radius the radius of the IcoSphere, optional default 1
  22461. * * radiusX allows stretching in the x direction, optional, default radius
  22462. * * radiusY allows stretching in the y direction, optional, default radius
  22463. * * radiusZ allows stretching in the z direction, optional, default radius
  22464. * * flat when true creates a flat shaded mesh, optional, default true
  22465. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22467. * * 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)
  22468. * * 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)
  22469. * @returns the VertexData of the IcoSphere
  22470. */
  22471. static CreateIcoSphere(options: {
  22472. radius?: number;
  22473. radiusX?: number;
  22474. radiusY?: number;
  22475. radiusZ?: number;
  22476. flat?: boolean;
  22477. subdivisions?: number;
  22478. sideOrientation?: number;
  22479. frontUVs?: Vector4;
  22480. backUVs?: Vector4;
  22481. }): VertexData;
  22482. /**
  22483. * Creates the VertexData for a Polyhedron
  22484. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22485. * * type provided types are:
  22486. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22487. * * 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)
  22488. * * size the size of the IcoSphere, optional default 1
  22489. * * sizeX allows stretching in the x direction, optional, default size
  22490. * * sizeY allows stretching in the y direction, optional, default size
  22491. * * sizeZ allows stretching in the z direction, optional, default size
  22492. * * 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
  22493. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22494. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22495. * * flat when true creates a flat shaded mesh, optional, default true
  22496. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22498. * * 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)
  22499. * * 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)
  22500. * @returns the VertexData of the Polyhedron
  22501. */
  22502. static CreatePolyhedron(options: {
  22503. type?: number;
  22504. size?: number;
  22505. sizeX?: number;
  22506. sizeY?: number;
  22507. sizeZ?: number;
  22508. custom?: any;
  22509. faceUV?: Vector4[];
  22510. faceColors?: Color4[];
  22511. flat?: boolean;
  22512. sideOrientation?: number;
  22513. frontUVs?: Vector4;
  22514. backUVs?: Vector4;
  22515. }): VertexData;
  22516. /**
  22517. * Creates the VertexData for a TorusKnot
  22518. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22519. * * radius the radius of the torus knot, optional, default 2
  22520. * * tube the thickness of the tube, optional, default 0.5
  22521. * * radialSegments the number of sides on each tube segments, optional, default 32
  22522. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22523. * * p the number of windings around the z axis, optional, default 2
  22524. * * q the number of windings around the x axis, optional, default 3
  22525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22526. * * 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)
  22527. * * 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)
  22528. * @returns the VertexData of the Torus Knot
  22529. */
  22530. static CreateTorusKnot(options: {
  22531. radius?: number;
  22532. tube?: number;
  22533. radialSegments?: number;
  22534. tubularSegments?: number;
  22535. p?: number;
  22536. q?: number;
  22537. sideOrientation?: number;
  22538. frontUVs?: Vector4;
  22539. backUVs?: Vector4;
  22540. }): VertexData;
  22541. /**
  22542. * Compute normals for given positions and indices
  22543. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22544. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22545. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22546. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22547. * * facetNormals : optional array of facet normals (vector3)
  22548. * * facetPositions : optional array of facet positions (vector3)
  22549. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22550. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22551. * * bInfo : optional bounding info, required for facetPartitioning computation
  22552. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22553. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22554. * * useRightHandedSystem: optional boolean to for right handed system computation
  22555. * * depthSort : optional boolean to enable the facet depth sort computation
  22556. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22557. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22558. */
  22559. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22560. facetNormals?: any;
  22561. facetPositions?: any;
  22562. facetPartitioning?: any;
  22563. ratio?: number;
  22564. bInfo?: any;
  22565. bbSize?: Vector3;
  22566. subDiv?: any;
  22567. useRightHandedSystem?: boolean;
  22568. depthSort?: boolean;
  22569. distanceTo?: Vector3;
  22570. depthSortedFacets?: any;
  22571. }): void;
  22572. /** @hidden */
  22573. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22574. /**
  22575. * Applies VertexData created from the imported parameters to the geometry
  22576. * @param parsedVertexData the parsed data from an imported file
  22577. * @param geometry the geometry to apply the VertexData to
  22578. */
  22579. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22580. }
  22581. }
  22582. declare module "babylonjs/Morph/morphTarget" {
  22583. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22584. import { Observable } from "babylonjs/Misc/observable";
  22585. import { Nullable, FloatArray } from "babylonjs/types";
  22586. import { Scene } from "babylonjs/scene";
  22587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22588. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22589. /**
  22590. * Defines a target to use with MorphTargetManager
  22591. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22592. */
  22593. export class MorphTarget implements IAnimatable {
  22594. /** defines the name of the target */
  22595. name: string;
  22596. /**
  22597. * Gets or sets the list of animations
  22598. */
  22599. animations: import("babylonjs/Animations/animation").Animation[];
  22600. private _scene;
  22601. private _positions;
  22602. private _normals;
  22603. private _tangents;
  22604. private _uvs;
  22605. private _influence;
  22606. /**
  22607. * Observable raised when the influence changes
  22608. */
  22609. onInfluenceChanged: Observable<boolean>;
  22610. /** @hidden */
  22611. _onDataLayoutChanged: Observable<void>;
  22612. /**
  22613. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22614. */
  22615. influence: number;
  22616. /**
  22617. * Gets or sets the id of the morph Target
  22618. */
  22619. id: string;
  22620. private _animationPropertiesOverride;
  22621. /**
  22622. * Gets or sets the animation properties override
  22623. */
  22624. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22625. /**
  22626. * Creates a new MorphTarget
  22627. * @param name defines the name of the target
  22628. * @param influence defines the influence to use
  22629. * @param scene defines the scene the morphtarget belongs to
  22630. */
  22631. constructor(
  22632. /** defines the name of the target */
  22633. name: string, influence?: number, scene?: Nullable<Scene>);
  22634. /**
  22635. * Gets a boolean defining if the target contains position data
  22636. */
  22637. readonly hasPositions: boolean;
  22638. /**
  22639. * Gets a boolean defining if the target contains normal data
  22640. */
  22641. readonly hasNormals: boolean;
  22642. /**
  22643. * Gets a boolean defining if the target contains tangent data
  22644. */
  22645. readonly hasTangents: boolean;
  22646. /**
  22647. * Gets a boolean defining if the target contains texture coordinates data
  22648. */
  22649. readonly hasUVs: boolean;
  22650. /**
  22651. * Affects position data to this target
  22652. * @param data defines the position data to use
  22653. */
  22654. setPositions(data: Nullable<FloatArray>): void;
  22655. /**
  22656. * Gets the position data stored in this target
  22657. * @returns a FloatArray containing the position data (or null if not present)
  22658. */
  22659. getPositions(): Nullable<FloatArray>;
  22660. /**
  22661. * Affects normal data to this target
  22662. * @param data defines the normal data to use
  22663. */
  22664. setNormals(data: Nullable<FloatArray>): void;
  22665. /**
  22666. * Gets the normal data stored in this target
  22667. * @returns a FloatArray containing the normal data (or null if not present)
  22668. */
  22669. getNormals(): Nullable<FloatArray>;
  22670. /**
  22671. * Affects tangent data to this target
  22672. * @param data defines the tangent data to use
  22673. */
  22674. setTangents(data: Nullable<FloatArray>): void;
  22675. /**
  22676. * Gets the tangent data stored in this target
  22677. * @returns a FloatArray containing the tangent data (or null if not present)
  22678. */
  22679. getTangents(): Nullable<FloatArray>;
  22680. /**
  22681. * Affects texture coordinates data to this target
  22682. * @param data defines the texture coordinates data to use
  22683. */
  22684. setUVs(data: Nullable<FloatArray>): void;
  22685. /**
  22686. * Gets the texture coordinates data stored in this target
  22687. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22688. */
  22689. getUVs(): Nullable<FloatArray>;
  22690. /**
  22691. * Serializes the current target into a Serialization object
  22692. * @returns the serialized object
  22693. */
  22694. serialize(): any;
  22695. /**
  22696. * Returns the string "MorphTarget"
  22697. * @returns "MorphTarget"
  22698. */
  22699. getClassName(): string;
  22700. /**
  22701. * Creates a new target from serialized data
  22702. * @param serializationObject defines the serialized data to use
  22703. * @returns a new MorphTarget
  22704. */
  22705. static Parse(serializationObject: any): MorphTarget;
  22706. /**
  22707. * Creates a MorphTarget from mesh data
  22708. * @param mesh defines the source mesh
  22709. * @param name defines the name to use for the new target
  22710. * @param influence defines the influence to attach to the target
  22711. * @returns a new MorphTarget
  22712. */
  22713. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22714. }
  22715. }
  22716. declare module "babylonjs/Morph/morphTargetManager" {
  22717. import { Nullable } from "babylonjs/types";
  22718. import { Scene } from "babylonjs/scene";
  22719. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22720. /**
  22721. * This class is used to deform meshes using morphing between different targets
  22722. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22723. */
  22724. export class MorphTargetManager {
  22725. private _targets;
  22726. private _targetInfluenceChangedObservers;
  22727. private _targetDataLayoutChangedObservers;
  22728. private _activeTargets;
  22729. private _scene;
  22730. private _influences;
  22731. private _supportsNormals;
  22732. private _supportsTangents;
  22733. private _supportsUVs;
  22734. private _vertexCount;
  22735. private _uniqueId;
  22736. private _tempInfluences;
  22737. /**
  22738. * Gets or sets a boolean indicating if normals must be morphed
  22739. */
  22740. enableNormalMorphing: boolean;
  22741. /**
  22742. * Gets or sets a boolean indicating if tangents must be morphed
  22743. */
  22744. enableTangentMorphing: boolean;
  22745. /**
  22746. * Gets or sets a boolean indicating if UV must be morphed
  22747. */
  22748. enableUVMorphing: boolean;
  22749. /**
  22750. * Creates a new MorphTargetManager
  22751. * @param scene defines the current scene
  22752. */
  22753. constructor(scene?: Nullable<Scene>);
  22754. /**
  22755. * Gets the unique ID of this manager
  22756. */
  22757. readonly uniqueId: number;
  22758. /**
  22759. * Gets the number of vertices handled by this manager
  22760. */
  22761. readonly vertexCount: number;
  22762. /**
  22763. * Gets a boolean indicating if this manager supports morphing of normals
  22764. */
  22765. readonly supportsNormals: boolean;
  22766. /**
  22767. * Gets a boolean indicating if this manager supports morphing of tangents
  22768. */
  22769. readonly supportsTangents: boolean;
  22770. /**
  22771. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22772. */
  22773. readonly supportsUVs: boolean;
  22774. /**
  22775. * Gets the number of targets stored in this manager
  22776. */
  22777. readonly numTargets: number;
  22778. /**
  22779. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22780. */
  22781. readonly numInfluencers: number;
  22782. /**
  22783. * Gets the list of influences (one per target)
  22784. */
  22785. readonly influences: Float32Array;
  22786. /**
  22787. * Gets the active target at specified index. An active target is a target with an influence > 0
  22788. * @param index defines the index to check
  22789. * @returns the requested target
  22790. */
  22791. getActiveTarget(index: number): MorphTarget;
  22792. /**
  22793. * Gets the target at specified index
  22794. * @param index defines the index to check
  22795. * @returns the requested target
  22796. */
  22797. getTarget(index: number): MorphTarget;
  22798. /**
  22799. * Add a new target to this manager
  22800. * @param target defines the target to add
  22801. */
  22802. addTarget(target: MorphTarget): void;
  22803. /**
  22804. * Removes a target from the manager
  22805. * @param target defines the target to remove
  22806. */
  22807. removeTarget(target: MorphTarget): void;
  22808. /**
  22809. * Serializes the current manager into a Serialization object
  22810. * @returns the serialized object
  22811. */
  22812. serialize(): any;
  22813. private _syncActiveTargets;
  22814. /**
  22815. * Syncrhonize the targets with all the meshes using this morph target manager
  22816. */
  22817. synchronize(): void;
  22818. /**
  22819. * Creates a new MorphTargetManager from serialized data
  22820. * @param serializationObject defines the serialized data
  22821. * @param scene defines the hosting scene
  22822. * @returns the new MorphTargetManager
  22823. */
  22824. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22825. }
  22826. }
  22827. declare module "babylonjs/Meshes/meshLODLevel" {
  22828. import { Mesh } from "babylonjs/Meshes/mesh";
  22829. import { Nullable } from "babylonjs/types";
  22830. /**
  22831. * Class used to represent a specific level of detail of a mesh
  22832. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22833. */
  22834. export class MeshLODLevel {
  22835. /** Defines the distance where this level should start being displayed */
  22836. distance: number;
  22837. /** Defines the mesh to use to render this level */
  22838. mesh: Nullable<Mesh>;
  22839. /**
  22840. * Creates a new LOD level
  22841. * @param distance defines the distance where this level should star being displayed
  22842. * @param mesh defines the mesh to use to render this level
  22843. */
  22844. constructor(
  22845. /** Defines the distance where this level should start being displayed */
  22846. distance: number,
  22847. /** Defines the mesh to use to render this level */
  22848. mesh: Nullable<Mesh>);
  22849. }
  22850. }
  22851. declare module "babylonjs/Meshes/groundMesh" {
  22852. import { Scene } from "babylonjs/scene";
  22853. import { Vector3 } from "babylonjs/Maths/math.vector";
  22854. import { Mesh } from "babylonjs/Meshes/mesh";
  22855. /**
  22856. * Mesh representing the gorund
  22857. */
  22858. export class GroundMesh extends Mesh {
  22859. /** If octree should be generated */
  22860. generateOctree: boolean;
  22861. private _heightQuads;
  22862. /** @hidden */
  22863. _subdivisionsX: number;
  22864. /** @hidden */
  22865. _subdivisionsY: number;
  22866. /** @hidden */
  22867. _width: number;
  22868. /** @hidden */
  22869. _height: number;
  22870. /** @hidden */
  22871. _minX: number;
  22872. /** @hidden */
  22873. _maxX: number;
  22874. /** @hidden */
  22875. _minZ: number;
  22876. /** @hidden */
  22877. _maxZ: number;
  22878. constructor(name: string, scene: Scene);
  22879. /**
  22880. * "GroundMesh"
  22881. * @returns "GroundMesh"
  22882. */
  22883. getClassName(): string;
  22884. /**
  22885. * The minimum of x and y subdivisions
  22886. */
  22887. readonly subdivisions: number;
  22888. /**
  22889. * X subdivisions
  22890. */
  22891. readonly subdivisionsX: number;
  22892. /**
  22893. * Y subdivisions
  22894. */
  22895. readonly subdivisionsY: number;
  22896. /**
  22897. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22898. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22899. * @param chunksCount the number of subdivisions for x and y
  22900. * @param octreeBlocksSize (Default: 32)
  22901. */
  22902. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22903. /**
  22904. * Returns a height (y) value in the Worl system :
  22905. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22906. * @param x x coordinate
  22907. * @param z z coordinate
  22908. * @returns the ground y position if (x, z) are outside the ground surface.
  22909. */
  22910. getHeightAtCoordinates(x: number, z: number): number;
  22911. /**
  22912. * Returns a normalized vector (Vector3) orthogonal to the ground
  22913. * at the ground coordinates (x, z) expressed in the World system.
  22914. * @param x x coordinate
  22915. * @param z z coordinate
  22916. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22917. */
  22918. getNormalAtCoordinates(x: number, z: number): Vector3;
  22919. /**
  22920. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22921. * at the ground coordinates (x, z) expressed in the World system.
  22922. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22923. * @param x x coordinate
  22924. * @param z z coordinate
  22925. * @param ref vector to store the result
  22926. * @returns the GroundMesh.
  22927. */
  22928. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22929. /**
  22930. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22931. * if the ground has been updated.
  22932. * This can be used in the render loop.
  22933. * @returns the GroundMesh.
  22934. */
  22935. updateCoordinateHeights(): GroundMesh;
  22936. private _getFacetAt;
  22937. private _initHeightQuads;
  22938. private _computeHeightQuads;
  22939. /**
  22940. * Serializes this ground mesh
  22941. * @param serializationObject object to write serialization to
  22942. */
  22943. serialize(serializationObject: any): void;
  22944. /**
  22945. * Parses a serialized ground mesh
  22946. * @param parsedMesh the serialized mesh
  22947. * @param scene the scene to create the ground mesh in
  22948. * @returns the created ground mesh
  22949. */
  22950. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22951. }
  22952. }
  22953. declare module "babylonjs/Physics/physicsJoint" {
  22954. import { Vector3 } from "babylonjs/Maths/math.vector";
  22955. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22956. /**
  22957. * Interface for Physics-Joint data
  22958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22959. */
  22960. export interface PhysicsJointData {
  22961. /**
  22962. * The main pivot of the joint
  22963. */
  22964. mainPivot?: Vector3;
  22965. /**
  22966. * The connected pivot of the joint
  22967. */
  22968. connectedPivot?: Vector3;
  22969. /**
  22970. * The main axis of the joint
  22971. */
  22972. mainAxis?: Vector3;
  22973. /**
  22974. * The connected axis of the joint
  22975. */
  22976. connectedAxis?: Vector3;
  22977. /**
  22978. * The collision of the joint
  22979. */
  22980. collision?: boolean;
  22981. /**
  22982. * Native Oimo/Cannon/Energy data
  22983. */
  22984. nativeParams?: any;
  22985. }
  22986. /**
  22987. * This is a holder class for the physics joint created by the physics plugin
  22988. * It holds a set of functions to control the underlying joint
  22989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22990. */
  22991. export class PhysicsJoint {
  22992. /**
  22993. * The type of the physics joint
  22994. */
  22995. type: number;
  22996. /**
  22997. * The data for the physics joint
  22998. */
  22999. jointData: PhysicsJointData;
  23000. private _physicsJoint;
  23001. protected _physicsPlugin: IPhysicsEnginePlugin;
  23002. /**
  23003. * Initializes the physics joint
  23004. * @param type The type of the physics joint
  23005. * @param jointData The data for the physics joint
  23006. */
  23007. constructor(
  23008. /**
  23009. * The type of the physics joint
  23010. */
  23011. type: number,
  23012. /**
  23013. * The data for the physics joint
  23014. */
  23015. jointData: PhysicsJointData);
  23016. /**
  23017. * Gets the physics joint
  23018. */
  23019. /**
  23020. * Sets the physics joint
  23021. */
  23022. physicsJoint: any;
  23023. /**
  23024. * Sets the physics plugin
  23025. */
  23026. physicsPlugin: IPhysicsEnginePlugin;
  23027. /**
  23028. * Execute a function that is physics-plugin specific.
  23029. * @param {Function} func the function that will be executed.
  23030. * It accepts two parameters: the physics world and the physics joint
  23031. */
  23032. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23033. /**
  23034. * Distance-Joint type
  23035. */
  23036. static DistanceJoint: number;
  23037. /**
  23038. * Hinge-Joint type
  23039. */
  23040. static HingeJoint: number;
  23041. /**
  23042. * Ball-and-Socket joint type
  23043. */
  23044. static BallAndSocketJoint: number;
  23045. /**
  23046. * Wheel-Joint type
  23047. */
  23048. static WheelJoint: number;
  23049. /**
  23050. * Slider-Joint type
  23051. */
  23052. static SliderJoint: number;
  23053. /**
  23054. * Prismatic-Joint type
  23055. */
  23056. static PrismaticJoint: number;
  23057. /**
  23058. * Universal-Joint type
  23059. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23060. */
  23061. static UniversalJoint: number;
  23062. /**
  23063. * Hinge-Joint 2 type
  23064. */
  23065. static Hinge2Joint: number;
  23066. /**
  23067. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23068. */
  23069. static PointToPointJoint: number;
  23070. /**
  23071. * Spring-Joint type
  23072. */
  23073. static SpringJoint: number;
  23074. /**
  23075. * Lock-Joint type
  23076. */
  23077. static LockJoint: number;
  23078. }
  23079. /**
  23080. * A class representing a physics distance joint
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class DistanceJoint extends PhysicsJoint {
  23084. /**
  23085. *
  23086. * @param jointData The data for the Distance-Joint
  23087. */
  23088. constructor(jointData: DistanceJointData);
  23089. /**
  23090. * Update the predefined distance.
  23091. * @param maxDistance The maximum preferred distance
  23092. * @param minDistance The minimum preferred distance
  23093. */
  23094. updateDistance(maxDistance: number, minDistance?: number): void;
  23095. }
  23096. /**
  23097. * Represents a Motor-Enabled Joint
  23098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23099. */
  23100. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23101. /**
  23102. * Initializes the Motor-Enabled Joint
  23103. * @param type The type of the joint
  23104. * @param jointData The physica joint data for the joint
  23105. */
  23106. constructor(type: number, jointData: PhysicsJointData);
  23107. /**
  23108. * Set the motor values.
  23109. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23110. * @param force the force to apply
  23111. * @param maxForce max force for this motor.
  23112. */
  23113. setMotor(force?: number, maxForce?: number): void;
  23114. /**
  23115. * Set the motor's limits.
  23116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23117. * @param upperLimit The upper limit of the motor
  23118. * @param lowerLimit The lower limit of the motor
  23119. */
  23120. setLimit(upperLimit: number, lowerLimit?: number): void;
  23121. }
  23122. /**
  23123. * This class represents a single physics Hinge-Joint
  23124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23125. */
  23126. export class HingeJoint extends MotorEnabledJoint {
  23127. /**
  23128. * Initializes the Hinge-Joint
  23129. * @param jointData The joint data for the Hinge-Joint
  23130. */
  23131. constructor(jointData: PhysicsJointData);
  23132. /**
  23133. * Set the motor values.
  23134. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23135. * @param {number} force the force to apply
  23136. * @param {number} maxForce max force for this motor.
  23137. */
  23138. setMotor(force?: number, maxForce?: number): void;
  23139. /**
  23140. * Set the motor's limits.
  23141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23142. * @param upperLimit The upper limit of the motor
  23143. * @param lowerLimit The lower limit of the motor
  23144. */
  23145. setLimit(upperLimit: number, lowerLimit?: number): void;
  23146. }
  23147. /**
  23148. * This class represents a dual hinge physics joint (same as wheel joint)
  23149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23150. */
  23151. export class Hinge2Joint extends MotorEnabledJoint {
  23152. /**
  23153. * Initializes the Hinge2-Joint
  23154. * @param jointData The joint data for the Hinge2-Joint
  23155. */
  23156. constructor(jointData: PhysicsJointData);
  23157. /**
  23158. * Set the motor values.
  23159. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23160. * @param {number} targetSpeed the speed the motor is to reach
  23161. * @param {number} maxForce max force for this motor.
  23162. * @param {motorIndex} the motor's index, 0 or 1.
  23163. */
  23164. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23165. /**
  23166. * Set the motor limits.
  23167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23168. * @param {number} upperLimit the upper limit
  23169. * @param {number} lowerLimit lower limit
  23170. * @param {motorIndex} the motor's index, 0 or 1.
  23171. */
  23172. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23173. }
  23174. /**
  23175. * Interface for a motor enabled joint
  23176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23177. */
  23178. export interface IMotorEnabledJoint {
  23179. /**
  23180. * Physics joint
  23181. */
  23182. physicsJoint: any;
  23183. /**
  23184. * Sets the motor of the motor-enabled joint
  23185. * @param force The force of the motor
  23186. * @param maxForce The maximum force of the motor
  23187. * @param motorIndex The index of the motor
  23188. */
  23189. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23190. /**
  23191. * Sets the limit of the motor
  23192. * @param upperLimit The upper limit of the motor
  23193. * @param lowerLimit The lower limit of the motor
  23194. * @param motorIndex The index of the motor
  23195. */
  23196. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23197. }
  23198. /**
  23199. * Joint data for a Distance-Joint
  23200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23201. */
  23202. export interface DistanceJointData extends PhysicsJointData {
  23203. /**
  23204. * Max distance the 2 joint objects can be apart
  23205. */
  23206. maxDistance: number;
  23207. }
  23208. /**
  23209. * Joint data from a spring joint
  23210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export interface SpringJointData extends PhysicsJointData {
  23213. /**
  23214. * Length of the spring
  23215. */
  23216. length: number;
  23217. /**
  23218. * Stiffness of the spring
  23219. */
  23220. stiffness: number;
  23221. /**
  23222. * Damping of the spring
  23223. */
  23224. damping: number;
  23225. /** this callback will be called when applying the force to the impostors. */
  23226. forceApplicationCallback: () => void;
  23227. }
  23228. }
  23229. declare module "babylonjs/Physics/physicsRaycastResult" {
  23230. import { Vector3 } from "babylonjs/Maths/math.vector";
  23231. /**
  23232. * Holds the data for the raycast result
  23233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23234. */
  23235. export class PhysicsRaycastResult {
  23236. private _hasHit;
  23237. private _hitDistance;
  23238. private _hitNormalWorld;
  23239. private _hitPointWorld;
  23240. private _rayFromWorld;
  23241. private _rayToWorld;
  23242. /**
  23243. * Gets if there was a hit
  23244. */
  23245. readonly hasHit: boolean;
  23246. /**
  23247. * Gets the distance from the hit
  23248. */
  23249. readonly hitDistance: number;
  23250. /**
  23251. * Gets the hit normal/direction in the world
  23252. */
  23253. readonly hitNormalWorld: Vector3;
  23254. /**
  23255. * Gets the hit point in the world
  23256. */
  23257. readonly hitPointWorld: Vector3;
  23258. /**
  23259. * Gets the ray "start point" of the ray in the world
  23260. */
  23261. readonly rayFromWorld: Vector3;
  23262. /**
  23263. * Gets the ray "end point" of the ray in the world
  23264. */
  23265. readonly rayToWorld: Vector3;
  23266. /**
  23267. * Sets the hit data (normal & point in world space)
  23268. * @param hitNormalWorld defines the normal in world space
  23269. * @param hitPointWorld defines the point in world space
  23270. */
  23271. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23272. /**
  23273. * Sets the distance from the start point to the hit point
  23274. * @param distance
  23275. */
  23276. setHitDistance(distance: number): void;
  23277. /**
  23278. * Calculates the distance manually
  23279. */
  23280. calculateHitDistance(): void;
  23281. /**
  23282. * Resets all the values to default
  23283. * @param from The from point on world space
  23284. * @param to The to point on world space
  23285. */
  23286. reset(from?: Vector3, to?: Vector3): void;
  23287. }
  23288. /**
  23289. * Interface for the size containing width and height
  23290. */
  23291. interface IXYZ {
  23292. /**
  23293. * X
  23294. */
  23295. x: number;
  23296. /**
  23297. * Y
  23298. */
  23299. y: number;
  23300. /**
  23301. * Z
  23302. */
  23303. z: number;
  23304. }
  23305. }
  23306. declare module "babylonjs/Physics/IPhysicsEngine" {
  23307. import { Nullable } from "babylonjs/types";
  23308. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23310. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23311. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23312. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23313. /**
  23314. * Interface used to describe a physics joint
  23315. */
  23316. export interface PhysicsImpostorJoint {
  23317. /** Defines the main impostor to which the joint is linked */
  23318. mainImpostor: PhysicsImpostor;
  23319. /** Defines the impostor that is connected to the main impostor using this joint */
  23320. connectedImpostor: PhysicsImpostor;
  23321. /** Defines the joint itself */
  23322. joint: PhysicsJoint;
  23323. }
  23324. /** @hidden */
  23325. export interface IPhysicsEnginePlugin {
  23326. world: any;
  23327. name: string;
  23328. setGravity(gravity: Vector3): void;
  23329. setTimeStep(timeStep: number): void;
  23330. getTimeStep(): number;
  23331. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23332. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23333. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23334. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23335. removePhysicsBody(impostor: PhysicsImpostor): void;
  23336. generateJoint(joint: PhysicsImpostorJoint): void;
  23337. removeJoint(joint: PhysicsImpostorJoint): void;
  23338. isSupported(): boolean;
  23339. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23340. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23341. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23342. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23343. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23344. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23345. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23346. getBodyMass(impostor: PhysicsImpostor): number;
  23347. getBodyFriction(impostor: PhysicsImpostor): number;
  23348. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23349. getBodyRestitution(impostor: PhysicsImpostor): number;
  23350. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23351. getBodyPressure?(impostor: PhysicsImpostor): number;
  23352. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23353. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23354. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23355. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23356. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23357. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23358. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23359. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23360. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23361. sleepBody(impostor: PhysicsImpostor): void;
  23362. wakeUpBody(impostor: PhysicsImpostor): void;
  23363. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23364. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23365. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23366. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23367. getRadius(impostor: PhysicsImpostor): number;
  23368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23370. dispose(): void;
  23371. }
  23372. /**
  23373. * Interface used to define a physics engine
  23374. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23375. */
  23376. export interface IPhysicsEngine {
  23377. /**
  23378. * Gets the gravity vector used by the simulation
  23379. */
  23380. gravity: Vector3;
  23381. /**
  23382. * Sets the gravity vector used by the simulation
  23383. * @param gravity defines the gravity vector to use
  23384. */
  23385. setGravity(gravity: Vector3): void;
  23386. /**
  23387. * Set the time step of the physics engine.
  23388. * Default is 1/60.
  23389. * To slow it down, enter 1/600 for example.
  23390. * To speed it up, 1/30
  23391. * @param newTimeStep the new timestep to apply to this world.
  23392. */
  23393. setTimeStep(newTimeStep: number): void;
  23394. /**
  23395. * Get the time step of the physics engine.
  23396. * @returns the current time step
  23397. */
  23398. getTimeStep(): number;
  23399. /**
  23400. * Release all resources
  23401. */
  23402. dispose(): void;
  23403. /**
  23404. * Gets the name of the current physics plugin
  23405. * @returns the name of the plugin
  23406. */
  23407. getPhysicsPluginName(): string;
  23408. /**
  23409. * Adding a new impostor for the impostor tracking.
  23410. * This will be done by the impostor itself.
  23411. * @param impostor the impostor to add
  23412. */
  23413. addImpostor(impostor: PhysicsImpostor): void;
  23414. /**
  23415. * Remove an impostor from the engine.
  23416. * This impostor and its mesh will not longer be updated by the physics engine.
  23417. * @param impostor the impostor to remove
  23418. */
  23419. removeImpostor(impostor: PhysicsImpostor): void;
  23420. /**
  23421. * Add a joint to the physics engine
  23422. * @param mainImpostor defines the main impostor to which the joint is added.
  23423. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23424. * @param joint defines the joint that will connect both impostors.
  23425. */
  23426. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23427. /**
  23428. * Removes a joint from the simulation
  23429. * @param mainImpostor defines the impostor used with the joint
  23430. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23431. * @param joint defines the joint to remove
  23432. */
  23433. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23434. /**
  23435. * Gets the current plugin used to run the simulation
  23436. * @returns current plugin
  23437. */
  23438. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23439. /**
  23440. * Gets the list of physic impostors
  23441. * @returns an array of PhysicsImpostor
  23442. */
  23443. getImpostors(): Array<PhysicsImpostor>;
  23444. /**
  23445. * Gets the impostor for a physics enabled object
  23446. * @param object defines the object impersonated by the impostor
  23447. * @returns the PhysicsImpostor or null if not found
  23448. */
  23449. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23450. /**
  23451. * Gets the impostor for a physics body object
  23452. * @param body defines physics body used by the impostor
  23453. * @returns the PhysicsImpostor or null if not found
  23454. */
  23455. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23456. /**
  23457. * Does a raycast in the physics world
  23458. * @param from when should the ray start?
  23459. * @param to when should the ray end?
  23460. * @returns PhysicsRaycastResult
  23461. */
  23462. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23463. /**
  23464. * Called by the scene. No need to call it.
  23465. * @param delta defines the timespam between frames
  23466. */
  23467. _step(delta: number): void;
  23468. }
  23469. }
  23470. declare module "babylonjs/Physics/physicsImpostor" {
  23471. import { Nullable, IndicesArray } from "babylonjs/types";
  23472. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23475. import { Scene } from "babylonjs/scene";
  23476. import { Bone } from "babylonjs/Bones/bone";
  23477. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23478. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23479. import { Space } from "babylonjs/Maths/math.axis";
  23480. /**
  23481. * The interface for the physics imposter parameters
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export interface PhysicsImpostorParameters {
  23485. /**
  23486. * The mass of the physics imposter
  23487. */
  23488. mass: number;
  23489. /**
  23490. * The friction of the physics imposter
  23491. */
  23492. friction?: number;
  23493. /**
  23494. * The coefficient of restitution of the physics imposter
  23495. */
  23496. restitution?: number;
  23497. /**
  23498. * The native options of the physics imposter
  23499. */
  23500. nativeOptions?: any;
  23501. /**
  23502. * Specifies if the parent should be ignored
  23503. */
  23504. ignoreParent?: boolean;
  23505. /**
  23506. * Specifies if bi-directional transformations should be disabled
  23507. */
  23508. disableBidirectionalTransformation?: boolean;
  23509. /**
  23510. * The pressure inside the physics imposter, soft object only
  23511. */
  23512. pressure?: number;
  23513. /**
  23514. * The stiffness the physics imposter, soft object only
  23515. */
  23516. stiffness?: number;
  23517. /**
  23518. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23519. */
  23520. velocityIterations?: number;
  23521. /**
  23522. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23523. */
  23524. positionIterations?: number;
  23525. /**
  23526. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23527. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23528. * Add to fix multiple points
  23529. */
  23530. fixedPoints?: number;
  23531. /**
  23532. * The collision margin around a soft object
  23533. */
  23534. margin?: number;
  23535. /**
  23536. * The collision margin around a soft object
  23537. */
  23538. damping?: number;
  23539. /**
  23540. * The path for a rope based on an extrusion
  23541. */
  23542. path?: any;
  23543. /**
  23544. * The shape of an extrusion used for a rope based on an extrusion
  23545. */
  23546. shape?: any;
  23547. }
  23548. /**
  23549. * Interface for a physics-enabled object
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface IPhysicsEnabledObject {
  23553. /**
  23554. * The position of the physics-enabled object
  23555. */
  23556. position: Vector3;
  23557. /**
  23558. * The rotation of the physics-enabled object
  23559. */
  23560. rotationQuaternion: Nullable<Quaternion>;
  23561. /**
  23562. * The scale of the physics-enabled object
  23563. */
  23564. scaling: Vector3;
  23565. /**
  23566. * The rotation of the physics-enabled object
  23567. */
  23568. rotation?: Vector3;
  23569. /**
  23570. * The parent of the physics-enabled object
  23571. */
  23572. parent?: any;
  23573. /**
  23574. * The bounding info of the physics-enabled object
  23575. * @returns The bounding info of the physics-enabled object
  23576. */
  23577. getBoundingInfo(): BoundingInfo;
  23578. /**
  23579. * Computes the world matrix
  23580. * @param force Specifies if the world matrix should be computed by force
  23581. * @returns A world matrix
  23582. */
  23583. computeWorldMatrix(force: boolean): Matrix;
  23584. /**
  23585. * Gets the world matrix
  23586. * @returns A world matrix
  23587. */
  23588. getWorldMatrix?(): Matrix;
  23589. /**
  23590. * Gets the child meshes
  23591. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23592. * @returns An array of abstract meshes
  23593. */
  23594. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23595. /**
  23596. * Gets the vertex data
  23597. * @param kind The type of vertex data
  23598. * @returns A nullable array of numbers, or a float32 array
  23599. */
  23600. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23601. /**
  23602. * Gets the indices from the mesh
  23603. * @returns A nullable array of index arrays
  23604. */
  23605. getIndices?(): Nullable<IndicesArray>;
  23606. /**
  23607. * Gets the scene from the mesh
  23608. * @returns the indices array or null
  23609. */
  23610. getScene?(): Scene;
  23611. /**
  23612. * Gets the absolute position from the mesh
  23613. * @returns the absolute position
  23614. */
  23615. getAbsolutePosition(): Vector3;
  23616. /**
  23617. * Gets the absolute pivot point from the mesh
  23618. * @returns the absolute pivot point
  23619. */
  23620. getAbsolutePivotPoint(): Vector3;
  23621. /**
  23622. * Rotates the mesh
  23623. * @param axis The axis of rotation
  23624. * @param amount The amount of rotation
  23625. * @param space The space of the rotation
  23626. * @returns The rotation transform node
  23627. */
  23628. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23629. /**
  23630. * Translates the mesh
  23631. * @param axis The axis of translation
  23632. * @param distance The distance of translation
  23633. * @param space The space of the translation
  23634. * @returns The transform node
  23635. */
  23636. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23637. /**
  23638. * Sets the absolute position of the mesh
  23639. * @param absolutePosition The absolute position of the mesh
  23640. * @returns The transform node
  23641. */
  23642. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23643. /**
  23644. * Gets the class name of the mesh
  23645. * @returns The class name
  23646. */
  23647. getClassName(): string;
  23648. }
  23649. /**
  23650. * Represents a physics imposter
  23651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23652. */
  23653. export class PhysicsImpostor {
  23654. /**
  23655. * The physics-enabled object used as the physics imposter
  23656. */
  23657. object: IPhysicsEnabledObject;
  23658. /**
  23659. * The type of the physics imposter
  23660. */
  23661. type: number;
  23662. private _options;
  23663. private _scene?;
  23664. /**
  23665. * The default object size of the imposter
  23666. */
  23667. static DEFAULT_OBJECT_SIZE: Vector3;
  23668. /**
  23669. * The identity quaternion of the imposter
  23670. */
  23671. static IDENTITY_QUATERNION: Quaternion;
  23672. /** @hidden */
  23673. _pluginData: any;
  23674. private _physicsEngine;
  23675. private _physicsBody;
  23676. private _bodyUpdateRequired;
  23677. private _onBeforePhysicsStepCallbacks;
  23678. private _onAfterPhysicsStepCallbacks;
  23679. /** @hidden */
  23680. _onPhysicsCollideCallbacks: Array<{
  23681. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23682. otherImpostors: Array<PhysicsImpostor>;
  23683. }>;
  23684. private _deltaPosition;
  23685. private _deltaRotation;
  23686. private _deltaRotationConjugated;
  23687. /** @hidden */
  23688. _isFromLine: boolean;
  23689. private _parent;
  23690. private _isDisposed;
  23691. private static _tmpVecs;
  23692. private static _tmpQuat;
  23693. /**
  23694. * Specifies if the physics imposter is disposed
  23695. */
  23696. readonly isDisposed: boolean;
  23697. /**
  23698. * Gets the mass of the physics imposter
  23699. */
  23700. mass: number;
  23701. /**
  23702. * Gets the coefficient of friction
  23703. */
  23704. /**
  23705. * Sets the coefficient of friction
  23706. */
  23707. friction: number;
  23708. /**
  23709. * Gets the coefficient of restitution
  23710. */
  23711. /**
  23712. * Sets the coefficient of restitution
  23713. */
  23714. restitution: number;
  23715. /**
  23716. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23717. */
  23718. /**
  23719. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23720. */
  23721. pressure: number;
  23722. /**
  23723. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23724. */
  23725. /**
  23726. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23727. */
  23728. stiffness: number;
  23729. /**
  23730. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23731. */
  23732. /**
  23733. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23734. */
  23735. velocityIterations: number;
  23736. /**
  23737. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23738. */
  23739. /**
  23740. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23741. */
  23742. positionIterations: number;
  23743. /**
  23744. * The unique id of the physics imposter
  23745. * set by the physics engine when adding this impostor to the array
  23746. */
  23747. uniqueId: number;
  23748. /**
  23749. * @hidden
  23750. */
  23751. soft: boolean;
  23752. /**
  23753. * @hidden
  23754. */
  23755. segments: number;
  23756. private _joints;
  23757. /**
  23758. * Initializes the physics imposter
  23759. * @param object The physics-enabled object used as the physics imposter
  23760. * @param type The type of the physics imposter
  23761. * @param _options The options for the physics imposter
  23762. * @param _scene The Babylon scene
  23763. */
  23764. constructor(
  23765. /**
  23766. * The physics-enabled object used as the physics imposter
  23767. */
  23768. object: IPhysicsEnabledObject,
  23769. /**
  23770. * The type of the physics imposter
  23771. */
  23772. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23773. /**
  23774. * This function will completly initialize this impostor.
  23775. * It will create a new body - but only if this mesh has no parent.
  23776. * If it has, this impostor will not be used other than to define the impostor
  23777. * of the child mesh.
  23778. * @hidden
  23779. */
  23780. _init(): void;
  23781. private _getPhysicsParent;
  23782. /**
  23783. * Should a new body be generated.
  23784. * @returns boolean specifying if body initialization is required
  23785. */
  23786. isBodyInitRequired(): boolean;
  23787. /**
  23788. * Sets the updated scaling
  23789. * @param updated Specifies if the scaling is updated
  23790. */
  23791. setScalingUpdated(): void;
  23792. /**
  23793. * Force a regeneration of this or the parent's impostor's body.
  23794. * Use under cautious - This will remove all joints already implemented.
  23795. */
  23796. forceUpdate(): void;
  23797. /**
  23798. * Gets the body that holds this impostor. Either its own, or its parent.
  23799. */
  23800. /**
  23801. * Set the physics body. Used mainly by the physics engine/plugin
  23802. */
  23803. physicsBody: any;
  23804. /**
  23805. * Get the parent of the physics imposter
  23806. * @returns Physics imposter or null
  23807. */
  23808. /**
  23809. * Sets the parent of the physics imposter
  23810. */
  23811. parent: Nullable<PhysicsImpostor>;
  23812. /**
  23813. * Resets the update flags
  23814. */
  23815. resetUpdateFlags(): void;
  23816. /**
  23817. * Gets the object extend size
  23818. * @returns the object extend size
  23819. */
  23820. getObjectExtendSize(): Vector3;
  23821. /**
  23822. * Gets the object center
  23823. * @returns The object center
  23824. */
  23825. getObjectCenter(): Vector3;
  23826. /**
  23827. * Get a specific parametes from the options parameter
  23828. * @param paramName The object parameter name
  23829. * @returns The object parameter
  23830. */
  23831. getParam(paramName: string): any;
  23832. /**
  23833. * Sets a specific parameter in the options given to the physics plugin
  23834. * @param paramName The parameter name
  23835. * @param value The value of the parameter
  23836. */
  23837. setParam(paramName: string, value: number): void;
  23838. /**
  23839. * Specifically change the body's mass option. Won't recreate the physics body object
  23840. * @param mass The mass of the physics imposter
  23841. */
  23842. setMass(mass: number): void;
  23843. /**
  23844. * Gets the linear velocity
  23845. * @returns linear velocity or null
  23846. */
  23847. getLinearVelocity(): Nullable<Vector3>;
  23848. /**
  23849. * Sets the linear velocity
  23850. * @param velocity linear velocity or null
  23851. */
  23852. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23853. /**
  23854. * Gets the angular velocity
  23855. * @returns angular velocity or null
  23856. */
  23857. getAngularVelocity(): Nullable<Vector3>;
  23858. /**
  23859. * Sets the angular velocity
  23860. * @param velocity The velocity or null
  23861. */
  23862. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23863. /**
  23864. * Execute a function with the physics plugin native code
  23865. * Provide a function the will have two variables - the world object and the physics body object
  23866. * @param func The function to execute with the physics plugin native code
  23867. */
  23868. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23869. /**
  23870. * Register a function that will be executed before the physics world is stepping forward
  23871. * @param func The function to execute before the physics world is stepped forward
  23872. */
  23873. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23874. /**
  23875. * Unregister a function that will be executed before the physics world is stepping forward
  23876. * @param func The function to execute before the physics world is stepped forward
  23877. */
  23878. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23879. /**
  23880. * Register a function that will be executed after the physics step
  23881. * @param func The function to execute after physics step
  23882. */
  23883. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23884. /**
  23885. * Unregisters a function that will be executed after the physics step
  23886. * @param func The function to execute after physics step
  23887. */
  23888. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23889. /**
  23890. * register a function that will be executed when this impostor collides against a different body
  23891. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23892. * @param func Callback that is executed on collision
  23893. */
  23894. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23895. /**
  23896. * Unregisters the physics imposter on contact
  23897. * @param collideAgainst The physics object to collide against
  23898. * @param func Callback to execute on collision
  23899. */
  23900. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23901. private _tmpQuat;
  23902. private _tmpQuat2;
  23903. /**
  23904. * Get the parent rotation
  23905. * @returns The parent rotation
  23906. */
  23907. getParentsRotation(): Quaternion;
  23908. /**
  23909. * this function is executed by the physics engine.
  23910. */
  23911. beforeStep: () => void;
  23912. /**
  23913. * this function is executed by the physics engine
  23914. */
  23915. afterStep: () => void;
  23916. /**
  23917. * Legacy collision detection event support
  23918. */
  23919. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23920. /**
  23921. * event and body object due to cannon's event-based architecture.
  23922. */
  23923. onCollide: (e: {
  23924. body: any;
  23925. }) => void;
  23926. /**
  23927. * Apply a force
  23928. * @param force The force to apply
  23929. * @param contactPoint The contact point for the force
  23930. * @returns The physics imposter
  23931. */
  23932. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23933. /**
  23934. * Apply an impulse
  23935. * @param force The impulse force
  23936. * @param contactPoint The contact point for the impulse force
  23937. * @returns The physics imposter
  23938. */
  23939. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23940. /**
  23941. * A help function to create a joint
  23942. * @param otherImpostor A physics imposter used to create a joint
  23943. * @param jointType The type of joint
  23944. * @param jointData The data for the joint
  23945. * @returns The physics imposter
  23946. */
  23947. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23948. /**
  23949. * Add a joint to this impostor with a different impostor
  23950. * @param otherImpostor A physics imposter used to add a joint
  23951. * @param joint The joint to add
  23952. * @returns The physics imposter
  23953. */
  23954. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23955. /**
  23956. * Add an anchor to a cloth impostor
  23957. * @param otherImpostor rigid impostor to anchor to
  23958. * @param width ratio across width from 0 to 1
  23959. * @param height ratio up height from 0 to 1
  23960. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23961. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23962. * @returns impostor the soft imposter
  23963. */
  23964. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23965. /**
  23966. * Add a hook to a rope impostor
  23967. * @param otherImpostor rigid impostor to anchor to
  23968. * @param length ratio across rope from 0 to 1
  23969. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23970. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23971. * @returns impostor the rope imposter
  23972. */
  23973. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23974. /**
  23975. * Will keep this body still, in a sleep mode.
  23976. * @returns the physics imposter
  23977. */
  23978. sleep(): PhysicsImpostor;
  23979. /**
  23980. * Wake the body up.
  23981. * @returns The physics imposter
  23982. */
  23983. wakeUp(): PhysicsImpostor;
  23984. /**
  23985. * Clones the physics imposter
  23986. * @param newObject The physics imposter clones to this physics-enabled object
  23987. * @returns A nullable physics imposter
  23988. */
  23989. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23990. /**
  23991. * Disposes the physics imposter
  23992. */
  23993. dispose(): void;
  23994. /**
  23995. * Sets the delta position
  23996. * @param position The delta position amount
  23997. */
  23998. setDeltaPosition(position: Vector3): void;
  23999. /**
  24000. * Sets the delta rotation
  24001. * @param rotation The delta rotation amount
  24002. */
  24003. setDeltaRotation(rotation: Quaternion): void;
  24004. /**
  24005. * Gets the box size of the physics imposter and stores the result in the input parameter
  24006. * @param result Stores the box size
  24007. * @returns The physics imposter
  24008. */
  24009. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24010. /**
  24011. * Gets the radius of the physics imposter
  24012. * @returns Radius of the physics imposter
  24013. */
  24014. getRadius(): number;
  24015. /**
  24016. * Sync a bone with this impostor
  24017. * @param bone The bone to sync to the impostor.
  24018. * @param boneMesh The mesh that the bone is influencing.
  24019. * @param jointPivot The pivot of the joint / bone in local space.
  24020. * @param distToJoint Optional distance from the impostor to the joint.
  24021. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24022. */
  24023. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24024. /**
  24025. * Sync impostor to a bone
  24026. * @param bone The bone that the impostor will be synced to.
  24027. * @param boneMesh The mesh that the bone is influencing.
  24028. * @param jointPivot The pivot of the joint / bone in local space.
  24029. * @param distToJoint Optional distance from the impostor to the joint.
  24030. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24031. * @param boneAxis Optional vector3 axis the bone is aligned with
  24032. */
  24033. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24034. /**
  24035. * No-Imposter type
  24036. */
  24037. static NoImpostor: number;
  24038. /**
  24039. * Sphere-Imposter type
  24040. */
  24041. static SphereImpostor: number;
  24042. /**
  24043. * Box-Imposter type
  24044. */
  24045. static BoxImpostor: number;
  24046. /**
  24047. * Plane-Imposter type
  24048. */
  24049. static PlaneImpostor: number;
  24050. /**
  24051. * Mesh-imposter type
  24052. */
  24053. static MeshImpostor: number;
  24054. /**
  24055. * Capsule-Impostor type (Ammo.js plugin only)
  24056. */
  24057. static CapsuleImpostor: number;
  24058. /**
  24059. * Cylinder-Imposter type
  24060. */
  24061. static CylinderImpostor: number;
  24062. /**
  24063. * Particle-Imposter type
  24064. */
  24065. static ParticleImpostor: number;
  24066. /**
  24067. * Heightmap-Imposter type
  24068. */
  24069. static HeightmapImpostor: number;
  24070. /**
  24071. * ConvexHull-Impostor type (Ammo.js plugin only)
  24072. */
  24073. static ConvexHullImpostor: number;
  24074. /**
  24075. * Rope-Imposter type
  24076. */
  24077. static RopeImpostor: number;
  24078. /**
  24079. * Cloth-Imposter type
  24080. */
  24081. static ClothImpostor: number;
  24082. /**
  24083. * Softbody-Imposter type
  24084. */
  24085. static SoftbodyImpostor: number;
  24086. }
  24087. }
  24088. declare module "babylonjs/Meshes/mesh" {
  24089. import { Observable } from "babylonjs/Misc/observable";
  24090. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24091. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24092. import { Camera } from "babylonjs/Cameras/camera";
  24093. import { Scene } from "babylonjs/scene";
  24094. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24095. import { Color4 } from "babylonjs/Maths/math.color";
  24096. import { Engine } from "babylonjs/Engines/engine";
  24097. import { Node } from "babylonjs/node";
  24098. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24099. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24100. import { Buffer } from "babylonjs/Meshes/buffer";
  24101. import { Geometry } from "babylonjs/Meshes/geometry";
  24102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24104. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24105. import { Effect } from "babylonjs/Materials/effect";
  24106. import { Material } from "babylonjs/Materials/material";
  24107. import { Skeleton } from "babylonjs/Bones/skeleton";
  24108. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24109. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24110. import { Path3D } from "babylonjs/Maths/math.path";
  24111. import { Plane } from "babylonjs/Maths/math.plane";
  24112. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24113. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24114. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24115. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24116. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24117. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24118. /**
  24119. * @hidden
  24120. **/
  24121. export class _CreationDataStorage {
  24122. closePath?: boolean;
  24123. closeArray?: boolean;
  24124. idx: number[];
  24125. dashSize: number;
  24126. gapSize: number;
  24127. path3D: Path3D;
  24128. pathArray: Vector3[][];
  24129. arc: number;
  24130. radius: number;
  24131. cap: number;
  24132. tessellation: number;
  24133. }
  24134. /**
  24135. * @hidden
  24136. **/
  24137. class _InstanceDataStorage {
  24138. visibleInstances: any;
  24139. batchCache: _InstancesBatch;
  24140. instancesBufferSize: number;
  24141. instancesBuffer: Nullable<Buffer>;
  24142. instancesData: Float32Array;
  24143. overridenInstanceCount: number;
  24144. isFrozen: boolean;
  24145. previousBatch: Nullable<_InstancesBatch>;
  24146. hardwareInstancedRendering: boolean;
  24147. sideOrientation: number;
  24148. }
  24149. /**
  24150. * @hidden
  24151. **/
  24152. export class _InstancesBatch {
  24153. mustReturn: boolean;
  24154. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24155. renderSelf: boolean[];
  24156. hardwareInstancedRendering: boolean[];
  24157. }
  24158. /**
  24159. * Class used to represent renderable models
  24160. */
  24161. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24162. /**
  24163. * Mesh side orientation : usually the external or front surface
  24164. */
  24165. static readonly FRONTSIDE: number;
  24166. /**
  24167. * Mesh side orientation : usually the internal or back surface
  24168. */
  24169. static readonly BACKSIDE: number;
  24170. /**
  24171. * Mesh side orientation : both internal and external or front and back surfaces
  24172. */
  24173. static readonly DOUBLESIDE: number;
  24174. /**
  24175. * Mesh side orientation : by default, `FRONTSIDE`
  24176. */
  24177. static readonly DEFAULTSIDE: number;
  24178. /**
  24179. * Mesh cap setting : no cap
  24180. */
  24181. static readonly NO_CAP: number;
  24182. /**
  24183. * Mesh cap setting : one cap at the beginning of the mesh
  24184. */
  24185. static readonly CAP_START: number;
  24186. /**
  24187. * Mesh cap setting : one cap at the end of the mesh
  24188. */
  24189. static readonly CAP_END: number;
  24190. /**
  24191. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24192. */
  24193. static readonly CAP_ALL: number;
  24194. /**
  24195. * Mesh pattern setting : no flip or rotate
  24196. */
  24197. static readonly NO_FLIP: number;
  24198. /**
  24199. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24200. */
  24201. static readonly FLIP_TILE: number;
  24202. /**
  24203. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24204. */
  24205. static readonly ROTATE_TILE: number;
  24206. /**
  24207. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24208. */
  24209. static readonly FLIP_ROW: number;
  24210. /**
  24211. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24212. */
  24213. static readonly ROTATE_ROW: number;
  24214. /**
  24215. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24216. */
  24217. static readonly FLIP_N_ROTATE_TILE: number;
  24218. /**
  24219. * Mesh pattern setting : rotate pattern and rotate
  24220. */
  24221. static readonly FLIP_N_ROTATE_ROW: number;
  24222. /**
  24223. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24224. */
  24225. static readonly CENTER: number;
  24226. /**
  24227. * Mesh tile positioning : part tiles on left
  24228. */
  24229. static readonly LEFT: number;
  24230. /**
  24231. * Mesh tile positioning : part tiles on right
  24232. */
  24233. static readonly RIGHT: number;
  24234. /**
  24235. * Mesh tile positioning : part tiles on top
  24236. */
  24237. static readonly TOP: number;
  24238. /**
  24239. * Mesh tile positioning : part tiles on bottom
  24240. */
  24241. static readonly BOTTOM: number;
  24242. /**
  24243. * Gets the default side orientation.
  24244. * @param orientation the orientation to value to attempt to get
  24245. * @returns the default orientation
  24246. * @hidden
  24247. */
  24248. static _GetDefaultSideOrientation(orientation?: number): number;
  24249. private _internalMeshDataInfo;
  24250. /**
  24251. * An event triggered before rendering the mesh
  24252. */
  24253. readonly onBeforeRenderObservable: Observable<Mesh>;
  24254. /**
  24255. * An event triggered before binding the mesh
  24256. */
  24257. readonly onBeforeBindObservable: Observable<Mesh>;
  24258. /**
  24259. * An event triggered after rendering the mesh
  24260. */
  24261. readonly onAfterRenderObservable: Observable<Mesh>;
  24262. /**
  24263. * An event triggered before drawing the mesh
  24264. */
  24265. readonly onBeforeDrawObservable: Observable<Mesh>;
  24266. private _onBeforeDrawObserver;
  24267. /**
  24268. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24269. */
  24270. onBeforeDraw: () => void;
  24271. readonly hasInstances: boolean;
  24272. /**
  24273. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24274. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24275. */
  24276. delayLoadState: number;
  24277. /**
  24278. * Gets the list of instances created from this mesh
  24279. * it is not supposed to be modified manually.
  24280. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24281. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24282. */
  24283. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24284. /**
  24285. * Gets the file containing delay loading data for this mesh
  24286. */
  24287. delayLoadingFile: string;
  24288. /** @hidden */
  24289. _binaryInfo: any;
  24290. /**
  24291. * User defined function used to change how LOD level selection is done
  24292. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24293. */
  24294. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24295. /**
  24296. * Gets or sets the morph target manager
  24297. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24298. */
  24299. morphTargetManager: Nullable<MorphTargetManager>;
  24300. /** @hidden */
  24301. _creationDataStorage: Nullable<_CreationDataStorage>;
  24302. /** @hidden */
  24303. _geometry: Nullable<Geometry>;
  24304. /** @hidden */
  24305. _delayInfo: Array<string>;
  24306. /** @hidden */
  24307. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24308. /** @hidden */
  24309. _instanceDataStorage: _InstanceDataStorage;
  24310. private _effectiveMaterial;
  24311. /** @hidden */
  24312. _shouldGenerateFlatShading: boolean;
  24313. /** @hidden */
  24314. _originalBuilderSideOrientation: number;
  24315. /**
  24316. * Use this property to change the original side orientation defined at construction time
  24317. */
  24318. overrideMaterialSideOrientation: Nullable<number>;
  24319. /**
  24320. * Gets the source mesh (the one used to clone this one from)
  24321. */
  24322. readonly source: Nullable<Mesh>;
  24323. /**
  24324. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24325. */
  24326. isUnIndexed: boolean;
  24327. /**
  24328. * @constructor
  24329. * @param name The value used by scene.getMeshByName() to do a lookup.
  24330. * @param scene The scene to add this mesh to.
  24331. * @param parent The parent of this mesh, if it has one
  24332. * @param source An optional Mesh from which geometry is shared, cloned.
  24333. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24334. * When false, achieved by calling a clone(), also passing False.
  24335. * This will make creation of children, recursive.
  24336. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24337. */
  24338. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24339. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24340. /**
  24341. * Gets the class name
  24342. * @returns the string "Mesh".
  24343. */
  24344. getClassName(): string;
  24345. /** @hidden */
  24346. readonly _isMesh: boolean;
  24347. /**
  24348. * Returns a description of this mesh
  24349. * @param fullDetails define if full details about this mesh must be used
  24350. * @returns a descriptive string representing this mesh
  24351. */
  24352. toString(fullDetails?: boolean): string;
  24353. /** @hidden */
  24354. _unBindEffect(): void;
  24355. /**
  24356. * Gets a boolean indicating if this mesh has LOD
  24357. */
  24358. readonly hasLODLevels: boolean;
  24359. /**
  24360. * Gets the list of MeshLODLevel associated with the current mesh
  24361. * @returns an array of MeshLODLevel
  24362. */
  24363. getLODLevels(): MeshLODLevel[];
  24364. private _sortLODLevels;
  24365. /**
  24366. * Add a mesh as LOD level triggered at the given distance.
  24367. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24368. * @param distance The distance from the center of the object to show this level
  24369. * @param mesh The mesh to be added as LOD level (can be null)
  24370. * @return This mesh (for chaining)
  24371. */
  24372. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24373. /**
  24374. * Returns the LOD level mesh at the passed distance or null if not found.
  24375. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24376. * @param distance The distance from the center of the object to show this level
  24377. * @returns a Mesh or `null`
  24378. */
  24379. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24380. /**
  24381. * Remove a mesh from the LOD array
  24382. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24383. * @param mesh defines the mesh to be removed
  24384. * @return This mesh (for chaining)
  24385. */
  24386. removeLODLevel(mesh: Mesh): Mesh;
  24387. /**
  24388. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24389. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24390. * @param camera defines the camera to use to compute distance
  24391. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24392. * @return This mesh (for chaining)
  24393. */
  24394. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24395. /**
  24396. * Gets the mesh internal Geometry object
  24397. */
  24398. readonly geometry: Nullable<Geometry>;
  24399. /**
  24400. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24401. * @returns the total number of vertices
  24402. */
  24403. getTotalVertices(): number;
  24404. /**
  24405. * Returns the content of an associated vertex buffer
  24406. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24407. * - VertexBuffer.PositionKind
  24408. * - VertexBuffer.UVKind
  24409. * - VertexBuffer.UV2Kind
  24410. * - VertexBuffer.UV3Kind
  24411. * - VertexBuffer.UV4Kind
  24412. * - VertexBuffer.UV5Kind
  24413. * - VertexBuffer.UV6Kind
  24414. * - VertexBuffer.ColorKind
  24415. * - VertexBuffer.MatricesIndicesKind
  24416. * - VertexBuffer.MatricesIndicesExtraKind
  24417. * - VertexBuffer.MatricesWeightsKind
  24418. * - VertexBuffer.MatricesWeightsExtraKind
  24419. * @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
  24420. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24421. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24422. */
  24423. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24424. /**
  24425. * Returns the mesh VertexBuffer object from the requested `kind`
  24426. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24427. * - VertexBuffer.PositionKind
  24428. * - VertexBuffer.NormalKind
  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. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24441. */
  24442. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24443. /**
  24444. * Tests if a specific vertex buffer is associated with this mesh
  24445. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24446. * - VertexBuffer.PositionKind
  24447. * - VertexBuffer.NormalKind
  24448. * - VertexBuffer.UVKind
  24449. * - VertexBuffer.UV2Kind
  24450. * - VertexBuffer.UV3Kind
  24451. * - VertexBuffer.UV4Kind
  24452. * - VertexBuffer.UV5Kind
  24453. * - VertexBuffer.UV6Kind
  24454. * - VertexBuffer.ColorKind
  24455. * - VertexBuffer.MatricesIndicesKind
  24456. * - VertexBuffer.MatricesIndicesExtraKind
  24457. * - VertexBuffer.MatricesWeightsKind
  24458. * - VertexBuffer.MatricesWeightsExtraKind
  24459. * @returns a boolean
  24460. */
  24461. isVerticesDataPresent(kind: string): boolean;
  24462. /**
  24463. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24464. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24465. * - VertexBuffer.PositionKind
  24466. * - VertexBuffer.UVKind
  24467. * - VertexBuffer.UV2Kind
  24468. * - VertexBuffer.UV3Kind
  24469. * - VertexBuffer.UV4Kind
  24470. * - VertexBuffer.UV5Kind
  24471. * - VertexBuffer.UV6Kind
  24472. * - VertexBuffer.ColorKind
  24473. * - VertexBuffer.MatricesIndicesKind
  24474. * - VertexBuffer.MatricesIndicesExtraKind
  24475. * - VertexBuffer.MatricesWeightsKind
  24476. * - VertexBuffer.MatricesWeightsExtraKind
  24477. * @returns a boolean
  24478. */
  24479. isVertexBufferUpdatable(kind: string): boolean;
  24480. /**
  24481. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24482. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24483. * - VertexBuffer.PositionKind
  24484. * - VertexBuffer.NormalKind
  24485. * - VertexBuffer.UVKind
  24486. * - VertexBuffer.UV2Kind
  24487. * - VertexBuffer.UV3Kind
  24488. * - VertexBuffer.UV4Kind
  24489. * - VertexBuffer.UV5Kind
  24490. * - VertexBuffer.UV6Kind
  24491. * - VertexBuffer.ColorKind
  24492. * - VertexBuffer.MatricesIndicesKind
  24493. * - VertexBuffer.MatricesIndicesExtraKind
  24494. * - VertexBuffer.MatricesWeightsKind
  24495. * - VertexBuffer.MatricesWeightsExtraKind
  24496. * @returns an array of strings
  24497. */
  24498. getVerticesDataKinds(): string[];
  24499. /**
  24500. * Returns a positive integer : the total number of indices in this mesh geometry.
  24501. * @returns the numner of indices or zero if the mesh has no geometry.
  24502. */
  24503. getTotalIndices(): number;
  24504. /**
  24505. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24506. * @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.
  24507. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24508. * @returns the indices array or an empty array if the mesh has no geometry
  24509. */
  24510. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24511. readonly isBlocked: boolean;
  24512. /**
  24513. * Determine if the current mesh is ready to be rendered
  24514. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24515. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24516. * @returns true if all associated assets are ready (material, textures, shaders)
  24517. */
  24518. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24519. /**
  24520. * 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.
  24521. */
  24522. readonly areNormalsFrozen: boolean;
  24523. /**
  24524. * 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.
  24525. * @returns the current mesh
  24526. */
  24527. freezeNormals(): Mesh;
  24528. /**
  24529. * 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
  24530. * @returns the current mesh
  24531. */
  24532. unfreezeNormals(): Mesh;
  24533. /**
  24534. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24535. */
  24536. overridenInstanceCount: number;
  24537. /** @hidden */
  24538. _preActivate(): Mesh;
  24539. /** @hidden */
  24540. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24541. /** @hidden */
  24542. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24543. /**
  24544. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24545. * This means the mesh underlying bounding box and sphere are recomputed.
  24546. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24547. * @returns the current mesh
  24548. */
  24549. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24550. /** @hidden */
  24551. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24552. /**
  24553. * This function will subdivide the mesh into multiple submeshes
  24554. * @param count defines the expected number of submeshes
  24555. */
  24556. subdivide(count: number): void;
  24557. /**
  24558. * Copy a FloatArray into a specific associated vertex buffer
  24559. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24560. * - VertexBuffer.PositionKind
  24561. * - VertexBuffer.UVKind
  24562. * - VertexBuffer.UV2Kind
  24563. * - VertexBuffer.UV3Kind
  24564. * - VertexBuffer.UV4Kind
  24565. * - VertexBuffer.UV5Kind
  24566. * - VertexBuffer.UV6Kind
  24567. * - VertexBuffer.ColorKind
  24568. * - VertexBuffer.MatricesIndicesKind
  24569. * - VertexBuffer.MatricesIndicesExtraKind
  24570. * - VertexBuffer.MatricesWeightsKind
  24571. * - VertexBuffer.MatricesWeightsExtraKind
  24572. * @param data defines the data source
  24573. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24574. * @param stride defines the data stride size (can be null)
  24575. * @returns the current mesh
  24576. */
  24577. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24578. /**
  24579. * Flags an associated vertex buffer as updatable
  24580. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24581. * - VertexBuffer.PositionKind
  24582. * - VertexBuffer.UVKind
  24583. * - VertexBuffer.UV2Kind
  24584. * - VertexBuffer.UV3Kind
  24585. * - VertexBuffer.UV4Kind
  24586. * - VertexBuffer.UV5Kind
  24587. * - VertexBuffer.UV6Kind
  24588. * - VertexBuffer.ColorKind
  24589. * - VertexBuffer.MatricesIndicesKind
  24590. * - VertexBuffer.MatricesIndicesExtraKind
  24591. * - VertexBuffer.MatricesWeightsKind
  24592. * - VertexBuffer.MatricesWeightsExtraKind
  24593. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24594. */
  24595. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24596. /**
  24597. * Sets the mesh global Vertex Buffer
  24598. * @param buffer defines the buffer to use
  24599. * @returns the current mesh
  24600. */
  24601. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24602. /**
  24603. * Update a specific associated vertex buffer
  24604. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24605. * - VertexBuffer.PositionKind
  24606. * - VertexBuffer.UVKind
  24607. * - VertexBuffer.UV2Kind
  24608. * - VertexBuffer.UV3Kind
  24609. * - VertexBuffer.UV4Kind
  24610. * - VertexBuffer.UV5Kind
  24611. * - VertexBuffer.UV6Kind
  24612. * - VertexBuffer.ColorKind
  24613. * - VertexBuffer.MatricesIndicesKind
  24614. * - VertexBuffer.MatricesIndicesExtraKind
  24615. * - VertexBuffer.MatricesWeightsKind
  24616. * - VertexBuffer.MatricesWeightsExtraKind
  24617. * @param data defines the data source
  24618. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24619. * @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)
  24620. * @returns the current mesh
  24621. */
  24622. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24623. /**
  24624. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24625. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24626. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24627. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24628. * @returns the current mesh
  24629. */
  24630. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24631. /**
  24632. * Creates a un-shared specific occurence of the geometry for the mesh.
  24633. * @returns the current mesh
  24634. */
  24635. makeGeometryUnique(): Mesh;
  24636. /**
  24637. * Set the index buffer of this mesh
  24638. * @param indices defines the source data
  24639. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24640. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24641. * @returns the current mesh
  24642. */
  24643. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24644. /**
  24645. * Update the current index buffer
  24646. * @param indices defines the source data
  24647. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24648. * @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)
  24649. * @returns the current mesh
  24650. */
  24651. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24652. /**
  24653. * Invert the geometry to move from a right handed system to a left handed one.
  24654. * @returns the current mesh
  24655. */
  24656. toLeftHanded(): Mesh;
  24657. /** @hidden */
  24658. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24659. /** @hidden */
  24660. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24661. /**
  24662. * Registers for this mesh a javascript function called just before the rendering process
  24663. * @param func defines the function to call before rendering this mesh
  24664. * @returns the current mesh
  24665. */
  24666. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24667. /**
  24668. * Disposes a previously registered javascript function called before the rendering
  24669. * @param func defines the function to remove
  24670. * @returns the current mesh
  24671. */
  24672. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24673. /**
  24674. * Registers for this mesh a javascript function called just after the rendering is complete
  24675. * @param func defines the function to call after rendering this mesh
  24676. * @returns the current mesh
  24677. */
  24678. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24679. /**
  24680. * Disposes a previously registered javascript function called after the rendering.
  24681. * @param func defines the function to remove
  24682. * @returns the current mesh
  24683. */
  24684. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24685. /** @hidden */
  24686. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24687. /** @hidden */
  24688. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24689. /** @hidden */
  24690. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24691. /** @hidden */
  24692. _rebuild(): void;
  24693. /** @hidden */
  24694. _freeze(): void;
  24695. /** @hidden */
  24696. _unFreeze(): void;
  24697. /**
  24698. * 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
  24699. * @param subMesh defines the subMesh to render
  24700. * @param enableAlphaMode defines if alpha mode can be changed
  24701. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24702. * @returns the current mesh
  24703. */
  24704. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24705. private _onBeforeDraw;
  24706. /**
  24707. * Renormalize the mesh and patch it up if there are no weights
  24708. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24709. * However in the case of zero weights then we set just a single influence to 1.
  24710. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24711. */
  24712. cleanMatrixWeights(): void;
  24713. private normalizeSkinFourWeights;
  24714. private normalizeSkinWeightsAndExtra;
  24715. /**
  24716. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24717. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24718. * the user know there was an issue with importing the mesh
  24719. * @returns a validation object with skinned, valid and report string
  24720. */
  24721. validateSkinning(): {
  24722. skinned: boolean;
  24723. valid: boolean;
  24724. report: string;
  24725. };
  24726. /** @hidden */
  24727. _checkDelayState(): Mesh;
  24728. private _queueLoad;
  24729. /**
  24730. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24731. * A mesh is in the frustum if its bounding box intersects the frustum
  24732. * @param frustumPlanes defines the frustum to test
  24733. * @returns true if the mesh is in the frustum planes
  24734. */
  24735. isInFrustum(frustumPlanes: Plane[]): boolean;
  24736. /**
  24737. * Sets the mesh material by the material or multiMaterial `id` property
  24738. * @param id is a string identifying the material or the multiMaterial
  24739. * @returns the current mesh
  24740. */
  24741. setMaterialByID(id: string): Mesh;
  24742. /**
  24743. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24744. * @returns an array of IAnimatable
  24745. */
  24746. getAnimatables(): IAnimatable[];
  24747. /**
  24748. * Modifies the mesh geometry according to the passed transformation matrix.
  24749. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24750. * The mesh normals are modified using the same transformation.
  24751. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24752. * @param transform defines the transform matrix to use
  24753. * @see http://doc.babylonjs.com/resources/baking_transformations
  24754. * @returns the current mesh
  24755. */
  24756. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24757. /**
  24758. * Modifies the mesh geometry according to its own current World Matrix.
  24759. * The mesh World Matrix is then reset.
  24760. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24761. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24762. * @see http://doc.babylonjs.com/resources/baking_transformations
  24763. * @returns the current mesh
  24764. */
  24765. bakeCurrentTransformIntoVertices(): Mesh;
  24766. /** @hidden */
  24767. readonly _positions: Nullable<Vector3[]>;
  24768. /** @hidden */
  24769. _resetPointsArrayCache(): Mesh;
  24770. /** @hidden */
  24771. _generatePointsArray(): boolean;
  24772. /**
  24773. * Returns a new Mesh object generated from the current mesh properties.
  24774. * This method must not get confused with createInstance()
  24775. * @param name is a string, the name given to the new mesh
  24776. * @param newParent can be any Node object (default `null`)
  24777. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24778. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24779. * @returns a new mesh
  24780. */
  24781. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24782. /**
  24783. * Releases resources associated with this mesh.
  24784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24786. */
  24787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24788. /**
  24789. * Modifies the mesh geometry according to a displacement map.
  24790. * 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.
  24791. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24792. * @param url is a string, the URL from the image file is to be downloaded.
  24793. * @param minHeight is the lower limit of the displacement.
  24794. * @param maxHeight is the upper limit of the displacement.
  24795. * @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.
  24796. * @param uvOffset is an optional vector2 used to offset UV.
  24797. * @param uvScale is an optional vector2 used to scale UV.
  24798. * @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.
  24799. * @returns the Mesh.
  24800. */
  24801. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24802. /**
  24803. * Modifies the mesh geometry according to a displacementMap buffer.
  24804. * 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.
  24805. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24806. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24807. * @param heightMapWidth is the width of the buffer image.
  24808. * @param heightMapHeight is the height of the buffer image.
  24809. * @param minHeight is the lower limit of the displacement.
  24810. * @param maxHeight is the upper limit of the displacement.
  24811. * @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.
  24812. * @param uvOffset is an optional vector2 used to offset UV.
  24813. * @param uvScale is an optional vector2 used to scale UV.
  24814. * @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.
  24815. * @returns the Mesh.
  24816. */
  24817. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24818. /**
  24819. * Modify the mesh to get a flat shading rendering.
  24820. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24821. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24822. * @returns current mesh
  24823. */
  24824. convertToFlatShadedMesh(): Mesh;
  24825. /**
  24826. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24827. * In other words, more vertices, no more indices and a single bigger VBO.
  24828. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24829. * @returns current mesh
  24830. */
  24831. convertToUnIndexedMesh(): Mesh;
  24832. /**
  24833. * Inverses facet orientations.
  24834. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24835. * @param flipNormals will also inverts the normals
  24836. * @returns current mesh
  24837. */
  24838. flipFaces(flipNormals?: boolean): Mesh;
  24839. /**
  24840. * Increase the number of facets and hence vertices in a mesh
  24841. * Vertex normals are interpolated from existing vertex normals
  24842. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24843. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24844. */
  24845. increaseVertices(numberPerEdge: number): void;
  24846. /**
  24847. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24848. * This will undo any application of covertToFlatShadedMesh
  24849. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24850. */
  24851. forceSharedVertices(): void;
  24852. /** @hidden */
  24853. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24854. /** @hidden */
  24855. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24856. /**
  24857. * Creates a new InstancedMesh object from the mesh model.
  24858. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24859. * @param name defines the name of the new instance
  24860. * @returns a new InstancedMesh
  24861. */
  24862. createInstance(name: string): InstancedMesh;
  24863. /**
  24864. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24865. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24866. * @returns the current mesh
  24867. */
  24868. synchronizeInstances(): Mesh;
  24869. /**
  24870. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24871. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24872. * This should be used together with the simplification to avoid disappearing triangles.
  24873. * @param successCallback an optional success callback to be called after the optimization finished.
  24874. * @returns the current mesh
  24875. */
  24876. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24877. /**
  24878. * Serialize current mesh
  24879. * @param serializationObject defines the object which will receive the serialization data
  24880. */
  24881. serialize(serializationObject: any): void;
  24882. /** @hidden */
  24883. _syncGeometryWithMorphTargetManager(): void;
  24884. /** @hidden */
  24885. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24886. /**
  24887. * Returns a new Mesh object parsed from the source provided.
  24888. * @param parsedMesh is the source
  24889. * @param scene defines the hosting scene
  24890. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24891. * @returns a new Mesh
  24892. */
  24893. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24894. /**
  24895. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24896. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24897. * @param name defines the name of the mesh to create
  24898. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24899. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24900. * @param closePath creates a seam between the first and the last points of each path of the path array
  24901. * @param offset is taken in account only if the `pathArray` is containing a single path
  24902. * @param scene defines the hosting scene
  24903. * @param updatable defines if the mesh must be flagged as updatable
  24904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24905. * @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)
  24906. * @returns a new Mesh
  24907. */
  24908. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24909. /**
  24910. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24911. * @param name defines the name of the mesh to create
  24912. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24913. * @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
  24914. * @param scene defines the hosting scene
  24915. * @param updatable defines if the mesh must be flagged as updatable
  24916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24917. * @returns a new Mesh
  24918. */
  24919. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24920. /**
  24921. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24922. * @param name defines the name of the mesh to create
  24923. * @param size sets the size (float) of each box side (default 1)
  24924. * @param scene defines the hosting scene
  24925. * @param updatable defines if the mesh must be flagged as updatable
  24926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24927. * @returns a new Mesh
  24928. */
  24929. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24930. /**
  24931. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24932. * @param name defines the name of the mesh to create
  24933. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24934. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24935. * @param scene defines the hosting scene
  24936. * @param updatable defines if the mesh must be flagged as updatable
  24937. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24938. * @returns a new Mesh
  24939. */
  24940. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24941. /**
  24942. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24943. * @param name defines the name of the mesh to create
  24944. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24945. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24946. * @param scene defines the hosting scene
  24947. * @returns a new Mesh
  24948. */
  24949. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24950. /**
  24951. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24952. * @param name defines the name of the mesh to create
  24953. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24954. * @param diameterTop set the top cap diameter (floats, default 1)
  24955. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24956. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24957. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24958. * @param scene defines the hosting scene
  24959. * @param updatable defines if the mesh must be flagged as updatable
  24960. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24961. * @returns a new Mesh
  24962. */
  24963. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24964. /**
  24965. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24966. * @param name defines the name of the mesh to create
  24967. * @param diameter sets the diameter size (float) of the torus (default 1)
  24968. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24969. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24970. * @param scene defines the hosting scene
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @returns a new Mesh
  24974. */
  24975. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24976. /**
  24977. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24978. * @param name defines the name of the mesh to create
  24979. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24980. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24981. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24982. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24983. * @param p the number of windings on X axis (positive integers, default 2)
  24984. * @param q the number of windings on Y axis (positive integers, default 3)
  24985. * @param scene defines the hosting scene
  24986. * @param updatable defines if the mesh must be flagged as updatable
  24987. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24988. * @returns a new Mesh
  24989. */
  24990. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24991. /**
  24992. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24993. * @param name defines the name of the mesh to create
  24994. * @param points is an array successive Vector3
  24995. * @param scene defines the hosting scene
  24996. * @param updatable defines if the mesh must be flagged as updatable
  24997. * @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).
  24998. * @returns a new Mesh
  24999. */
  25000. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25001. /**
  25002. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25003. * @param name defines the name of the mesh to create
  25004. * @param points is an array successive Vector3
  25005. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25006. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25007. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25008. * @param scene defines the hosting scene
  25009. * @param updatable defines if the mesh must be flagged as updatable
  25010. * @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)
  25011. * @returns a new Mesh
  25012. */
  25013. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25014. /**
  25015. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25016. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25017. * 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.
  25018. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25019. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25020. * Remember you can only change the shape positions, not their number when updating a polygon.
  25021. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25022. * @param name defines the name of the mesh to create
  25023. * @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
  25024. * @param scene defines the hosting scene
  25025. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25026. * @param updatable defines if the mesh must be flagged as updatable
  25027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25028. * @param earcutInjection can be used to inject your own earcut reference
  25029. * @returns a new Mesh
  25030. */
  25031. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25032. /**
  25033. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25034. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25035. * @param name defines the name of the mesh to create
  25036. * @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
  25037. * @param depth defines the height of extrusion
  25038. * @param scene defines the hosting scene
  25039. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25040. * @param updatable defines if the mesh must be flagged as updatable
  25041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25042. * @param earcutInjection can be used to inject your own earcut reference
  25043. * @returns a new Mesh
  25044. */
  25045. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25046. /**
  25047. * Creates an extruded shape mesh.
  25048. * 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
  25049. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25050. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25051. * @param name defines the name of the mesh to create
  25052. * @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
  25053. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25054. * @param scale is the value to scale the shape
  25055. * @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
  25056. * @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
  25057. * @param scene defines the hosting scene
  25058. * @param updatable defines if the mesh must be flagged as updatable
  25059. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25060. * @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)
  25061. * @returns a new Mesh
  25062. */
  25063. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25064. /**
  25065. * Creates an custom extruded shape mesh.
  25066. * The custom extrusion is a parametric shape.
  25067. * It has no predefined shape. Its final shape will depend on the input parameters.
  25068. * Please consider using the same method from the MeshBuilder class instead
  25069. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25070. * @param name defines the name of the mesh to create
  25071. * @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
  25072. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25073. * @param scaleFunction is a custom Javascript function called on each path point
  25074. * @param rotationFunction is a custom Javascript function called on each path point
  25075. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25076. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25077. * @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
  25078. * @param scene defines the hosting scene
  25079. * @param updatable defines if the mesh must be flagged as updatable
  25080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25081. * @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)
  25082. * @returns a new Mesh
  25083. */
  25084. 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;
  25085. /**
  25086. * Creates lathe mesh.
  25087. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25088. * Please consider using the same method from the MeshBuilder class instead
  25089. * @param name defines the name of the mesh to create
  25090. * @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
  25091. * @param radius is the radius value of the lathe
  25092. * @param tessellation is the side number of the lathe.
  25093. * @param scene defines the hosting scene
  25094. * @param updatable defines if the mesh must be flagged as updatable
  25095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25096. * @returns a new Mesh
  25097. */
  25098. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25099. /**
  25100. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25101. * @param name defines the name of the mesh to create
  25102. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25103. * @param scene defines the hosting scene
  25104. * @param updatable defines if the mesh must be flagged as updatable
  25105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25106. * @returns a new Mesh
  25107. */
  25108. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25109. /**
  25110. * Creates a ground mesh.
  25111. * Please consider using the same method from the MeshBuilder class instead
  25112. * @param name defines the name of the mesh to create
  25113. * @param width set the width of the ground
  25114. * @param height set the height of the ground
  25115. * @param subdivisions sets the number of subdivisions per side
  25116. * @param scene defines the hosting scene
  25117. * @param updatable defines if the mesh must be flagged as updatable
  25118. * @returns a new Mesh
  25119. */
  25120. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25121. /**
  25122. * Creates a tiled ground mesh.
  25123. * Please consider using the same method from the MeshBuilder class instead
  25124. * @param name defines the name of the mesh to create
  25125. * @param xmin set the ground minimum X coordinate
  25126. * @param zmin set the ground minimum Y coordinate
  25127. * @param xmax set the ground maximum X coordinate
  25128. * @param zmax set the ground maximum Z coordinate
  25129. * @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
  25130. * @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
  25131. * @param scene defines the hosting scene
  25132. * @param updatable defines if the mesh must be flagged as updatable
  25133. * @returns a new Mesh
  25134. */
  25135. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25136. w: number;
  25137. h: number;
  25138. }, precision: {
  25139. w: number;
  25140. h: number;
  25141. }, scene: Scene, updatable?: boolean): Mesh;
  25142. /**
  25143. * Creates a ground mesh from a height map.
  25144. * Please consider using the same method from the MeshBuilder class instead
  25145. * @see http://doc.babylonjs.com/babylon101/height_map
  25146. * @param name defines the name of the mesh to create
  25147. * @param url sets the URL of the height map image resource
  25148. * @param width set the ground width size
  25149. * @param height set the ground height size
  25150. * @param subdivisions sets the number of subdivision per side
  25151. * @param minHeight is the minimum altitude on the ground
  25152. * @param maxHeight is the maximum altitude on the ground
  25153. * @param scene defines the hosting scene
  25154. * @param updatable defines if the mesh must be flagged as updatable
  25155. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25156. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25157. * @returns a new Mesh
  25158. */
  25159. 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;
  25160. /**
  25161. * Creates a tube mesh.
  25162. * The tube is a parametric shape.
  25163. * It has no predefined shape. Its final shape will depend on the input parameters.
  25164. * Please consider using the same method from the MeshBuilder class instead
  25165. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25166. * @param name defines the name of the mesh to create
  25167. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25168. * @param radius sets the tube radius size
  25169. * @param tessellation is the number of sides on the tubular surface
  25170. * @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
  25171. * @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
  25172. * @param scene defines the hosting scene
  25173. * @param updatable defines if the mesh must be flagged as updatable
  25174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25175. * @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)
  25176. * @returns a new Mesh
  25177. */
  25178. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25179. (i: number, distance: number): number;
  25180. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25181. /**
  25182. * Creates a polyhedron mesh.
  25183. * Please consider using the same method from the MeshBuilder class instead.
  25184. * * 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
  25185. * * The parameter `size` (positive float, default 1) sets the polygon size
  25186. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25187. * * 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`
  25188. * * 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
  25189. * * 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)`)
  25190. * * 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
  25191. * * 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
  25192. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25193. * * If you create a double-sided mesh, you can choose what parts of 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
  25194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25195. * @param name defines the name of the mesh to create
  25196. * @param options defines the options used to create the mesh
  25197. * @param scene defines the hosting scene
  25198. * @returns a new Mesh
  25199. */
  25200. static CreatePolyhedron(name: string, options: {
  25201. type?: number;
  25202. size?: number;
  25203. sizeX?: number;
  25204. sizeY?: number;
  25205. sizeZ?: number;
  25206. custom?: any;
  25207. faceUV?: Vector4[];
  25208. faceColors?: Color4[];
  25209. updatable?: boolean;
  25210. sideOrientation?: number;
  25211. }, scene: Scene): Mesh;
  25212. /**
  25213. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25214. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25215. * * 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`)
  25216. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25217. * * 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
  25218. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25219. * * If you create a double-sided mesh, you can choose what parts of 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
  25220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25221. * @param name defines the name of the mesh
  25222. * @param options defines the options used to create the mesh
  25223. * @param scene defines the hosting scene
  25224. * @returns a new Mesh
  25225. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25226. */
  25227. static CreateIcoSphere(name: string, options: {
  25228. radius?: number;
  25229. flat?: boolean;
  25230. subdivisions?: number;
  25231. sideOrientation?: number;
  25232. updatable?: boolean;
  25233. }, scene: Scene): Mesh;
  25234. /**
  25235. * Creates a decal mesh.
  25236. * Please consider using the same method from the MeshBuilder class instead.
  25237. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25238. * @param name defines the name of the mesh
  25239. * @param sourceMesh defines the mesh receiving the decal
  25240. * @param position sets the position of the decal in world coordinates
  25241. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25242. * @param size sets the decal scaling
  25243. * @param angle sets the angle to rotate the decal
  25244. * @returns a new Mesh
  25245. */
  25246. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25247. /**
  25248. * Prepare internal position array for software CPU skinning
  25249. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25250. */
  25251. setPositionsForCPUSkinning(): Float32Array;
  25252. /**
  25253. * Prepare internal normal array for software CPU skinning
  25254. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25255. */
  25256. setNormalsForCPUSkinning(): Float32Array;
  25257. /**
  25258. * Updates the vertex buffer by applying transformation from the bones
  25259. * @param skeleton defines the skeleton to apply to current mesh
  25260. * @returns the current mesh
  25261. */
  25262. applySkeleton(skeleton: Skeleton): Mesh;
  25263. /**
  25264. * 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
  25265. * @param meshes defines the list of meshes to scan
  25266. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25267. */
  25268. static MinMax(meshes: AbstractMesh[]): {
  25269. min: Vector3;
  25270. max: Vector3;
  25271. };
  25272. /**
  25273. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25274. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25275. * @returns a vector3
  25276. */
  25277. static Center(meshesOrMinMaxVector: {
  25278. min: Vector3;
  25279. max: Vector3;
  25280. } | AbstractMesh[]): Vector3;
  25281. /**
  25282. * Merge the array of meshes into a single mesh for performance reasons.
  25283. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25284. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25285. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25286. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25287. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25288. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25289. * @returns a new mesh
  25290. */
  25291. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25292. /** @hidden */
  25293. addInstance(instance: InstancedMesh): void;
  25294. /** @hidden */
  25295. removeInstance(instance: InstancedMesh): void;
  25296. }
  25297. }
  25298. declare module "babylonjs/Cameras/camera" {
  25299. import { SmartArray } from "babylonjs/Misc/smartArray";
  25300. import { Observable } from "babylonjs/Misc/observable";
  25301. import { Nullable } from "babylonjs/types";
  25302. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25303. import { Scene } from "babylonjs/scene";
  25304. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25305. import { Node } from "babylonjs/node";
  25306. import { Mesh } from "babylonjs/Meshes/mesh";
  25307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25308. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25309. import { Viewport } from "babylonjs/Maths/math.viewport";
  25310. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25311. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25312. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25313. import { Ray } from "babylonjs/Culling/ray";
  25314. /**
  25315. * This is the base class of all the camera used in the application.
  25316. * @see http://doc.babylonjs.com/features/cameras
  25317. */
  25318. export class Camera extends Node {
  25319. /** @hidden */
  25320. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25321. /**
  25322. * This is the default projection mode used by the cameras.
  25323. * It helps recreating a feeling of perspective and better appreciate depth.
  25324. * This is the best way to simulate real life cameras.
  25325. */
  25326. static readonly PERSPECTIVE_CAMERA: number;
  25327. /**
  25328. * This helps creating camera with an orthographic mode.
  25329. * 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.
  25330. */
  25331. static readonly ORTHOGRAPHIC_CAMERA: number;
  25332. /**
  25333. * This is the default FOV mode for perspective cameras.
  25334. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25335. */
  25336. static readonly FOVMODE_VERTICAL_FIXED: number;
  25337. /**
  25338. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25339. */
  25340. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25341. /**
  25342. * This specifies ther is no need for a camera rig.
  25343. * Basically only one eye is rendered corresponding to the camera.
  25344. */
  25345. static readonly RIG_MODE_NONE: number;
  25346. /**
  25347. * Simulates a camera Rig with one blue eye and one red eye.
  25348. * This can be use with 3d blue and red glasses.
  25349. */
  25350. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25351. /**
  25352. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25353. */
  25354. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25355. /**
  25356. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25357. */
  25358. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25359. /**
  25360. * Defines that both eyes of the camera will be rendered over under each other.
  25361. */
  25362. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25363. /**
  25364. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25365. */
  25366. static readonly RIG_MODE_VR: number;
  25367. /**
  25368. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25369. */
  25370. static readonly RIG_MODE_WEBVR: number;
  25371. /**
  25372. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25373. */
  25374. static readonly RIG_MODE_CUSTOM: number;
  25375. /**
  25376. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25377. */
  25378. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25379. /**
  25380. * Define the input manager associated with the camera.
  25381. */
  25382. inputs: CameraInputsManager<Camera>;
  25383. /** @hidden */
  25384. _position: Vector3;
  25385. /**
  25386. * Define the current local position of the camera in the scene
  25387. */
  25388. position: Vector3;
  25389. /**
  25390. * The vector the camera should consider as up.
  25391. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25392. */
  25393. upVector: Vector3;
  25394. /**
  25395. * Define the current limit on the left side for an orthographic camera
  25396. * In scene unit
  25397. */
  25398. orthoLeft: Nullable<number>;
  25399. /**
  25400. * Define the current limit on the right side for an orthographic camera
  25401. * In scene unit
  25402. */
  25403. orthoRight: Nullable<number>;
  25404. /**
  25405. * Define the current limit on the bottom side for an orthographic camera
  25406. * In scene unit
  25407. */
  25408. orthoBottom: Nullable<number>;
  25409. /**
  25410. * Define the current limit on the top side for an orthographic camera
  25411. * In scene unit
  25412. */
  25413. orthoTop: Nullable<number>;
  25414. /**
  25415. * Field Of View is set in Radians. (default is 0.8)
  25416. */
  25417. fov: number;
  25418. /**
  25419. * Define the minimum distance the camera can see from.
  25420. * This is important to note that the depth buffer are not infinite and the closer it starts
  25421. * the more your scene might encounter depth fighting issue.
  25422. */
  25423. minZ: number;
  25424. /**
  25425. * Define the maximum distance the camera can see to.
  25426. * This is important to note that the depth buffer are not infinite and the further it end
  25427. * the more your scene might encounter depth fighting issue.
  25428. */
  25429. maxZ: number;
  25430. /**
  25431. * Define the default inertia of the camera.
  25432. * This helps giving a smooth feeling to the camera movement.
  25433. */
  25434. inertia: number;
  25435. /**
  25436. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25437. */
  25438. mode: number;
  25439. /**
  25440. * Define wether the camera is intermediate.
  25441. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25442. */
  25443. isIntermediate: boolean;
  25444. /**
  25445. * Define the viewport of the camera.
  25446. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25447. */
  25448. viewport: Viewport;
  25449. /**
  25450. * Restricts the camera to viewing objects with the same layerMask.
  25451. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25452. */
  25453. layerMask: number;
  25454. /**
  25455. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25456. */
  25457. fovMode: number;
  25458. /**
  25459. * Rig mode of the camera.
  25460. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25461. * This is normally controlled byt the camera themselves as internal use.
  25462. */
  25463. cameraRigMode: number;
  25464. /**
  25465. * Defines the distance between both "eyes" in case of a RIG
  25466. */
  25467. interaxialDistance: number;
  25468. /**
  25469. * Defines if stereoscopic rendering is done side by side or over under.
  25470. */
  25471. isStereoscopicSideBySide: boolean;
  25472. /**
  25473. * 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
  25474. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25475. * else in the scene. (Eg. security camera)
  25476. *
  25477. * 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)
  25478. */
  25479. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25480. /**
  25481. * When set, the camera will render to this render target instead of the default canvas
  25482. *
  25483. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25484. */
  25485. outputRenderTarget: Nullable<RenderTargetTexture>;
  25486. /**
  25487. * Observable triggered when the camera view matrix has changed.
  25488. */
  25489. onViewMatrixChangedObservable: Observable<Camera>;
  25490. /**
  25491. * Observable triggered when the camera Projection matrix has changed.
  25492. */
  25493. onProjectionMatrixChangedObservable: Observable<Camera>;
  25494. /**
  25495. * Observable triggered when the inputs have been processed.
  25496. */
  25497. onAfterCheckInputsObservable: Observable<Camera>;
  25498. /**
  25499. * Observable triggered when reset has been called and applied to the camera.
  25500. */
  25501. onRestoreStateObservable: Observable<Camera>;
  25502. /** @hidden */
  25503. _cameraRigParams: any;
  25504. /** @hidden */
  25505. _rigCameras: Camera[];
  25506. /** @hidden */
  25507. _rigPostProcess: Nullable<PostProcess>;
  25508. protected _webvrViewMatrix: Matrix;
  25509. /** @hidden */
  25510. _skipRendering: boolean;
  25511. /** @hidden */
  25512. _projectionMatrix: Matrix;
  25513. /** @hidden */
  25514. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25515. /** @hidden */
  25516. _activeMeshes: SmartArray<AbstractMesh>;
  25517. protected _globalPosition: Vector3;
  25518. /** @hidden */
  25519. _computedViewMatrix: Matrix;
  25520. private _doNotComputeProjectionMatrix;
  25521. private _transformMatrix;
  25522. private _frustumPlanes;
  25523. private _refreshFrustumPlanes;
  25524. private _storedFov;
  25525. private _stateStored;
  25526. /**
  25527. * Instantiates a new camera object.
  25528. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25529. * @see http://doc.babylonjs.com/features/cameras
  25530. * @param name Defines the name of the camera in the scene
  25531. * @param position Defines the position of the camera
  25532. * @param scene Defines the scene the camera belongs too
  25533. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25534. */
  25535. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25536. /**
  25537. * Store current camera state (fov, position, etc..)
  25538. * @returns the camera
  25539. */
  25540. storeState(): Camera;
  25541. /**
  25542. * Restores the camera state values if it has been stored. You must call storeState() first
  25543. */
  25544. protected _restoreStateValues(): boolean;
  25545. /**
  25546. * Restored camera state. You must call storeState() first.
  25547. * @returns true if restored and false otherwise
  25548. */
  25549. restoreState(): boolean;
  25550. /**
  25551. * Gets the class name of the camera.
  25552. * @returns the class name
  25553. */
  25554. getClassName(): string;
  25555. /** @hidden */
  25556. readonly _isCamera: boolean;
  25557. /**
  25558. * Gets a string representation of the camera useful for debug purpose.
  25559. * @param fullDetails Defines that a more verboe level of logging is required
  25560. * @returns the string representation
  25561. */
  25562. toString(fullDetails?: boolean): string;
  25563. /**
  25564. * Gets the current world space position of the camera.
  25565. */
  25566. readonly globalPosition: Vector3;
  25567. /**
  25568. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25569. * @returns the active meshe list
  25570. */
  25571. getActiveMeshes(): SmartArray<AbstractMesh>;
  25572. /**
  25573. * Check wether a mesh is part of the current active mesh list of the camera
  25574. * @param mesh Defines the mesh to check
  25575. * @returns true if active, false otherwise
  25576. */
  25577. isActiveMesh(mesh: Mesh): boolean;
  25578. /**
  25579. * Is this camera ready to be used/rendered
  25580. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25581. * @return true if the camera is ready
  25582. */
  25583. isReady(completeCheck?: boolean): boolean;
  25584. /** @hidden */
  25585. _initCache(): void;
  25586. /** @hidden */
  25587. _updateCache(ignoreParentClass?: boolean): void;
  25588. /** @hidden */
  25589. _isSynchronized(): boolean;
  25590. /** @hidden */
  25591. _isSynchronizedViewMatrix(): boolean;
  25592. /** @hidden */
  25593. _isSynchronizedProjectionMatrix(): boolean;
  25594. /**
  25595. * Attach the input controls to a specific dom element to get the input from.
  25596. * @param element Defines the element the controls should be listened from
  25597. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25598. */
  25599. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25600. /**
  25601. * Detach the current controls from the specified dom element.
  25602. * @param element Defines the element to stop listening the inputs from
  25603. */
  25604. detachControl(element: HTMLElement): void;
  25605. /**
  25606. * Update the camera state according to the different inputs gathered during the frame.
  25607. */
  25608. update(): void;
  25609. /** @hidden */
  25610. _checkInputs(): void;
  25611. /** @hidden */
  25612. readonly rigCameras: Camera[];
  25613. /**
  25614. * Gets the post process used by the rig cameras
  25615. */
  25616. readonly rigPostProcess: Nullable<PostProcess>;
  25617. /**
  25618. * Internal, gets the first post proces.
  25619. * @returns the first post process to be run on this camera.
  25620. */
  25621. _getFirstPostProcess(): Nullable<PostProcess>;
  25622. private _cascadePostProcessesToRigCams;
  25623. /**
  25624. * Attach a post process to the camera.
  25625. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25626. * @param postProcess The post process to attach to the camera
  25627. * @param insertAt The position of the post process in case several of them are in use in the scene
  25628. * @returns the position the post process has been inserted at
  25629. */
  25630. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25631. /**
  25632. * Detach a post process to the camera.
  25633. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25634. * @param postProcess The post process to detach from the camera
  25635. */
  25636. detachPostProcess(postProcess: PostProcess): void;
  25637. /**
  25638. * Gets the current world matrix of the camera
  25639. */
  25640. getWorldMatrix(): Matrix;
  25641. /** @hidden */
  25642. _getViewMatrix(): Matrix;
  25643. /**
  25644. * Gets the current view matrix of the camera.
  25645. * @param force forces the camera to recompute the matrix without looking at the cached state
  25646. * @returns the view matrix
  25647. */
  25648. getViewMatrix(force?: boolean): Matrix;
  25649. /**
  25650. * Freeze the projection matrix.
  25651. * It will prevent the cache check of the camera projection compute and can speed up perf
  25652. * if no parameter of the camera are meant to change
  25653. * @param projection Defines manually a projection if necessary
  25654. */
  25655. freezeProjectionMatrix(projection?: Matrix): void;
  25656. /**
  25657. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25658. */
  25659. unfreezeProjectionMatrix(): void;
  25660. /**
  25661. * Gets the current projection matrix of the camera.
  25662. * @param force forces the camera to recompute the matrix without looking at the cached state
  25663. * @returns the projection matrix
  25664. */
  25665. getProjectionMatrix(force?: boolean): Matrix;
  25666. /**
  25667. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25668. * @returns a Matrix
  25669. */
  25670. getTransformationMatrix(): Matrix;
  25671. private _updateFrustumPlanes;
  25672. /**
  25673. * Checks if a cullable object (mesh...) is in the camera frustum
  25674. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25675. * @param target The object to check
  25676. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25677. * @returns true if the object is in frustum otherwise false
  25678. */
  25679. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25680. /**
  25681. * Checks if a cullable object (mesh...) is in the camera frustum
  25682. * Unlike isInFrustum this cheks the full bounding box
  25683. * @param target The object to check
  25684. * @returns true if the object is in frustum otherwise false
  25685. */
  25686. isCompletelyInFrustum(target: ICullable): boolean;
  25687. /**
  25688. * Gets a ray in the forward direction from the camera.
  25689. * @param length Defines the length of the ray to create
  25690. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25691. * @param origin Defines the start point of the ray which defaults to the camera position
  25692. * @returns the forward ray
  25693. */
  25694. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25695. /**
  25696. * Releases resources associated with this node.
  25697. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25698. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25699. */
  25700. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25701. /** @hidden */
  25702. _isLeftCamera: boolean;
  25703. /**
  25704. * Gets the left camera of a rig setup in case of Rigged Camera
  25705. */
  25706. readonly isLeftCamera: boolean;
  25707. /** @hidden */
  25708. _isRightCamera: boolean;
  25709. /**
  25710. * Gets the right camera of a rig setup in case of Rigged Camera
  25711. */
  25712. readonly isRightCamera: boolean;
  25713. /**
  25714. * Gets the left camera of a rig setup in case of Rigged Camera
  25715. */
  25716. readonly leftCamera: Nullable<FreeCamera>;
  25717. /**
  25718. * Gets the right camera of a rig setup in case of Rigged Camera
  25719. */
  25720. readonly rightCamera: Nullable<FreeCamera>;
  25721. /**
  25722. * Gets the left camera target of a rig setup in case of Rigged Camera
  25723. * @returns the target position
  25724. */
  25725. getLeftTarget(): Nullable<Vector3>;
  25726. /**
  25727. * Gets the right camera target of a rig setup in case of Rigged Camera
  25728. * @returns the target position
  25729. */
  25730. getRightTarget(): Nullable<Vector3>;
  25731. /**
  25732. * @hidden
  25733. */
  25734. setCameraRigMode(mode: number, rigParams: any): void;
  25735. /** @hidden */
  25736. static _setStereoscopicRigMode(camera: Camera): void;
  25737. /** @hidden */
  25738. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25739. /** @hidden */
  25740. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25741. /** @hidden */
  25742. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25743. /** @hidden */
  25744. _getVRProjectionMatrix(): Matrix;
  25745. protected _updateCameraRotationMatrix(): void;
  25746. protected _updateWebVRCameraRotationMatrix(): void;
  25747. /**
  25748. * This function MUST be overwritten by the different WebVR cameras available.
  25749. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25750. * @hidden
  25751. */
  25752. _getWebVRProjectionMatrix(): Matrix;
  25753. /**
  25754. * This function MUST be overwritten by the different WebVR cameras available.
  25755. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25756. * @hidden
  25757. */
  25758. _getWebVRViewMatrix(): Matrix;
  25759. /** @hidden */
  25760. setCameraRigParameter(name: string, value: any): void;
  25761. /**
  25762. * needs to be overridden by children so sub has required properties to be copied
  25763. * @hidden
  25764. */
  25765. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25766. /**
  25767. * May need to be overridden by children
  25768. * @hidden
  25769. */
  25770. _updateRigCameras(): void;
  25771. /** @hidden */
  25772. _setupInputs(): void;
  25773. /**
  25774. * Serialiaze the camera setup to a json represention
  25775. * @returns the JSON representation
  25776. */
  25777. serialize(): any;
  25778. /**
  25779. * Clones the current camera.
  25780. * @param name The cloned camera name
  25781. * @returns the cloned camera
  25782. */
  25783. clone(name: string): Camera;
  25784. /**
  25785. * Gets the direction of the camera relative to a given local axis.
  25786. * @param localAxis Defines the reference axis to provide a relative direction.
  25787. * @return the direction
  25788. */
  25789. getDirection(localAxis: Vector3): Vector3;
  25790. /**
  25791. * Returns the current camera absolute rotation
  25792. */
  25793. readonly absoluteRotation: Quaternion;
  25794. /**
  25795. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25796. * @param localAxis Defines the reference axis to provide a relative direction.
  25797. * @param result Defines the vector to store the result in
  25798. */
  25799. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25800. /**
  25801. * Gets a camera constructor for a given camera type
  25802. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25803. * @param name The name of the camera the result will be able to instantiate
  25804. * @param scene The scene the result will construct the camera in
  25805. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25806. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25807. * @returns a factory method to construc the camera
  25808. */
  25809. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25810. /**
  25811. * Compute the world matrix of the camera.
  25812. * @returns the camera workd matrix
  25813. */
  25814. computeWorldMatrix(): Matrix;
  25815. /**
  25816. * Parse a JSON and creates the camera from the parsed information
  25817. * @param parsedCamera The JSON to parse
  25818. * @param scene The scene to instantiate the camera in
  25819. * @returns the newly constructed camera
  25820. */
  25821. static Parse(parsedCamera: any, scene: Scene): Camera;
  25822. }
  25823. }
  25824. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25825. import { Nullable } from "babylonjs/types";
  25826. import { Scene } from "babylonjs/scene";
  25827. import { Vector4 } from "babylonjs/Maths/math.vector";
  25828. import { Mesh } from "babylonjs/Meshes/mesh";
  25829. /**
  25830. * Class containing static functions to help procedurally build meshes
  25831. */
  25832. export class DiscBuilder {
  25833. /**
  25834. * Creates a plane polygonal mesh. By default, this is a disc
  25835. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25836. * * 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
  25837. * * 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
  25838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25841. * @param name defines the name of the mesh
  25842. * @param options defines the options used to create the mesh
  25843. * @param scene defines the hosting scene
  25844. * @returns the plane polygonal mesh
  25845. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25846. */
  25847. static CreateDisc(name: string, options: {
  25848. radius?: number;
  25849. tessellation?: number;
  25850. arc?: number;
  25851. updatable?: boolean;
  25852. sideOrientation?: number;
  25853. frontUVs?: Vector4;
  25854. backUVs?: Vector4;
  25855. }, scene?: Nullable<Scene>): Mesh;
  25856. }
  25857. }
  25858. declare module "babylonjs/Particles/solidParticleSystem" {
  25859. import { Vector3 } from "babylonjs/Maths/math.vector";
  25860. import { Mesh } from "babylonjs/Meshes/mesh";
  25861. import { Scene, IDisposable } from "babylonjs/scene";
  25862. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25863. /**
  25864. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25865. *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.
  25866. * The SPS is also a particle system. It provides some methods to manage the particles.
  25867. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25868. *
  25869. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25870. */
  25871. export class SolidParticleSystem implements IDisposable {
  25872. /**
  25873. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25874. * Example : var p = SPS.particles[i];
  25875. */
  25876. particles: SolidParticle[];
  25877. /**
  25878. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25879. */
  25880. nbParticles: number;
  25881. /**
  25882. * If the particles must ever face the camera (default false). Useful for planar particles.
  25883. */
  25884. billboard: boolean;
  25885. /**
  25886. * Recompute normals when adding a shape
  25887. */
  25888. recomputeNormals: boolean;
  25889. /**
  25890. * This a counter ofr your own usage. It's not set by any SPS functions.
  25891. */
  25892. counter: number;
  25893. /**
  25894. * The SPS name. This name is also given to the underlying mesh.
  25895. */
  25896. name: string;
  25897. /**
  25898. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25899. */
  25900. mesh: Mesh;
  25901. /**
  25902. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25903. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25904. */
  25905. vars: any;
  25906. /**
  25907. * This array is populated when the SPS is set as 'pickable'.
  25908. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25909. * Each element of this array is an object `{idx: int, faceId: int}`.
  25910. * `idx` is the picked particle index in the `SPS.particles` array
  25911. * `faceId` is the picked face index counted within this particle.
  25912. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25913. */
  25914. pickedParticles: {
  25915. idx: number;
  25916. faceId: number;
  25917. }[];
  25918. /**
  25919. * This array is populated when `enableDepthSort` is set to true.
  25920. * Each element of this array is an instance of the class DepthSortedParticle.
  25921. */
  25922. depthSortedParticles: DepthSortedParticle[];
  25923. /**
  25924. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25925. * @hidden
  25926. */
  25927. _bSphereOnly: boolean;
  25928. /**
  25929. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25930. * @hidden
  25931. */
  25932. _bSphereRadiusFactor: number;
  25933. private _scene;
  25934. private _positions;
  25935. private _indices;
  25936. private _normals;
  25937. private _colors;
  25938. private _uvs;
  25939. private _indices32;
  25940. private _positions32;
  25941. private _normals32;
  25942. private _fixedNormal32;
  25943. private _colors32;
  25944. private _uvs32;
  25945. private _index;
  25946. private _updatable;
  25947. private _pickable;
  25948. private _isVisibilityBoxLocked;
  25949. private _alwaysVisible;
  25950. private _depthSort;
  25951. private _expandable;
  25952. private _shapeCounter;
  25953. private _copy;
  25954. private _color;
  25955. private _computeParticleColor;
  25956. private _computeParticleTexture;
  25957. private _computeParticleRotation;
  25958. private _computeParticleVertex;
  25959. private _computeBoundingBox;
  25960. private _depthSortParticles;
  25961. private _camera;
  25962. private _mustUnrotateFixedNormals;
  25963. private _particlesIntersect;
  25964. private _needs32Bits;
  25965. /**
  25966. * Creates a SPS (Solid Particle System) object.
  25967. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25968. * @param scene (Scene) is the scene in which the SPS is added.
  25969. * @param options defines the options of the sps e.g.
  25970. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25971. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25972. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25973. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25974. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25975. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25976. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25977. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25978. */
  25979. constructor(name: string, scene: Scene, options?: {
  25980. updatable?: boolean;
  25981. isPickable?: boolean;
  25982. enableDepthSort?: boolean;
  25983. particleIntersection?: boolean;
  25984. boundingSphereOnly?: boolean;
  25985. bSphereRadiusFactor?: number;
  25986. expandable?: boolean;
  25987. });
  25988. /**
  25989. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25990. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25991. * @returns the created mesh
  25992. */
  25993. buildMesh(): Mesh;
  25994. /**
  25995. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25996. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25997. * Thus the particles generated from `digest()` have their property `position` set yet.
  25998. * @param mesh ( Mesh ) is the mesh to be digested
  25999. * @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
  26000. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26001. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26002. * @returns the current SPS
  26003. */
  26004. digest(mesh: Mesh, options?: {
  26005. facetNb?: number;
  26006. number?: number;
  26007. delta?: number;
  26008. }): SolidParticleSystem;
  26009. private _unrotateFixedNormals;
  26010. private _resetCopy;
  26011. private _meshBuilder;
  26012. private _posToShape;
  26013. private _uvsToShapeUV;
  26014. private _addParticle;
  26015. /**
  26016. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26017. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26018. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26019. * @param nb (positive integer) the number of particles to be created from this model
  26020. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26021. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26022. * @returns the number of shapes in the system
  26023. */
  26024. addShape(mesh: Mesh, nb: number, options?: {
  26025. positionFunction?: any;
  26026. vertexFunction?: any;
  26027. }): number;
  26028. private _rebuildParticle;
  26029. /**
  26030. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26031. * @returns the SPS.
  26032. */
  26033. rebuildMesh(): SolidParticleSystem;
  26034. /**
  26035. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26036. * This method calls `updateParticle()` for each particle of the SPS.
  26037. * For an animated SPS, it is usually called within the render loop.
  26038. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26039. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26040. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26041. * @returns the SPS.
  26042. */
  26043. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26044. /**
  26045. * Disposes the SPS.
  26046. */
  26047. dispose(): void;
  26048. /**
  26049. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26050. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26051. * @returns the SPS.
  26052. */
  26053. refreshVisibleSize(): SolidParticleSystem;
  26054. /**
  26055. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26056. * @param size the size (float) of the visibility box
  26057. * note : this doesn't lock the SPS mesh bounding box.
  26058. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26059. */
  26060. setVisibilityBox(size: number): void;
  26061. /**
  26062. * Gets whether the SPS as always visible or not
  26063. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26064. */
  26065. /**
  26066. * Sets the SPS as always visible or not
  26067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26068. */
  26069. isAlwaysVisible: boolean;
  26070. /**
  26071. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26073. */
  26074. /**
  26075. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26077. */
  26078. isVisibilityBoxLocked: boolean;
  26079. /**
  26080. * Tells to `setParticles()` to compute the particle rotations or not.
  26081. * Default value : true. The SPS is faster when it's set to false.
  26082. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26083. */
  26084. /**
  26085. * Gets if `setParticles()` computes the particle rotations or not.
  26086. * Default value : true. The SPS is faster when it's set to false.
  26087. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26088. */
  26089. computeParticleRotation: boolean;
  26090. /**
  26091. * Tells to `setParticles()` to compute the particle colors or not.
  26092. * Default value : true. The SPS is faster when it's set to false.
  26093. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26094. */
  26095. /**
  26096. * Gets if `setParticles()` computes the particle colors or not.
  26097. * Default value : true. The SPS is faster when it's set to false.
  26098. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26099. */
  26100. computeParticleColor: boolean;
  26101. /**
  26102. * Gets if `setParticles()` computes the particle textures or not.
  26103. * Default value : true. The SPS is faster when it's set to false.
  26104. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26105. */
  26106. computeParticleTexture: boolean;
  26107. /**
  26108. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26109. * Default value : false. The SPS is faster when it's set to false.
  26110. * Note : the particle custom vertex positions aren't stored values.
  26111. */
  26112. /**
  26113. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26114. * Default value : false. The SPS is faster when it's set to false.
  26115. * Note : the particle custom vertex positions aren't stored values.
  26116. */
  26117. computeParticleVertex: boolean;
  26118. /**
  26119. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26120. */
  26121. /**
  26122. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26123. */
  26124. computeBoundingBox: boolean;
  26125. /**
  26126. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26127. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26128. * Default : `true`
  26129. */
  26130. /**
  26131. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26132. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26133. * Default : `true`
  26134. */
  26135. depthSortParticles: boolean;
  26136. /**
  26137. * Gets if the SPS is created as expandable at construction time.
  26138. * Default : `false`
  26139. */
  26140. readonly expandable: boolean;
  26141. /**
  26142. * This function does nothing. It may be overwritten to set all the particle first values.
  26143. * The SPS doesn't call this function, you may have to call it by your own.
  26144. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26145. */
  26146. initParticles(): void;
  26147. /**
  26148. * This function does nothing. It may be overwritten to recycle a particle.
  26149. * The SPS doesn't call this function, you may have to call it by your own.
  26150. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26151. * @param particle The particle to recycle
  26152. * @returns the recycled particle
  26153. */
  26154. recycleParticle(particle: SolidParticle): SolidParticle;
  26155. /**
  26156. * Updates a particle : this function should be overwritten by the user.
  26157. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26158. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26159. * @example : just set a particle position or velocity and recycle conditions
  26160. * @param particle The particle to update
  26161. * @returns the updated particle
  26162. */
  26163. updateParticle(particle: SolidParticle): SolidParticle;
  26164. /**
  26165. * Updates a vertex of a particle : it can be overwritten by the user.
  26166. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26167. * @param particle the current particle
  26168. * @param vertex the current index of the current particle
  26169. * @param pt the index of the current vertex in the particle shape
  26170. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26171. * @example : just set a vertex particle position
  26172. * @returns the updated vertex
  26173. */
  26174. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26175. /**
  26176. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26177. * This does nothing and may be overwritten by the user.
  26178. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26180. * @param update the boolean update value actually passed to setParticles()
  26181. */
  26182. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26183. /**
  26184. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26185. * This will be passed three parameters.
  26186. * This does nothing and may be overwritten by the user.
  26187. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26188. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26189. * @param update the boolean update value actually passed to setParticles()
  26190. */
  26191. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26192. }
  26193. }
  26194. declare module "babylonjs/Particles/solidParticle" {
  26195. import { Nullable } from "babylonjs/types";
  26196. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26197. import { Color4 } from "babylonjs/Maths/math.color";
  26198. import { Mesh } from "babylonjs/Meshes/mesh";
  26199. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26200. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26201. import { Plane } from "babylonjs/Maths/math.plane";
  26202. /**
  26203. * Represents one particle of a solid particle system.
  26204. */
  26205. export class SolidParticle {
  26206. /**
  26207. * particle global index
  26208. */
  26209. idx: number;
  26210. /**
  26211. * The color of the particle
  26212. */
  26213. color: Nullable<Color4>;
  26214. /**
  26215. * The world space position of the particle.
  26216. */
  26217. position: Vector3;
  26218. /**
  26219. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26220. */
  26221. rotation: Vector3;
  26222. /**
  26223. * The world space rotation quaternion of the particle.
  26224. */
  26225. rotationQuaternion: Nullable<Quaternion>;
  26226. /**
  26227. * The scaling of the particle.
  26228. */
  26229. scaling: Vector3;
  26230. /**
  26231. * The uvs of the particle.
  26232. */
  26233. uvs: Vector4;
  26234. /**
  26235. * The current speed of the particle.
  26236. */
  26237. velocity: Vector3;
  26238. /**
  26239. * The pivot point in the particle local space.
  26240. */
  26241. pivot: Vector3;
  26242. /**
  26243. * Must the particle be translated from its pivot point in its local space ?
  26244. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26245. * Default : false
  26246. */
  26247. translateFromPivot: boolean;
  26248. /**
  26249. * Is the particle active or not ?
  26250. */
  26251. alive: boolean;
  26252. /**
  26253. * Is the particle visible or not ?
  26254. */
  26255. isVisible: boolean;
  26256. /**
  26257. * Index of this particle in the global "positions" array (Internal use)
  26258. * @hidden
  26259. */
  26260. _pos: number;
  26261. /**
  26262. * @hidden Index of this particle in the global "indices" array (Internal use)
  26263. */
  26264. _ind: number;
  26265. /**
  26266. * @hidden ModelShape of this particle (Internal use)
  26267. */
  26268. _model: ModelShape;
  26269. /**
  26270. * ModelShape id of this particle
  26271. */
  26272. shapeId: number;
  26273. /**
  26274. * Index of the particle in its shape id
  26275. */
  26276. idxInShape: number;
  26277. /**
  26278. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26279. */
  26280. _modelBoundingInfo: BoundingInfo;
  26281. /**
  26282. * @hidden Particle BoundingInfo object (Internal use)
  26283. */
  26284. _boundingInfo: BoundingInfo;
  26285. /**
  26286. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26287. */
  26288. _sps: SolidParticleSystem;
  26289. /**
  26290. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26291. */
  26292. _stillInvisible: boolean;
  26293. /**
  26294. * @hidden Last computed particle rotation matrix
  26295. */
  26296. _rotationMatrix: number[];
  26297. /**
  26298. * Parent particle Id, if any.
  26299. * Default null.
  26300. */
  26301. parentId: Nullable<number>;
  26302. /**
  26303. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26304. * The possible values are :
  26305. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26306. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26307. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26308. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26309. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26310. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26311. * */
  26312. cullingStrategy: number;
  26313. /**
  26314. * @hidden Internal global position in the SPS.
  26315. */
  26316. _globalPosition: Vector3;
  26317. /**
  26318. * Creates a Solid Particle object.
  26319. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26320. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26321. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26322. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26323. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26324. * @param shapeId (integer) is the model shape identifier in the SPS.
  26325. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26326. * @param sps defines the sps it is associated to
  26327. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26328. */
  26329. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26330. /**
  26331. * Legacy support, changed scale to scaling
  26332. */
  26333. /**
  26334. * Legacy support, changed scale to scaling
  26335. */
  26336. scale: Vector3;
  26337. /**
  26338. * Legacy support, changed quaternion to rotationQuaternion
  26339. */
  26340. /**
  26341. * Legacy support, changed quaternion to rotationQuaternion
  26342. */
  26343. quaternion: Nullable<Quaternion>;
  26344. /**
  26345. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26346. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26347. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26348. * @returns true if it intersects
  26349. */
  26350. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26351. /**
  26352. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26353. * A particle is in the frustum if its bounding box intersects the frustum
  26354. * @param frustumPlanes defines the frustum to test
  26355. * @returns true if the particle is in the frustum planes
  26356. */
  26357. isInFrustum(frustumPlanes: Plane[]): boolean;
  26358. /**
  26359. * get the rotation matrix of the particle
  26360. * @hidden
  26361. */
  26362. getRotationMatrix(m: Matrix): void;
  26363. }
  26364. /**
  26365. * Represents the shape of the model used by one particle of a solid particle system.
  26366. * SPS internal tool, don't use it manually.
  26367. */
  26368. export class ModelShape {
  26369. /**
  26370. * The shape id
  26371. * @hidden
  26372. */
  26373. shapeID: number;
  26374. /**
  26375. * flat array of model positions (internal use)
  26376. * @hidden
  26377. */
  26378. _shape: Vector3[];
  26379. /**
  26380. * flat array of model UVs (internal use)
  26381. * @hidden
  26382. */
  26383. _shapeUV: number[];
  26384. /**
  26385. * length of the shape in the model indices array (internal use)
  26386. * @hidden
  26387. */
  26388. _indicesLength: number;
  26389. /**
  26390. * Custom position function (internal use)
  26391. * @hidden
  26392. */
  26393. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26394. /**
  26395. * Custom vertex function (internal use)
  26396. * @hidden
  26397. */
  26398. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26399. /**
  26400. * 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.
  26401. * SPS internal tool, don't use it manually.
  26402. * @hidden
  26403. */
  26404. 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>);
  26405. }
  26406. /**
  26407. * Represents a Depth Sorted Particle in the solid particle system.
  26408. */
  26409. export class DepthSortedParticle {
  26410. /**
  26411. * Index of the particle in the "indices" array
  26412. */
  26413. ind: number;
  26414. /**
  26415. * Length of the particle shape in the "indices" array
  26416. */
  26417. indicesLength: number;
  26418. /**
  26419. * Squared distance from the particle to the camera
  26420. */
  26421. sqDistance: number;
  26422. }
  26423. }
  26424. declare module "babylonjs/Collisions/meshCollisionData" {
  26425. import { Collider } from "babylonjs/Collisions/collider";
  26426. import { Vector3 } from "babylonjs/Maths/math.vector";
  26427. import { Nullable } from "babylonjs/types";
  26428. import { Observer } from "babylonjs/Misc/observable";
  26429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26430. /**
  26431. * @hidden
  26432. */
  26433. export class _MeshCollisionData {
  26434. _checkCollisions: boolean;
  26435. _collisionMask: number;
  26436. _collisionGroup: number;
  26437. _collider: Nullable<Collider>;
  26438. _oldPositionForCollisions: Vector3;
  26439. _diffPositionForCollisions: Vector3;
  26440. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26441. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26442. }
  26443. }
  26444. declare module "babylonjs/Meshes/abstractMesh" {
  26445. import { Observable } from "babylonjs/Misc/observable";
  26446. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26447. import { Camera } from "babylonjs/Cameras/camera";
  26448. import { Scene, IDisposable } from "babylonjs/scene";
  26449. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26450. import { Node } from "babylonjs/node";
  26451. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26452. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26454. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26455. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26456. import { Material } from "babylonjs/Materials/material";
  26457. import { Light } from "babylonjs/Lights/light";
  26458. import { Skeleton } from "babylonjs/Bones/skeleton";
  26459. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26460. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26461. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26462. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26463. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26464. import { Plane } from "babylonjs/Maths/math.plane";
  26465. import { Ray } from "babylonjs/Culling/ray";
  26466. import { Collider } from "babylonjs/Collisions/collider";
  26467. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26468. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26469. /** @hidden */
  26470. class _FacetDataStorage {
  26471. facetPositions: Vector3[];
  26472. facetNormals: Vector3[];
  26473. facetPartitioning: number[][];
  26474. facetNb: number;
  26475. partitioningSubdivisions: number;
  26476. partitioningBBoxRatio: number;
  26477. facetDataEnabled: boolean;
  26478. facetParameters: any;
  26479. bbSize: Vector3;
  26480. subDiv: {
  26481. max: number;
  26482. X: number;
  26483. Y: number;
  26484. Z: number;
  26485. };
  26486. facetDepthSort: boolean;
  26487. facetDepthSortEnabled: boolean;
  26488. depthSortedIndices: IndicesArray;
  26489. depthSortedFacets: {
  26490. ind: number;
  26491. sqDistance: number;
  26492. }[];
  26493. facetDepthSortFunction: (f1: {
  26494. ind: number;
  26495. sqDistance: number;
  26496. }, f2: {
  26497. ind: number;
  26498. sqDistance: number;
  26499. }) => number;
  26500. facetDepthSortFrom: Vector3;
  26501. facetDepthSortOrigin: Vector3;
  26502. invertedMatrix: Matrix;
  26503. }
  26504. /**
  26505. * @hidden
  26506. **/
  26507. class _InternalAbstractMeshDataInfo {
  26508. _hasVertexAlpha: boolean;
  26509. _useVertexColors: boolean;
  26510. _numBoneInfluencers: number;
  26511. _applyFog: boolean;
  26512. _receiveShadows: boolean;
  26513. _facetData: _FacetDataStorage;
  26514. _visibility: number;
  26515. _skeleton: Nullable<Skeleton>;
  26516. _layerMask: number;
  26517. _computeBonesUsingShaders: boolean;
  26518. _isActive: boolean;
  26519. _onlyForInstances: boolean;
  26520. _isActiveIntermediate: boolean;
  26521. _onlyForInstancesIntermediate: boolean;
  26522. _actAsRegularMesh: boolean;
  26523. }
  26524. /**
  26525. * Class used to store all common mesh properties
  26526. */
  26527. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26528. /** No occlusion */
  26529. static OCCLUSION_TYPE_NONE: number;
  26530. /** Occlusion set to optimisitic */
  26531. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26532. /** Occlusion set to strict */
  26533. static OCCLUSION_TYPE_STRICT: number;
  26534. /** Use an accurante occlusion algorithm */
  26535. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26536. /** Use a conservative occlusion algorithm */
  26537. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26538. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26539. * Test order :
  26540. * Is the bounding sphere outside the frustum ?
  26541. * If not, are the bounding box vertices outside the frustum ?
  26542. * It not, then the cullable object is in the frustum.
  26543. */
  26544. static readonly CULLINGSTRATEGY_STANDARD: number;
  26545. /** Culling strategy : Bounding Sphere Only.
  26546. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26547. * It's also less accurate than the standard because some not visible objects can still be selected.
  26548. * Test : is the bounding sphere outside the frustum ?
  26549. * If not, then the cullable object is in the frustum.
  26550. */
  26551. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26552. /** Culling strategy : Optimistic Inclusion.
  26553. * This in an inclusion test first, then the standard exclusion test.
  26554. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26555. * 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.
  26556. * Anyway, it's as accurate as the standard strategy.
  26557. * Test :
  26558. * Is the cullable object bounding sphere center in the frustum ?
  26559. * If not, apply the default culling strategy.
  26560. */
  26561. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26562. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26563. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26564. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26565. * 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.
  26566. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26567. * Test :
  26568. * Is the cullable object bounding sphere center in the frustum ?
  26569. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26570. */
  26571. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26572. /**
  26573. * No billboard
  26574. */
  26575. static readonly BILLBOARDMODE_NONE: number;
  26576. /** Billboard on X axis */
  26577. static readonly BILLBOARDMODE_X: number;
  26578. /** Billboard on Y axis */
  26579. static readonly BILLBOARDMODE_Y: number;
  26580. /** Billboard on Z axis */
  26581. static readonly BILLBOARDMODE_Z: number;
  26582. /** Billboard on all axes */
  26583. static readonly BILLBOARDMODE_ALL: number;
  26584. /** Billboard on using position instead of orientation */
  26585. static readonly BILLBOARDMODE_USE_POSITION: number;
  26586. /** @hidden */
  26587. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26588. /**
  26589. * The culling strategy to use to check whether the mesh must be rendered or not.
  26590. * This value can be changed at any time and will be used on the next render mesh selection.
  26591. * The possible values are :
  26592. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26593. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26594. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26595. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26596. * Please read each static variable documentation to get details about the culling process.
  26597. * */
  26598. cullingStrategy: number;
  26599. /**
  26600. * Gets the number of facets in the mesh
  26601. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26602. */
  26603. readonly facetNb: number;
  26604. /**
  26605. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26606. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26607. */
  26608. partitioningSubdivisions: number;
  26609. /**
  26610. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26611. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26613. */
  26614. partitioningBBoxRatio: number;
  26615. /**
  26616. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26617. * Works only for updatable meshes.
  26618. * Doesn't work with multi-materials
  26619. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26620. */
  26621. mustDepthSortFacets: boolean;
  26622. /**
  26623. * The location (Vector3) where the facet depth sort must be computed from.
  26624. * By default, the active camera position.
  26625. * Used only when facet depth sort is enabled
  26626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26627. */
  26628. facetDepthSortFrom: Vector3;
  26629. /**
  26630. * gets a boolean indicating if facetData is enabled
  26631. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26632. */
  26633. readonly isFacetDataEnabled: boolean;
  26634. /** @hidden */
  26635. _updateNonUniformScalingState(value: boolean): boolean;
  26636. /**
  26637. * An event triggered when this mesh collides with another one
  26638. */
  26639. onCollideObservable: Observable<AbstractMesh>;
  26640. /** Set a function to call when this mesh collides with another one */
  26641. onCollide: () => void;
  26642. /**
  26643. * An event triggered when the collision's position changes
  26644. */
  26645. onCollisionPositionChangeObservable: Observable<Vector3>;
  26646. /** Set a function to call when the collision's position changes */
  26647. onCollisionPositionChange: () => void;
  26648. /**
  26649. * An event triggered when material is changed
  26650. */
  26651. onMaterialChangedObservable: Observable<AbstractMesh>;
  26652. /**
  26653. * Gets or sets the orientation for POV movement & rotation
  26654. */
  26655. definedFacingForward: boolean;
  26656. /** @hidden */
  26657. _occlusionQuery: Nullable<WebGLQuery>;
  26658. /** @hidden */
  26659. _renderingGroup: Nullable<RenderingGroup>;
  26660. /**
  26661. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26662. */
  26663. /**
  26664. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26665. */
  26666. visibility: number;
  26667. /** Gets or sets the alpha index used to sort transparent meshes
  26668. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26669. */
  26670. alphaIndex: number;
  26671. /**
  26672. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26673. */
  26674. isVisible: boolean;
  26675. /**
  26676. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26677. */
  26678. isPickable: boolean;
  26679. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26680. showSubMeshesBoundingBox: boolean;
  26681. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26683. */
  26684. isBlocker: boolean;
  26685. /**
  26686. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26687. */
  26688. enablePointerMoveEvents: boolean;
  26689. /**
  26690. * Specifies the rendering group id for this mesh (0 by default)
  26691. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26692. */
  26693. renderingGroupId: number;
  26694. private _material;
  26695. /** Gets or sets current material */
  26696. material: Nullable<Material>;
  26697. /**
  26698. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26699. * @see http://doc.babylonjs.com/babylon101/shadows
  26700. */
  26701. receiveShadows: boolean;
  26702. /** Defines color to use when rendering outline */
  26703. outlineColor: Color3;
  26704. /** Define width to use when rendering outline */
  26705. outlineWidth: number;
  26706. /** Defines color to use when rendering overlay */
  26707. overlayColor: Color3;
  26708. /** Defines alpha to use when rendering overlay */
  26709. overlayAlpha: number;
  26710. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26711. hasVertexAlpha: boolean;
  26712. /** 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) */
  26713. useVertexColors: boolean;
  26714. /**
  26715. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26716. */
  26717. computeBonesUsingShaders: boolean;
  26718. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26719. numBoneInfluencers: number;
  26720. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26721. applyFog: boolean;
  26722. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26723. useOctreeForRenderingSelection: boolean;
  26724. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26725. useOctreeForPicking: boolean;
  26726. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26727. useOctreeForCollisions: boolean;
  26728. /**
  26729. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26730. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26731. */
  26732. layerMask: number;
  26733. /**
  26734. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26735. */
  26736. alwaysSelectAsActiveMesh: boolean;
  26737. /**
  26738. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26739. */
  26740. doNotSyncBoundingInfo: boolean;
  26741. /**
  26742. * Gets or sets the current action manager
  26743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26744. */
  26745. actionManager: Nullable<AbstractActionManager>;
  26746. private _meshCollisionData;
  26747. /**
  26748. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26749. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26750. */
  26751. ellipsoid: Vector3;
  26752. /**
  26753. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26755. */
  26756. ellipsoidOffset: Vector3;
  26757. /**
  26758. * Gets or sets a collision mask used to mask collisions (default is -1).
  26759. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26760. */
  26761. collisionMask: number;
  26762. /**
  26763. * Gets or sets the current collision group mask (-1 by default).
  26764. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26765. */
  26766. collisionGroup: number;
  26767. /**
  26768. * Defines edge width used when edgesRenderer is enabled
  26769. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26770. */
  26771. edgesWidth: number;
  26772. /**
  26773. * Defines edge color used when edgesRenderer is enabled
  26774. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26775. */
  26776. edgesColor: Color4;
  26777. /** @hidden */
  26778. _edgesRenderer: Nullable<IEdgesRenderer>;
  26779. /** @hidden */
  26780. _masterMesh: Nullable<AbstractMesh>;
  26781. /** @hidden */
  26782. _boundingInfo: Nullable<BoundingInfo>;
  26783. /** @hidden */
  26784. _renderId: number;
  26785. /**
  26786. * Gets or sets the list of subMeshes
  26787. * @see http://doc.babylonjs.com/how_to/multi_materials
  26788. */
  26789. subMeshes: SubMesh[];
  26790. /** @hidden */
  26791. _intersectionsInProgress: AbstractMesh[];
  26792. /** @hidden */
  26793. _unIndexed: boolean;
  26794. /** @hidden */
  26795. _lightSources: Light[];
  26796. /** Gets the list of lights affecting that mesh */
  26797. readonly lightSources: Light[];
  26798. /** @hidden */
  26799. readonly _positions: Nullable<Vector3[]>;
  26800. /** @hidden */
  26801. _waitingData: {
  26802. lods: Nullable<any>;
  26803. actions: Nullable<any>;
  26804. freezeWorldMatrix: Nullable<boolean>;
  26805. };
  26806. /** @hidden */
  26807. _bonesTransformMatrices: Nullable<Float32Array>;
  26808. /** @hidden */
  26809. _transformMatrixTexture: Nullable<RawTexture>;
  26810. /**
  26811. * Gets or sets a skeleton to apply skining transformations
  26812. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26813. */
  26814. skeleton: Nullable<Skeleton>;
  26815. /**
  26816. * An event triggered when the mesh is rebuilt.
  26817. */
  26818. onRebuildObservable: Observable<AbstractMesh>;
  26819. /**
  26820. * Creates a new AbstractMesh
  26821. * @param name defines the name of the mesh
  26822. * @param scene defines the hosting scene
  26823. */
  26824. constructor(name: string, scene?: Nullable<Scene>);
  26825. /**
  26826. * Returns the string "AbstractMesh"
  26827. * @returns "AbstractMesh"
  26828. */
  26829. getClassName(): string;
  26830. /**
  26831. * Gets a string representation of the current mesh
  26832. * @param fullDetails defines a boolean indicating if full details must be included
  26833. * @returns a string representation of the current mesh
  26834. */
  26835. toString(fullDetails?: boolean): string;
  26836. /**
  26837. * @hidden
  26838. */
  26839. protected _getEffectiveParent(): Nullable<Node>;
  26840. /** @hidden */
  26841. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26842. /** @hidden */
  26843. _rebuild(): void;
  26844. /** @hidden */
  26845. _resyncLightSources(): void;
  26846. /** @hidden */
  26847. _resyncLighSource(light: Light): void;
  26848. /** @hidden */
  26849. _unBindEffect(): void;
  26850. /** @hidden */
  26851. _removeLightSource(light: Light, dispose: boolean): void;
  26852. private _markSubMeshesAsDirty;
  26853. /** @hidden */
  26854. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26855. /** @hidden */
  26856. _markSubMeshesAsAttributesDirty(): void;
  26857. /** @hidden */
  26858. _markSubMeshesAsMiscDirty(): void;
  26859. /**
  26860. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26861. */
  26862. scaling: Vector3;
  26863. /**
  26864. * Returns true if the mesh is blocked. Implemented by child classes
  26865. */
  26866. readonly isBlocked: boolean;
  26867. /**
  26868. * Returns the mesh itself by default. Implemented by child classes
  26869. * @param camera defines the camera to use to pick the right LOD level
  26870. * @returns the currentAbstractMesh
  26871. */
  26872. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26873. /**
  26874. * Returns 0 by default. Implemented by child classes
  26875. * @returns an integer
  26876. */
  26877. getTotalVertices(): number;
  26878. /**
  26879. * Returns a positive integer : the total number of indices in this mesh geometry.
  26880. * @returns the numner of indices or zero if the mesh has no geometry.
  26881. */
  26882. getTotalIndices(): number;
  26883. /**
  26884. * Returns null by default. Implemented by child classes
  26885. * @returns null
  26886. */
  26887. getIndices(): Nullable<IndicesArray>;
  26888. /**
  26889. * Returns the array of the requested vertex data kind. Implemented by child classes
  26890. * @param kind defines the vertex data kind to use
  26891. * @returns null
  26892. */
  26893. getVerticesData(kind: string): Nullable<FloatArray>;
  26894. /**
  26895. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26896. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26897. * Note that a new underlying VertexBuffer object is created each call.
  26898. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26899. * @param kind defines vertex data kind:
  26900. * * VertexBuffer.PositionKind
  26901. * * VertexBuffer.UVKind
  26902. * * VertexBuffer.UV2Kind
  26903. * * VertexBuffer.UV3Kind
  26904. * * VertexBuffer.UV4Kind
  26905. * * VertexBuffer.UV5Kind
  26906. * * VertexBuffer.UV6Kind
  26907. * * VertexBuffer.ColorKind
  26908. * * VertexBuffer.MatricesIndicesKind
  26909. * * VertexBuffer.MatricesIndicesExtraKind
  26910. * * VertexBuffer.MatricesWeightsKind
  26911. * * VertexBuffer.MatricesWeightsExtraKind
  26912. * @param data defines the data source
  26913. * @param updatable defines if the data must be flagged as updatable (or static)
  26914. * @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
  26915. * @returns the current mesh
  26916. */
  26917. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26918. /**
  26919. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26920. * If the mesh has no geometry, it is simply returned as it is.
  26921. * @param kind defines vertex data kind:
  26922. * * VertexBuffer.PositionKind
  26923. * * VertexBuffer.UVKind
  26924. * * VertexBuffer.UV2Kind
  26925. * * VertexBuffer.UV3Kind
  26926. * * VertexBuffer.UV4Kind
  26927. * * VertexBuffer.UV5Kind
  26928. * * VertexBuffer.UV6Kind
  26929. * * VertexBuffer.ColorKind
  26930. * * VertexBuffer.MatricesIndicesKind
  26931. * * VertexBuffer.MatricesIndicesExtraKind
  26932. * * VertexBuffer.MatricesWeightsKind
  26933. * * VertexBuffer.MatricesWeightsExtraKind
  26934. * @param data defines the data source
  26935. * @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
  26936. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26937. * @returns the current mesh
  26938. */
  26939. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26940. /**
  26941. * Sets the mesh indices,
  26942. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26943. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26944. * @param totalVertices Defines the total number of vertices
  26945. * @returns the current mesh
  26946. */
  26947. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26948. /**
  26949. * Gets a boolean indicating if specific vertex data is present
  26950. * @param kind defines the vertex data kind to use
  26951. * @returns true is data kind is present
  26952. */
  26953. isVerticesDataPresent(kind: string): boolean;
  26954. /**
  26955. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26956. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26957. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26958. * @returns a BoundingInfo
  26959. */
  26960. getBoundingInfo(): BoundingInfo;
  26961. /**
  26962. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26963. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26964. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26965. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26966. * @returns the current mesh
  26967. */
  26968. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26969. /**
  26970. * Overwrite the current bounding info
  26971. * @param boundingInfo defines the new bounding info
  26972. * @returns the current mesh
  26973. */
  26974. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26975. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26976. readonly useBones: boolean;
  26977. /** @hidden */
  26978. _preActivate(): void;
  26979. /** @hidden */
  26980. _preActivateForIntermediateRendering(renderId: number): void;
  26981. /** @hidden */
  26982. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26983. /** @hidden */
  26984. _postActivate(): void;
  26985. /** @hidden */
  26986. _freeze(): void;
  26987. /** @hidden */
  26988. _unFreeze(): void;
  26989. /**
  26990. * Gets the current world matrix
  26991. * @returns a Matrix
  26992. */
  26993. getWorldMatrix(): Matrix;
  26994. /** @hidden */
  26995. _getWorldMatrixDeterminant(): number;
  26996. /**
  26997. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26998. */
  26999. readonly isAnInstance: boolean;
  27000. /**
  27001. * Gets a boolean indicating if this mesh has instances
  27002. */
  27003. readonly hasInstances: boolean;
  27004. /**
  27005. * Perform relative position change from the point of view of behind the front of the mesh.
  27006. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27007. * Supports definition of mesh facing forward or backward
  27008. * @param amountRight defines the distance on the right axis
  27009. * @param amountUp defines the distance on the up axis
  27010. * @param amountForward defines the distance on the forward axis
  27011. * @returns the current mesh
  27012. */
  27013. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27014. /**
  27015. * Calculate relative position change from the point of view of behind the front of the mesh.
  27016. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27017. * Supports definition of mesh facing forward or backward
  27018. * @param amountRight defines the distance on the right axis
  27019. * @param amountUp defines the distance on the up axis
  27020. * @param amountForward defines the distance on the forward axis
  27021. * @returns the new displacement vector
  27022. */
  27023. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27024. /**
  27025. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27026. * Supports definition of mesh facing forward or backward
  27027. * @param flipBack defines the flip
  27028. * @param twirlClockwise defines the twirl
  27029. * @param tiltRight defines the tilt
  27030. * @returns the current mesh
  27031. */
  27032. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27033. /**
  27034. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27035. * Supports definition of mesh facing forward or backward.
  27036. * @param flipBack defines the flip
  27037. * @param twirlClockwise defines the twirl
  27038. * @param tiltRight defines the tilt
  27039. * @returns the new rotation vector
  27040. */
  27041. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27042. /**
  27043. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27044. * This means the mesh underlying bounding box and sphere are recomputed.
  27045. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27046. * @returns the current mesh
  27047. */
  27048. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27049. /** @hidden */
  27050. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27051. /** @hidden */
  27052. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27053. /** @hidden */
  27054. _updateBoundingInfo(): AbstractMesh;
  27055. /** @hidden */
  27056. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27057. /** @hidden */
  27058. protected _afterComputeWorldMatrix(): void;
  27059. /** @hidden */
  27060. readonly _effectiveMesh: AbstractMesh;
  27061. /**
  27062. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27063. * A mesh is in the frustum if its bounding box intersects the frustum
  27064. * @param frustumPlanes defines the frustum to test
  27065. * @returns true if the mesh is in the frustum planes
  27066. */
  27067. isInFrustum(frustumPlanes: Plane[]): boolean;
  27068. /**
  27069. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27070. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27071. * @param frustumPlanes defines the frustum to test
  27072. * @returns true if the mesh is completely in the frustum planes
  27073. */
  27074. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27075. /**
  27076. * True if the mesh intersects another mesh or a SolidParticle object
  27077. * @param mesh defines a target mesh or SolidParticle to test
  27078. * @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)
  27079. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27080. * @returns true if there is an intersection
  27081. */
  27082. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27083. /**
  27084. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27085. * @param point defines the point to test
  27086. * @returns true if there is an intersection
  27087. */
  27088. intersectsPoint(point: Vector3): boolean;
  27089. /**
  27090. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27092. */
  27093. checkCollisions: boolean;
  27094. /**
  27095. * Gets Collider object used to compute collisions (not physics)
  27096. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27097. */
  27098. readonly collider: Nullable<Collider>;
  27099. /**
  27100. * Move the mesh using collision engine
  27101. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27102. * @param displacement defines the requested displacement vector
  27103. * @returns the current mesh
  27104. */
  27105. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27106. private _onCollisionPositionChange;
  27107. /** @hidden */
  27108. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27109. /** @hidden */
  27110. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27111. /** @hidden */
  27112. _checkCollision(collider: Collider): AbstractMesh;
  27113. /** @hidden */
  27114. _generatePointsArray(): boolean;
  27115. /**
  27116. * Checks if the passed Ray intersects with the mesh
  27117. * @param ray defines the ray to use
  27118. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27119. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27120. * @returns the picking info
  27121. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27122. */
  27123. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27124. /**
  27125. * Clones the current mesh
  27126. * @param name defines the mesh name
  27127. * @param newParent defines the new mesh parent
  27128. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27129. * @returns the new mesh
  27130. */
  27131. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27132. /**
  27133. * Disposes all the submeshes of the current meshnp
  27134. * @returns the current mesh
  27135. */
  27136. releaseSubMeshes(): AbstractMesh;
  27137. /**
  27138. * Releases resources associated with this abstract mesh.
  27139. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27140. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27141. */
  27142. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27143. /**
  27144. * Adds the passed mesh as a child to the current mesh
  27145. * @param mesh defines the child mesh
  27146. * @returns the current mesh
  27147. */
  27148. addChild(mesh: AbstractMesh): AbstractMesh;
  27149. /**
  27150. * Removes the passed mesh from the current mesh children list
  27151. * @param mesh defines the child mesh
  27152. * @returns the current mesh
  27153. */
  27154. removeChild(mesh: AbstractMesh): AbstractMesh;
  27155. /** @hidden */
  27156. private _initFacetData;
  27157. /**
  27158. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27159. * This method can be called within the render loop.
  27160. * 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
  27161. * @returns the current mesh
  27162. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27163. */
  27164. updateFacetData(): AbstractMesh;
  27165. /**
  27166. * Returns the facetLocalNormals array.
  27167. * The normals are expressed in the mesh local spac
  27168. * @returns an array of Vector3
  27169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27170. */
  27171. getFacetLocalNormals(): Vector3[];
  27172. /**
  27173. * Returns the facetLocalPositions array.
  27174. * The facet positions are expressed in the mesh local space
  27175. * @returns an array of Vector3
  27176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27177. */
  27178. getFacetLocalPositions(): Vector3[];
  27179. /**
  27180. * Returns the facetLocalPartioning array
  27181. * @returns an array of array of numbers
  27182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27183. */
  27184. getFacetLocalPartitioning(): number[][];
  27185. /**
  27186. * Returns the i-th facet position in the world system.
  27187. * This method allocates a new Vector3 per call
  27188. * @param i defines the facet index
  27189. * @returns a new Vector3
  27190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27191. */
  27192. getFacetPosition(i: number): Vector3;
  27193. /**
  27194. * Sets the reference Vector3 with the i-th facet position in the world system
  27195. * @param i defines the facet index
  27196. * @param ref defines the target vector
  27197. * @returns the current mesh
  27198. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27199. */
  27200. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27201. /**
  27202. * Returns the i-th facet normal in the world system.
  27203. * This method allocates a new Vector3 per call
  27204. * @param i defines the facet index
  27205. * @returns a new Vector3
  27206. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27207. */
  27208. getFacetNormal(i: number): Vector3;
  27209. /**
  27210. * Sets the reference Vector3 with the i-th facet normal in the world system
  27211. * @param i defines the facet index
  27212. * @param ref defines the target vector
  27213. * @returns the current mesh
  27214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27215. */
  27216. getFacetNormalToRef(i: number, ref: Vector3): this;
  27217. /**
  27218. * 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)
  27219. * @param x defines x coordinate
  27220. * @param y defines y coordinate
  27221. * @param z defines z coordinate
  27222. * @returns the array of facet indexes
  27223. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27224. */
  27225. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27226. /**
  27227. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27228. * @param projected sets as the (x,y,z) world projection on the facet
  27229. * @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
  27230. * @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
  27231. * @param x defines x coordinate
  27232. * @param y defines y coordinate
  27233. * @param z defines z coordinate
  27234. * @returns the face index if found (or null instead)
  27235. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27236. */
  27237. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27238. /**
  27239. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27240. * @param projected sets as the (x,y,z) local projection on the facet
  27241. * @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
  27242. * @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
  27243. * @param x defines x coordinate
  27244. * @param y defines y coordinate
  27245. * @param z defines z coordinate
  27246. * @returns the face index if found (or null instead)
  27247. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27248. */
  27249. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27250. /**
  27251. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27252. * @returns the parameters
  27253. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27254. */
  27255. getFacetDataParameters(): any;
  27256. /**
  27257. * Disables the feature FacetData and frees the related memory
  27258. * @returns the current mesh
  27259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27260. */
  27261. disableFacetData(): AbstractMesh;
  27262. /**
  27263. * Updates the AbstractMesh indices array
  27264. * @param indices defines the data source
  27265. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27266. * @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)
  27267. * @returns the current mesh
  27268. */
  27269. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27270. /**
  27271. * Creates new normals data for the mesh
  27272. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27273. * @returns the current mesh
  27274. */
  27275. createNormals(updatable: boolean): AbstractMesh;
  27276. /**
  27277. * Align the mesh with a normal
  27278. * @param normal defines the normal to use
  27279. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27280. * @returns the current mesh
  27281. */
  27282. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27283. /** @hidden */
  27284. _checkOcclusionQuery(): boolean;
  27285. /**
  27286. * Disables the mesh edge rendering mode
  27287. * @returns the currentAbstractMesh
  27288. */
  27289. disableEdgesRendering(): AbstractMesh;
  27290. /**
  27291. * Enables the edge rendering mode on the mesh.
  27292. * This mode makes the mesh edges visible
  27293. * @param epsilon defines the maximal distance between two angles to detect a face
  27294. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27295. * @returns the currentAbstractMesh
  27296. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27297. */
  27298. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27299. }
  27300. }
  27301. declare module "babylonjs/Actions/actionEvent" {
  27302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27303. import { Nullable } from "babylonjs/types";
  27304. import { Sprite } from "babylonjs/Sprites/sprite";
  27305. import { Scene } from "babylonjs/scene";
  27306. import { Vector2 } from "babylonjs/Maths/math.vector";
  27307. /**
  27308. * Interface used to define ActionEvent
  27309. */
  27310. export interface IActionEvent {
  27311. /** The mesh or sprite that triggered the action */
  27312. source: any;
  27313. /** The X mouse cursor position at the time of the event */
  27314. pointerX: number;
  27315. /** The Y mouse cursor position at the time of the event */
  27316. pointerY: number;
  27317. /** The mesh that is currently pointed at (can be null) */
  27318. meshUnderPointer: Nullable<AbstractMesh>;
  27319. /** the original (browser) event that triggered the ActionEvent */
  27320. sourceEvent?: any;
  27321. /** additional data for the event */
  27322. additionalData?: any;
  27323. }
  27324. /**
  27325. * ActionEvent is the event being sent when an action is triggered.
  27326. */
  27327. export class ActionEvent implements IActionEvent {
  27328. /** The mesh or sprite that triggered the action */
  27329. source: any;
  27330. /** The X mouse cursor position at the time of the event */
  27331. pointerX: number;
  27332. /** The Y mouse cursor position at the time of the event */
  27333. pointerY: number;
  27334. /** The mesh that is currently pointed at (can be null) */
  27335. meshUnderPointer: Nullable<AbstractMesh>;
  27336. /** the original (browser) event that triggered the ActionEvent */
  27337. sourceEvent?: any;
  27338. /** additional data for the event */
  27339. additionalData?: any;
  27340. /**
  27341. * Creates a new ActionEvent
  27342. * @param source The mesh or sprite that triggered the action
  27343. * @param pointerX The X mouse cursor position at the time of the event
  27344. * @param pointerY The Y mouse cursor position at the time of the event
  27345. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27346. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27347. * @param additionalData additional data for the event
  27348. */
  27349. constructor(
  27350. /** The mesh or sprite that triggered the action */
  27351. source: any,
  27352. /** The X mouse cursor position at the time of the event */
  27353. pointerX: number,
  27354. /** The Y mouse cursor position at the time of the event */
  27355. pointerY: number,
  27356. /** The mesh that is currently pointed at (can be null) */
  27357. meshUnderPointer: Nullable<AbstractMesh>,
  27358. /** the original (browser) event that triggered the ActionEvent */
  27359. sourceEvent?: any,
  27360. /** additional data for the event */
  27361. additionalData?: any);
  27362. /**
  27363. * Helper function to auto-create an ActionEvent from a source mesh.
  27364. * @param source The source mesh that triggered the event
  27365. * @param evt The original (browser) event
  27366. * @param additionalData additional data for the event
  27367. * @returns the new ActionEvent
  27368. */
  27369. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27370. /**
  27371. * Helper function to auto-create an ActionEvent from a source sprite
  27372. * @param source The source sprite that triggered the event
  27373. * @param scene Scene associated with the sprite
  27374. * @param evt The original (browser) event
  27375. * @param additionalData additional data for the event
  27376. * @returns the new ActionEvent
  27377. */
  27378. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27379. /**
  27380. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27381. * @param scene the scene where the event occurred
  27382. * @param evt The original (browser) event
  27383. * @returns the new ActionEvent
  27384. */
  27385. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27386. /**
  27387. * Helper function to auto-create an ActionEvent from a primitive
  27388. * @param prim defines the target primitive
  27389. * @param pointerPos defines the pointer position
  27390. * @param evt The original (browser) event
  27391. * @param additionalData additional data for the event
  27392. * @returns the new ActionEvent
  27393. */
  27394. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27395. }
  27396. }
  27397. declare module "babylonjs/Actions/abstractActionManager" {
  27398. import { IDisposable } from "babylonjs/scene";
  27399. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27400. import { IAction } from "babylonjs/Actions/action";
  27401. import { Nullable } from "babylonjs/types";
  27402. /**
  27403. * Abstract class used to decouple action Manager from scene and meshes.
  27404. * Do not instantiate.
  27405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27406. */
  27407. export abstract class AbstractActionManager implements IDisposable {
  27408. /** Gets the list of active triggers */
  27409. static Triggers: {
  27410. [key: string]: number;
  27411. };
  27412. /** Gets the cursor to use when hovering items */
  27413. hoverCursor: string;
  27414. /** Gets the list of actions */
  27415. actions: IAction[];
  27416. /**
  27417. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27418. */
  27419. isRecursive: boolean;
  27420. /**
  27421. * Releases all associated resources
  27422. */
  27423. abstract dispose(): void;
  27424. /**
  27425. * Does this action manager has pointer triggers
  27426. */
  27427. abstract readonly hasPointerTriggers: boolean;
  27428. /**
  27429. * Does this action manager has pick triggers
  27430. */
  27431. abstract readonly hasPickTriggers: boolean;
  27432. /**
  27433. * Process a specific trigger
  27434. * @param trigger defines the trigger to process
  27435. * @param evt defines the event details to be processed
  27436. */
  27437. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27438. /**
  27439. * Does this action manager handles actions of any of the given triggers
  27440. * @param triggers defines the triggers to be tested
  27441. * @return a boolean indicating whether one (or more) of the triggers is handled
  27442. */
  27443. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27444. /**
  27445. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27446. * speed.
  27447. * @param triggerA defines the trigger to be tested
  27448. * @param triggerB defines the trigger to be tested
  27449. * @return a boolean indicating whether one (or more) of the triggers is handled
  27450. */
  27451. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27452. /**
  27453. * Does this action manager handles actions of a given trigger
  27454. * @param trigger defines the trigger to be tested
  27455. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27456. * @return whether the trigger is handled
  27457. */
  27458. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27459. /**
  27460. * Serialize this manager to a JSON object
  27461. * @param name defines the property name to store this manager
  27462. * @returns a JSON representation of this manager
  27463. */
  27464. abstract serialize(name: string): any;
  27465. /**
  27466. * Registers an action to this action manager
  27467. * @param action defines the action to be registered
  27468. * @return the action amended (prepared) after registration
  27469. */
  27470. abstract registerAction(action: IAction): Nullable<IAction>;
  27471. /**
  27472. * Unregisters an action to this action manager
  27473. * @param action defines the action to be unregistered
  27474. * @return a boolean indicating whether the action has been unregistered
  27475. */
  27476. abstract unregisterAction(action: IAction): Boolean;
  27477. /**
  27478. * Does exist one action manager with at least one trigger
  27479. **/
  27480. static readonly HasTriggers: boolean;
  27481. /**
  27482. * Does exist one action manager with at least one pick trigger
  27483. **/
  27484. static readonly HasPickTriggers: boolean;
  27485. /**
  27486. * Does exist one action manager that handles actions of a given trigger
  27487. * @param trigger defines the trigger to be tested
  27488. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27489. **/
  27490. static HasSpecificTrigger(trigger: number): boolean;
  27491. }
  27492. }
  27493. declare module "babylonjs/node" {
  27494. import { Scene } from "babylonjs/scene";
  27495. import { Nullable } from "babylonjs/types";
  27496. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27497. import { Engine } from "babylonjs/Engines/engine";
  27498. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27499. import { Observable } from "babylonjs/Misc/observable";
  27500. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27501. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27502. import { Animatable } from "babylonjs/Animations/animatable";
  27503. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27504. import { Animation } from "babylonjs/Animations/animation";
  27505. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27507. /**
  27508. * Defines how a node can be built from a string name.
  27509. */
  27510. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27511. /**
  27512. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27513. */
  27514. export class Node implements IBehaviorAware<Node> {
  27515. /** @hidden */
  27516. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27517. private static _NodeConstructors;
  27518. /**
  27519. * Add a new node constructor
  27520. * @param type defines the type name of the node to construct
  27521. * @param constructorFunc defines the constructor function
  27522. */
  27523. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27524. /**
  27525. * Returns a node constructor based on type name
  27526. * @param type defines the type name
  27527. * @param name defines the new node name
  27528. * @param scene defines the hosting scene
  27529. * @param options defines optional options to transmit to constructors
  27530. * @returns the new constructor or null
  27531. */
  27532. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27533. /**
  27534. * Gets or sets the name of the node
  27535. */
  27536. name: string;
  27537. /**
  27538. * Gets or sets the id of the node
  27539. */
  27540. id: string;
  27541. /**
  27542. * Gets or sets the unique id of the node
  27543. */
  27544. uniqueId: number;
  27545. /**
  27546. * Gets or sets a string used to store user defined state for the node
  27547. */
  27548. state: string;
  27549. /**
  27550. * Gets or sets an object used to store user defined information for the node
  27551. */
  27552. metadata: any;
  27553. /**
  27554. * For internal use only. Please do not use.
  27555. */
  27556. reservedDataStore: any;
  27557. /**
  27558. * List of inspectable custom properties (used by the Inspector)
  27559. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27560. */
  27561. inspectableCustomProperties: IInspectable[];
  27562. private _doNotSerialize;
  27563. /**
  27564. * Gets or sets a boolean used to define if the node must be serialized
  27565. */
  27566. doNotSerialize: boolean;
  27567. /** @hidden */
  27568. _isDisposed: boolean;
  27569. /**
  27570. * Gets a list of Animations associated with the node
  27571. */
  27572. animations: import("babylonjs/Animations/animation").Animation[];
  27573. protected _ranges: {
  27574. [name: string]: Nullable<AnimationRange>;
  27575. };
  27576. /**
  27577. * Callback raised when the node is ready to be used
  27578. */
  27579. onReady: Nullable<(node: Node) => void>;
  27580. private _isEnabled;
  27581. private _isParentEnabled;
  27582. private _isReady;
  27583. /** @hidden */
  27584. _currentRenderId: number;
  27585. private _parentUpdateId;
  27586. /** @hidden */
  27587. _childUpdateId: number;
  27588. /** @hidden */
  27589. _waitingParentId: Nullable<string>;
  27590. /** @hidden */
  27591. _scene: Scene;
  27592. /** @hidden */
  27593. _cache: any;
  27594. private _parentNode;
  27595. private _children;
  27596. /** @hidden */
  27597. _worldMatrix: Matrix;
  27598. /** @hidden */
  27599. _worldMatrixDeterminant: number;
  27600. /** @hidden */
  27601. _worldMatrixDeterminantIsDirty: boolean;
  27602. /** @hidden */
  27603. private _sceneRootNodesIndex;
  27604. /**
  27605. * Gets a boolean indicating if the node has been disposed
  27606. * @returns true if the node was disposed
  27607. */
  27608. isDisposed(): boolean;
  27609. /**
  27610. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27611. * @see https://doc.babylonjs.com/how_to/parenting
  27612. */
  27613. parent: Nullable<Node>;
  27614. private addToSceneRootNodes;
  27615. private removeFromSceneRootNodes;
  27616. private _animationPropertiesOverride;
  27617. /**
  27618. * Gets or sets the animation properties override
  27619. */
  27620. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27621. /**
  27622. * Gets a string idenfifying the name of the class
  27623. * @returns "Node" string
  27624. */
  27625. getClassName(): string;
  27626. /** @hidden */
  27627. readonly _isNode: boolean;
  27628. /**
  27629. * An event triggered when the mesh is disposed
  27630. */
  27631. onDisposeObservable: Observable<Node>;
  27632. private _onDisposeObserver;
  27633. /**
  27634. * Sets a callback that will be raised when the node will be disposed
  27635. */
  27636. onDispose: () => void;
  27637. /**
  27638. * Creates a new Node
  27639. * @param name the name and id to be given to this node
  27640. * @param scene the scene this node will be added to
  27641. * @param addToRootNodes the node will be added to scene.rootNodes
  27642. */
  27643. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27644. /**
  27645. * Gets the scene of the node
  27646. * @returns a scene
  27647. */
  27648. getScene(): Scene;
  27649. /**
  27650. * Gets the engine of the node
  27651. * @returns a Engine
  27652. */
  27653. getEngine(): Engine;
  27654. private _behaviors;
  27655. /**
  27656. * Attach a behavior to the node
  27657. * @see http://doc.babylonjs.com/features/behaviour
  27658. * @param behavior defines the behavior to attach
  27659. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27660. * @returns the current Node
  27661. */
  27662. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27663. /**
  27664. * Remove an attached behavior
  27665. * @see http://doc.babylonjs.com/features/behaviour
  27666. * @param behavior defines the behavior to attach
  27667. * @returns the current Node
  27668. */
  27669. removeBehavior(behavior: Behavior<Node>): Node;
  27670. /**
  27671. * Gets the list of attached behaviors
  27672. * @see http://doc.babylonjs.com/features/behaviour
  27673. */
  27674. readonly behaviors: Behavior<Node>[];
  27675. /**
  27676. * Gets an attached behavior by name
  27677. * @param name defines the name of the behavior to look for
  27678. * @see http://doc.babylonjs.com/features/behaviour
  27679. * @returns null if behavior was not found else the requested behavior
  27680. */
  27681. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27682. /**
  27683. * Returns the latest update of the World matrix
  27684. * @returns a Matrix
  27685. */
  27686. getWorldMatrix(): Matrix;
  27687. /** @hidden */
  27688. _getWorldMatrixDeterminant(): number;
  27689. /**
  27690. * Returns directly the latest state of the mesh World matrix.
  27691. * A Matrix is returned.
  27692. */
  27693. readonly worldMatrixFromCache: Matrix;
  27694. /** @hidden */
  27695. _initCache(): void;
  27696. /** @hidden */
  27697. updateCache(force?: boolean): void;
  27698. /** @hidden */
  27699. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27700. /** @hidden */
  27701. _updateCache(ignoreParentClass?: boolean): void;
  27702. /** @hidden */
  27703. _isSynchronized(): boolean;
  27704. /** @hidden */
  27705. _markSyncedWithParent(): void;
  27706. /** @hidden */
  27707. isSynchronizedWithParent(): boolean;
  27708. /** @hidden */
  27709. isSynchronized(): boolean;
  27710. /**
  27711. * Is this node ready to be used/rendered
  27712. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27713. * @return true if the node is ready
  27714. */
  27715. isReady(completeCheck?: boolean): boolean;
  27716. /**
  27717. * Is this node enabled?
  27718. * 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
  27719. * @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
  27720. * @return whether this node (and its parent) is enabled
  27721. */
  27722. isEnabled(checkAncestors?: boolean): boolean;
  27723. /** @hidden */
  27724. protected _syncParentEnabledState(): void;
  27725. /**
  27726. * Set the enabled state of this node
  27727. * @param value defines the new enabled state
  27728. */
  27729. setEnabled(value: boolean): void;
  27730. /**
  27731. * Is this node a descendant of the given node?
  27732. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27733. * @param ancestor defines the parent node to inspect
  27734. * @returns a boolean indicating if this node is a descendant of the given node
  27735. */
  27736. isDescendantOf(ancestor: Node): boolean;
  27737. /** @hidden */
  27738. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27739. /**
  27740. * Will return all nodes that have this node as ascendant
  27741. * @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
  27742. * @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
  27743. * @return all children nodes of all types
  27744. */
  27745. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27746. /**
  27747. * Get all child-meshes of this node
  27748. * @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)
  27749. * @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
  27750. * @returns an array of AbstractMesh
  27751. */
  27752. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27753. /**
  27754. * Get all direct children of this node
  27755. * @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
  27756. * @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)
  27757. * @returns an array of Node
  27758. */
  27759. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27760. /** @hidden */
  27761. _setReady(state: boolean): void;
  27762. /**
  27763. * Get an animation by name
  27764. * @param name defines the name of the animation to look for
  27765. * @returns null if not found else the requested animation
  27766. */
  27767. getAnimationByName(name: string): Nullable<Animation>;
  27768. /**
  27769. * Creates an animation range for this node
  27770. * @param name defines the name of the range
  27771. * @param from defines the starting key
  27772. * @param to defines the end key
  27773. */
  27774. createAnimationRange(name: string, from: number, to: number): void;
  27775. /**
  27776. * Delete a specific animation range
  27777. * @param name defines the name of the range to delete
  27778. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27779. */
  27780. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27781. /**
  27782. * Get an animation range by name
  27783. * @param name defines the name of the animation range to look for
  27784. * @returns null if not found else the requested animation range
  27785. */
  27786. getAnimationRange(name: string): Nullable<AnimationRange>;
  27787. /**
  27788. * Gets the list of all animation ranges defined on this node
  27789. * @returns an array
  27790. */
  27791. getAnimationRanges(): Nullable<AnimationRange>[];
  27792. /**
  27793. * Will start the animation sequence
  27794. * @param name defines the range frames for animation sequence
  27795. * @param loop defines if the animation should loop (false by default)
  27796. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27797. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27798. * @returns the object created for this animation. If range does not exist, it will return null
  27799. */
  27800. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27801. /**
  27802. * Serialize animation ranges into a JSON compatible object
  27803. * @returns serialization object
  27804. */
  27805. serializeAnimationRanges(): any;
  27806. /**
  27807. * Computes the world matrix of the node
  27808. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27809. * @returns the world matrix
  27810. */
  27811. computeWorldMatrix(force?: boolean): Matrix;
  27812. /**
  27813. * Releases resources associated with this node.
  27814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27816. */
  27817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27818. /**
  27819. * Parse animation range data from a serialization object and store them into a given node
  27820. * @param node defines where to store the animation ranges
  27821. * @param parsedNode defines the serialization object to read data from
  27822. * @param scene defines the hosting scene
  27823. */
  27824. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27825. /**
  27826. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27827. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27828. * @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
  27829. * @returns the new bounding vectors
  27830. */
  27831. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27832. min: Vector3;
  27833. max: Vector3;
  27834. };
  27835. }
  27836. }
  27837. declare module "babylonjs/Animations/animation" {
  27838. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27839. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27840. import { Color3 } from "babylonjs/Maths/math.color";
  27841. import { Nullable } from "babylonjs/types";
  27842. import { Scene } from "babylonjs/scene";
  27843. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27844. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27845. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27846. import { Node } from "babylonjs/node";
  27847. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27848. import { Size } from "babylonjs/Maths/math.size";
  27849. import { Animatable } from "babylonjs/Animations/animatable";
  27850. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27851. /**
  27852. * @hidden
  27853. */
  27854. export class _IAnimationState {
  27855. key: number;
  27856. repeatCount: number;
  27857. workValue?: any;
  27858. loopMode?: number;
  27859. offsetValue?: any;
  27860. highLimitValue?: any;
  27861. }
  27862. /**
  27863. * Class used to store any kind of animation
  27864. */
  27865. export class Animation {
  27866. /**Name of the animation */
  27867. name: string;
  27868. /**Property to animate */
  27869. targetProperty: string;
  27870. /**The frames per second of the animation */
  27871. framePerSecond: number;
  27872. /**The data type of the animation */
  27873. dataType: number;
  27874. /**The loop mode of the animation */
  27875. loopMode?: number | undefined;
  27876. /**Specifies if blending should be enabled */
  27877. enableBlending?: boolean | undefined;
  27878. /**
  27879. * Use matrix interpolation instead of using direct key value when animating matrices
  27880. */
  27881. static AllowMatricesInterpolation: boolean;
  27882. /**
  27883. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27884. */
  27885. static AllowMatrixDecomposeForInterpolation: boolean;
  27886. /**
  27887. * Stores the key frames of the animation
  27888. */
  27889. private _keys;
  27890. /**
  27891. * Stores the easing function of the animation
  27892. */
  27893. private _easingFunction;
  27894. /**
  27895. * @hidden Internal use only
  27896. */
  27897. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27898. /**
  27899. * The set of event that will be linked to this animation
  27900. */
  27901. private _events;
  27902. /**
  27903. * Stores an array of target property paths
  27904. */
  27905. targetPropertyPath: string[];
  27906. /**
  27907. * Stores the blending speed of the animation
  27908. */
  27909. blendingSpeed: number;
  27910. /**
  27911. * Stores the animation ranges for the animation
  27912. */
  27913. private _ranges;
  27914. /**
  27915. * @hidden Internal use
  27916. */
  27917. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27918. /**
  27919. * Sets up an animation
  27920. * @param property The property to animate
  27921. * @param animationType The animation type to apply
  27922. * @param framePerSecond The frames per second of the animation
  27923. * @param easingFunction The easing function used in the animation
  27924. * @returns The created animation
  27925. */
  27926. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27927. /**
  27928. * Create and start an animation on a node
  27929. * @param name defines the name of the global animation that will be run on all nodes
  27930. * @param node defines the root node where the animation will take place
  27931. * @param targetProperty defines property to animate
  27932. * @param framePerSecond defines the number of frame per second yo use
  27933. * @param totalFrame defines the number of frames in total
  27934. * @param from defines the initial value
  27935. * @param to defines the final value
  27936. * @param loopMode defines which loop mode you want to use (off by default)
  27937. * @param easingFunction defines the easing function to use (linear by default)
  27938. * @param onAnimationEnd defines the callback to call when animation end
  27939. * @returns the animatable created for this animation
  27940. */
  27941. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27942. /**
  27943. * Create and start an animation on a node and its descendants
  27944. * @param name defines the name of the global animation that will be run on all nodes
  27945. * @param node defines the root node where the animation will take place
  27946. * @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
  27947. * @param targetProperty defines property to animate
  27948. * @param framePerSecond defines the number of frame per second to use
  27949. * @param totalFrame defines the number of frames in total
  27950. * @param from defines the initial value
  27951. * @param to defines the final value
  27952. * @param loopMode defines which loop mode you want to use (off by default)
  27953. * @param easingFunction defines the easing function to use (linear by default)
  27954. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27955. * @returns the list of animatables created for all nodes
  27956. * @example https://www.babylonjs-playground.com/#MH0VLI
  27957. */
  27958. 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[]>;
  27959. /**
  27960. * Creates a new animation, merges it with the existing animations and starts it
  27961. * @param name Name of the animation
  27962. * @param node Node which contains the scene that begins the animations
  27963. * @param targetProperty Specifies which property to animate
  27964. * @param framePerSecond The frames per second of the animation
  27965. * @param totalFrame The total number of frames
  27966. * @param from The frame at the beginning of the animation
  27967. * @param to The frame at the end of the animation
  27968. * @param loopMode Specifies the loop mode of the animation
  27969. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27970. * @param onAnimationEnd Callback to run once the animation is complete
  27971. * @returns Nullable animation
  27972. */
  27973. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27974. /**
  27975. * Transition property of an host to the target Value
  27976. * @param property The property to transition
  27977. * @param targetValue The target Value of the property
  27978. * @param host The object where the property to animate belongs
  27979. * @param scene Scene used to run the animation
  27980. * @param frameRate Framerate (in frame/s) to use
  27981. * @param transition The transition type we want to use
  27982. * @param duration The duration of the animation, in milliseconds
  27983. * @param onAnimationEnd Callback trigger at the end of the animation
  27984. * @returns Nullable animation
  27985. */
  27986. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27987. /**
  27988. * Return the array of runtime animations currently using this animation
  27989. */
  27990. readonly runtimeAnimations: RuntimeAnimation[];
  27991. /**
  27992. * Specifies if any of the runtime animations are currently running
  27993. */
  27994. readonly hasRunningRuntimeAnimations: boolean;
  27995. /**
  27996. * Initializes the animation
  27997. * @param name Name of the animation
  27998. * @param targetProperty Property to animate
  27999. * @param framePerSecond The frames per second of the animation
  28000. * @param dataType The data type of the animation
  28001. * @param loopMode The loop mode of the animation
  28002. * @param enableBlending Specifies if blending should be enabled
  28003. */
  28004. constructor(
  28005. /**Name of the animation */
  28006. name: string,
  28007. /**Property to animate */
  28008. targetProperty: string,
  28009. /**The frames per second of the animation */
  28010. framePerSecond: number,
  28011. /**The data type of the animation */
  28012. dataType: number,
  28013. /**The loop mode of the animation */
  28014. loopMode?: number | undefined,
  28015. /**Specifies if blending should be enabled */
  28016. enableBlending?: boolean | undefined);
  28017. /**
  28018. * Converts the animation to a string
  28019. * @param fullDetails support for multiple levels of logging within scene loading
  28020. * @returns String form of the animation
  28021. */
  28022. toString(fullDetails?: boolean): string;
  28023. /**
  28024. * Add an event to this animation
  28025. * @param event Event to add
  28026. */
  28027. addEvent(event: AnimationEvent): void;
  28028. /**
  28029. * Remove all events found at the given frame
  28030. * @param frame The frame to remove events from
  28031. */
  28032. removeEvents(frame: number): void;
  28033. /**
  28034. * Retrieves all the events from the animation
  28035. * @returns Events from the animation
  28036. */
  28037. getEvents(): AnimationEvent[];
  28038. /**
  28039. * Creates an animation range
  28040. * @param name Name of the animation range
  28041. * @param from Starting frame of the animation range
  28042. * @param to Ending frame of the animation
  28043. */
  28044. createRange(name: string, from: number, to: number): void;
  28045. /**
  28046. * Deletes an animation range by name
  28047. * @param name Name of the animation range to delete
  28048. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28049. */
  28050. deleteRange(name: string, deleteFrames?: boolean): void;
  28051. /**
  28052. * Gets the animation range by name, or null if not defined
  28053. * @param name Name of the animation range
  28054. * @returns Nullable animation range
  28055. */
  28056. getRange(name: string): Nullable<AnimationRange>;
  28057. /**
  28058. * Gets the key frames from the animation
  28059. * @returns The key frames of the animation
  28060. */
  28061. getKeys(): Array<IAnimationKey>;
  28062. /**
  28063. * Gets the highest frame rate of the animation
  28064. * @returns Highest frame rate of the animation
  28065. */
  28066. getHighestFrame(): number;
  28067. /**
  28068. * Gets the easing function of the animation
  28069. * @returns Easing function of the animation
  28070. */
  28071. getEasingFunction(): IEasingFunction;
  28072. /**
  28073. * Sets the easing function of the animation
  28074. * @param easingFunction A custom mathematical formula for animation
  28075. */
  28076. setEasingFunction(easingFunction: EasingFunction): void;
  28077. /**
  28078. * Interpolates a scalar linearly
  28079. * @param startValue Start value of the animation curve
  28080. * @param endValue End value of the animation curve
  28081. * @param gradient Scalar amount to interpolate
  28082. * @returns Interpolated scalar value
  28083. */
  28084. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28085. /**
  28086. * Interpolates a scalar cubically
  28087. * @param startValue Start value of the animation curve
  28088. * @param outTangent End tangent of the animation
  28089. * @param endValue End value of the animation curve
  28090. * @param inTangent Start tangent of the animation curve
  28091. * @param gradient Scalar amount to interpolate
  28092. * @returns Interpolated scalar value
  28093. */
  28094. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28095. /**
  28096. * Interpolates a quaternion using a spherical linear interpolation
  28097. * @param startValue Start value of the animation curve
  28098. * @param endValue End value of the animation curve
  28099. * @param gradient Scalar amount to interpolate
  28100. * @returns Interpolated quaternion value
  28101. */
  28102. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28103. /**
  28104. * Interpolates a quaternion cubically
  28105. * @param startValue Start value of the animation curve
  28106. * @param outTangent End tangent of the animation curve
  28107. * @param endValue End value of the animation curve
  28108. * @param inTangent Start tangent of the animation curve
  28109. * @param gradient Scalar amount to interpolate
  28110. * @returns Interpolated quaternion value
  28111. */
  28112. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28113. /**
  28114. * Interpolates a Vector3 linearl
  28115. * @param startValue Start value of the animation curve
  28116. * @param endValue End value of the animation curve
  28117. * @param gradient Scalar amount to interpolate
  28118. * @returns Interpolated scalar value
  28119. */
  28120. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28121. /**
  28122. * Interpolates a Vector3 cubically
  28123. * @param startValue Start value of the animation curve
  28124. * @param outTangent End tangent of the animation
  28125. * @param endValue End value of the animation curve
  28126. * @param inTangent Start tangent of the animation curve
  28127. * @param gradient Scalar amount to interpolate
  28128. * @returns InterpolatedVector3 value
  28129. */
  28130. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28131. /**
  28132. * Interpolates a Vector2 linearly
  28133. * @param startValue Start value of the animation curve
  28134. * @param endValue End value of the animation curve
  28135. * @param gradient Scalar amount to interpolate
  28136. * @returns Interpolated Vector2 value
  28137. */
  28138. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28139. /**
  28140. * Interpolates a Vector2 cubically
  28141. * @param startValue Start value of the animation curve
  28142. * @param outTangent End tangent of the animation
  28143. * @param endValue End value of the animation curve
  28144. * @param inTangent Start tangent of the animation curve
  28145. * @param gradient Scalar amount to interpolate
  28146. * @returns Interpolated Vector2 value
  28147. */
  28148. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28149. /**
  28150. * Interpolates a size linearly
  28151. * @param startValue Start value of the animation curve
  28152. * @param endValue End value of the animation curve
  28153. * @param gradient Scalar amount to interpolate
  28154. * @returns Interpolated Size value
  28155. */
  28156. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28157. /**
  28158. * Interpolates a Color3 linearly
  28159. * @param startValue Start value of the animation curve
  28160. * @param endValue End value of the animation curve
  28161. * @param gradient Scalar amount to interpolate
  28162. * @returns Interpolated Color3 value
  28163. */
  28164. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28165. /**
  28166. * @hidden Internal use only
  28167. */
  28168. _getKeyValue(value: any): any;
  28169. /**
  28170. * @hidden Internal use only
  28171. */
  28172. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28173. /**
  28174. * Defines the function to use to interpolate matrices
  28175. * @param startValue defines the start matrix
  28176. * @param endValue defines the end matrix
  28177. * @param gradient defines the gradient between both matrices
  28178. * @param result defines an optional target matrix where to store the interpolation
  28179. * @returns the interpolated matrix
  28180. */
  28181. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28182. /**
  28183. * Makes a copy of the animation
  28184. * @returns Cloned animation
  28185. */
  28186. clone(): Animation;
  28187. /**
  28188. * Sets the key frames of the animation
  28189. * @param values The animation key frames to set
  28190. */
  28191. setKeys(values: Array<IAnimationKey>): void;
  28192. /**
  28193. * Serializes the animation to an object
  28194. * @returns Serialized object
  28195. */
  28196. serialize(): any;
  28197. /**
  28198. * Float animation type
  28199. */
  28200. private static _ANIMATIONTYPE_FLOAT;
  28201. /**
  28202. * Vector3 animation type
  28203. */
  28204. private static _ANIMATIONTYPE_VECTOR3;
  28205. /**
  28206. * Quaternion animation type
  28207. */
  28208. private static _ANIMATIONTYPE_QUATERNION;
  28209. /**
  28210. * Matrix animation type
  28211. */
  28212. private static _ANIMATIONTYPE_MATRIX;
  28213. /**
  28214. * Color3 animation type
  28215. */
  28216. private static _ANIMATIONTYPE_COLOR3;
  28217. /**
  28218. * Vector2 animation type
  28219. */
  28220. private static _ANIMATIONTYPE_VECTOR2;
  28221. /**
  28222. * Size animation type
  28223. */
  28224. private static _ANIMATIONTYPE_SIZE;
  28225. /**
  28226. * Relative Loop Mode
  28227. */
  28228. private static _ANIMATIONLOOPMODE_RELATIVE;
  28229. /**
  28230. * Cycle Loop Mode
  28231. */
  28232. private static _ANIMATIONLOOPMODE_CYCLE;
  28233. /**
  28234. * Constant Loop Mode
  28235. */
  28236. private static _ANIMATIONLOOPMODE_CONSTANT;
  28237. /**
  28238. * Get the float animation type
  28239. */
  28240. static readonly ANIMATIONTYPE_FLOAT: number;
  28241. /**
  28242. * Get the Vector3 animation type
  28243. */
  28244. static readonly ANIMATIONTYPE_VECTOR3: number;
  28245. /**
  28246. * Get the Vector2 animation type
  28247. */
  28248. static readonly ANIMATIONTYPE_VECTOR2: number;
  28249. /**
  28250. * Get the Size animation type
  28251. */
  28252. static readonly ANIMATIONTYPE_SIZE: number;
  28253. /**
  28254. * Get the Quaternion animation type
  28255. */
  28256. static readonly ANIMATIONTYPE_QUATERNION: number;
  28257. /**
  28258. * Get the Matrix animation type
  28259. */
  28260. static readonly ANIMATIONTYPE_MATRIX: number;
  28261. /**
  28262. * Get the Color3 animation type
  28263. */
  28264. static readonly ANIMATIONTYPE_COLOR3: number;
  28265. /**
  28266. * Get the Relative Loop Mode
  28267. */
  28268. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28269. /**
  28270. * Get the Cycle Loop Mode
  28271. */
  28272. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28273. /**
  28274. * Get the Constant Loop Mode
  28275. */
  28276. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28277. /** @hidden */
  28278. static _UniversalLerp(left: any, right: any, amount: number): any;
  28279. /**
  28280. * Parses an animation object and creates an animation
  28281. * @param parsedAnimation Parsed animation object
  28282. * @returns Animation object
  28283. */
  28284. static Parse(parsedAnimation: any): Animation;
  28285. /**
  28286. * Appends the serialized animations from the source animations
  28287. * @param source Source containing the animations
  28288. * @param destination Target to store the animations
  28289. */
  28290. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28291. }
  28292. }
  28293. declare module "babylonjs/Animations/animatable.interface" {
  28294. import { Nullable } from "babylonjs/types";
  28295. import { Animation } from "babylonjs/Animations/animation";
  28296. /**
  28297. * Interface containing an array of animations
  28298. */
  28299. export interface IAnimatable {
  28300. /**
  28301. * Array of animations
  28302. */
  28303. animations: Nullable<Array<Animation>>;
  28304. }
  28305. }
  28306. declare module "babylonjs/Materials/fresnelParameters" {
  28307. import { Color3 } from "babylonjs/Maths/math.color";
  28308. /**
  28309. * This represents all the required information to add a fresnel effect on a material:
  28310. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28311. */
  28312. export class FresnelParameters {
  28313. private _isEnabled;
  28314. /**
  28315. * Define if the fresnel effect is enable or not.
  28316. */
  28317. isEnabled: boolean;
  28318. /**
  28319. * Define the color used on edges (grazing angle)
  28320. */
  28321. leftColor: Color3;
  28322. /**
  28323. * Define the color used on center
  28324. */
  28325. rightColor: Color3;
  28326. /**
  28327. * Define bias applied to computed fresnel term
  28328. */
  28329. bias: number;
  28330. /**
  28331. * Defined the power exponent applied to fresnel term
  28332. */
  28333. power: number;
  28334. /**
  28335. * Clones the current fresnel and its valuues
  28336. * @returns a clone fresnel configuration
  28337. */
  28338. clone(): FresnelParameters;
  28339. /**
  28340. * Serializes the current fresnel parameters to a JSON representation.
  28341. * @return the JSON serialization
  28342. */
  28343. serialize(): any;
  28344. /**
  28345. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28346. * @param parsedFresnelParameters Define the JSON representation
  28347. * @returns the parsed parameters
  28348. */
  28349. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28350. }
  28351. }
  28352. declare module "babylonjs/Misc/decorators" {
  28353. import { Nullable } from "babylonjs/types";
  28354. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28355. import { Scene } from "babylonjs/scene";
  28356. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28357. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28358. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28359. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28360. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28361. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28362. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28363. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28364. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28365. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28366. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28367. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28368. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28369. /**
  28370. * Decorator used to define property that can be serialized as reference to a camera
  28371. * @param sourceName defines the name of the property to decorate
  28372. */
  28373. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28374. /**
  28375. * Class used to help serialization objects
  28376. */
  28377. export class SerializationHelper {
  28378. /** @hidden */
  28379. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28380. /** @hidden */
  28381. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28382. /** @hidden */
  28383. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28384. /** @hidden */
  28385. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28386. /**
  28387. * Appends the serialized animations from the source animations
  28388. * @param source Source containing the animations
  28389. * @param destination Target to store the animations
  28390. */
  28391. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28392. /**
  28393. * Static function used to serialized a specific entity
  28394. * @param entity defines the entity to serialize
  28395. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28396. * @returns a JSON compatible object representing the serialization of the entity
  28397. */
  28398. static Serialize<T>(entity: T, serializationObject?: any): any;
  28399. /**
  28400. * Creates a new entity from a serialization data object
  28401. * @param creationFunction defines a function used to instanciated the new entity
  28402. * @param source defines the source serialization data
  28403. * @param scene defines the hosting scene
  28404. * @param rootUrl defines the root url for resources
  28405. * @returns a new entity
  28406. */
  28407. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28408. /**
  28409. * Clones an object
  28410. * @param creationFunction defines the function used to instanciate the new object
  28411. * @param source defines the source object
  28412. * @returns the cloned object
  28413. */
  28414. static Clone<T>(creationFunction: () => T, source: T): T;
  28415. /**
  28416. * Instanciates a new object based on a source one (some data will be shared between both object)
  28417. * @param creationFunction defines the function used to instanciate the new object
  28418. * @param source defines the source object
  28419. * @returns the new object
  28420. */
  28421. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28422. }
  28423. }
  28424. declare module "babylonjs/Misc/guid" {
  28425. /**
  28426. * Class used to manipulate GUIDs
  28427. */
  28428. export class GUID {
  28429. /**
  28430. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28431. * Be aware Math.random() could cause collisions, but:
  28432. * "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"
  28433. * @returns a pseudo random id
  28434. */
  28435. static RandomId(): string;
  28436. }
  28437. }
  28438. declare module "babylonjs/Materials/Textures/baseTexture" {
  28439. import { Observable } from "babylonjs/Misc/observable";
  28440. import { Nullable } from "babylonjs/types";
  28441. import { Scene } from "babylonjs/scene";
  28442. import { Matrix } from "babylonjs/Maths/math.vector";
  28443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28444. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28445. import { ISize } from "babylonjs/Maths/math.size";
  28446. /**
  28447. * Base class of all the textures in babylon.
  28448. * It groups all the common properties the materials, post process, lights... might need
  28449. * in order to make a correct use of the texture.
  28450. */
  28451. export class BaseTexture implements IAnimatable {
  28452. /**
  28453. * Default anisotropic filtering level for the application.
  28454. * It is set to 4 as a good tradeoff between perf and quality.
  28455. */
  28456. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28457. /**
  28458. * Gets or sets the unique id of the texture
  28459. */
  28460. uniqueId: number;
  28461. /**
  28462. * Define the name of the texture.
  28463. */
  28464. name: string;
  28465. /**
  28466. * Gets or sets an object used to store user defined information.
  28467. */
  28468. metadata: any;
  28469. /**
  28470. * For internal use only. Please do not use.
  28471. */
  28472. reservedDataStore: any;
  28473. private _hasAlpha;
  28474. /**
  28475. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28476. */
  28477. hasAlpha: boolean;
  28478. /**
  28479. * Defines if the alpha value should be determined via the rgb values.
  28480. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28481. */
  28482. getAlphaFromRGB: boolean;
  28483. /**
  28484. * Intensity or strength of the texture.
  28485. * It is commonly used by materials to fine tune the intensity of the texture
  28486. */
  28487. level: number;
  28488. /**
  28489. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28490. * This is part of the texture as textures usually maps to one uv set.
  28491. */
  28492. coordinatesIndex: number;
  28493. private _coordinatesMode;
  28494. /**
  28495. * How a texture is mapped.
  28496. *
  28497. * | Value | Type | Description |
  28498. * | ----- | ----------------------------------- | ----------- |
  28499. * | 0 | EXPLICIT_MODE | |
  28500. * | 1 | SPHERICAL_MODE | |
  28501. * | 2 | PLANAR_MODE | |
  28502. * | 3 | CUBIC_MODE | |
  28503. * | 4 | PROJECTION_MODE | |
  28504. * | 5 | SKYBOX_MODE | |
  28505. * | 6 | INVCUBIC_MODE | |
  28506. * | 7 | EQUIRECTANGULAR_MODE | |
  28507. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28508. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28509. */
  28510. coordinatesMode: number;
  28511. /**
  28512. * | Value | Type | Description |
  28513. * | ----- | ------------------ | ----------- |
  28514. * | 0 | CLAMP_ADDRESSMODE | |
  28515. * | 1 | WRAP_ADDRESSMODE | |
  28516. * | 2 | MIRROR_ADDRESSMODE | |
  28517. */
  28518. wrapU: number;
  28519. /**
  28520. * | Value | Type | Description |
  28521. * | ----- | ------------------ | ----------- |
  28522. * | 0 | CLAMP_ADDRESSMODE | |
  28523. * | 1 | WRAP_ADDRESSMODE | |
  28524. * | 2 | MIRROR_ADDRESSMODE | |
  28525. */
  28526. wrapV: number;
  28527. /**
  28528. * | Value | Type | Description |
  28529. * | ----- | ------------------ | ----------- |
  28530. * | 0 | CLAMP_ADDRESSMODE | |
  28531. * | 1 | WRAP_ADDRESSMODE | |
  28532. * | 2 | MIRROR_ADDRESSMODE | |
  28533. */
  28534. wrapR: number;
  28535. /**
  28536. * With compliant hardware and browser (supporting anisotropic filtering)
  28537. * this defines the level of anisotropic filtering in the texture.
  28538. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28539. */
  28540. anisotropicFilteringLevel: number;
  28541. /**
  28542. * Define if the texture is a cube texture or if false a 2d texture.
  28543. */
  28544. isCube: boolean;
  28545. /**
  28546. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28547. */
  28548. is3D: boolean;
  28549. /**
  28550. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28551. * HDR texture are usually stored in linear space.
  28552. * This only impacts the PBR and Background materials
  28553. */
  28554. gammaSpace: boolean;
  28555. /**
  28556. * Gets or sets whether or not the texture contains RGBD data.
  28557. */
  28558. isRGBD: boolean;
  28559. /**
  28560. * Is Z inverted in the texture (useful in a cube texture).
  28561. */
  28562. invertZ: boolean;
  28563. /**
  28564. * Are mip maps generated for this texture or not.
  28565. */
  28566. readonly noMipmap: boolean;
  28567. /**
  28568. * @hidden
  28569. */
  28570. lodLevelInAlpha: boolean;
  28571. /**
  28572. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28573. */
  28574. lodGenerationOffset: number;
  28575. /**
  28576. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28577. */
  28578. lodGenerationScale: number;
  28579. /**
  28580. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28581. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28582. * average roughness values.
  28583. */
  28584. linearSpecularLOD: boolean;
  28585. /**
  28586. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28587. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28588. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28589. */
  28590. irradianceTexture: Nullable<BaseTexture>;
  28591. /**
  28592. * Define if the texture is a render target.
  28593. */
  28594. isRenderTarget: boolean;
  28595. /**
  28596. * Define the unique id of the texture in the scene.
  28597. */
  28598. readonly uid: string;
  28599. /**
  28600. * Return a string representation of the texture.
  28601. * @returns the texture as a string
  28602. */
  28603. toString(): string;
  28604. /**
  28605. * Get the class name of the texture.
  28606. * @returns "BaseTexture"
  28607. */
  28608. getClassName(): string;
  28609. /**
  28610. * Define the list of animation attached to the texture.
  28611. */
  28612. animations: import("babylonjs/Animations/animation").Animation[];
  28613. /**
  28614. * An event triggered when the texture is disposed.
  28615. */
  28616. onDisposeObservable: Observable<BaseTexture>;
  28617. private _onDisposeObserver;
  28618. /**
  28619. * Callback triggered when the texture has been disposed.
  28620. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28621. */
  28622. onDispose: () => void;
  28623. /**
  28624. * Define the current state of the loading sequence when in delayed load mode.
  28625. */
  28626. delayLoadState: number;
  28627. private _scene;
  28628. /** @hidden */
  28629. _texture: Nullable<InternalTexture>;
  28630. private _uid;
  28631. /**
  28632. * Define if the texture is preventinga material to render or not.
  28633. * If not and the texture is not ready, the engine will use a default black texture instead.
  28634. */
  28635. readonly isBlocking: boolean;
  28636. /**
  28637. * Instantiates a new BaseTexture.
  28638. * Base class of all the textures in babylon.
  28639. * It groups all the common properties the materials, post process, lights... might need
  28640. * in order to make a correct use of the texture.
  28641. * @param scene Define the scene the texture blongs to
  28642. */
  28643. constructor(scene: Nullable<Scene>);
  28644. /**
  28645. * Get the scene the texture belongs to.
  28646. * @returns the scene or null if undefined
  28647. */
  28648. getScene(): Nullable<Scene>;
  28649. /**
  28650. * Get the texture transform matrix used to offset tile the texture for istance.
  28651. * @returns the transformation matrix
  28652. */
  28653. getTextureMatrix(): Matrix;
  28654. /**
  28655. * Get the texture reflection matrix used to rotate/transform the reflection.
  28656. * @returns the reflection matrix
  28657. */
  28658. getReflectionTextureMatrix(): Matrix;
  28659. /**
  28660. * Get the underlying lower level texture from Babylon.
  28661. * @returns the insternal texture
  28662. */
  28663. getInternalTexture(): Nullable<InternalTexture>;
  28664. /**
  28665. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28666. * @returns true if ready or not blocking
  28667. */
  28668. isReadyOrNotBlocking(): boolean;
  28669. /**
  28670. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28671. * @returns true if fully ready
  28672. */
  28673. isReady(): boolean;
  28674. private _cachedSize;
  28675. /**
  28676. * Get the size of the texture.
  28677. * @returns the texture size.
  28678. */
  28679. getSize(): ISize;
  28680. /**
  28681. * Get the base size of the texture.
  28682. * It can be different from the size if the texture has been resized for POT for instance
  28683. * @returns the base size
  28684. */
  28685. getBaseSize(): ISize;
  28686. /**
  28687. * Update the sampling mode of the texture.
  28688. * Default is Trilinear mode.
  28689. *
  28690. * | Value | Type | Description |
  28691. * | ----- | ------------------ | ----------- |
  28692. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28693. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28694. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28695. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28696. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28697. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28698. * | 7 | NEAREST_LINEAR | |
  28699. * | 8 | NEAREST_NEAREST | |
  28700. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28701. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28702. * | 11 | LINEAR_LINEAR | |
  28703. * | 12 | LINEAR_NEAREST | |
  28704. *
  28705. * > _mag_: magnification filter (close to the viewer)
  28706. * > _min_: minification filter (far from the viewer)
  28707. * > _mip_: filter used between mip map levels
  28708. *@param samplingMode Define the new sampling mode of the texture
  28709. */
  28710. updateSamplingMode(samplingMode: number): void;
  28711. /**
  28712. * Scales the texture if is `canRescale()`
  28713. * @param ratio the resize factor we want to use to rescale
  28714. */
  28715. scale(ratio: number): void;
  28716. /**
  28717. * Get if the texture can rescale.
  28718. */
  28719. readonly canRescale: boolean;
  28720. /** @hidden */
  28721. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28722. /** @hidden */
  28723. _rebuild(): void;
  28724. /**
  28725. * Triggers the load sequence in delayed load mode.
  28726. */
  28727. delayLoad(): void;
  28728. /**
  28729. * Clones the texture.
  28730. * @returns the cloned texture
  28731. */
  28732. clone(): Nullable<BaseTexture>;
  28733. /**
  28734. * Get the texture underlying type (INT, FLOAT...)
  28735. */
  28736. readonly textureType: number;
  28737. /**
  28738. * Get the texture underlying format (RGB, RGBA...)
  28739. */
  28740. readonly textureFormat: number;
  28741. /**
  28742. * Indicates that textures need to be re-calculated for all materials
  28743. */
  28744. protected _markAllSubMeshesAsTexturesDirty(): void;
  28745. /**
  28746. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28747. * This will returns an RGBA array buffer containing either in values (0-255) or
  28748. * float values (0-1) depending of the underlying buffer type.
  28749. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28750. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28751. * @param buffer defines a user defined buffer to fill with data (can be null)
  28752. * @returns The Array buffer containing the pixels data.
  28753. */
  28754. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28755. /**
  28756. * Release and destroy the underlying lower level texture aka internalTexture.
  28757. */
  28758. releaseInternalTexture(): void;
  28759. /** @hidden */
  28760. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28761. /** @hidden */
  28762. readonly _lodTextureMid: Nullable<BaseTexture>;
  28763. /** @hidden */
  28764. readonly _lodTextureLow: Nullable<BaseTexture>;
  28765. /**
  28766. * Dispose the texture and release its associated resources.
  28767. */
  28768. dispose(): void;
  28769. /**
  28770. * Serialize the texture into a JSON representation that can be parsed later on.
  28771. * @returns the JSON representation of the texture
  28772. */
  28773. serialize(): any;
  28774. /**
  28775. * Helper function to be called back once a list of texture contains only ready textures.
  28776. * @param textures Define the list of textures to wait for
  28777. * @param callback Define the callback triggered once the entire list will be ready
  28778. */
  28779. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28780. }
  28781. }
  28782. declare module "babylonjs/Materials/effect" {
  28783. import { Observable } from "babylonjs/Misc/observable";
  28784. import { Nullable } from "babylonjs/types";
  28785. import { IDisposable } from "babylonjs/scene";
  28786. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28787. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28788. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28789. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28790. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28791. import { Engine } from "babylonjs/Engines/engine";
  28792. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28793. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28794. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28795. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28796. /**
  28797. * Options to be used when creating an effect.
  28798. */
  28799. export interface IEffectCreationOptions {
  28800. /**
  28801. * Atrributes that will be used in the shader.
  28802. */
  28803. attributes: string[];
  28804. /**
  28805. * Uniform varible names that will be set in the shader.
  28806. */
  28807. uniformsNames: string[];
  28808. /**
  28809. * Uniform buffer varible names that will be set in the shader.
  28810. */
  28811. uniformBuffersNames: string[];
  28812. /**
  28813. * Sampler texture variable names that will be set in the shader.
  28814. */
  28815. samplers: string[];
  28816. /**
  28817. * Define statements that will be set in the shader.
  28818. */
  28819. defines: any;
  28820. /**
  28821. * Possible fallbacks for this effect to improve performance when needed.
  28822. */
  28823. fallbacks: Nullable<IEffectFallbacks>;
  28824. /**
  28825. * Callback that will be called when the shader is compiled.
  28826. */
  28827. onCompiled: Nullable<(effect: Effect) => void>;
  28828. /**
  28829. * Callback that will be called if an error occurs during shader compilation.
  28830. */
  28831. onError: Nullable<(effect: Effect, errors: string) => void>;
  28832. /**
  28833. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28834. */
  28835. indexParameters?: any;
  28836. /**
  28837. * Max number of lights that can be used in the shader.
  28838. */
  28839. maxSimultaneousLights?: number;
  28840. /**
  28841. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28842. */
  28843. transformFeedbackVaryings?: Nullable<string[]>;
  28844. }
  28845. /**
  28846. * Effect containing vertex and fragment shader that can be executed on an object.
  28847. */
  28848. export class Effect implements IDisposable {
  28849. /**
  28850. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28851. */
  28852. static ShadersRepository: string;
  28853. /**
  28854. * Name of the effect.
  28855. */
  28856. name: any;
  28857. /**
  28858. * String container all the define statements that should be set on the shader.
  28859. */
  28860. defines: string;
  28861. /**
  28862. * Callback that will be called when the shader is compiled.
  28863. */
  28864. onCompiled: Nullable<(effect: Effect) => void>;
  28865. /**
  28866. * Callback that will be called if an error occurs during shader compilation.
  28867. */
  28868. onError: Nullable<(effect: Effect, errors: string) => void>;
  28869. /**
  28870. * Callback that will be called when effect is bound.
  28871. */
  28872. onBind: Nullable<(effect: Effect) => void>;
  28873. /**
  28874. * Unique ID of the effect.
  28875. */
  28876. uniqueId: number;
  28877. /**
  28878. * Observable that will be called when the shader is compiled.
  28879. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28880. */
  28881. onCompileObservable: Observable<Effect>;
  28882. /**
  28883. * Observable that will be called if an error occurs during shader compilation.
  28884. */
  28885. onErrorObservable: Observable<Effect>;
  28886. /** @hidden */
  28887. _onBindObservable: Nullable<Observable<Effect>>;
  28888. /**
  28889. * Observable that will be called when effect is bound.
  28890. */
  28891. readonly onBindObservable: Observable<Effect>;
  28892. /** @hidden */
  28893. _bonesComputationForcedToCPU: boolean;
  28894. private static _uniqueIdSeed;
  28895. private _engine;
  28896. private _uniformBuffersNames;
  28897. private _uniformsNames;
  28898. private _samplerList;
  28899. private _samplers;
  28900. private _isReady;
  28901. private _compilationError;
  28902. private _allFallbacksProcessed;
  28903. private _attributesNames;
  28904. private _attributes;
  28905. private _uniforms;
  28906. /**
  28907. * Key for the effect.
  28908. * @hidden
  28909. */
  28910. _key: string;
  28911. private _indexParameters;
  28912. private _fallbacks;
  28913. private _vertexSourceCode;
  28914. private _fragmentSourceCode;
  28915. private _vertexSourceCodeOverride;
  28916. private _fragmentSourceCodeOverride;
  28917. private _transformFeedbackVaryings;
  28918. /**
  28919. * Compiled shader to webGL program.
  28920. * @hidden
  28921. */
  28922. _pipelineContext: Nullable<IPipelineContext>;
  28923. private _valueCache;
  28924. private static _baseCache;
  28925. /**
  28926. * Instantiates an effect.
  28927. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28928. * @param baseName Name of the effect.
  28929. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28930. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28931. * @param samplers List of sampler variables that will be passed to the shader.
  28932. * @param engine Engine to be used to render the effect
  28933. * @param defines Define statements to be added to the shader.
  28934. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28935. * @param onCompiled Callback that will be called when the shader is compiled.
  28936. * @param onError Callback that will be called if an error occurs during shader compilation.
  28937. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28938. */
  28939. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28940. private _useFinalCode;
  28941. /**
  28942. * Unique key for this effect
  28943. */
  28944. readonly key: string;
  28945. /**
  28946. * If the effect has been compiled and prepared.
  28947. * @returns if the effect is compiled and prepared.
  28948. */
  28949. isReady(): boolean;
  28950. private _isReadyInternal;
  28951. /**
  28952. * The engine the effect was initialized with.
  28953. * @returns the engine.
  28954. */
  28955. getEngine(): Engine;
  28956. /**
  28957. * The pipeline context for this effect
  28958. * @returns the associated pipeline context
  28959. */
  28960. getPipelineContext(): Nullable<IPipelineContext>;
  28961. /**
  28962. * The set of names of attribute variables for the shader.
  28963. * @returns An array of attribute names.
  28964. */
  28965. getAttributesNames(): string[];
  28966. /**
  28967. * Returns the attribute at the given index.
  28968. * @param index The index of the attribute.
  28969. * @returns The location of the attribute.
  28970. */
  28971. getAttributeLocation(index: number): number;
  28972. /**
  28973. * Returns the attribute based on the name of the variable.
  28974. * @param name of the attribute to look up.
  28975. * @returns the attribute location.
  28976. */
  28977. getAttributeLocationByName(name: string): number;
  28978. /**
  28979. * The number of attributes.
  28980. * @returns the numnber of attributes.
  28981. */
  28982. getAttributesCount(): number;
  28983. /**
  28984. * Gets the index of a uniform variable.
  28985. * @param uniformName of the uniform to look up.
  28986. * @returns the index.
  28987. */
  28988. getUniformIndex(uniformName: string): number;
  28989. /**
  28990. * Returns the attribute based on the name of the variable.
  28991. * @param uniformName of the uniform to look up.
  28992. * @returns the location of the uniform.
  28993. */
  28994. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28995. /**
  28996. * Returns an array of sampler variable names
  28997. * @returns The array of sampler variable neames.
  28998. */
  28999. getSamplers(): string[];
  29000. /**
  29001. * The error from the last compilation.
  29002. * @returns the error string.
  29003. */
  29004. getCompilationError(): string;
  29005. /**
  29006. * Gets a boolean indicating that all fallbacks were used during compilation
  29007. * @returns true if all fallbacks were used
  29008. */
  29009. allFallbacksProcessed(): boolean;
  29010. /**
  29011. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29012. * @param func The callback to be used.
  29013. */
  29014. executeWhenCompiled(func: (effect: Effect) => void): void;
  29015. private _checkIsReady;
  29016. private _loadShader;
  29017. /**
  29018. * Recompiles the webGL program
  29019. * @param vertexSourceCode The source code for the vertex shader.
  29020. * @param fragmentSourceCode The source code for the fragment shader.
  29021. * @param onCompiled Callback called when completed.
  29022. * @param onError Callback called on error.
  29023. * @hidden
  29024. */
  29025. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29026. /**
  29027. * Prepares the effect
  29028. * @hidden
  29029. */
  29030. _prepareEffect(): void;
  29031. private _processCompilationErrors;
  29032. /**
  29033. * Checks if the effect is supported. (Must be called after compilation)
  29034. */
  29035. readonly isSupported: boolean;
  29036. /**
  29037. * Binds a texture to the engine to be used as output of the shader.
  29038. * @param channel Name of the output variable.
  29039. * @param texture Texture to bind.
  29040. * @hidden
  29041. */
  29042. _bindTexture(channel: string, texture: InternalTexture): void;
  29043. /**
  29044. * Sets a texture on the engine to be used in the shader.
  29045. * @param channel Name of the sampler variable.
  29046. * @param texture Texture to set.
  29047. */
  29048. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29049. /**
  29050. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29051. * @param channel Name of the sampler variable.
  29052. * @param texture Texture to set.
  29053. */
  29054. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29055. /**
  29056. * Sets an array of textures on the engine to be used in the shader.
  29057. * @param channel Name of the variable.
  29058. * @param textures Textures to set.
  29059. */
  29060. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29061. /**
  29062. * 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)
  29063. * @param channel Name of the sampler variable.
  29064. * @param postProcess Post process to get the input texture from.
  29065. */
  29066. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29067. /**
  29068. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29069. * 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)
  29070. * @param channel Name of the sampler variable.
  29071. * @param postProcess Post process to get the output texture from.
  29072. */
  29073. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29074. /** @hidden */
  29075. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29076. /** @hidden */
  29077. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29078. /** @hidden */
  29079. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29080. /** @hidden */
  29081. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29082. /**
  29083. * Binds a buffer to a uniform.
  29084. * @param buffer Buffer to bind.
  29085. * @param name Name of the uniform variable to bind to.
  29086. */
  29087. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29088. /**
  29089. * Binds block to a uniform.
  29090. * @param blockName Name of the block to bind.
  29091. * @param index Index to bind.
  29092. */
  29093. bindUniformBlock(blockName: string, index: number): void;
  29094. /**
  29095. * Sets an interger value on a uniform variable.
  29096. * @param uniformName Name of the variable.
  29097. * @param value Value to be set.
  29098. * @returns this effect.
  29099. */
  29100. setInt(uniformName: string, value: number): Effect;
  29101. /**
  29102. * Sets an int array on a uniform variable.
  29103. * @param uniformName Name of the variable.
  29104. * @param array array to be set.
  29105. * @returns this effect.
  29106. */
  29107. setIntArray(uniformName: string, array: Int32Array): Effect;
  29108. /**
  29109. * 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)
  29110. * @param uniformName Name of the variable.
  29111. * @param array array to be set.
  29112. * @returns this effect.
  29113. */
  29114. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29115. /**
  29116. * 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)
  29117. * @param uniformName Name of the variable.
  29118. * @param array array to be set.
  29119. * @returns this effect.
  29120. */
  29121. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29122. /**
  29123. * 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)
  29124. * @param uniformName Name of the variable.
  29125. * @param array array to be set.
  29126. * @returns this effect.
  29127. */
  29128. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29129. /**
  29130. * Sets an float array on a uniform variable.
  29131. * @param uniformName Name of the variable.
  29132. * @param array array to be set.
  29133. * @returns this effect.
  29134. */
  29135. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29136. /**
  29137. * 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)
  29138. * @param uniformName Name of the variable.
  29139. * @param array array to be set.
  29140. * @returns this effect.
  29141. */
  29142. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29143. /**
  29144. * 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)
  29145. * @param uniformName Name of the variable.
  29146. * @param array array to be set.
  29147. * @returns this effect.
  29148. */
  29149. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29150. /**
  29151. * 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)
  29152. * @param uniformName Name of the variable.
  29153. * @param array array to be set.
  29154. * @returns this effect.
  29155. */
  29156. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29157. /**
  29158. * Sets an array on a uniform variable.
  29159. * @param uniformName Name of the variable.
  29160. * @param array array to be set.
  29161. * @returns this effect.
  29162. */
  29163. setArray(uniformName: string, array: number[]): Effect;
  29164. /**
  29165. * 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)
  29166. * @param uniformName Name of the variable.
  29167. * @param array array to be set.
  29168. * @returns this effect.
  29169. */
  29170. setArray2(uniformName: string, array: number[]): Effect;
  29171. /**
  29172. * 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)
  29173. * @param uniformName Name of the variable.
  29174. * @param array array to be set.
  29175. * @returns this effect.
  29176. */
  29177. setArray3(uniformName: string, array: number[]): Effect;
  29178. /**
  29179. * 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)
  29180. * @param uniformName Name of the variable.
  29181. * @param array array to be set.
  29182. * @returns this effect.
  29183. */
  29184. setArray4(uniformName: string, array: number[]): Effect;
  29185. /**
  29186. * Sets matrices on a uniform variable.
  29187. * @param uniformName Name of the variable.
  29188. * @param matrices matrices to be set.
  29189. * @returns this effect.
  29190. */
  29191. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29192. /**
  29193. * Sets matrix on a uniform variable.
  29194. * @param uniformName Name of the variable.
  29195. * @param matrix matrix to be set.
  29196. * @returns this effect.
  29197. */
  29198. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29199. /**
  29200. * 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)
  29201. * @param uniformName Name of the variable.
  29202. * @param matrix matrix to be set.
  29203. * @returns this effect.
  29204. */
  29205. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29206. /**
  29207. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29208. * @param uniformName Name of the variable.
  29209. * @param matrix matrix to be set.
  29210. * @returns this effect.
  29211. */
  29212. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29213. /**
  29214. * Sets a float on a uniform variable.
  29215. * @param uniformName Name of the variable.
  29216. * @param value value to be set.
  29217. * @returns this effect.
  29218. */
  29219. setFloat(uniformName: string, value: number): Effect;
  29220. /**
  29221. * Sets a boolean on a uniform variable.
  29222. * @param uniformName Name of the variable.
  29223. * @param bool value to be set.
  29224. * @returns this effect.
  29225. */
  29226. setBool(uniformName: string, bool: boolean): Effect;
  29227. /**
  29228. * Sets a Vector2 on a uniform variable.
  29229. * @param uniformName Name of the variable.
  29230. * @param vector2 vector2 to be set.
  29231. * @returns this effect.
  29232. */
  29233. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29234. /**
  29235. * Sets a float2 on a uniform variable.
  29236. * @param uniformName Name of the variable.
  29237. * @param x First float in float2.
  29238. * @param y Second float in float2.
  29239. * @returns this effect.
  29240. */
  29241. setFloat2(uniformName: string, x: number, y: number): Effect;
  29242. /**
  29243. * Sets a Vector3 on a uniform variable.
  29244. * @param uniformName Name of the variable.
  29245. * @param vector3 Value to be set.
  29246. * @returns this effect.
  29247. */
  29248. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29249. /**
  29250. * Sets a float3 on a uniform variable.
  29251. * @param uniformName Name of the variable.
  29252. * @param x First float in float3.
  29253. * @param y Second float in float3.
  29254. * @param z Third float in float3.
  29255. * @returns this effect.
  29256. */
  29257. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29258. /**
  29259. * Sets a Vector4 on a uniform variable.
  29260. * @param uniformName Name of the variable.
  29261. * @param vector4 Value to be set.
  29262. * @returns this effect.
  29263. */
  29264. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29265. /**
  29266. * Sets a float4 on a uniform variable.
  29267. * @param uniformName Name of the variable.
  29268. * @param x First float in float4.
  29269. * @param y Second float in float4.
  29270. * @param z Third float in float4.
  29271. * @param w Fourth float in float4.
  29272. * @returns this effect.
  29273. */
  29274. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29275. /**
  29276. * Sets a Color3 on a uniform variable.
  29277. * @param uniformName Name of the variable.
  29278. * @param color3 Value to be set.
  29279. * @returns this effect.
  29280. */
  29281. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29282. /**
  29283. * Sets a Color4 on a uniform variable.
  29284. * @param uniformName Name of the variable.
  29285. * @param color3 Value to be set.
  29286. * @param alpha Alpha value to be set.
  29287. * @returns this effect.
  29288. */
  29289. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29290. /**
  29291. * Sets a Color4 on a uniform variable
  29292. * @param uniformName defines the name of the variable
  29293. * @param color4 defines the value to be set
  29294. * @returns this effect.
  29295. */
  29296. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29297. /** Release all associated resources */
  29298. dispose(): void;
  29299. /**
  29300. * This function will add a new shader to the shader store
  29301. * @param name the name of the shader
  29302. * @param pixelShader optional pixel shader content
  29303. * @param vertexShader optional vertex shader content
  29304. */
  29305. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29306. /**
  29307. * Store of each shader (The can be looked up using effect.key)
  29308. */
  29309. static ShadersStore: {
  29310. [key: string]: string;
  29311. };
  29312. /**
  29313. * Store of each included file for a shader (The can be looked up using effect.key)
  29314. */
  29315. static IncludesShadersStore: {
  29316. [key: string]: string;
  29317. };
  29318. /**
  29319. * Resets the cache of effects.
  29320. */
  29321. static ResetCache(): void;
  29322. }
  29323. }
  29324. declare module "babylonjs/Engines/engineCapabilities" {
  29325. import { Nullable } from "babylonjs/types";
  29326. /**
  29327. * Class used to describe the capabilities of the engine relatively to the current browser
  29328. */
  29329. export class EngineCapabilities {
  29330. /** Maximum textures units per fragment shader */
  29331. maxTexturesImageUnits: number;
  29332. /** Maximum texture units per vertex shader */
  29333. maxVertexTextureImageUnits: number;
  29334. /** Maximum textures units in the entire pipeline */
  29335. maxCombinedTexturesImageUnits: number;
  29336. /** Maximum texture size */
  29337. maxTextureSize: number;
  29338. /** Maximum cube texture size */
  29339. maxCubemapTextureSize: number;
  29340. /** Maximum render texture size */
  29341. maxRenderTextureSize: number;
  29342. /** Maximum number of vertex attributes */
  29343. maxVertexAttribs: number;
  29344. /** Maximum number of varyings */
  29345. maxVaryingVectors: number;
  29346. /** Maximum number of uniforms per vertex shader */
  29347. maxVertexUniformVectors: number;
  29348. /** Maximum number of uniforms per fragment shader */
  29349. maxFragmentUniformVectors: number;
  29350. /** Defines if standard derivates (dx/dy) are supported */
  29351. standardDerivatives: boolean;
  29352. /** Defines if s3tc texture compression is supported */
  29353. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29354. /** Defines if pvrtc texture compression is supported */
  29355. pvrtc: any;
  29356. /** Defines if etc1 texture compression is supported */
  29357. etc1: any;
  29358. /** Defines if etc2 texture compression is supported */
  29359. etc2: any;
  29360. /** Defines if astc texture compression is supported */
  29361. astc: any;
  29362. /** Defines if float textures are supported */
  29363. textureFloat: boolean;
  29364. /** Defines if vertex array objects are supported */
  29365. vertexArrayObject: boolean;
  29366. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29367. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29368. /** Gets the maximum level of anisotropy supported */
  29369. maxAnisotropy: number;
  29370. /** Defines if instancing is supported */
  29371. instancedArrays: boolean;
  29372. /** Defines if 32 bits indices are supported */
  29373. uintIndices: boolean;
  29374. /** Defines if high precision shaders are supported */
  29375. highPrecisionShaderSupported: boolean;
  29376. /** Defines if depth reading in the fragment shader is supported */
  29377. fragmentDepthSupported: boolean;
  29378. /** Defines if float texture linear filtering is supported*/
  29379. textureFloatLinearFiltering: boolean;
  29380. /** Defines if rendering to float textures is supported */
  29381. textureFloatRender: boolean;
  29382. /** Defines if half float textures are supported*/
  29383. textureHalfFloat: boolean;
  29384. /** Defines if half float texture linear filtering is supported*/
  29385. textureHalfFloatLinearFiltering: boolean;
  29386. /** Defines if rendering to half float textures is supported */
  29387. textureHalfFloatRender: boolean;
  29388. /** Defines if textureLOD shader command is supported */
  29389. textureLOD: boolean;
  29390. /** Defines if draw buffers extension is supported */
  29391. drawBuffersExtension: boolean;
  29392. /** Defines if depth textures are supported */
  29393. depthTextureExtension: boolean;
  29394. /** Defines if float color buffer are supported */
  29395. colorBufferFloat: boolean;
  29396. /** Gets disjoint timer query extension (null if not supported) */
  29397. timerQuery: EXT_disjoint_timer_query;
  29398. /** Defines if timestamp can be used with timer query */
  29399. canUseTimestampForTimerQuery: boolean;
  29400. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29401. multiview: any;
  29402. /** Function used to let the system compiles shaders in background */
  29403. parallelShaderCompile: {
  29404. COMPLETION_STATUS_KHR: number;
  29405. };
  29406. /** Max number of texture samples for MSAA */
  29407. maxMSAASamples: number;
  29408. /** Defines if the blend min max extension is supported */
  29409. blendMinMax: boolean;
  29410. }
  29411. }
  29412. declare module "babylonjs/States/depthCullingState" {
  29413. import { Nullable } from "babylonjs/types";
  29414. /**
  29415. * @hidden
  29416. **/
  29417. export class DepthCullingState {
  29418. private _isDepthTestDirty;
  29419. private _isDepthMaskDirty;
  29420. private _isDepthFuncDirty;
  29421. private _isCullFaceDirty;
  29422. private _isCullDirty;
  29423. private _isZOffsetDirty;
  29424. private _isFrontFaceDirty;
  29425. private _depthTest;
  29426. private _depthMask;
  29427. private _depthFunc;
  29428. private _cull;
  29429. private _cullFace;
  29430. private _zOffset;
  29431. private _frontFace;
  29432. /**
  29433. * Initializes the state.
  29434. */
  29435. constructor();
  29436. readonly isDirty: boolean;
  29437. zOffset: number;
  29438. cullFace: Nullable<number>;
  29439. cull: Nullable<boolean>;
  29440. depthFunc: Nullable<number>;
  29441. depthMask: boolean;
  29442. depthTest: boolean;
  29443. frontFace: Nullable<number>;
  29444. reset(): void;
  29445. apply(gl: WebGLRenderingContext): void;
  29446. }
  29447. }
  29448. declare module "babylonjs/States/stencilState" {
  29449. /**
  29450. * @hidden
  29451. **/
  29452. export class StencilState {
  29453. /** 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 */
  29454. static readonly ALWAYS: number;
  29455. /** Passed to stencilOperation to specify that stencil value must be kept */
  29456. static readonly KEEP: number;
  29457. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29458. static readonly REPLACE: number;
  29459. private _isStencilTestDirty;
  29460. private _isStencilMaskDirty;
  29461. private _isStencilFuncDirty;
  29462. private _isStencilOpDirty;
  29463. private _stencilTest;
  29464. private _stencilMask;
  29465. private _stencilFunc;
  29466. private _stencilFuncRef;
  29467. private _stencilFuncMask;
  29468. private _stencilOpStencilFail;
  29469. private _stencilOpDepthFail;
  29470. private _stencilOpStencilDepthPass;
  29471. readonly isDirty: boolean;
  29472. stencilFunc: number;
  29473. stencilFuncRef: number;
  29474. stencilFuncMask: number;
  29475. stencilOpStencilFail: number;
  29476. stencilOpDepthFail: number;
  29477. stencilOpStencilDepthPass: number;
  29478. stencilMask: number;
  29479. stencilTest: boolean;
  29480. constructor();
  29481. reset(): void;
  29482. apply(gl: WebGLRenderingContext): void;
  29483. }
  29484. }
  29485. declare module "babylonjs/States/alphaCullingState" {
  29486. /**
  29487. * @hidden
  29488. **/
  29489. export class AlphaState {
  29490. private _isAlphaBlendDirty;
  29491. private _isBlendFunctionParametersDirty;
  29492. private _isBlendEquationParametersDirty;
  29493. private _isBlendConstantsDirty;
  29494. private _alphaBlend;
  29495. private _blendFunctionParameters;
  29496. private _blendEquationParameters;
  29497. private _blendConstants;
  29498. /**
  29499. * Initializes the state.
  29500. */
  29501. constructor();
  29502. readonly isDirty: boolean;
  29503. alphaBlend: boolean;
  29504. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29505. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29506. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29507. reset(): void;
  29508. apply(gl: WebGLRenderingContext): void;
  29509. }
  29510. }
  29511. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29512. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29513. /** @hidden */
  29514. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29515. attributeProcessor(attribute: string): string;
  29516. varyingProcessor(varying: string, isFragment: boolean): string;
  29517. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29518. }
  29519. }
  29520. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29521. /**
  29522. * Interface for attribute information associated with buffer instanciation
  29523. */
  29524. export class InstancingAttributeInfo {
  29525. /**
  29526. * Index/offset of the attribute in the vertex shader
  29527. */
  29528. index: number;
  29529. /**
  29530. * size of the attribute, 1, 2, 3 or 4
  29531. */
  29532. attributeSize: number;
  29533. /**
  29534. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29535. * default is FLOAT
  29536. */
  29537. attribyteType: number;
  29538. /**
  29539. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29540. */
  29541. normalized: boolean;
  29542. /**
  29543. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29544. */
  29545. offset: number;
  29546. /**
  29547. * Name of the GLSL attribute, for debugging purpose only
  29548. */
  29549. attributeName: string;
  29550. }
  29551. }
  29552. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29553. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29554. import { Nullable } from "babylonjs/types";
  29555. module "babylonjs/Engines/thinEngine" {
  29556. interface ThinEngine {
  29557. /**
  29558. * Update a video texture
  29559. * @param texture defines the texture to update
  29560. * @param video defines the video element to use
  29561. * @param invertY defines if data must be stored with Y axis inverted
  29562. */
  29563. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29564. }
  29565. }
  29566. }
  29567. declare module "babylonjs/Materials/Textures/videoTexture" {
  29568. import { Observable } from "babylonjs/Misc/observable";
  29569. import { Nullable } from "babylonjs/types";
  29570. import { Scene } from "babylonjs/scene";
  29571. import { Texture } from "babylonjs/Materials/Textures/texture";
  29572. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29573. /**
  29574. * Settings for finer control over video usage
  29575. */
  29576. export interface VideoTextureSettings {
  29577. /**
  29578. * Applies `autoplay` to video, if specified
  29579. */
  29580. autoPlay?: boolean;
  29581. /**
  29582. * Applies `loop` to video, if specified
  29583. */
  29584. loop?: boolean;
  29585. /**
  29586. * Automatically updates internal texture from video at every frame in the render loop
  29587. */
  29588. autoUpdateTexture: boolean;
  29589. /**
  29590. * Image src displayed during the video loading or until the user interacts with the video.
  29591. */
  29592. poster?: string;
  29593. }
  29594. /**
  29595. * If you want to display a video in your scene, this is the special texture for that.
  29596. * This special texture works similar to other textures, with the exception of a few parameters.
  29597. * @see https://doc.babylonjs.com/how_to/video_texture
  29598. */
  29599. export class VideoTexture extends Texture {
  29600. /**
  29601. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29602. */
  29603. readonly autoUpdateTexture: boolean;
  29604. /**
  29605. * The video instance used by the texture internally
  29606. */
  29607. readonly video: HTMLVideoElement;
  29608. private _onUserActionRequestedObservable;
  29609. /**
  29610. * Event triggerd when a dom action is required by the user to play the video.
  29611. * This happens due to recent changes in browser policies preventing video to auto start.
  29612. */
  29613. readonly onUserActionRequestedObservable: Observable<Texture>;
  29614. private _generateMipMaps;
  29615. private _engine;
  29616. private _stillImageCaptured;
  29617. private _displayingPosterTexture;
  29618. private _settings;
  29619. private _createInternalTextureOnEvent;
  29620. private _frameId;
  29621. /**
  29622. * Creates a video texture.
  29623. * If you want to display a video in your scene, this is the special texture for that.
  29624. * This special texture works similar to other textures, with the exception of a few parameters.
  29625. * @see https://doc.babylonjs.com/how_to/video_texture
  29626. * @param name optional name, will detect from video source, if not defined
  29627. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29628. * @param scene is obviously the current scene.
  29629. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29630. * @param invertY is false by default but can be used to invert video on Y axis
  29631. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29632. * @param settings allows finer control over video usage
  29633. */
  29634. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29635. private _getName;
  29636. private _getVideo;
  29637. private _createInternalTexture;
  29638. private reset;
  29639. /**
  29640. * @hidden Internal method to initiate `update`.
  29641. */
  29642. _rebuild(): void;
  29643. /**
  29644. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29645. */
  29646. update(): void;
  29647. /**
  29648. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29649. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29650. */
  29651. updateTexture(isVisible: boolean): void;
  29652. protected _updateInternalTexture: () => void;
  29653. /**
  29654. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29655. * @param url New url.
  29656. */
  29657. updateURL(url: string): void;
  29658. /**
  29659. * Dispose the texture and release its associated resources.
  29660. */
  29661. dispose(): void;
  29662. /**
  29663. * Creates a video texture straight from a stream.
  29664. * @param scene Define the scene the texture should be created in
  29665. * @param stream Define the stream the texture should be created from
  29666. * @returns The created video texture as a promise
  29667. */
  29668. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29669. /**
  29670. * Creates a video texture straight from your WebCam video feed.
  29671. * @param scene Define the scene the texture should be created in
  29672. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29673. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29674. * @returns The created video texture as a promise
  29675. */
  29676. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29677. minWidth: number;
  29678. maxWidth: number;
  29679. minHeight: number;
  29680. maxHeight: number;
  29681. deviceId: string;
  29682. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29683. /**
  29684. * Creates a video texture straight from your WebCam video feed.
  29685. * @param scene Define the scene the texture should be created in
  29686. * @param onReady Define a callback to triggered once the texture will be ready
  29687. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29688. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29689. */
  29690. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29691. minWidth: number;
  29692. maxWidth: number;
  29693. minHeight: number;
  29694. maxHeight: number;
  29695. deviceId: string;
  29696. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29697. }
  29698. }
  29699. declare module "babylonjs/Engines/thinEngine" {
  29700. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29701. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29702. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29703. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29704. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29705. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29706. import { Observable } from "babylonjs/Misc/observable";
  29707. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29708. import { StencilState } from "babylonjs/States/stencilState";
  29709. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29710. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29711. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29712. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29713. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29714. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29715. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29716. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29717. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29718. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29720. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29721. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29722. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29723. /**
  29724. * Defines the interface used by objects working like Scene
  29725. * @hidden
  29726. */
  29727. interface ISceneLike {
  29728. _addPendingData(data: any): void;
  29729. _removePendingData(data: any): void;
  29730. offlineProvider: IOfflineProvider;
  29731. }
  29732. /** Interface defining initialization parameters for Engine class */
  29733. export interface EngineOptions extends WebGLContextAttributes {
  29734. /**
  29735. * Defines if the engine should no exceed a specified device ratio
  29736. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29737. */
  29738. limitDeviceRatio?: number;
  29739. /**
  29740. * Defines if webvr should be enabled automatically
  29741. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29742. */
  29743. autoEnableWebVR?: boolean;
  29744. /**
  29745. * Defines if webgl2 should be turned off even if supported
  29746. * @see http://doc.babylonjs.com/features/webgl2
  29747. */
  29748. disableWebGL2Support?: boolean;
  29749. /**
  29750. * Defines if webaudio should be initialized as well
  29751. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29752. */
  29753. audioEngine?: boolean;
  29754. /**
  29755. * Defines if animations should run using a deterministic lock step
  29756. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29757. */
  29758. deterministicLockstep?: boolean;
  29759. /** Defines the maximum steps to use with deterministic lock step mode */
  29760. lockstepMaxSteps?: number;
  29761. /**
  29762. * Defines that engine should ignore context lost events
  29763. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29764. */
  29765. doNotHandleContextLost?: boolean;
  29766. /**
  29767. * Defines that engine should ignore modifying touch action attribute and style
  29768. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29769. */
  29770. doNotHandleTouchAction?: boolean;
  29771. /**
  29772. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29773. */
  29774. useHighPrecisionFloats?: boolean;
  29775. }
  29776. /**
  29777. * The base engine class (root of all engines)
  29778. */
  29779. export class ThinEngine {
  29780. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29781. static ExceptionList: ({
  29782. key: string;
  29783. capture: string;
  29784. captureConstraint: number;
  29785. targets: string[];
  29786. } | {
  29787. key: string;
  29788. capture: null;
  29789. captureConstraint: null;
  29790. targets: string[];
  29791. })[];
  29792. /** @hidden */
  29793. static _TextureLoaders: IInternalTextureLoader[];
  29794. /**
  29795. * Returns the current npm package of the sdk
  29796. */
  29797. static readonly NpmPackage: string;
  29798. /**
  29799. * Returns the current version of the framework
  29800. */
  29801. static readonly Version: string;
  29802. /**
  29803. * Returns a string describing the current engine
  29804. */
  29805. readonly description: string;
  29806. /**
  29807. * Gets or sets the epsilon value used by collision engine
  29808. */
  29809. static CollisionsEpsilon: number;
  29810. /**
  29811. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29812. */
  29813. static ShadersRepository: string;
  29814. /** @hidden */
  29815. _shaderProcessor: IShaderProcessor;
  29816. /**
  29817. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29818. */
  29819. forcePOTTextures: boolean;
  29820. /**
  29821. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29822. */
  29823. isFullscreen: boolean;
  29824. /**
  29825. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29826. */
  29827. cullBackFaces: boolean;
  29828. /**
  29829. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29830. */
  29831. renderEvenInBackground: boolean;
  29832. /**
  29833. * Gets or sets a boolean indicating that cache can be kept between frames
  29834. */
  29835. preventCacheWipeBetweenFrames: boolean;
  29836. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29837. validateShaderPrograms: boolean;
  29838. /**
  29839. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29840. */
  29841. disableUniformBuffers: boolean;
  29842. /** @hidden */
  29843. _uniformBuffers: UniformBuffer[];
  29844. /**
  29845. * Gets a boolean indicating that the engine supports uniform buffers
  29846. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29847. */
  29848. readonly supportsUniformBuffers: boolean;
  29849. /** @hidden */
  29850. _gl: WebGLRenderingContext;
  29851. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29852. protected _windowIsBackground: boolean;
  29853. protected _webGLVersion: number;
  29854. protected _highPrecisionShadersAllowed: boolean;
  29855. /** @hidden */
  29856. readonly _shouldUseHighPrecisionShader: boolean;
  29857. /**
  29858. * Gets a boolean indicating that only power of 2 textures are supported
  29859. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29860. */
  29861. readonly needPOTTextures: boolean;
  29862. /** @hidden */
  29863. _badOS: boolean;
  29864. /** @hidden */
  29865. _badDesktopOS: boolean;
  29866. private _hardwareScalingLevel;
  29867. /** @hidden */
  29868. _caps: EngineCapabilities;
  29869. private _isStencilEnable;
  29870. protected _colorWrite: boolean;
  29871. private _glVersion;
  29872. private _glRenderer;
  29873. private _glVendor;
  29874. /** @hidden */
  29875. _videoTextureSupported: boolean;
  29876. protected _renderingQueueLaunched: boolean;
  29877. protected _activeRenderLoops: (() => void)[];
  29878. /**
  29879. * Observable signaled when a context lost event is raised
  29880. */
  29881. onContextLostObservable: Observable<ThinEngine>;
  29882. /**
  29883. * Observable signaled when a context restored event is raised
  29884. */
  29885. onContextRestoredObservable: Observable<ThinEngine>;
  29886. private _onContextLost;
  29887. private _onContextRestored;
  29888. protected _contextWasLost: boolean;
  29889. /** @hidden */
  29890. _doNotHandleContextLost: boolean;
  29891. /**
  29892. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29894. */
  29895. doNotHandleContextLost: boolean;
  29896. /**
  29897. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29898. */
  29899. disableVertexArrayObjects: boolean;
  29900. /** @hidden */
  29901. protected _depthCullingState: DepthCullingState;
  29902. /** @hidden */
  29903. protected _stencilState: StencilState;
  29904. /** @hidden */
  29905. protected _alphaState: AlphaState;
  29906. /** @hidden */
  29907. _internalTexturesCache: InternalTexture[];
  29908. /** @hidden */
  29909. protected _activeChannel: number;
  29910. private _currentTextureChannel;
  29911. /** @hidden */
  29912. protected _boundTexturesCache: {
  29913. [key: string]: Nullable<InternalTexture>;
  29914. };
  29915. /** @hidden */
  29916. protected _currentEffect: Nullable<Effect>;
  29917. /** @hidden */
  29918. protected _currentProgram: Nullable<WebGLProgram>;
  29919. private _compiledEffects;
  29920. private _vertexAttribArraysEnabled;
  29921. /** @hidden */
  29922. protected _cachedViewport: Nullable<IViewportLike>;
  29923. private _cachedVertexArrayObject;
  29924. /** @hidden */
  29925. protected _cachedVertexBuffers: any;
  29926. /** @hidden */
  29927. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29928. /** @hidden */
  29929. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29930. /** @hidden */
  29931. _currentRenderTarget: Nullable<InternalTexture>;
  29932. private _uintIndicesCurrentlySet;
  29933. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29934. /** @hidden */
  29935. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29936. private _currentBufferPointers;
  29937. private _currentInstanceLocations;
  29938. private _currentInstanceBuffers;
  29939. private _textureUnits;
  29940. /** @hidden */
  29941. _workingCanvas: Nullable<HTMLCanvasElement>;
  29942. /** @hidden */
  29943. _workingContext: Nullable<CanvasRenderingContext2D>;
  29944. /** @hidden */
  29945. _bindedRenderFunction: any;
  29946. private _vaoRecordInProgress;
  29947. private _mustWipeVertexAttributes;
  29948. private _emptyTexture;
  29949. private _emptyCubeTexture;
  29950. private _emptyTexture3D;
  29951. /** @hidden */
  29952. _frameHandler: number;
  29953. private _nextFreeTextureSlots;
  29954. private _maxSimultaneousTextures;
  29955. private _activeRequests;
  29956. protected _texturesSupported: string[];
  29957. /** @hidden */
  29958. _textureFormatInUse: Nullable<string>;
  29959. protected readonly _supportsHardwareTextureRescaling: boolean;
  29960. /**
  29961. * Gets the list of texture formats supported
  29962. */
  29963. readonly texturesSupported: Array<string>;
  29964. /**
  29965. * Gets the list of texture formats in use
  29966. */
  29967. readonly textureFormatInUse: Nullable<string>;
  29968. /**
  29969. * Gets the current viewport
  29970. */
  29971. readonly currentViewport: Nullable<IViewportLike>;
  29972. /**
  29973. * Gets the default empty texture
  29974. */
  29975. readonly emptyTexture: InternalTexture;
  29976. /**
  29977. * Gets the default empty 3D texture
  29978. */
  29979. readonly emptyTexture3D: InternalTexture;
  29980. /**
  29981. * Gets the default empty cube texture
  29982. */
  29983. readonly emptyCubeTexture: InternalTexture;
  29984. /**
  29985. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29986. */
  29987. readonly premultipliedAlpha: boolean;
  29988. /**
  29989. * Observable event triggered before each texture is initialized
  29990. */
  29991. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  29992. /**
  29993. * Creates a new engine
  29994. * @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
  29995. * @param antialias defines enable antialiasing (default: false)
  29996. * @param options defines further options to be sent to the getContext() function
  29997. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29998. */
  29999. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30000. private _rebuildInternalTextures;
  30001. private _rebuildEffects;
  30002. /**
  30003. * Gets a boolean indicating if all created effects are ready
  30004. * @returns true if all effects are ready
  30005. */
  30006. areAllEffectsReady(): boolean;
  30007. protected _rebuildBuffers(): void;
  30008. private _initGLContext;
  30009. /**
  30010. * Gets version of the current webGL context
  30011. */
  30012. readonly webGLVersion: number;
  30013. /**
  30014. * Gets a string idenfifying the name of the class
  30015. * @returns "Engine" string
  30016. */
  30017. getClassName(): string;
  30018. /**
  30019. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30020. */
  30021. readonly isStencilEnable: boolean;
  30022. /** @hidden */
  30023. _prepareWorkingCanvas(): void;
  30024. /**
  30025. * Reset the texture cache to empty state
  30026. */
  30027. resetTextureCache(): void;
  30028. /**
  30029. * Gets an object containing information about the current webGL context
  30030. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30031. */
  30032. getGlInfo(): {
  30033. vendor: string;
  30034. renderer: string;
  30035. version: string;
  30036. };
  30037. /**
  30038. * Defines the hardware scaling level.
  30039. * By default the hardware scaling level is computed from the window device ratio.
  30040. * 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.
  30041. * @param level defines the level to use
  30042. */
  30043. setHardwareScalingLevel(level: number): void;
  30044. /**
  30045. * Gets the current hardware scaling level.
  30046. * By default the hardware scaling level is computed from the window device ratio.
  30047. * 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.
  30048. * @returns a number indicating the current hardware scaling level
  30049. */
  30050. getHardwareScalingLevel(): number;
  30051. /**
  30052. * Gets the list of loaded textures
  30053. * @returns an array containing all loaded textures
  30054. */
  30055. getLoadedTexturesCache(): InternalTexture[];
  30056. /**
  30057. * Gets the object containing all engine capabilities
  30058. * @returns the EngineCapabilities object
  30059. */
  30060. getCaps(): EngineCapabilities;
  30061. /**
  30062. * stop executing a render loop function and remove it from the execution array
  30063. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30064. */
  30065. stopRenderLoop(renderFunction?: () => void): void;
  30066. /** @hidden */
  30067. _renderLoop(): void;
  30068. /**
  30069. * Gets the HTML canvas attached with the current webGL context
  30070. * @returns a HTML canvas
  30071. */
  30072. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30073. /**
  30074. * Gets host window
  30075. * @returns the host window object
  30076. */
  30077. getHostWindow(): Window;
  30078. /**
  30079. * Gets the current render width
  30080. * @param useScreen defines if screen size must be used (or the current render target if any)
  30081. * @returns a number defining the current render width
  30082. */
  30083. getRenderWidth(useScreen?: boolean): number;
  30084. /**
  30085. * Gets the current render height
  30086. * @param useScreen defines if screen size must be used (or the current render target if any)
  30087. * @returns a number defining the current render height
  30088. */
  30089. getRenderHeight(useScreen?: boolean): number;
  30090. /**
  30091. * Can be used to override the current requestAnimationFrame requester.
  30092. * @hidden
  30093. */
  30094. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30095. /**
  30096. * Register and execute a render loop. The engine can have more than one render function
  30097. * @param renderFunction defines the function to continuously execute
  30098. */
  30099. runRenderLoop(renderFunction: () => void): void;
  30100. /**
  30101. * Clear the current render buffer or the current render target (if any is set up)
  30102. * @param color defines the color to use
  30103. * @param backBuffer defines if the back buffer must be cleared
  30104. * @param depth defines if the depth buffer must be cleared
  30105. * @param stencil defines if the stencil buffer must be cleared
  30106. */
  30107. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30108. private _viewportCached;
  30109. /** @hidden */
  30110. _viewport(x: number, y: number, width: number, height: number): void;
  30111. /**
  30112. * Set the WebGL's viewport
  30113. * @param viewport defines the viewport element to be used
  30114. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30115. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30116. */
  30117. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30118. /**
  30119. * Begin a new frame
  30120. */
  30121. beginFrame(): void;
  30122. /**
  30123. * Enf the current frame
  30124. */
  30125. endFrame(): void;
  30126. /**
  30127. * Resize the view according to the canvas' size
  30128. */
  30129. resize(): void;
  30130. /**
  30131. * Force a specific size of the canvas
  30132. * @param width defines the new canvas' width
  30133. * @param height defines the new canvas' height
  30134. */
  30135. setSize(width: number, height: number): void;
  30136. /**
  30137. * Binds the frame buffer to the specified texture.
  30138. * @param texture The texture to render to or null for the default canvas
  30139. * @param faceIndex The face of the texture to render to in case of cube texture
  30140. * @param requiredWidth The width of the target to render to
  30141. * @param requiredHeight The height of the target to render to
  30142. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30143. * @param depthStencilTexture The depth stencil texture to use to render
  30144. * @param lodLevel defines le lod level to bind to the frame buffer
  30145. */
  30146. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30147. /** @hidden */
  30148. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30149. /**
  30150. * Unbind the current render target texture from the webGL context
  30151. * @param texture defines the render target texture to unbind
  30152. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30153. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30154. */
  30155. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30156. /**
  30157. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30158. */
  30159. flushFramebuffer(): void;
  30160. /**
  30161. * Unbind the current render target and bind the default framebuffer
  30162. */
  30163. restoreDefaultFramebuffer(): void;
  30164. private _resetVertexBufferBinding;
  30165. /**
  30166. * Creates a vertex buffer
  30167. * @param data the data for the vertex buffer
  30168. * @returns the new WebGL static buffer
  30169. */
  30170. createVertexBuffer(data: DataArray): DataBuffer;
  30171. private _createVertexBuffer;
  30172. /**
  30173. * Creates a dynamic vertex buffer
  30174. * @param data the data for the dynamic vertex buffer
  30175. * @returns the new WebGL dynamic buffer
  30176. */
  30177. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30178. /**
  30179. * Updates a dynamic vertex buffer.
  30180. * @param vertexBuffer the vertex buffer to update
  30181. * @param data the data used to update the vertex buffer
  30182. * @param byteOffset the byte offset of the data
  30183. * @param byteLength the byte length of the data
  30184. */
  30185. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30186. protected _resetIndexBufferBinding(): void;
  30187. /**
  30188. * Creates a new index buffer
  30189. * @param indices defines the content of the index buffer
  30190. * @param updatable defines if the index buffer must be updatable
  30191. * @returns a new webGL buffer
  30192. */
  30193. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30194. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30195. /**
  30196. * Bind a webGL buffer to the webGL context
  30197. * @param buffer defines the buffer to bind
  30198. */
  30199. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30200. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30201. private bindBuffer;
  30202. /**
  30203. * update the bound buffer with the given data
  30204. * @param data defines the data to update
  30205. */
  30206. updateArrayBuffer(data: Float32Array): void;
  30207. private _vertexAttribPointer;
  30208. private _bindIndexBufferWithCache;
  30209. private _bindVertexBuffersAttributes;
  30210. /**
  30211. * Records a vertex array object
  30212. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30213. * @param vertexBuffers defines the list of vertex buffers to store
  30214. * @param indexBuffer defines the index buffer to store
  30215. * @param effect defines the effect to store
  30216. * @returns the new vertex array object
  30217. */
  30218. recordVertexArrayObject(vertexBuffers: {
  30219. [key: string]: VertexBuffer;
  30220. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30221. /**
  30222. * Bind a specific vertex array object
  30223. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30224. * @param vertexArrayObject defines the vertex array object to bind
  30225. * @param indexBuffer defines the index buffer to bind
  30226. */
  30227. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30228. /**
  30229. * Bind webGl buffers directly to the webGL context
  30230. * @param vertexBuffer defines the vertex buffer to bind
  30231. * @param indexBuffer defines the index buffer to bind
  30232. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30233. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30234. * @param effect defines the effect associated with the vertex buffer
  30235. */
  30236. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30237. private _unbindVertexArrayObject;
  30238. /**
  30239. * Bind a list of vertex buffers to the webGL context
  30240. * @param vertexBuffers defines the list of vertex buffers to bind
  30241. * @param indexBuffer defines the index buffer to bind
  30242. * @param effect defines the effect associated with the vertex buffers
  30243. */
  30244. bindBuffers(vertexBuffers: {
  30245. [key: string]: Nullable<VertexBuffer>;
  30246. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30247. /**
  30248. * Unbind all instance attributes
  30249. */
  30250. unbindInstanceAttributes(): void;
  30251. /**
  30252. * Release and free the memory of a vertex array object
  30253. * @param vao defines the vertex array object to delete
  30254. */
  30255. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30256. /** @hidden */
  30257. _releaseBuffer(buffer: DataBuffer): boolean;
  30258. protected _deleteBuffer(buffer: DataBuffer): void;
  30259. /**
  30260. * Creates a webGL buffer to use with instanciation
  30261. * @param capacity defines the size of the buffer
  30262. * @returns the webGL buffer
  30263. */
  30264. createInstancesBuffer(capacity: number): DataBuffer;
  30265. /**
  30266. * Delete a webGL buffer used with instanciation
  30267. * @param buffer defines the webGL buffer to delete
  30268. */
  30269. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30270. /**
  30271. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30272. * @param instancesBuffer defines the webGL buffer to update and bind
  30273. * @param data defines the data to store in the buffer
  30274. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30275. */
  30276. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30277. /**
  30278. * Apply all cached states (depth, culling, stencil and alpha)
  30279. */
  30280. applyStates(): void;
  30281. /**
  30282. * Send a draw order
  30283. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30284. * @param indexStart defines the starting index
  30285. * @param indexCount defines the number of index to draw
  30286. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30287. */
  30288. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30289. /**
  30290. * Draw a list of points
  30291. * @param verticesStart defines the index of first vertex to draw
  30292. * @param verticesCount defines the count of vertices to draw
  30293. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30294. */
  30295. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30296. /**
  30297. * Draw a list of unindexed primitives
  30298. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30299. * @param verticesStart defines the index of first vertex to draw
  30300. * @param verticesCount defines the count of vertices to draw
  30301. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30302. */
  30303. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30304. /**
  30305. * Draw a list of indexed primitives
  30306. * @param fillMode defines the primitive to use
  30307. * @param indexStart defines the starting index
  30308. * @param indexCount defines the number of index to draw
  30309. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30310. */
  30311. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30312. /**
  30313. * Draw a list of unindexed primitives
  30314. * @param fillMode defines the primitive to use
  30315. * @param verticesStart defines the index of first vertex to draw
  30316. * @param verticesCount defines the count of vertices to draw
  30317. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30318. */
  30319. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30320. private _drawMode;
  30321. /** @hidden */
  30322. protected _reportDrawCall(): void;
  30323. /** @hidden */
  30324. _releaseEffect(effect: Effect): void;
  30325. /** @hidden */
  30326. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30327. /**
  30328. * Create a new effect (used to store vertex/fragment shaders)
  30329. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30330. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30331. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30332. * @param samplers defines an array of string used to represent textures
  30333. * @param defines defines the string containing the defines to use to compile the shaders
  30334. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30335. * @param onCompiled defines a function to call when the effect creation is successful
  30336. * @param onError defines a function to call when the effect creation has failed
  30337. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30338. * @returns the new Effect
  30339. */
  30340. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30341. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30342. private _compileShader;
  30343. private _compileRawShader;
  30344. /**
  30345. * Directly creates a webGL program
  30346. * @param pipelineContext defines the pipeline context to attach to
  30347. * @param vertexCode defines the vertex shader code to use
  30348. * @param fragmentCode defines the fragment shader code to use
  30349. * @param context defines the webGL context to use (if not set, the current one will be used)
  30350. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30351. * @returns the new webGL program
  30352. */
  30353. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30354. /**
  30355. * Creates a webGL program
  30356. * @param pipelineContext defines the pipeline context to attach to
  30357. * @param vertexCode defines the vertex shader code to use
  30358. * @param fragmentCode defines the fragment shader code to use
  30359. * @param defines defines the string containing the defines to use to compile the shaders
  30360. * @param context defines the webGL context to use (if not set, the current one will be used)
  30361. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30362. * @returns the new webGL program
  30363. */
  30364. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30365. /**
  30366. * Creates a new pipeline context
  30367. * @returns the new pipeline
  30368. */
  30369. createPipelineContext(): IPipelineContext;
  30370. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30371. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30372. /** @hidden */
  30373. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30374. /** @hidden */
  30375. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30376. /** @hidden */
  30377. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30378. /**
  30379. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30380. * @param pipelineContext defines the pipeline context to use
  30381. * @param uniformsNames defines the list of uniform names
  30382. * @returns an array of webGL uniform locations
  30383. */
  30384. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30385. /**
  30386. * Gets the lsit of active attributes for a given webGL program
  30387. * @param pipelineContext defines the pipeline context to use
  30388. * @param attributesNames defines the list of attribute names to get
  30389. * @returns an array of indices indicating the offset of each attribute
  30390. */
  30391. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30392. /**
  30393. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30394. * @param effect defines the effect to activate
  30395. */
  30396. enableEffect(effect: Nullable<Effect>): void;
  30397. /**
  30398. * Set the value of an uniform to an array of int32
  30399. * @param uniform defines the webGL uniform location where to store the value
  30400. * @param array defines the array of int32 to store
  30401. */
  30402. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30403. /**
  30404. * Set the value of an uniform to an array of int32 (stored as vec2)
  30405. * @param uniform defines the webGL uniform location where to store the value
  30406. * @param array defines the array of int32 to store
  30407. */
  30408. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30409. /**
  30410. * Set the value of an uniform to an array of int32 (stored as vec3)
  30411. * @param uniform defines the webGL uniform location where to store the value
  30412. * @param array defines the array of int32 to store
  30413. */
  30414. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30415. /**
  30416. * Set the value of an uniform to an array of int32 (stored as vec4)
  30417. * @param uniform defines the webGL uniform location where to store the value
  30418. * @param array defines the array of int32 to store
  30419. */
  30420. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30421. /**
  30422. * Set the value of an uniform to an array of float32
  30423. * @param uniform defines the webGL uniform location where to store the value
  30424. * @param array defines the array of float32 to store
  30425. */
  30426. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30427. /**
  30428. * Set the value of an uniform to an array of float32 (stored as vec2)
  30429. * @param uniform defines the webGL uniform location where to store the value
  30430. * @param array defines the array of float32 to store
  30431. */
  30432. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30433. /**
  30434. * Set the value of an uniform to an array of float32 (stored as vec3)
  30435. * @param uniform defines the webGL uniform location where to store the value
  30436. * @param array defines the array of float32 to store
  30437. */
  30438. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30439. /**
  30440. * Set the value of an uniform to an array of float32 (stored as vec4)
  30441. * @param uniform defines the webGL uniform location where to store the value
  30442. * @param array defines the array of float32 to store
  30443. */
  30444. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30445. /**
  30446. * Set the value of an uniform to an array of number
  30447. * @param uniform defines the webGL uniform location where to store the value
  30448. * @param array defines the array of number to store
  30449. */
  30450. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30451. /**
  30452. * Set the value of an uniform to an array of number (stored as vec2)
  30453. * @param uniform defines the webGL uniform location where to store the value
  30454. * @param array defines the array of number to store
  30455. */
  30456. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30457. /**
  30458. * Set the value of an uniform to an array of number (stored as vec3)
  30459. * @param uniform defines the webGL uniform location where to store the value
  30460. * @param array defines the array of number to store
  30461. */
  30462. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30463. /**
  30464. * Set the value of an uniform to an array of number (stored as vec4)
  30465. * @param uniform defines the webGL uniform location where to store the value
  30466. * @param array defines the array of number to store
  30467. */
  30468. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30469. /**
  30470. * Set the value of an uniform to an array of float32 (stored as matrices)
  30471. * @param uniform defines the webGL uniform location where to store the value
  30472. * @param matrices defines the array of float32 to store
  30473. */
  30474. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30475. /**
  30476. * Set the value of an uniform to a matrix (3x3)
  30477. * @param uniform defines the webGL uniform location where to store the value
  30478. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30479. */
  30480. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30481. /**
  30482. * Set the value of an uniform to a matrix (2x2)
  30483. * @param uniform defines the webGL uniform location where to store the value
  30484. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30485. */
  30486. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30487. /**
  30488. * Set the value of an uniform to a number (int)
  30489. * @param uniform defines the webGL uniform location where to store the value
  30490. * @param value defines the int number to store
  30491. */
  30492. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30493. /**
  30494. * Set the value of an uniform to a number (float)
  30495. * @param uniform defines the webGL uniform location where to store the value
  30496. * @param value defines the float number to store
  30497. */
  30498. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30499. /**
  30500. * Set the value of an uniform to a vec2
  30501. * @param uniform defines the webGL uniform location where to store the value
  30502. * @param x defines the 1st component of the value
  30503. * @param y defines the 2nd component of the value
  30504. */
  30505. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30506. /**
  30507. * Set the value of an uniform to a vec3
  30508. * @param uniform defines the webGL uniform location where to store the value
  30509. * @param x defines the 1st component of the value
  30510. * @param y defines the 2nd component of the value
  30511. * @param z defines the 3rd component of the value
  30512. */
  30513. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30514. /**
  30515. * Set the value of an uniform to a boolean
  30516. * @param uniform defines the webGL uniform location where to store the value
  30517. * @param bool defines the boolean to store
  30518. */
  30519. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30520. /**
  30521. * Set the value of an uniform to a vec4
  30522. * @param uniform defines the webGL uniform location where to store the value
  30523. * @param x defines the 1st component of the value
  30524. * @param y defines the 2nd component of the value
  30525. * @param z defines the 3rd component of the value
  30526. * @param w defines the 4th component of the value
  30527. */
  30528. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30529. /**
  30530. * Sets a Color4 on a uniform variable
  30531. * @param uniform defines the uniform location
  30532. * @param color4 defines the value to be set
  30533. */
  30534. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30535. /**
  30536. * Gets the depth culling state manager
  30537. */
  30538. readonly depthCullingState: DepthCullingState;
  30539. /**
  30540. * Gets the alpha state manager
  30541. */
  30542. readonly alphaState: AlphaState;
  30543. /**
  30544. * Gets the stencil state manager
  30545. */
  30546. readonly stencilState: StencilState;
  30547. /**
  30548. * Clears the list of texture accessible through engine.
  30549. * This can help preventing texture load conflict due to name collision.
  30550. */
  30551. clearInternalTexturesCache(): void;
  30552. /**
  30553. * Force the entire cache to be cleared
  30554. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30555. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30556. */
  30557. wipeCaches(bruteForce?: boolean): void;
  30558. /** @hidden */
  30559. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30560. min: number;
  30561. mag: number;
  30562. };
  30563. /** @hidden */
  30564. _createTexture(): WebGLTexture;
  30565. /**
  30566. * Usually called from Texture.ts.
  30567. * Passed information to create a WebGLTexture
  30568. * @param urlArg defines a value which contains one of the following:
  30569. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30570. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30571. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30573. * @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)
  30574. * @param scene needed for loading to the correct scene
  30575. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30576. * @param onLoad optional callback to be called upon successful completion
  30577. * @param onError optional callback to be called upon failure
  30578. * @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
  30579. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30580. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30581. * @param forcedExtension defines the extension to use to pick the right loader
  30582. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30583. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30584. */
  30585. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30586. /**
  30587. * @hidden
  30588. */
  30589. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30590. /**
  30591. * Creates a raw texture
  30592. * @param data defines the data to store in the texture
  30593. * @param width defines the width of the texture
  30594. * @param height defines the height of the texture
  30595. * @param format defines the format of the data
  30596. * @param generateMipMaps defines if the engine should generate the mip levels
  30597. * @param invertY defines if data must be stored with Y axis inverted
  30598. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30599. * @param compression defines the compression used (null by default)
  30600. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30601. * @returns the raw texture inside an InternalTexture
  30602. */
  30603. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30604. /**
  30605. * Creates a new raw cube texture
  30606. * @param data defines the array of data to use to create each face
  30607. * @param size defines the size of the textures
  30608. * @param format defines the format of the data
  30609. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30610. * @param generateMipMaps defines if the engine should generate the mip levels
  30611. * @param invertY defines if data must be stored with Y axis inverted
  30612. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30613. * @param compression defines the compression used (null by default)
  30614. * @returns the cube texture as an InternalTexture
  30615. */
  30616. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30617. /**
  30618. * Creates a new raw 3D texture
  30619. * @param data defines the data used to create the texture
  30620. * @param width defines the width of the texture
  30621. * @param height defines the height of the texture
  30622. * @param depth defines the depth of the texture
  30623. * @param format defines the format of the texture
  30624. * @param generateMipMaps defines if the engine must generate mip levels
  30625. * @param invertY defines if data must be stored with Y axis inverted
  30626. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30627. * @param compression defines the compressed used (can be null)
  30628. * @param textureType defines the compressed used (can be null)
  30629. * @returns a new raw 3D texture (stored in an InternalTexture)
  30630. */
  30631. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30632. private _unpackFlipYCached;
  30633. /**
  30634. * In case you are sharing the context with other applications, it might
  30635. * be interested to not cache the unpack flip y state to ensure a consistent
  30636. * value would be set.
  30637. */
  30638. enableUnpackFlipYCached: boolean;
  30639. /** @hidden */
  30640. _unpackFlipY(value: boolean): void;
  30641. /** @hidden */
  30642. _getUnpackAlignement(): number;
  30643. /**
  30644. * Update the sampling mode of a given texture
  30645. * @param samplingMode defines the required sampling mode
  30646. * @param texture defines the texture to update
  30647. */
  30648. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30649. /**
  30650. * Updates a depth texture Comparison Mode and Function.
  30651. * If the comparison Function is equal to 0, the mode will be set to none.
  30652. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30653. * @param texture The texture to set the comparison function for
  30654. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30655. */
  30656. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30657. /** @hidden */
  30658. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30659. width: number;
  30660. height: number;
  30661. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30662. /**
  30663. * Creates a depth stencil texture.
  30664. * This is only available in WebGL 2 or with the depth texture extension available.
  30665. * @param size The size of face edge in the texture.
  30666. * @param options The options defining the texture.
  30667. * @returns The texture
  30668. */
  30669. createDepthStencilTexture(size: number | {
  30670. width: number;
  30671. height: number;
  30672. }, options: DepthTextureCreationOptions): InternalTexture;
  30673. /**
  30674. * Creates a depth stencil texture.
  30675. * This is only available in WebGL 2 or with the depth texture extension available.
  30676. * @param size The size of face edge in the texture.
  30677. * @param options The options defining the texture.
  30678. * @returns The texture
  30679. */
  30680. private _createDepthStencilTexture;
  30681. /** @hidden */
  30682. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30683. /** @hidden */
  30684. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30685. /** @hidden */
  30686. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30687. /** @hidden */
  30688. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30689. /**
  30690. * @hidden
  30691. */
  30692. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30693. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30694. private _prepareWebGLTexture;
  30695. /** @hidden */
  30696. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30697. /** @hidden */
  30698. _releaseFramebufferObjects(texture: InternalTexture): void;
  30699. /** @hidden */
  30700. _releaseTexture(texture: InternalTexture): void;
  30701. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30702. protected _setProgram(program: WebGLProgram): void;
  30703. protected _boundUniforms: {
  30704. [key: number]: WebGLUniformLocation;
  30705. };
  30706. /**
  30707. * Binds an effect to the webGL context
  30708. * @param effect defines the effect to bind
  30709. */
  30710. bindSamplers(effect: Effect): void;
  30711. private _activateCurrentTexture;
  30712. /** @hidden */
  30713. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30714. /** @hidden */
  30715. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30716. /**
  30717. * Unbind all textures from the webGL context
  30718. */
  30719. unbindAllTextures(): void;
  30720. /**
  30721. * Sets a texture to the according uniform.
  30722. * @param channel The texture channel
  30723. * @param uniform The uniform to set
  30724. * @param texture The texture to apply
  30725. */
  30726. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30727. private _bindSamplerUniformToChannel;
  30728. private _getTextureWrapMode;
  30729. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30730. /**
  30731. * Sets an array of texture to the webGL context
  30732. * @param channel defines the channel where the texture array must be set
  30733. * @param uniform defines the associated uniform location
  30734. * @param textures defines the array of textures to bind
  30735. */
  30736. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30737. /** @hidden */
  30738. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30739. private _setTextureParameterFloat;
  30740. private _setTextureParameterInteger;
  30741. /**
  30742. * Unbind all vertex attributes from the webGL context
  30743. */
  30744. unbindAllAttributes(): void;
  30745. /**
  30746. * 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
  30747. */
  30748. releaseEffects(): void;
  30749. /**
  30750. * Dispose and release all associated resources
  30751. */
  30752. dispose(): void;
  30753. /**
  30754. * Attach a new callback raised when context lost event is fired
  30755. * @param callback defines the callback to call
  30756. */
  30757. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30758. /**
  30759. * Attach a new callback raised when context restored event is fired
  30760. * @param callback defines the callback to call
  30761. */
  30762. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30763. /**
  30764. * Get the current error code of the webGL context
  30765. * @returns the error code
  30766. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30767. */
  30768. getError(): number;
  30769. private _canRenderToFloatFramebuffer;
  30770. private _canRenderToHalfFloatFramebuffer;
  30771. private _canRenderToFramebuffer;
  30772. /** @hidden */
  30773. _getWebGLTextureType(type: number): number;
  30774. /** @hidden */
  30775. _getInternalFormat(format: number): number;
  30776. /** @hidden */
  30777. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30778. /** @hidden */
  30779. _getRGBAMultiSampleBufferFormat(type: number): number;
  30780. /** @hidden */
  30781. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30782. /**
  30783. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30784. * @returns true if the engine can be created
  30785. * @ignorenaming
  30786. */
  30787. static isSupported(): boolean;
  30788. /**
  30789. * Find the next highest power of two.
  30790. * @param x Number to start search from.
  30791. * @return Next highest power of two.
  30792. */
  30793. static CeilingPOT(x: number): number;
  30794. /**
  30795. * Find the next lowest power of two.
  30796. * @param x Number to start search from.
  30797. * @return Next lowest power of two.
  30798. */
  30799. static FloorPOT(x: number): number;
  30800. /**
  30801. * Find the nearest power of two.
  30802. * @param x Number to start search from.
  30803. * @return Next nearest power of two.
  30804. */
  30805. static NearestPOT(x: number): number;
  30806. /**
  30807. * Get the closest exponent of two
  30808. * @param value defines the value to approximate
  30809. * @param max defines the maximum value to return
  30810. * @param mode defines how to define the closest value
  30811. * @returns closest exponent of two of the given value
  30812. */
  30813. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30814. /**
  30815. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30816. * @param func - the function to be called
  30817. * @param requester - the object that will request the next frame. Falls back to window.
  30818. * @returns frame number
  30819. */
  30820. static QueueNewFrame(func: () => void, requester?: any): number;
  30821. }
  30822. }
  30823. declare module "babylonjs/Maths/sphericalPolynomial" {
  30824. import { Vector3 } from "babylonjs/Maths/math.vector";
  30825. import { Color3 } from "babylonjs/Maths/math.color";
  30826. /**
  30827. * Class representing spherical harmonics coefficients to the 3rd degree
  30828. */
  30829. export class SphericalHarmonics {
  30830. /**
  30831. * Defines whether or not the harmonics have been prescaled for rendering.
  30832. */
  30833. preScaled: boolean;
  30834. /**
  30835. * The l0,0 coefficients of the spherical harmonics
  30836. */
  30837. l00: Vector3;
  30838. /**
  30839. * The l1,-1 coefficients of the spherical harmonics
  30840. */
  30841. l1_1: Vector3;
  30842. /**
  30843. * The l1,0 coefficients of the spherical harmonics
  30844. */
  30845. l10: Vector3;
  30846. /**
  30847. * The l1,1 coefficients of the spherical harmonics
  30848. */
  30849. l11: Vector3;
  30850. /**
  30851. * The l2,-2 coefficients of the spherical harmonics
  30852. */
  30853. l2_2: Vector3;
  30854. /**
  30855. * The l2,-1 coefficients of the spherical harmonics
  30856. */
  30857. l2_1: Vector3;
  30858. /**
  30859. * The l2,0 coefficients of the spherical harmonics
  30860. */
  30861. l20: Vector3;
  30862. /**
  30863. * The l2,1 coefficients of the spherical harmonics
  30864. */
  30865. l21: Vector3;
  30866. /**
  30867. * The l2,2 coefficients of the spherical harmonics
  30868. */
  30869. l22: Vector3;
  30870. /**
  30871. * Adds a light to the spherical harmonics
  30872. * @param direction the direction of the light
  30873. * @param color the color of the light
  30874. * @param deltaSolidAngle the delta solid angle of the light
  30875. */
  30876. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30877. /**
  30878. * Scales the spherical harmonics by the given amount
  30879. * @param scale the amount to scale
  30880. */
  30881. scaleInPlace(scale: number): void;
  30882. /**
  30883. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30884. *
  30885. * ```
  30886. * E_lm = A_l * L_lm
  30887. * ```
  30888. *
  30889. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30890. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30891. * the scaling factors are given in equation 9.
  30892. */
  30893. convertIncidentRadianceToIrradiance(): void;
  30894. /**
  30895. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30896. *
  30897. * ```
  30898. * L = (1/pi) * E * rho
  30899. * ```
  30900. *
  30901. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30902. */
  30903. convertIrradianceToLambertianRadiance(): void;
  30904. /**
  30905. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30906. * required operations at run time.
  30907. *
  30908. * This is simply done by scaling back the SH with Ylm constants parameter.
  30909. * The trigonometric part being applied by the shader at run time.
  30910. */
  30911. preScaleForRendering(): void;
  30912. /**
  30913. * Constructs a spherical harmonics from an array.
  30914. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30915. * @returns the spherical harmonics
  30916. */
  30917. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30918. /**
  30919. * Gets the spherical harmonics from polynomial
  30920. * @param polynomial the spherical polynomial
  30921. * @returns the spherical harmonics
  30922. */
  30923. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30924. }
  30925. /**
  30926. * Class representing spherical polynomial coefficients to the 3rd degree
  30927. */
  30928. export class SphericalPolynomial {
  30929. private _harmonics;
  30930. /**
  30931. * The spherical harmonics used to create the polynomials.
  30932. */
  30933. readonly preScaledHarmonics: SphericalHarmonics;
  30934. /**
  30935. * The x coefficients of the spherical polynomial
  30936. */
  30937. x: Vector3;
  30938. /**
  30939. * The y coefficients of the spherical polynomial
  30940. */
  30941. y: Vector3;
  30942. /**
  30943. * The z coefficients of the spherical polynomial
  30944. */
  30945. z: Vector3;
  30946. /**
  30947. * The xx coefficients of the spherical polynomial
  30948. */
  30949. xx: Vector3;
  30950. /**
  30951. * The yy coefficients of the spherical polynomial
  30952. */
  30953. yy: Vector3;
  30954. /**
  30955. * The zz coefficients of the spherical polynomial
  30956. */
  30957. zz: Vector3;
  30958. /**
  30959. * The xy coefficients of the spherical polynomial
  30960. */
  30961. xy: Vector3;
  30962. /**
  30963. * The yz coefficients of the spherical polynomial
  30964. */
  30965. yz: Vector3;
  30966. /**
  30967. * The zx coefficients of the spherical polynomial
  30968. */
  30969. zx: Vector3;
  30970. /**
  30971. * Adds an ambient color to the spherical polynomial
  30972. * @param color the color to add
  30973. */
  30974. addAmbient(color: Color3): void;
  30975. /**
  30976. * Scales the spherical polynomial by the given amount
  30977. * @param scale the amount to scale
  30978. */
  30979. scaleInPlace(scale: number): void;
  30980. /**
  30981. * Gets the spherical polynomial from harmonics
  30982. * @param harmonics the spherical harmonics
  30983. * @returns the spherical polynomial
  30984. */
  30985. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30986. /**
  30987. * Constructs a spherical polynomial from an array.
  30988. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30989. * @returns the spherical polynomial
  30990. */
  30991. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30992. }
  30993. }
  30994. declare module "babylonjs/Materials/Textures/internalTexture" {
  30995. import { Observable } from "babylonjs/Misc/observable";
  30996. import { Nullable, int } from "babylonjs/types";
  30997. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30998. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30999. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31000. /**
  31001. * Defines the source of the internal texture
  31002. */
  31003. export enum InternalTextureSource {
  31004. /**
  31005. * The source of the texture data is unknown
  31006. */
  31007. Unknown = 0,
  31008. /**
  31009. * Texture data comes from an URL
  31010. */
  31011. Url = 1,
  31012. /**
  31013. * Texture data is only used for temporary storage
  31014. */
  31015. Temp = 2,
  31016. /**
  31017. * Texture data comes from raw data (ArrayBuffer)
  31018. */
  31019. Raw = 3,
  31020. /**
  31021. * Texture content is dynamic (video or dynamic texture)
  31022. */
  31023. Dynamic = 4,
  31024. /**
  31025. * Texture content is generated by rendering to it
  31026. */
  31027. RenderTarget = 5,
  31028. /**
  31029. * Texture content is part of a multi render target process
  31030. */
  31031. MultiRenderTarget = 6,
  31032. /**
  31033. * Texture data comes from a cube data file
  31034. */
  31035. Cube = 7,
  31036. /**
  31037. * Texture data comes from a raw cube data
  31038. */
  31039. CubeRaw = 8,
  31040. /**
  31041. * Texture data come from a prefiltered cube data file
  31042. */
  31043. CubePrefiltered = 9,
  31044. /**
  31045. * Texture content is raw 3D data
  31046. */
  31047. Raw3D = 10,
  31048. /**
  31049. * Texture content is a depth texture
  31050. */
  31051. Depth = 11,
  31052. /**
  31053. * Texture data comes from a raw cube data encoded with RGBD
  31054. */
  31055. CubeRawRGBD = 12
  31056. }
  31057. /**
  31058. * Class used to store data associated with WebGL texture data for the engine
  31059. * This class should not be used directly
  31060. */
  31061. export class InternalTexture {
  31062. /** @hidden */
  31063. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31064. /**
  31065. * Defines if the texture is ready
  31066. */
  31067. isReady: boolean;
  31068. /**
  31069. * Defines if the texture is a cube texture
  31070. */
  31071. isCube: boolean;
  31072. /**
  31073. * Defines if the texture contains 3D data
  31074. */
  31075. is3D: boolean;
  31076. /**
  31077. * Defines if the texture contains multiview data
  31078. */
  31079. isMultiview: boolean;
  31080. /**
  31081. * Gets the URL used to load this texture
  31082. */
  31083. url: string;
  31084. /**
  31085. * Gets the sampling mode of the texture
  31086. */
  31087. samplingMode: number;
  31088. /**
  31089. * Gets a boolean indicating if the texture needs mipmaps generation
  31090. */
  31091. generateMipMaps: boolean;
  31092. /**
  31093. * Gets the number of samples used by the texture (WebGL2+ only)
  31094. */
  31095. samples: number;
  31096. /**
  31097. * Gets the type of the texture (int, float...)
  31098. */
  31099. type: number;
  31100. /**
  31101. * Gets the format of the texture (RGB, RGBA...)
  31102. */
  31103. format: number;
  31104. /**
  31105. * Observable called when the texture is loaded
  31106. */
  31107. onLoadedObservable: Observable<InternalTexture>;
  31108. /**
  31109. * Gets the width of the texture
  31110. */
  31111. width: number;
  31112. /**
  31113. * Gets the height of the texture
  31114. */
  31115. height: number;
  31116. /**
  31117. * Gets the depth of the texture
  31118. */
  31119. depth: number;
  31120. /**
  31121. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31122. */
  31123. baseWidth: number;
  31124. /**
  31125. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31126. */
  31127. baseHeight: number;
  31128. /**
  31129. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31130. */
  31131. baseDepth: number;
  31132. /**
  31133. * Gets a boolean indicating if the texture is inverted on Y axis
  31134. */
  31135. invertY: boolean;
  31136. /** @hidden */
  31137. _invertVScale: boolean;
  31138. /** @hidden */
  31139. _associatedChannel: number;
  31140. /** @hidden */
  31141. _source: InternalTextureSource;
  31142. /** @hidden */
  31143. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31144. /** @hidden */
  31145. _bufferView: Nullable<ArrayBufferView>;
  31146. /** @hidden */
  31147. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31148. /** @hidden */
  31149. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31150. /** @hidden */
  31151. _size: number;
  31152. /** @hidden */
  31153. _extension: string;
  31154. /** @hidden */
  31155. _files: Nullable<string[]>;
  31156. /** @hidden */
  31157. _workingCanvas: Nullable<HTMLCanvasElement>;
  31158. /** @hidden */
  31159. _workingContext: Nullable<CanvasRenderingContext2D>;
  31160. /** @hidden */
  31161. _framebuffer: Nullable<WebGLFramebuffer>;
  31162. /** @hidden */
  31163. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31164. /** @hidden */
  31165. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31166. /** @hidden */
  31167. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31168. /** @hidden */
  31169. _attachments: Nullable<number[]>;
  31170. /** @hidden */
  31171. _cachedCoordinatesMode: Nullable<number>;
  31172. /** @hidden */
  31173. _cachedWrapU: Nullable<number>;
  31174. /** @hidden */
  31175. _cachedWrapV: Nullable<number>;
  31176. /** @hidden */
  31177. _cachedWrapR: Nullable<number>;
  31178. /** @hidden */
  31179. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31180. /** @hidden */
  31181. _isDisabled: boolean;
  31182. /** @hidden */
  31183. _compression: Nullable<string>;
  31184. /** @hidden */
  31185. _generateStencilBuffer: boolean;
  31186. /** @hidden */
  31187. _generateDepthBuffer: boolean;
  31188. /** @hidden */
  31189. _comparisonFunction: number;
  31190. /** @hidden */
  31191. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31192. /** @hidden */
  31193. _lodGenerationScale: number;
  31194. /** @hidden */
  31195. _lodGenerationOffset: number;
  31196. /** @hidden */
  31197. _colorTextureArray: Nullable<WebGLTexture>;
  31198. /** @hidden */
  31199. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31200. /** @hidden */
  31201. _lodTextureHigh: Nullable<BaseTexture>;
  31202. /** @hidden */
  31203. _lodTextureMid: Nullable<BaseTexture>;
  31204. /** @hidden */
  31205. _lodTextureLow: Nullable<BaseTexture>;
  31206. /** @hidden */
  31207. _isRGBD: boolean;
  31208. /** @hidden */
  31209. _linearSpecularLOD: boolean;
  31210. /** @hidden */
  31211. _irradianceTexture: Nullable<BaseTexture>;
  31212. /** @hidden */
  31213. _webGLTexture: Nullable<WebGLTexture>;
  31214. /** @hidden */
  31215. _references: number;
  31216. private _engine;
  31217. /**
  31218. * Gets the Engine the texture belongs to.
  31219. * @returns The babylon engine
  31220. */
  31221. getEngine(): ThinEngine;
  31222. /**
  31223. * Gets the data source type of the texture
  31224. */
  31225. readonly source: InternalTextureSource;
  31226. /**
  31227. * Creates a new InternalTexture
  31228. * @param engine defines the engine to use
  31229. * @param source defines the type of data that will be used
  31230. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31231. */
  31232. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31233. /**
  31234. * Increments the number of references (ie. the number of Texture that point to it)
  31235. */
  31236. incrementReferences(): void;
  31237. /**
  31238. * Change the size of the texture (not the size of the content)
  31239. * @param width defines the new width
  31240. * @param height defines the new height
  31241. * @param depth defines the new depth (1 by default)
  31242. */
  31243. updateSize(width: int, height: int, depth?: int): void;
  31244. /** @hidden */
  31245. _rebuild(): void;
  31246. /** @hidden */
  31247. _swapAndDie(target: InternalTexture): void;
  31248. /**
  31249. * Dispose the current allocated resources
  31250. */
  31251. dispose(): void;
  31252. }
  31253. }
  31254. declare module "babylonjs/Audio/analyser" {
  31255. import { Scene } from "babylonjs/scene";
  31256. /**
  31257. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31259. */
  31260. export class Analyser {
  31261. /**
  31262. * Gets or sets the smoothing
  31263. * @ignorenaming
  31264. */
  31265. SMOOTHING: number;
  31266. /**
  31267. * Gets or sets the FFT table size
  31268. * @ignorenaming
  31269. */
  31270. FFT_SIZE: number;
  31271. /**
  31272. * Gets or sets the bar graph amplitude
  31273. * @ignorenaming
  31274. */
  31275. BARGRAPHAMPLITUDE: number;
  31276. /**
  31277. * Gets or sets the position of the debug canvas
  31278. * @ignorenaming
  31279. */
  31280. DEBUGCANVASPOS: {
  31281. x: number;
  31282. y: number;
  31283. };
  31284. /**
  31285. * Gets or sets the debug canvas size
  31286. * @ignorenaming
  31287. */
  31288. DEBUGCANVASSIZE: {
  31289. width: number;
  31290. height: number;
  31291. };
  31292. private _byteFreqs;
  31293. private _byteTime;
  31294. private _floatFreqs;
  31295. private _webAudioAnalyser;
  31296. private _debugCanvas;
  31297. private _debugCanvasContext;
  31298. private _scene;
  31299. private _registerFunc;
  31300. private _audioEngine;
  31301. /**
  31302. * Creates a new analyser
  31303. * @param scene defines hosting scene
  31304. */
  31305. constructor(scene: Scene);
  31306. /**
  31307. * Get the number of data values you will have to play with for the visualization
  31308. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31309. * @returns a number
  31310. */
  31311. getFrequencyBinCount(): number;
  31312. /**
  31313. * Gets the current frequency data as a byte array
  31314. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31315. * @returns a Uint8Array
  31316. */
  31317. getByteFrequencyData(): Uint8Array;
  31318. /**
  31319. * Gets the current waveform as a byte array
  31320. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31321. * @returns a Uint8Array
  31322. */
  31323. getByteTimeDomainData(): Uint8Array;
  31324. /**
  31325. * Gets the current frequency data as a float array
  31326. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31327. * @returns a Float32Array
  31328. */
  31329. getFloatFrequencyData(): Float32Array;
  31330. /**
  31331. * Renders the debug canvas
  31332. */
  31333. drawDebugCanvas(): void;
  31334. /**
  31335. * Stops rendering the debug canvas and removes it
  31336. */
  31337. stopDebugCanvas(): void;
  31338. /**
  31339. * Connects two audio nodes
  31340. * @param inputAudioNode defines first node to connect
  31341. * @param outputAudioNode defines second node to connect
  31342. */
  31343. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31344. /**
  31345. * Releases all associated resources
  31346. */
  31347. dispose(): void;
  31348. }
  31349. }
  31350. declare module "babylonjs/Audio/audioEngine" {
  31351. import { IDisposable } from "babylonjs/scene";
  31352. import { Analyser } from "babylonjs/Audio/analyser";
  31353. import { Nullable } from "babylonjs/types";
  31354. import { Observable } from "babylonjs/Misc/observable";
  31355. /**
  31356. * This represents an audio engine and it is responsible
  31357. * to play, synchronize and analyse sounds throughout the application.
  31358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31359. */
  31360. export interface IAudioEngine extends IDisposable {
  31361. /**
  31362. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31363. */
  31364. readonly canUseWebAudio: boolean;
  31365. /**
  31366. * Gets the current AudioContext if available.
  31367. */
  31368. readonly audioContext: Nullable<AudioContext>;
  31369. /**
  31370. * The master gain node defines the global audio volume of your audio engine.
  31371. */
  31372. readonly masterGain: GainNode;
  31373. /**
  31374. * Gets whether or not mp3 are supported by your browser.
  31375. */
  31376. readonly isMP3supported: boolean;
  31377. /**
  31378. * Gets whether or not ogg are supported by your browser.
  31379. */
  31380. readonly isOGGsupported: boolean;
  31381. /**
  31382. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31383. * @ignoreNaming
  31384. */
  31385. WarnedWebAudioUnsupported: boolean;
  31386. /**
  31387. * Defines if the audio engine relies on a custom unlocked button.
  31388. * In this case, the embedded button will not be displayed.
  31389. */
  31390. useCustomUnlockedButton: boolean;
  31391. /**
  31392. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31393. */
  31394. readonly unlocked: boolean;
  31395. /**
  31396. * Event raised when audio has been unlocked on the browser.
  31397. */
  31398. onAudioUnlockedObservable: Observable<AudioEngine>;
  31399. /**
  31400. * Event raised when audio has been locked on the browser.
  31401. */
  31402. onAudioLockedObservable: Observable<AudioEngine>;
  31403. /**
  31404. * Flags the audio engine in Locked state.
  31405. * This happens due to new browser policies preventing audio to autoplay.
  31406. */
  31407. lock(): void;
  31408. /**
  31409. * Unlocks the audio engine once a user action has been done on the dom.
  31410. * This is helpful to resume play once browser policies have been satisfied.
  31411. */
  31412. unlock(): void;
  31413. }
  31414. /**
  31415. * This represents the default audio engine used in babylon.
  31416. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31418. */
  31419. export class AudioEngine implements IAudioEngine {
  31420. private _audioContext;
  31421. private _audioContextInitialized;
  31422. private _muteButton;
  31423. private _hostElement;
  31424. /**
  31425. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31426. */
  31427. canUseWebAudio: boolean;
  31428. /**
  31429. * The master gain node defines the global audio volume of your audio engine.
  31430. */
  31431. masterGain: GainNode;
  31432. /**
  31433. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31434. * @ignoreNaming
  31435. */
  31436. WarnedWebAudioUnsupported: boolean;
  31437. /**
  31438. * Gets whether or not mp3 are supported by your browser.
  31439. */
  31440. isMP3supported: boolean;
  31441. /**
  31442. * Gets whether or not ogg are supported by your browser.
  31443. */
  31444. isOGGsupported: boolean;
  31445. /**
  31446. * Gets whether audio has been unlocked on the device.
  31447. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31448. * a user interaction has happened.
  31449. */
  31450. unlocked: boolean;
  31451. /**
  31452. * Defines if the audio engine relies on a custom unlocked button.
  31453. * In this case, the embedded button will not be displayed.
  31454. */
  31455. useCustomUnlockedButton: boolean;
  31456. /**
  31457. * Event raised when audio has been unlocked on the browser.
  31458. */
  31459. onAudioUnlockedObservable: Observable<AudioEngine>;
  31460. /**
  31461. * Event raised when audio has been locked on the browser.
  31462. */
  31463. onAudioLockedObservable: Observable<AudioEngine>;
  31464. /**
  31465. * Gets the current AudioContext if available.
  31466. */
  31467. readonly audioContext: Nullable<AudioContext>;
  31468. private _connectedAnalyser;
  31469. /**
  31470. * Instantiates a new audio engine.
  31471. *
  31472. * There should be only one per page as some browsers restrict the number
  31473. * of audio contexts you can create.
  31474. * @param hostElement defines the host element where to display the mute icon if necessary
  31475. */
  31476. constructor(hostElement?: Nullable<HTMLElement>);
  31477. /**
  31478. * Flags the audio engine in Locked state.
  31479. * This happens due to new browser policies preventing audio to autoplay.
  31480. */
  31481. lock(): void;
  31482. /**
  31483. * Unlocks the audio engine once a user action has been done on the dom.
  31484. * This is helpful to resume play once browser policies have been satisfied.
  31485. */
  31486. unlock(): void;
  31487. private _resumeAudioContext;
  31488. private _initializeAudioContext;
  31489. private _tryToRun;
  31490. private _triggerRunningState;
  31491. private _triggerSuspendedState;
  31492. private _displayMuteButton;
  31493. private _moveButtonToTopLeft;
  31494. private _onResize;
  31495. private _hideMuteButton;
  31496. /**
  31497. * Destroy and release the resources associated with the audio ccontext.
  31498. */
  31499. dispose(): void;
  31500. /**
  31501. * Gets the global volume sets on the master gain.
  31502. * @returns the global volume if set or -1 otherwise
  31503. */
  31504. getGlobalVolume(): number;
  31505. /**
  31506. * Sets the global volume of your experience (sets on the master gain).
  31507. * @param newVolume Defines the new global volume of the application
  31508. */
  31509. setGlobalVolume(newVolume: number): void;
  31510. /**
  31511. * Connect the audio engine to an audio analyser allowing some amazing
  31512. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31514. * @param analyser The analyser to connect to the engine
  31515. */
  31516. connectToAnalyser(analyser: Analyser): void;
  31517. }
  31518. }
  31519. declare module "babylonjs/Loading/loadingScreen" {
  31520. /**
  31521. * Interface used to present a loading screen while loading a scene
  31522. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31523. */
  31524. export interface ILoadingScreen {
  31525. /**
  31526. * Function called to display the loading screen
  31527. */
  31528. displayLoadingUI: () => void;
  31529. /**
  31530. * Function called to hide the loading screen
  31531. */
  31532. hideLoadingUI: () => void;
  31533. /**
  31534. * Gets or sets the color to use for the background
  31535. */
  31536. loadingUIBackgroundColor: string;
  31537. /**
  31538. * Gets or sets the text to display while loading
  31539. */
  31540. loadingUIText: string;
  31541. }
  31542. /**
  31543. * Class used for the default loading screen
  31544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31545. */
  31546. export class DefaultLoadingScreen implements ILoadingScreen {
  31547. private _renderingCanvas;
  31548. private _loadingText;
  31549. private _loadingDivBackgroundColor;
  31550. private _loadingDiv;
  31551. private _loadingTextDiv;
  31552. /** Gets or sets the logo url to use for the default loading screen */
  31553. static DefaultLogoUrl: string;
  31554. /** Gets or sets the spinner url to use for the default loading screen */
  31555. static DefaultSpinnerUrl: string;
  31556. /**
  31557. * Creates a new default loading screen
  31558. * @param _renderingCanvas defines the canvas used to render the scene
  31559. * @param _loadingText defines the default text to display
  31560. * @param _loadingDivBackgroundColor defines the default background color
  31561. */
  31562. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31563. /**
  31564. * Function called to display the loading screen
  31565. */
  31566. displayLoadingUI(): void;
  31567. /**
  31568. * Function called to hide the loading screen
  31569. */
  31570. hideLoadingUI(): void;
  31571. /**
  31572. * Gets or sets the text to display while loading
  31573. */
  31574. loadingUIText: string;
  31575. /**
  31576. * Gets or sets the color to use for the background
  31577. */
  31578. loadingUIBackgroundColor: string;
  31579. private _resizeLoadingUI;
  31580. }
  31581. }
  31582. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31583. /**
  31584. * Interface for any object that can request an animation frame
  31585. */
  31586. export interface ICustomAnimationFrameRequester {
  31587. /**
  31588. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31589. */
  31590. renderFunction?: Function;
  31591. /**
  31592. * Called to request the next frame to render to
  31593. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31594. */
  31595. requestAnimationFrame: Function;
  31596. /**
  31597. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31598. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31599. */
  31600. requestID?: number;
  31601. }
  31602. }
  31603. declare module "babylonjs/Misc/performanceMonitor" {
  31604. /**
  31605. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31606. */
  31607. export class PerformanceMonitor {
  31608. private _enabled;
  31609. private _rollingFrameTime;
  31610. private _lastFrameTimeMs;
  31611. /**
  31612. * constructor
  31613. * @param frameSampleSize The number of samples required to saturate the sliding window
  31614. */
  31615. constructor(frameSampleSize?: number);
  31616. /**
  31617. * Samples current frame
  31618. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31619. */
  31620. sampleFrame(timeMs?: number): void;
  31621. /**
  31622. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31623. */
  31624. readonly averageFrameTime: number;
  31625. /**
  31626. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31627. */
  31628. readonly averageFrameTimeVariance: number;
  31629. /**
  31630. * Returns the frame time of the most recent frame
  31631. */
  31632. readonly instantaneousFrameTime: number;
  31633. /**
  31634. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31635. */
  31636. readonly averageFPS: number;
  31637. /**
  31638. * Returns the average framerate in frames per second using the most recent frame time
  31639. */
  31640. readonly instantaneousFPS: number;
  31641. /**
  31642. * Returns true if enough samples have been taken to completely fill the sliding window
  31643. */
  31644. readonly isSaturated: boolean;
  31645. /**
  31646. * Enables contributions to the sliding window sample set
  31647. */
  31648. enable(): void;
  31649. /**
  31650. * Disables contributions to the sliding window sample set
  31651. * Samples will not be interpolated over the disabled period
  31652. */
  31653. disable(): void;
  31654. /**
  31655. * Returns true if sampling is enabled
  31656. */
  31657. readonly isEnabled: boolean;
  31658. /**
  31659. * Resets performance monitor
  31660. */
  31661. reset(): void;
  31662. }
  31663. /**
  31664. * RollingAverage
  31665. *
  31666. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31667. */
  31668. export class RollingAverage {
  31669. /**
  31670. * Current average
  31671. */
  31672. average: number;
  31673. /**
  31674. * Current variance
  31675. */
  31676. variance: number;
  31677. protected _samples: Array<number>;
  31678. protected _sampleCount: number;
  31679. protected _pos: number;
  31680. protected _m2: number;
  31681. /**
  31682. * constructor
  31683. * @param length The number of samples required to saturate the sliding window
  31684. */
  31685. constructor(length: number);
  31686. /**
  31687. * Adds a sample to the sample set
  31688. * @param v The sample value
  31689. */
  31690. add(v: number): void;
  31691. /**
  31692. * Returns previously added values or null if outside of history or outside the sliding window domain
  31693. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31694. * @return Value previously recorded with add() or null if outside of range
  31695. */
  31696. history(i: number): number;
  31697. /**
  31698. * Returns true if enough samples have been taken to completely fill the sliding window
  31699. * @return true if sample-set saturated
  31700. */
  31701. isSaturated(): boolean;
  31702. /**
  31703. * Resets the rolling average (equivalent to 0 samples taken so far)
  31704. */
  31705. reset(): void;
  31706. /**
  31707. * Wraps a value around the sample range boundaries
  31708. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31709. * @return Wrapped position in sample range
  31710. */
  31711. protected _wrapPosition(i: number): number;
  31712. }
  31713. }
  31714. declare module "babylonjs/Misc/perfCounter" {
  31715. /**
  31716. * This class is used to track a performance counter which is number based.
  31717. * The user has access to many properties which give statistics of different nature.
  31718. *
  31719. * The implementer can track two kinds of Performance Counter: time and count.
  31720. * 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.
  31721. * 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.
  31722. */
  31723. export class PerfCounter {
  31724. /**
  31725. * Gets or sets a global boolean to turn on and off all the counters
  31726. */
  31727. static Enabled: boolean;
  31728. /**
  31729. * Returns the smallest value ever
  31730. */
  31731. readonly min: number;
  31732. /**
  31733. * Returns the biggest value ever
  31734. */
  31735. readonly max: number;
  31736. /**
  31737. * Returns the average value since the performance counter is running
  31738. */
  31739. readonly average: number;
  31740. /**
  31741. * Returns the average value of the last second the counter was monitored
  31742. */
  31743. readonly lastSecAverage: number;
  31744. /**
  31745. * Returns the current value
  31746. */
  31747. readonly current: number;
  31748. /**
  31749. * Gets the accumulated total
  31750. */
  31751. readonly total: number;
  31752. /**
  31753. * Gets the total value count
  31754. */
  31755. readonly count: number;
  31756. /**
  31757. * Creates a new counter
  31758. */
  31759. constructor();
  31760. /**
  31761. * Call this method to start monitoring a new frame.
  31762. * 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.
  31763. */
  31764. fetchNewFrame(): void;
  31765. /**
  31766. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31767. * @param newCount the count value to add to the monitored count
  31768. * @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.
  31769. */
  31770. addCount(newCount: number, fetchResult: boolean): void;
  31771. /**
  31772. * Start monitoring this performance counter
  31773. */
  31774. beginMonitoring(): void;
  31775. /**
  31776. * Compute the time lapsed since the previous beginMonitoring() call.
  31777. * @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
  31778. */
  31779. endMonitoring(newFrame?: boolean): void;
  31780. private _fetchResult;
  31781. private _startMonitoringTime;
  31782. private _min;
  31783. private _max;
  31784. private _average;
  31785. private _current;
  31786. private _totalValueCount;
  31787. private _totalAccumulated;
  31788. private _lastSecAverage;
  31789. private _lastSecAccumulated;
  31790. private _lastSecTime;
  31791. private _lastSecValueCount;
  31792. }
  31793. }
  31794. declare module "babylonjs/Engines/engine" {
  31795. import { Observable } from "babylonjs/Misc/observable";
  31796. import { Nullable, IndicesArray } from "babylonjs/types";
  31797. import { Scene } from "babylonjs/scene";
  31798. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31799. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31800. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31801. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31802. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31803. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31804. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31805. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31806. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31807. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31808. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31809. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31810. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31811. import { Material } from "babylonjs/Materials/material";
  31812. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31813. /**
  31814. * Defines the interface used by display changed events
  31815. */
  31816. export interface IDisplayChangedEventArgs {
  31817. /** Gets the vrDisplay object (if any) */
  31818. vrDisplay: Nullable<any>;
  31819. /** Gets a boolean indicating if webVR is supported */
  31820. vrSupported: boolean;
  31821. }
  31822. /**
  31823. * Defines the interface used by objects containing a viewport (like a camera)
  31824. */
  31825. interface IViewportOwnerLike {
  31826. /**
  31827. * Gets or sets the viewport
  31828. */
  31829. viewport: IViewportLike;
  31830. }
  31831. /**
  31832. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31833. */
  31834. export class Engine extends ThinEngine {
  31835. /** Defines that alpha blending is disabled */
  31836. static readonly ALPHA_DISABLE: number;
  31837. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31838. static readonly ALPHA_ADD: number;
  31839. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31840. static readonly ALPHA_COMBINE: number;
  31841. /** Defines that alpha blending to DEST - SRC * DEST */
  31842. static readonly ALPHA_SUBTRACT: number;
  31843. /** Defines that alpha blending to SRC * DEST */
  31844. static readonly ALPHA_MULTIPLY: number;
  31845. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31846. static readonly ALPHA_MAXIMIZED: number;
  31847. /** Defines that alpha blending to SRC + DEST */
  31848. static readonly ALPHA_ONEONE: number;
  31849. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31850. static readonly ALPHA_PREMULTIPLIED: number;
  31851. /**
  31852. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31853. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31854. */
  31855. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31856. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31857. static readonly ALPHA_INTERPOLATE: number;
  31858. /**
  31859. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31860. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31861. */
  31862. static readonly ALPHA_SCREENMODE: number;
  31863. /** Defines that the ressource is not delayed*/
  31864. static readonly DELAYLOADSTATE_NONE: number;
  31865. /** Defines that the ressource was successfully delay loaded */
  31866. static readonly DELAYLOADSTATE_LOADED: number;
  31867. /** Defines that the ressource is currently delay loading */
  31868. static readonly DELAYLOADSTATE_LOADING: number;
  31869. /** Defines that the ressource is delayed and has not started loading */
  31870. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31871. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31872. static readonly NEVER: number;
  31873. /** 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 */
  31874. static readonly ALWAYS: number;
  31875. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31876. static readonly LESS: number;
  31877. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31878. static readonly EQUAL: number;
  31879. /** 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 */
  31880. static readonly LEQUAL: number;
  31881. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31882. static readonly GREATER: number;
  31883. /** 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 */
  31884. static readonly GEQUAL: number;
  31885. /** 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 */
  31886. static readonly NOTEQUAL: number;
  31887. /** Passed to stencilOperation to specify that stencil value must be kept */
  31888. static readonly KEEP: number;
  31889. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31890. static readonly REPLACE: number;
  31891. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31892. static readonly INCR: number;
  31893. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31894. static readonly DECR: number;
  31895. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31896. static readonly INVERT: number;
  31897. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31898. static readonly INCR_WRAP: number;
  31899. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31900. static readonly DECR_WRAP: number;
  31901. /** Texture is not repeating outside of 0..1 UVs */
  31902. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31903. /** Texture is repeating outside of 0..1 UVs */
  31904. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31905. /** Texture is repeating and mirrored */
  31906. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31907. /** ALPHA */
  31908. static readonly TEXTUREFORMAT_ALPHA: number;
  31909. /** LUMINANCE */
  31910. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31911. /** LUMINANCE_ALPHA */
  31912. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31913. /** RGB */
  31914. static readonly TEXTUREFORMAT_RGB: number;
  31915. /** RGBA */
  31916. static readonly TEXTUREFORMAT_RGBA: number;
  31917. /** RED */
  31918. static readonly TEXTUREFORMAT_RED: number;
  31919. /** RED (2nd reference) */
  31920. static readonly TEXTUREFORMAT_R: number;
  31921. /** RG */
  31922. static readonly TEXTUREFORMAT_RG: number;
  31923. /** RED_INTEGER */
  31924. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31925. /** RED_INTEGER (2nd reference) */
  31926. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31927. /** RG_INTEGER */
  31928. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31929. /** RGB_INTEGER */
  31930. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31931. /** RGBA_INTEGER */
  31932. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31933. /** UNSIGNED_BYTE */
  31934. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31935. /** UNSIGNED_BYTE (2nd reference) */
  31936. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31937. /** FLOAT */
  31938. static readonly TEXTURETYPE_FLOAT: number;
  31939. /** HALF_FLOAT */
  31940. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31941. /** BYTE */
  31942. static readonly TEXTURETYPE_BYTE: number;
  31943. /** SHORT */
  31944. static readonly TEXTURETYPE_SHORT: number;
  31945. /** UNSIGNED_SHORT */
  31946. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31947. /** INT */
  31948. static readonly TEXTURETYPE_INT: number;
  31949. /** UNSIGNED_INT */
  31950. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31951. /** UNSIGNED_SHORT_4_4_4_4 */
  31952. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31953. /** UNSIGNED_SHORT_5_5_5_1 */
  31954. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31955. /** UNSIGNED_SHORT_5_6_5 */
  31956. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31957. /** UNSIGNED_INT_2_10_10_10_REV */
  31958. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31959. /** UNSIGNED_INT_24_8 */
  31960. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31961. /** UNSIGNED_INT_10F_11F_11F_REV */
  31962. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31963. /** UNSIGNED_INT_5_9_9_9_REV */
  31964. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31965. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31966. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31967. /** nearest is mag = nearest and min = nearest and mip = linear */
  31968. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31969. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31970. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31971. /** Trilinear is mag = linear and min = linear and mip = linear */
  31972. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31973. /** nearest is mag = nearest and min = nearest and mip = linear */
  31974. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31975. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31976. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31977. /** Trilinear is mag = linear and min = linear and mip = linear */
  31978. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31979. /** mag = nearest and min = nearest and mip = nearest */
  31980. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31981. /** mag = nearest and min = linear and mip = nearest */
  31982. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31983. /** mag = nearest and min = linear and mip = linear */
  31984. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31985. /** mag = nearest and min = linear and mip = none */
  31986. static readonly TEXTURE_NEAREST_LINEAR: number;
  31987. /** mag = nearest and min = nearest and mip = none */
  31988. static readonly TEXTURE_NEAREST_NEAREST: number;
  31989. /** mag = linear and min = nearest and mip = nearest */
  31990. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31991. /** mag = linear and min = nearest and mip = linear */
  31992. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31993. /** mag = linear and min = linear and mip = none */
  31994. static readonly TEXTURE_LINEAR_LINEAR: number;
  31995. /** mag = linear and min = nearest and mip = none */
  31996. static readonly TEXTURE_LINEAR_NEAREST: number;
  31997. /** Explicit coordinates mode */
  31998. static readonly TEXTURE_EXPLICIT_MODE: number;
  31999. /** Spherical coordinates mode */
  32000. static readonly TEXTURE_SPHERICAL_MODE: number;
  32001. /** Planar coordinates mode */
  32002. static readonly TEXTURE_PLANAR_MODE: number;
  32003. /** Cubic coordinates mode */
  32004. static readonly TEXTURE_CUBIC_MODE: number;
  32005. /** Projection coordinates mode */
  32006. static readonly TEXTURE_PROJECTION_MODE: number;
  32007. /** Skybox coordinates mode */
  32008. static readonly TEXTURE_SKYBOX_MODE: number;
  32009. /** Inverse Cubic coordinates mode */
  32010. static readonly TEXTURE_INVCUBIC_MODE: number;
  32011. /** Equirectangular coordinates mode */
  32012. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32013. /** Equirectangular Fixed coordinates mode */
  32014. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32015. /** Equirectangular Fixed Mirrored coordinates mode */
  32016. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32017. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32018. static readonly SCALEMODE_FLOOR: number;
  32019. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32020. static readonly SCALEMODE_NEAREST: number;
  32021. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32022. static readonly SCALEMODE_CEILING: number;
  32023. /**
  32024. * Returns the current npm package of the sdk
  32025. */
  32026. static readonly NpmPackage: string;
  32027. /**
  32028. * Returns the current version of the framework
  32029. */
  32030. static readonly Version: string;
  32031. /** Gets the list of created engines */
  32032. static readonly Instances: Engine[];
  32033. /**
  32034. * Gets the latest created engine
  32035. */
  32036. static readonly LastCreatedEngine: Nullable<Engine>;
  32037. /**
  32038. * Gets the latest created scene
  32039. */
  32040. static readonly LastCreatedScene: Nullable<Scene>;
  32041. /**
  32042. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32043. * @param flag defines which part of the materials must be marked as dirty
  32044. * @param predicate defines a predicate used to filter which materials should be affected
  32045. */
  32046. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32047. /**
  32048. * Method called to create the default loading screen.
  32049. * This can be overriden in your own app.
  32050. * @param canvas The rendering canvas element
  32051. * @returns The loading screen
  32052. */
  32053. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32054. /**
  32055. * Method called to create the default rescale post process on each engine.
  32056. */
  32057. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32058. /**
  32059. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32060. **/
  32061. enableOfflineSupport: boolean;
  32062. /**
  32063. * 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)
  32064. **/
  32065. disableManifestCheck: boolean;
  32066. /**
  32067. * Gets the list of created scenes
  32068. */
  32069. scenes: Scene[];
  32070. /**
  32071. * Event raised when a new scene is created
  32072. */
  32073. onNewSceneAddedObservable: Observable<Scene>;
  32074. /**
  32075. * Gets the list of created postprocesses
  32076. */
  32077. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32078. /**
  32079. * Gets a boolean indicating if the pointer is currently locked
  32080. */
  32081. isPointerLock: boolean;
  32082. /**
  32083. * Observable event triggered each time the rendering canvas is resized
  32084. */
  32085. onResizeObservable: Observable<Engine>;
  32086. /**
  32087. * Observable event triggered each time the canvas loses focus
  32088. */
  32089. onCanvasBlurObservable: Observable<Engine>;
  32090. /**
  32091. * Observable event triggered each time the canvas gains focus
  32092. */
  32093. onCanvasFocusObservable: Observable<Engine>;
  32094. /**
  32095. * Observable event triggered each time the canvas receives pointerout event
  32096. */
  32097. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32098. /**
  32099. * Observable raised when the engine begins a new frame
  32100. */
  32101. onBeginFrameObservable: Observable<Engine>;
  32102. /**
  32103. * If set, will be used to request the next animation frame for the render loop
  32104. */
  32105. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32106. /**
  32107. * Observable raised when the engine ends the current frame
  32108. */
  32109. onEndFrameObservable: Observable<Engine>;
  32110. /**
  32111. * Observable raised when the engine is about to compile a shader
  32112. */
  32113. onBeforeShaderCompilationObservable: Observable<Engine>;
  32114. /**
  32115. * Observable raised when the engine has jsut compiled a shader
  32116. */
  32117. onAfterShaderCompilationObservable: Observable<Engine>;
  32118. /**
  32119. * Gets the audio engine
  32120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32121. * @ignorenaming
  32122. */
  32123. static audioEngine: IAudioEngine;
  32124. /**
  32125. * Default AudioEngine factory responsible of creating the Audio Engine.
  32126. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32127. */
  32128. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32129. /**
  32130. * Default offline support factory responsible of creating a tool used to store data locally.
  32131. * By default, this will create a Database object if the workload has been embedded.
  32132. */
  32133. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32134. private _loadingScreen;
  32135. private _pointerLockRequested;
  32136. private _dummyFramebuffer;
  32137. private _rescalePostProcess;
  32138. /** @hidden */
  32139. protected _alphaMode: number;
  32140. /** @hidden */
  32141. protected _alphaEquation: number;
  32142. private _deterministicLockstep;
  32143. private _lockstepMaxSteps;
  32144. protected readonly _supportsHardwareTextureRescaling: boolean;
  32145. private _fps;
  32146. private _deltaTime;
  32147. /** @hidden */
  32148. _drawCalls: PerfCounter;
  32149. /**
  32150. * Turn this value on if you want to pause FPS computation when in background
  32151. */
  32152. disablePerformanceMonitorInBackground: boolean;
  32153. private _performanceMonitor;
  32154. /**
  32155. * Gets the performance monitor attached to this engine
  32156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32157. */
  32158. readonly performanceMonitor: PerformanceMonitor;
  32159. private _onFocus;
  32160. private _onBlur;
  32161. private _onCanvasPointerOut;
  32162. private _onCanvasBlur;
  32163. private _onCanvasFocus;
  32164. private _onFullscreenChange;
  32165. private _onPointerLockChange;
  32166. /**
  32167. * Creates a new engine
  32168. * @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
  32169. * @param antialias defines enable antialiasing (default: false)
  32170. * @param options defines further options to be sent to the getContext() function
  32171. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32172. */
  32173. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32174. /**
  32175. * Gets current aspect ratio
  32176. * @param viewportOwner defines the camera to use to get the aspect ratio
  32177. * @param useScreen defines if screen size must be used (or the current render target if any)
  32178. * @returns a number defining the aspect ratio
  32179. */
  32180. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32181. /**
  32182. * Gets current screen aspect ratio
  32183. * @returns a number defining the aspect ratio
  32184. */
  32185. getScreenAspectRatio(): number;
  32186. /**
  32187. * Gets host document
  32188. * @returns the host document object
  32189. */
  32190. getHostDocument(): Document;
  32191. /**
  32192. * Gets the client rect of the HTML canvas attached with the current webGL context
  32193. * @returns a client rectanglee
  32194. */
  32195. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32196. /**
  32197. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32198. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32199. * @returns true if engine is in deterministic lock step mode
  32200. */
  32201. isDeterministicLockStep(): boolean;
  32202. /**
  32203. * Gets the max steps when engine is running in deterministic lock step
  32204. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32205. * @returns the max steps
  32206. */
  32207. getLockstepMaxSteps(): number;
  32208. /**
  32209. * Force the mipmap generation for the given render target texture
  32210. * @param texture defines the render target texture to use
  32211. */
  32212. generateMipMapsForCubemap(texture: InternalTexture): void;
  32213. /** States */
  32214. /**
  32215. * Set various states to the webGL context
  32216. * @param culling defines backface culling state
  32217. * @param zOffset defines the value to apply to zOffset (0 by default)
  32218. * @param force defines if states must be applied even if cache is up to date
  32219. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32220. */
  32221. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32222. /**
  32223. * Set the z offset to apply to current rendering
  32224. * @param value defines the offset to apply
  32225. */
  32226. setZOffset(value: number): void;
  32227. /**
  32228. * Gets the current value of the zOffset
  32229. * @returns the current zOffset state
  32230. */
  32231. getZOffset(): number;
  32232. /**
  32233. * Enable or disable depth buffering
  32234. * @param enable defines the state to set
  32235. */
  32236. setDepthBuffer(enable: boolean): void;
  32237. /**
  32238. * Gets a boolean indicating if depth writing is enabled
  32239. * @returns the current depth writing state
  32240. */
  32241. getDepthWrite(): boolean;
  32242. /**
  32243. * Enable or disable depth writing
  32244. * @param enable defines the state to set
  32245. */
  32246. setDepthWrite(enable: boolean): void;
  32247. /**
  32248. * Enable or disable color writing
  32249. * @param enable defines the state to set
  32250. */
  32251. setColorWrite(enable: boolean): void;
  32252. /**
  32253. * Gets a boolean indicating if color writing is enabled
  32254. * @returns the current color writing state
  32255. */
  32256. getColorWrite(): boolean;
  32257. /**
  32258. * Sets alpha constants used by some alpha blending modes
  32259. * @param r defines the red component
  32260. * @param g defines the green component
  32261. * @param b defines the blue component
  32262. * @param a defines the alpha component
  32263. */
  32264. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32265. /**
  32266. * Sets the current alpha mode
  32267. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32268. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32269. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32270. */
  32271. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32272. /**
  32273. * Gets the current alpha mode
  32274. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32275. * @returns the current alpha mode
  32276. */
  32277. getAlphaMode(): number;
  32278. /**
  32279. * Sets the current alpha equation
  32280. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32281. */
  32282. setAlphaEquation(equation: number): void;
  32283. /**
  32284. * Gets the current alpha equation.
  32285. * @returns the current alpha equation
  32286. */
  32287. getAlphaEquation(): number;
  32288. /**
  32289. * Gets a boolean indicating if stencil buffer is enabled
  32290. * @returns the current stencil buffer state
  32291. */
  32292. getStencilBuffer(): boolean;
  32293. /**
  32294. * Enable or disable the stencil buffer
  32295. * @param enable defines if the stencil buffer must be enabled or disabled
  32296. */
  32297. setStencilBuffer(enable: boolean): void;
  32298. /**
  32299. * Gets the current stencil mask
  32300. * @returns a number defining the new stencil mask to use
  32301. */
  32302. getStencilMask(): number;
  32303. /**
  32304. * Sets the current stencil mask
  32305. * @param mask defines the new stencil mask to use
  32306. */
  32307. setStencilMask(mask: number): void;
  32308. /**
  32309. * Gets the current stencil function
  32310. * @returns a number defining the stencil function to use
  32311. */
  32312. getStencilFunction(): number;
  32313. /**
  32314. * Gets the current stencil reference value
  32315. * @returns a number defining the stencil reference value to use
  32316. */
  32317. getStencilFunctionReference(): number;
  32318. /**
  32319. * Gets the current stencil mask
  32320. * @returns a number defining the stencil mask to use
  32321. */
  32322. getStencilFunctionMask(): number;
  32323. /**
  32324. * Sets the current stencil function
  32325. * @param stencilFunc defines the new stencil function to use
  32326. */
  32327. setStencilFunction(stencilFunc: number): void;
  32328. /**
  32329. * Sets the current stencil reference
  32330. * @param reference defines the new stencil reference to use
  32331. */
  32332. setStencilFunctionReference(reference: number): void;
  32333. /**
  32334. * Sets the current stencil mask
  32335. * @param mask defines the new stencil mask to use
  32336. */
  32337. setStencilFunctionMask(mask: number): void;
  32338. /**
  32339. * Gets the current stencil operation when stencil fails
  32340. * @returns a number defining stencil operation to use when stencil fails
  32341. */
  32342. getStencilOperationFail(): number;
  32343. /**
  32344. * Gets the current stencil operation when depth fails
  32345. * @returns a number defining stencil operation to use when depth fails
  32346. */
  32347. getStencilOperationDepthFail(): number;
  32348. /**
  32349. * Gets the current stencil operation when stencil passes
  32350. * @returns a number defining stencil operation to use when stencil passes
  32351. */
  32352. getStencilOperationPass(): number;
  32353. /**
  32354. * Sets the stencil operation to use when stencil fails
  32355. * @param operation defines the stencil operation to use when stencil fails
  32356. */
  32357. setStencilOperationFail(operation: number): void;
  32358. /**
  32359. * Sets the stencil operation to use when depth fails
  32360. * @param operation defines the stencil operation to use when depth fails
  32361. */
  32362. setStencilOperationDepthFail(operation: number): void;
  32363. /**
  32364. * Sets the stencil operation to use when stencil passes
  32365. * @param operation defines the stencil operation to use when stencil passes
  32366. */
  32367. setStencilOperationPass(operation: number): void;
  32368. /**
  32369. * Sets a boolean indicating if the dithering state is enabled or disabled
  32370. * @param value defines the dithering state
  32371. */
  32372. setDitheringState(value: boolean): void;
  32373. /**
  32374. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32375. * @param value defines the rasterizer state
  32376. */
  32377. setRasterizerState(value: boolean): void;
  32378. /**
  32379. * Gets the current depth function
  32380. * @returns a number defining the depth function
  32381. */
  32382. getDepthFunction(): Nullable<number>;
  32383. /**
  32384. * Sets the current depth function
  32385. * @param depthFunc defines the function to use
  32386. */
  32387. setDepthFunction(depthFunc: number): void;
  32388. /**
  32389. * Sets the current depth function to GREATER
  32390. */
  32391. setDepthFunctionToGreater(): void;
  32392. /**
  32393. * Sets the current depth function to GEQUAL
  32394. */
  32395. setDepthFunctionToGreaterOrEqual(): void;
  32396. /**
  32397. * Sets the current depth function to LESS
  32398. */
  32399. setDepthFunctionToLess(): void;
  32400. /**
  32401. * Sets the current depth function to LEQUAL
  32402. */
  32403. setDepthFunctionToLessOrEqual(): void;
  32404. private _cachedStencilBuffer;
  32405. private _cachedStencilFunction;
  32406. private _cachedStencilMask;
  32407. private _cachedStencilOperationPass;
  32408. private _cachedStencilOperationFail;
  32409. private _cachedStencilOperationDepthFail;
  32410. private _cachedStencilReference;
  32411. /**
  32412. * Caches the the state of the stencil buffer
  32413. */
  32414. cacheStencilState(): void;
  32415. /**
  32416. * Restores the state of the stencil buffer
  32417. */
  32418. restoreStencilState(): void;
  32419. /**
  32420. * Directly set the WebGL Viewport
  32421. * @param x defines the x coordinate of the viewport (in screen space)
  32422. * @param y defines the y coordinate of the viewport (in screen space)
  32423. * @param width defines the width of the viewport (in screen space)
  32424. * @param height defines the height of the viewport (in screen space)
  32425. * @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
  32426. */
  32427. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32428. /**
  32429. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32430. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32431. * @param y defines the y-coordinate of the corner of the clear rectangle
  32432. * @param width defines the width of the clear rectangle
  32433. * @param height defines the height of the clear rectangle
  32434. * @param clearColor defines the clear color
  32435. */
  32436. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32437. /**
  32438. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32439. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32440. * @param y defines the y-coordinate of the corner of the clear rectangle
  32441. * @param width defines the width of the clear rectangle
  32442. * @param height defines the height of the clear rectangle
  32443. */
  32444. enableScissor(x: number, y: number, width: number, height: number): void;
  32445. /**
  32446. * Disable previously set scissor test rectangle
  32447. */
  32448. disableScissor(): void;
  32449. protected _reportDrawCall(): void;
  32450. /**
  32451. * Initializes a webVR display and starts listening to display change events
  32452. * The onVRDisplayChangedObservable will be notified upon these changes
  32453. * @returns The onVRDisplayChangedObservable
  32454. */
  32455. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32456. /** @hidden */
  32457. _prepareVRComponent(): void;
  32458. /** @hidden */
  32459. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32460. /** @hidden */
  32461. _submitVRFrame(): void;
  32462. /**
  32463. * Call this function to leave webVR mode
  32464. * Will do nothing if webVR is not supported or if there is no webVR device
  32465. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32466. */
  32467. disableVR(): void;
  32468. /**
  32469. * Gets a boolean indicating that the system is in VR mode and is presenting
  32470. * @returns true if VR mode is engaged
  32471. */
  32472. isVRPresenting(): boolean;
  32473. /** @hidden */
  32474. _requestVRFrame(): void;
  32475. /** @hidden */
  32476. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32477. /**
  32478. * Gets the source code of the vertex shader associated with a specific webGL program
  32479. * @param program defines the program to use
  32480. * @returns a string containing the source code of the vertex shader associated with the program
  32481. */
  32482. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32483. /**
  32484. * Gets the source code of the fragment shader associated with a specific webGL program
  32485. * @param program defines the program to use
  32486. * @returns a string containing the source code of the fragment shader associated with the program
  32487. */
  32488. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32489. /**
  32490. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32491. * @param x defines the x coordinate of the rectangle where pixels must be read
  32492. * @param y defines the y coordinate of the rectangle where pixels must be read
  32493. * @param width defines the width of the rectangle where pixels must be read
  32494. * @param height defines the height of the rectangle where pixels must be read
  32495. * @returns a Uint8Array containing RGBA colors
  32496. */
  32497. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32498. /**
  32499. * Sets a depth stencil texture from a render target to the according uniform.
  32500. * @param channel The texture channel
  32501. * @param uniform The uniform to set
  32502. * @param texture The render target texture containing the depth stencil texture to apply
  32503. */
  32504. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32505. /**
  32506. * Sets a texture to the webGL context from a postprocess
  32507. * @param channel defines the channel to use
  32508. * @param postProcess defines the source postprocess
  32509. */
  32510. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32511. /**
  32512. * Binds the output of the passed in post process to the texture channel specified
  32513. * @param channel The channel the texture should be bound to
  32514. * @param postProcess The post process which's output should be bound
  32515. */
  32516. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32517. /** @hidden */
  32518. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32519. protected _rebuildBuffers(): void;
  32520. _renderLoop(): void;
  32521. /**
  32522. * Toggle full screen mode
  32523. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32524. */
  32525. switchFullscreen(requestPointerLock: boolean): void;
  32526. /**
  32527. * Enters full screen mode
  32528. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32529. */
  32530. enterFullscreen(requestPointerLock: boolean): void;
  32531. /**
  32532. * Exits full screen mode
  32533. */
  32534. exitFullscreen(): void;
  32535. /**
  32536. * Enters Pointerlock mode
  32537. */
  32538. enterPointerlock(): void;
  32539. /**
  32540. * Exits Pointerlock mode
  32541. */
  32542. exitPointerlock(): void;
  32543. /**
  32544. * Begin a new frame
  32545. */
  32546. beginFrame(): void;
  32547. /**
  32548. * Enf the current frame
  32549. */
  32550. endFrame(): void;
  32551. resize(): void;
  32552. /**
  32553. * Set the compressed texture format to use, based on the formats you have, and the formats
  32554. * supported by the hardware / browser.
  32555. *
  32556. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32557. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32558. * to API arguments needed to compressed textures. This puts the burden on the container
  32559. * generator to house the arcane code for determining these for current & future formats.
  32560. *
  32561. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32562. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32563. *
  32564. * Note: The result of this call is not taken into account when a texture is base64.
  32565. *
  32566. * @param formatsAvailable defines the list of those format families you have created
  32567. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32568. *
  32569. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32570. * @returns The extension selected.
  32571. */
  32572. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32573. /**
  32574. * Force a specific size of the canvas
  32575. * @param width defines the new canvas' width
  32576. * @param height defines the new canvas' height
  32577. */
  32578. setSize(width: number, height: number): void;
  32579. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32580. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32581. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32582. _releaseTexture(texture: InternalTexture): void;
  32583. /**
  32584. * @hidden
  32585. * Rescales a texture
  32586. * @param source input texutre
  32587. * @param destination destination texture
  32588. * @param scene scene to use to render the resize
  32589. * @param internalFormat format to use when resizing
  32590. * @param onComplete callback to be called when resize has completed
  32591. */
  32592. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32593. /**
  32594. * Gets the current framerate
  32595. * @returns a number representing the framerate
  32596. */
  32597. getFps(): number;
  32598. /**
  32599. * Gets the time spent between current and previous frame
  32600. * @returns a number representing the delta time in ms
  32601. */
  32602. getDeltaTime(): number;
  32603. private _measureFps;
  32604. /**
  32605. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32606. * @param renderTarget The render target to set the frame buffer for
  32607. */
  32608. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32609. /**
  32610. * Update a dynamic index buffer
  32611. * @param indexBuffer defines the target index buffer
  32612. * @param indices defines the data to update
  32613. * @param offset defines the offset in the target index buffer where update should start
  32614. */
  32615. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32616. /**
  32617. * Updates the sample count of a render target texture
  32618. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32619. * @param texture defines the texture to update
  32620. * @param samples defines the sample count to set
  32621. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32622. */
  32623. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32624. /** @hidden */
  32625. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32626. dispose(): void;
  32627. private _disableTouchAction;
  32628. /**
  32629. * Display the loading screen
  32630. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32631. */
  32632. displayLoadingUI(): void;
  32633. /**
  32634. * Hide the loading screen
  32635. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32636. */
  32637. hideLoadingUI(): void;
  32638. /**
  32639. * Gets the current loading screen object
  32640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32641. */
  32642. /**
  32643. * Sets the current loading screen object
  32644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32645. */
  32646. loadingScreen: ILoadingScreen;
  32647. /**
  32648. * Sets the current loading screen text
  32649. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32650. */
  32651. loadingUIText: string;
  32652. /**
  32653. * Sets the current loading screen background color
  32654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32655. */
  32656. loadingUIBackgroundColor: string;
  32657. /** Pointerlock and fullscreen */
  32658. /**
  32659. * Ask the browser to promote the current element to pointerlock mode
  32660. * @param element defines the DOM element to promote
  32661. */
  32662. static _RequestPointerlock(element: HTMLElement): void;
  32663. /**
  32664. * Asks the browser to exit pointerlock mode
  32665. */
  32666. static _ExitPointerlock(): void;
  32667. /**
  32668. * Ask the browser to promote the current element to fullscreen rendering mode
  32669. * @param element defines the DOM element to promote
  32670. */
  32671. static _RequestFullscreen(element: HTMLElement): void;
  32672. /**
  32673. * Asks the browser to exit fullscreen mode
  32674. */
  32675. static _ExitFullscreen(): void;
  32676. }
  32677. }
  32678. declare module "babylonjs/Engines/engineStore" {
  32679. import { Nullable } from "babylonjs/types";
  32680. import { Engine } from "babylonjs/Engines/engine";
  32681. import { Scene } from "babylonjs/scene";
  32682. /**
  32683. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32684. * during the life time of the application.
  32685. */
  32686. export class EngineStore {
  32687. /** Gets the list of created engines */
  32688. static Instances: import("babylonjs/Engines/engine").Engine[];
  32689. /** @hidden */
  32690. static _LastCreatedScene: Nullable<Scene>;
  32691. /**
  32692. * Gets the latest created engine
  32693. */
  32694. static readonly LastCreatedEngine: Nullable<Engine>;
  32695. /**
  32696. * Gets the latest created scene
  32697. */
  32698. static readonly LastCreatedScene: Nullable<Scene>;
  32699. /**
  32700. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32701. * @ignorenaming
  32702. */
  32703. static UseFallbackTexture: boolean;
  32704. /**
  32705. * Texture content used if a texture cannot loaded
  32706. * @ignorenaming
  32707. */
  32708. static FallbackTexture: string;
  32709. }
  32710. }
  32711. declare module "babylonjs/Misc/promise" {
  32712. /**
  32713. * Helper class that provides a small promise polyfill
  32714. */
  32715. export class PromisePolyfill {
  32716. /**
  32717. * Static function used to check if the polyfill is required
  32718. * If this is the case then the function will inject the polyfill to window.Promise
  32719. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32720. */
  32721. static Apply(force?: boolean): void;
  32722. }
  32723. }
  32724. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32725. /**
  32726. * Interface for screenshot methods with describe argument called `size` as object with options
  32727. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32728. */
  32729. export interface IScreenshotSize {
  32730. /**
  32731. * number in pixels for canvas height
  32732. */
  32733. height?: number;
  32734. /**
  32735. * multiplier allowing render at a higher or lower resolution
  32736. * If value is defined then height and width will be ignored and taken from camera
  32737. */
  32738. precision?: number;
  32739. /**
  32740. * number in pixels for canvas width
  32741. */
  32742. width?: number;
  32743. }
  32744. }
  32745. declare module "babylonjs/Misc/tools" {
  32746. import { Nullable, float } from "babylonjs/types";
  32747. import { DomManagement } from "babylonjs/Misc/domManagement";
  32748. import { WebRequest } from "babylonjs/Misc/webRequest";
  32749. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32750. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32751. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32752. import { Camera } from "babylonjs/Cameras/camera";
  32753. import { Engine } from "babylonjs/Engines/engine";
  32754. interface IColor4Like {
  32755. r: float;
  32756. g: float;
  32757. b: float;
  32758. a: float;
  32759. }
  32760. /**
  32761. * Class containing a set of static utilities functions
  32762. */
  32763. export class Tools {
  32764. /**
  32765. * Gets or sets the base URL to use to load assets
  32766. */
  32767. static BaseUrl: string;
  32768. /**
  32769. * Enable/Disable Custom HTTP Request Headers globally.
  32770. * default = false
  32771. * @see CustomRequestHeaders
  32772. */
  32773. static UseCustomRequestHeaders: boolean;
  32774. /**
  32775. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32776. * i.e. when loading files, where the server/service expects an Authorization header
  32777. */
  32778. static CustomRequestHeaders: {
  32779. [key: string]: string;
  32780. };
  32781. /**
  32782. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32783. */
  32784. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32785. /**
  32786. * Default behaviour for cors in the application.
  32787. * It can be a string if the expected behavior is identical in the entire app.
  32788. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32789. */
  32790. static CorsBehavior: string | ((url: string | string[]) => string);
  32791. /**
  32792. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32793. * @ignorenaming
  32794. */
  32795. static UseFallbackTexture: boolean;
  32796. /**
  32797. * Use this object to register external classes like custom textures or material
  32798. * to allow the laoders to instantiate them
  32799. */
  32800. static RegisteredExternalClasses: {
  32801. [key: string]: Object;
  32802. };
  32803. /**
  32804. * Texture content used if a texture cannot loaded
  32805. * @ignorenaming
  32806. */
  32807. static fallbackTexture: string;
  32808. /**
  32809. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32810. * @param u defines the coordinate on X axis
  32811. * @param v defines the coordinate on Y axis
  32812. * @param width defines the width of the source data
  32813. * @param height defines the height of the source data
  32814. * @param pixels defines the source byte array
  32815. * @param color defines the output color
  32816. */
  32817. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32818. /**
  32819. * Interpolates between a and b via alpha
  32820. * @param a The lower value (returned when alpha = 0)
  32821. * @param b The upper value (returned when alpha = 1)
  32822. * @param alpha The interpolation-factor
  32823. * @return The mixed value
  32824. */
  32825. static Mix(a: number, b: number, alpha: number): number;
  32826. /**
  32827. * Tries to instantiate a new object from a given class name
  32828. * @param className defines the class name to instantiate
  32829. * @returns the new object or null if the system was not able to do the instantiation
  32830. */
  32831. static Instantiate(className: string): any;
  32832. /**
  32833. * Provides a slice function that will work even on IE
  32834. * @param data defines the array to slice
  32835. * @param start defines the start of the data (optional)
  32836. * @param end defines the end of the data (optional)
  32837. * @returns the new sliced array
  32838. */
  32839. static Slice<T>(data: T, start?: number, end?: number): T;
  32840. /**
  32841. * Polyfill for setImmediate
  32842. * @param action defines the action to execute after the current execution block
  32843. */
  32844. static SetImmediate(action: () => void): void;
  32845. /**
  32846. * Function indicating if a number is an exponent of 2
  32847. * @param value defines the value to test
  32848. * @returns true if the value is an exponent of 2
  32849. */
  32850. static IsExponentOfTwo(value: number): boolean;
  32851. private static _tmpFloatArray;
  32852. /**
  32853. * Returns the nearest 32-bit single precision float representation of a Number
  32854. * @param value A Number. If the parameter is of a different type, it will get converted
  32855. * to a number or to NaN if it cannot be converted
  32856. * @returns number
  32857. */
  32858. static FloatRound(value: number): number;
  32859. /**
  32860. * Extracts the filename from a path
  32861. * @param path defines the path to use
  32862. * @returns the filename
  32863. */
  32864. static GetFilename(path: string): string;
  32865. /**
  32866. * Extracts the "folder" part of a path (everything before the filename).
  32867. * @param uri The URI to extract the info from
  32868. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32869. * @returns The "folder" part of the path
  32870. */
  32871. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32872. /**
  32873. * Extracts text content from a DOM element hierarchy
  32874. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32875. */
  32876. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32877. /**
  32878. * Convert an angle in radians to degrees
  32879. * @param angle defines the angle to convert
  32880. * @returns the angle in degrees
  32881. */
  32882. static ToDegrees(angle: number): number;
  32883. /**
  32884. * Convert an angle in degrees to radians
  32885. * @param angle defines the angle to convert
  32886. * @returns the angle in radians
  32887. */
  32888. static ToRadians(angle: number): number;
  32889. /**
  32890. * Encode a buffer to a base64 string
  32891. * @param buffer defines the buffer to encode
  32892. * @returns the encoded string
  32893. */
  32894. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32895. /**
  32896. * Returns an array if obj is not an array
  32897. * @param obj defines the object to evaluate as an array
  32898. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32899. * @returns either obj directly if obj is an array or a new array containing obj
  32900. */
  32901. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32902. /**
  32903. * Gets the pointer prefix to use
  32904. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32905. */
  32906. static GetPointerPrefix(): string;
  32907. /**
  32908. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32909. * @param url define the url we are trying
  32910. * @param element define the dom element where to configure the cors policy
  32911. */
  32912. static SetCorsBehavior(url: string | string[], element: {
  32913. crossOrigin: string | null;
  32914. }): void;
  32915. /**
  32916. * Removes unwanted characters from an url
  32917. * @param url defines the url to clean
  32918. * @returns the cleaned url
  32919. */
  32920. static CleanUrl(url: string): string;
  32921. /**
  32922. * Gets or sets a function used to pre-process url before using them to load assets
  32923. */
  32924. static PreprocessUrl: (url: string) => string;
  32925. /**
  32926. * Loads an image as an HTMLImageElement.
  32927. * @param input url string, ArrayBuffer, or Blob to load
  32928. * @param onLoad callback called when the image successfully loads
  32929. * @param onError callback called when the image fails to load
  32930. * @param offlineProvider offline provider for caching
  32931. * @returns the HTMLImageElement of the loaded image
  32932. */
  32933. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32934. /**
  32935. * Loads a file
  32936. * @param url url string, ArrayBuffer, or Blob to load
  32937. * @param onSuccess callback called when the file successfully loads
  32938. * @param onProgress callback called while file is loading (if the server supports this mode)
  32939. * @param offlineProvider defines the offline provider for caching
  32940. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32941. * @param onError callback called when the file fails to load
  32942. * @returns a file request object
  32943. */
  32944. 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;
  32945. /**
  32946. * Loads a file from a url
  32947. * @param url the file url to load
  32948. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32949. */
  32950. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32951. /**
  32952. * Load a script (identified by an url). When the url returns, the
  32953. * content of this file is added into a new script element, attached to the DOM (body element)
  32954. * @param scriptUrl defines the url of the script to laod
  32955. * @param onSuccess defines the callback called when the script is loaded
  32956. * @param onError defines the callback to call if an error occurs
  32957. * @param scriptId defines the id of the script element
  32958. */
  32959. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32960. /**
  32961. * Load an asynchronous script (identified by an url). When the url returns, the
  32962. * content of this file is added into a new script element, attached to the DOM (body element)
  32963. * @param scriptUrl defines the url of the script to laod
  32964. * @param scriptId defines the id of the script element
  32965. * @returns a promise request object
  32966. */
  32967. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32968. /**
  32969. * Loads a file from a blob
  32970. * @param fileToLoad defines the blob to use
  32971. * @param callback defines the callback to call when data is loaded
  32972. * @param progressCallback defines the callback to call during loading process
  32973. * @returns a file request object
  32974. */
  32975. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32976. /**
  32977. * Loads a file
  32978. * @param fileToLoad defines the file to load
  32979. * @param callback defines the callback to call when data is loaded
  32980. * @param progressCallBack defines the callback to call during loading process
  32981. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32982. * @returns a file request object
  32983. */
  32984. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32985. /**
  32986. * Creates a data url from a given string content
  32987. * @param content defines the content to convert
  32988. * @returns the new data url link
  32989. */
  32990. static FileAsURL(content: string): string;
  32991. /**
  32992. * Format the given number to a specific decimal format
  32993. * @param value defines the number to format
  32994. * @param decimals defines the number of decimals to use
  32995. * @returns the formatted string
  32996. */
  32997. static Format(value: number, decimals?: number): string;
  32998. /**
  32999. * Tries to copy an object by duplicating every property
  33000. * @param source defines the source object
  33001. * @param destination defines the target object
  33002. * @param doNotCopyList defines a list of properties to avoid
  33003. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33004. */
  33005. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33006. /**
  33007. * Gets a boolean indicating if the given object has no own property
  33008. * @param obj defines the object to test
  33009. * @returns true if object has no own property
  33010. */
  33011. static IsEmpty(obj: any): boolean;
  33012. /**
  33013. * Function used to register events at window level
  33014. * @param windowElement defines the Window object to use
  33015. * @param events defines the events to register
  33016. */
  33017. static RegisterTopRootEvents(windowElement: Window, events: {
  33018. name: string;
  33019. handler: Nullable<(e: FocusEvent) => any>;
  33020. }[]): void;
  33021. /**
  33022. * Function used to unregister events from window level
  33023. * @param windowElement defines the Window object to use
  33024. * @param events defines the events to unregister
  33025. */
  33026. static UnregisterTopRootEvents(windowElement: Window, events: {
  33027. name: string;
  33028. handler: Nullable<(e: FocusEvent) => any>;
  33029. }[]): void;
  33030. /**
  33031. * @ignore
  33032. */
  33033. static _ScreenshotCanvas: HTMLCanvasElement;
  33034. /**
  33035. * Dumps the current bound framebuffer
  33036. * @param width defines the rendering width
  33037. * @param height defines the rendering height
  33038. * @param engine defines the hosting engine
  33039. * @param successCallback defines the callback triggered once the data are available
  33040. * @param mimeType defines the mime type of the result
  33041. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33042. */
  33043. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33044. /**
  33045. * Converts the canvas data to blob.
  33046. * This acts as a polyfill for browsers not supporting the to blob function.
  33047. * @param canvas Defines the canvas to extract the data from
  33048. * @param successCallback Defines the callback triggered once the data are available
  33049. * @param mimeType Defines the mime type of the result
  33050. */
  33051. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33052. /**
  33053. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33054. * @param successCallback defines the callback triggered once the data are available
  33055. * @param mimeType defines the mime type of the result
  33056. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33057. */
  33058. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33059. /**
  33060. * Downloads a blob in the browser
  33061. * @param blob defines the blob to download
  33062. * @param fileName defines the name of the downloaded file
  33063. */
  33064. static Download(blob: Blob, fileName: string): void;
  33065. /**
  33066. * Captures a screenshot of the current rendering
  33067. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33068. * @param engine defines the rendering engine
  33069. * @param camera defines the source camera
  33070. * @param size This parameter can be set to a single number or to an object with the
  33071. * following (optional) properties: precision, width, height. If a single number is passed,
  33072. * it will be used for both width and height. If an object is passed, the screenshot size
  33073. * will be derived from the parameters. The precision property is a multiplier allowing
  33074. * rendering at a higher or lower resolution
  33075. * @param successCallback defines the callback receives a single parameter which contains the
  33076. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33077. * src parameter of an <img> to display it
  33078. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33079. * Check your browser for supported MIME types
  33080. */
  33081. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33082. /**
  33083. * Captures a screenshot of the current rendering
  33084. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33085. * @param engine defines the rendering engine
  33086. * @param camera defines the source camera
  33087. * @param size This parameter can be set to a single number or to an object with the
  33088. * following (optional) properties: precision, width, height. If a single number is passed,
  33089. * it will be used for both width and height. If an object is passed, the screenshot size
  33090. * will be derived from the parameters. The precision property is a multiplier allowing
  33091. * rendering at a higher or lower resolution
  33092. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33093. * Check your browser for supported MIME types
  33094. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33095. * to the src parameter of an <img> to display it
  33096. */
  33097. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33098. /**
  33099. * Generates an image screenshot from the specified camera.
  33100. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33101. * @param engine The engine to use for rendering
  33102. * @param camera The camera to use for rendering
  33103. * @param size This parameter can be set to a single number or to an object with the
  33104. * following (optional) properties: precision, width, height. If a single number is passed,
  33105. * it will be used for both width and height. If an object is passed, the screenshot size
  33106. * will be derived from the parameters. The precision property is a multiplier allowing
  33107. * rendering at a higher or lower resolution
  33108. * @param successCallback The callback receives a single parameter which contains the
  33109. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33110. * src parameter of an <img> to display it
  33111. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33112. * Check your browser for supported MIME types
  33113. * @param samples Texture samples (default: 1)
  33114. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33115. * @param fileName A name for for the downloaded file.
  33116. */
  33117. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33118. /**
  33119. * Generates an image screenshot from the specified camera.
  33120. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33121. * @param engine The engine to use for rendering
  33122. * @param camera The camera to use for rendering
  33123. * @param size This parameter can be set to a single number or to an object with the
  33124. * following (optional) properties: precision, width, height. If a single number is passed,
  33125. * it will be used for both width and height. If an object is passed, the screenshot size
  33126. * will be derived from the parameters. The precision property is a multiplier allowing
  33127. * rendering at a higher or lower resolution
  33128. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33129. * Check your browser for supported MIME types
  33130. * @param samples Texture samples (default: 1)
  33131. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33132. * @param fileName A name for for the downloaded file.
  33133. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33134. * to the src parameter of an <img> to display it
  33135. */
  33136. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33137. /**
  33138. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33139. * Be aware Math.random() could cause collisions, but:
  33140. * "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"
  33141. * @returns a pseudo random id
  33142. */
  33143. static RandomId(): string;
  33144. /**
  33145. * Test if the given uri is a base64 string
  33146. * @param uri The uri to test
  33147. * @return True if the uri is a base64 string or false otherwise
  33148. */
  33149. static IsBase64(uri: string): boolean;
  33150. /**
  33151. * Decode the given base64 uri.
  33152. * @param uri The uri to decode
  33153. * @return The decoded base64 data.
  33154. */
  33155. static DecodeBase64(uri: string): ArrayBuffer;
  33156. /**
  33157. * Gets the absolute url.
  33158. * @param url the input url
  33159. * @return the absolute url
  33160. */
  33161. static GetAbsoluteUrl(url: string): string;
  33162. /**
  33163. * No log
  33164. */
  33165. static readonly NoneLogLevel: number;
  33166. /**
  33167. * Only message logs
  33168. */
  33169. static readonly MessageLogLevel: number;
  33170. /**
  33171. * Only warning logs
  33172. */
  33173. static readonly WarningLogLevel: number;
  33174. /**
  33175. * Only error logs
  33176. */
  33177. static readonly ErrorLogLevel: number;
  33178. /**
  33179. * All logs
  33180. */
  33181. static readonly AllLogLevel: number;
  33182. /**
  33183. * Gets a value indicating the number of loading errors
  33184. * @ignorenaming
  33185. */
  33186. static readonly errorsCount: number;
  33187. /**
  33188. * Callback called when a new log is added
  33189. */
  33190. static OnNewCacheEntry: (entry: string) => void;
  33191. /**
  33192. * Log a message to the console
  33193. * @param message defines the message to log
  33194. */
  33195. static Log(message: string): void;
  33196. /**
  33197. * Write a warning message to the console
  33198. * @param message defines the message to log
  33199. */
  33200. static Warn(message: string): void;
  33201. /**
  33202. * Write an error message to the console
  33203. * @param message defines the message to log
  33204. */
  33205. static Error(message: string): void;
  33206. /**
  33207. * Gets current log cache (list of logs)
  33208. */
  33209. static readonly LogCache: string;
  33210. /**
  33211. * Clears the log cache
  33212. */
  33213. static ClearLogCache(): void;
  33214. /**
  33215. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33216. */
  33217. static LogLevels: number;
  33218. /**
  33219. * Checks if the window object exists
  33220. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33221. */
  33222. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33223. /**
  33224. * No performance log
  33225. */
  33226. static readonly PerformanceNoneLogLevel: number;
  33227. /**
  33228. * Use user marks to log performance
  33229. */
  33230. static readonly PerformanceUserMarkLogLevel: number;
  33231. /**
  33232. * Log performance to the console
  33233. */
  33234. static readonly PerformanceConsoleLogLevel: number;
  33235. private static _performance;
  33236. /**
  33237. * Sets the current performance log level
  33238. */
  33239. static PerformanceLogLevel: number;
  33240. private static _StartPerformanceCounterDisabled;
  33241. private static _EndPerformanceCounterDisabled;
  33242. private static _StartUserMark;
  33243. private static _EndUserMark;
  33244. private static _StartPerformanceConsole;
  33245. private static _EndPerformanceConsole;
  33246. /**
  33247. * Starts a performance counter
  33248. */
  33249. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33250. /**
  33251. * Ends a specific performance coutner
  33252. */
  33253. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33254. /**
  33255. * Gets either window.performance.now() if supported or Date.now() else
  33256. */
  33257. static readonly Now: number;
  33258. /**
  33259. * This method will return the name of the class used to create the instance of the given object.
  33260. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33261. * @param object the object to get the class name from
  33262. * @param isType defines if the object is actually a type
  33263. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33264. */
  33265. static GetClassName(object: any, isType?: boolean): string;
  33266. /**
  33267. * Gets the first element of an array satisfying a given predicate
  33268. * @param array defines the array to browse
  33269. * @param predicate defines the predicate to use
  33270. * @returns null if not found or the element
  33271. */
  33272. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33273. /**
  33274. * This method will return the name of the full name of the class, including its owning module (if any).
  33275. * 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).
  33276. * @param object the object to get the class name from
  33277. * @param isType defines if the object is actually a type
  33278. * @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.
  33279. * @ignorenaming
  33280. */
  33281. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33282. /**
  33283. * Returns a promise that resolves after the given amount of time.
  33284. * @param delay Number of milliseconds to delay
  33285. * @returns Promise that resolves after the given amount of time
  33286. */
  33287. static DelayAsync(delay: number): Promise<void>;
  33288. }
  33289. /**
  33290. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33291. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33292. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33293. * @param name The name of the class, case should be preserved
  33294. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33295. */
  33296. export function className(name: string, module?: string): (target: Object) => void;
  33297. /**
  33298. * An implementation of a loop for asynchronous functions.
  33299. */
  33300. export class AsyncLoop {
  33301. /**
  33302. * Defines the number of iterations for the loop
  33303. */
  33304. iterations: number;
  33305. /**
  33306. * Defines the current index of the loop.
  33307. */
  33308. index: number;
  33309. private _done;
  33310. private _fn;
  33311. private _successCallback;
  33312. /**
  33313. * Constructor.
  33314. * @param iterations the number of iterations.
  33315. * @param func the function to run each iteration
  33316. * @param successCallback the callback that will be called upon succesful execution
  33317. * @param offset starting offset.
  33318. */
  33319. constructor(
  33320. /**
  33321. * Defines the number of iterations for the loop
  33322. */
  33323. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33324. /**
  33325. * Execute the next iteration. Must be called after the last iteration was finished.
  33326. */
  33327. executeNext(): void;
  33328. /**
  33329. * Break the loop and run the success callback.
  33330. */
  33331. breakLoop(): void;
  33332. /**
  33333. * Create and run an async loop.
  33334. * @param iterations the number of iterations.
  33335. * @param fn the function to run each iteration
  33336. * @param successCallback the callback that will be called upon succesful execution
  33337. * @param offset starting offset.
  33338. * @returns the created async loop object
  33339. */
  33340. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33341. /**
  33342. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33343. * @param iterations total number of iterations
  33344. * @param syncedIterations number of synchronous iterations in each async iteration.
  33345. * @param fn the function to call each iteration.
  33346. * @param callback a success call back that will be called when iterating stops.
  33347. * @param breakFunction a break condition (optional)
  33348. * @param timeout timeout settings for the setTimeout function. default - 0.
  33349. * @returns the created async loop object
  33350. */
  33351. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33352. }
  33353. }
  33354. declare module "babylonjs/Misc/stringDictionary" {
  33355. import { Nullable } from "babylonjs/types";
  33356. /**
  33357. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33358. * The underlying implementation relies on an associative array to ensure the best performances.
  33359. * The value can be anything including 'null' but except 'undefined'
  33360. */
  33361. export class StringDictionary<T> {
  33362. /**
  33363. * This will clear this dictionary and copy the content from the 'source' one.
  33364. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33365. * @param source the dictionary to take the content from and copy to this dictionary
  33366. */
  33367. copyFrom(source: StringDictionary<T>): void;
  33368. /**
  33369. * Get a value based from its key
  33370. * @param key the given key to get the matching value from
  33371. * @return the value if found, otherwise undefined is returned
  33372. */
  33373. get(key: string): T | undefined;
  33374. /**
  33375. * Get a value from its key or add it if it doesn't exist.
  33376. * This method will ensure you that a given key/data will be present in the dictionary.
  33377. * @param key the given key to get the matching value from
  33378. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33379. * The factory will only be invoked if there's no data for the given key.
  33380. * @return the value corresponding to the key.
  33381. */
  33382. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33383. /**
  33384. * Get a value from its key if present in the dictionary otherwise add it
  33385. * @param key the key to get the value from
  33386. * @param val if there's no such key/value pair in the dictionary add it with this value
  33387. * @return the value corresponding to the key
  33388. */
  33389. getOrAdd(key: string, val: T): T;
  33390. /**
  33391. * Check if there's a given key in the dictionary
  33392. * @param key the key to check for
  33393. * @return true if the key is present, false otherwise
  33394. */
  33395. contains(key: string): boolean;
  33396. /**
  33397. * Add a new key and its corresponding value
  33398. * @param key the key to add
  33399. * @param value the value corresponding to the key
  33400. * @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
  33401. */
  33402. add(key: string, value: T): boolean;
  33403. /**
  33404. * Update a specific value associated to a key
  33405. * @param key defines the key to use
  33406. * @param value defines the value to store
  33407. * @returns true if the value was updated (or false if the key was not found)
  33408. */
  33409. set(key: string, value: T): boolean;
  33410. /**
  33411. * Get the element of the given key and remove it from the dictionary
  33412. * @param key defines the key to search
  33413. * @returns the value associated with the key or null if not found
  33414. */
  33415. getAndRemove(key: string): Nullable<T>;
  33416. /**
  33417. * Remove a key/value from the dictionary.
  33418. * @param key the key to remove
  33419. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33420. */
  33421. remove(key: string): boolean;
  33422. /**
  33423. * Clear the whole content of the dictionary
  33424. */
  33425. clear(): void;
  33426. /**
  33427. * Gets the current count
  33428. */
  33429. readonly count: number;
  33430. /**
  33431. * Execute a callback on each key/val of the dictionary.
  33432. * Note that you can remove any element in this dictionary in the callback implementation
  33433. * @param callback the callback to execute on a given key/value pair
  33434. */
  33435. forEach(callback: (key: string, val: T) => void): void;
  33436. /**
  33437. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33438. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33439. * Note that you can remove any element in this dictionary in the callback implementation
  33440. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33441. * @returns the first item
  33442. */
  33443. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33444. private _count;
  33445. private _data;
  33446. }
  33447. }
  33448. declare module "babylonjs/Collisions/collisionCoordinator" {
  33449. import { Nullable } from "babylonjs/types";
  33450. import { Scene } from "babylonjs/scene";
  33451. import { Vector3 } from "babylonjs/Maths/math.vector";
  33452. import { Collider } from "babylonjs/Collisions/collider";
  33453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33454. /** @hidden */
  33455. export interface ICollisionCoordinator {
  33456. createCollider(): Collider;
  33457. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33458. init(scene: Scene): void;
  33459. }
  33460. /** @hidden */
  33461. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33462. private _scene;
  33463. private _scaledPosition;
  33464. private _scaledVelocity;
  33465. private _finalPosition;
  33466. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33467. createCollider(): Collider;
  33468. init(scene: Scene): void;
  33469. private _collideWithWorld;
  33470. }
  33471. }
  33472. declare module "babylonjs/Inputs/scene.inputManager" {
  33473. import { Nullable } from "babylonjs/types";
  33474. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33475. import { Vector2 } from "babylonjs/Maths/math.vector";
  33476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33477. import { Scene } from "babylonjs/scene";
  33478. /**
  33479. * Class used to manage all inputs for the scene.
  33480. */
  33481. export class InputManager {
  33482. /** The distance in pixel that you have to move to prevent some events */
  33483. static DragMovementThreshold: number;
  33484. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33485. static LongPressDelay: number;
  33486. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33487. static DoubleClickDelay: number;
  33488. /** If you need to check double click without raising a single click at first click, enable this flag */
  33489. static ExclusiveDoubleClickMode: boolean;
  33490. private _wheelEventName;
  33491. private _onPointerMove;
  33492. private _onPointerDown;
  33493. private _onPointerUp;
  33494. private _initClickEvent;
  33495. private _initActionManager;
  33496. private _delayedSimpleClick;
  33497. private _delayedSimpleClickTimeout;
  33498. private _previousDelayedSimpleClickTimeout;
  33499. private _meshPickProceed;
  33500. private _previousButtonPressed;
  33501. private _currentPickResult;
  33502. private _previousPickResult;
  33503. private _totalPointersPressed;
  33504. private _doubleClickOccured;
  33505. private _pointerOverMesh;
  33506. private _pickedDownMesh;
  33507. private _pickedUpMesh;
  33508. private _pointerX;
  33509. private _pointerY;
  33510. private _unTranslatedPointerX;
  33511. private _unTranslatedPointerY;
  33512. private _startingPointerPosition;
  33513. private _previousStartingPointerPosition;
  33514. private _startingPointerTime;
  33515. private _previousStartingPointerTime;
  33516. private _pointerCaptures;
  33517. private _onKeyDown;
  33518. private _onKeyUp;
  33519. private _onCanvasFocusObserver;
  33520. private _onCanvasBlurObserver;
  33521. private _scene;
  33522. /**
  33523. * Creates a new InputManager
  33524. * @param scene defines the hosting scene
  33525. */
  33526. constructor(scene: Scene);
  33527. /**
  33528. * Gets the mesh that is currently under the pointer
  33529. */
  33530. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33531. /**
  33532. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33533. */
  33534. readonly unTranslatedPointer: Vector2;
  33535. /**
  33536. * Gets or sets the current on-screen X position of the pointer
  33537. */
  33538. pointerX: number;
  33539. /**
  33540. * Gets or sets the current on-screen Y position of the pointer
  33541. */
  33542. pointerY: number;
  33543. private _updatePointerPosition;
  33544. private _processPointerMove;
  33545. private _setRayOnPointerInfo;
  33546. private _checkPrePointerObservable;
  33547. /**
  33548. * Use this method to simulate a pointer move on a mesh
  33549. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33550. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33551. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33552. */
  33553. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33554. /**
  33555. * Use this method to simulate a pointer down on a mesh
  33556. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33557. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33558. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33559. */
  33560. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33561. private _processPointerDown;
  33562. /** @hidden */
  33563. _isPointerSwiping(): boolean;
  33564. /**
  33565. * Use this method to simulate a pointer up on a mesh
  33566. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33567. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33568. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33569. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33570. */
  33571. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33572. private _processPointerUp;
  33573. /**
  33574. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33575. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33576. * @returns true if the pointer was captured
  33577. */
  33578. isPointerCaptured(pointerId?: number): boolean;
  33579. /**
  33580. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33581. * @param attachUp defines if you want to attach events to pointerup
  33582. * @param attachDown defines if you want to attach events to pointerdown
  33583. * @param attachMove defines if you want to attach events to pointermove
  33584. */
  33585. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33586. /**
  33587. * Detaches all event handlers
  33588. */
  33589. detachControl(): void;
  33590. /**
  33591. * Force the value of meshUnderPointer
  33592. * @param mesh defines the mesh to use
  33593. */
  33594. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33595. /**
  33596. * Gets the mesh under the pointer
  33597. * @returns a Mesh or null if no mesh is under the pointer
  33598. */
  33599. getPointerOverMesh(): Nullable<AbstractMesh>;
  33600. }
  33601. }
  33602. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33603. /**
  33604. * Helper class used to generate session unique ID
  33605. */
  33606. export class UniqueIdGenerator {
  33607. private static _UniqueIdCounter;
  33608. /**
  33609. * Gets an unique (relatively to the current scene) Id
  33610. */
  33611. static readonly UniqueId: number;
  33612. }
  33613. }
  33614. declare module "babylonjs/Animations/animationGroup" {
  33615. import { Animatable } from "babylonjs/Animations/animatable";
  33616. import { Animation } from "babylonjs/Animations/animation";
  33617. import { Scene, IDisposable } from "babylonjs/scene";
  33618. import { Observable } from "babylonjs/Misc/observable";
  33619. import { Nullable } from "babylonjs/types";
  33620. import "babylonjs/Animations/animatable";
  33621. /**
  33622. * This class defines the direct association between an animation and a target
  33623. */
  33624. export class TargetedAnimation {
  33625. /**
  33626. * Animation to perform
  33627. */
  33628. animation: Animation;
  33629. /**
  33630. * Target to animate
  33631. */
  33632. target: any;
  33633. /**
  33634. * Serialize the object
  33635. * @returns the JSON object representing the current entity
  33636. */
  33637. serialize(): any;
  33638. }
  33639. /**
  33640. * Use this class to create coordinated animations on multiple targets
  33641. */
  33642. export class AnimationGroup implements IDisposable {
  33643. /** The name of the animation group */
  33644. name: string;
  33645. private _scene;
  33646. private _targetedAnimations;
  33647. private _animatables;
  33648. private _from;
  33649. private _to;
  33650. private _isStarted;
  33651. private _isPaused;
  33652. private _speedRatio;
  33653. private _loopAnimation;
  33654. /**
  33655. * Gets or sets the unique id of the node
  33656. */
  33657. uniqueId: number;
  33658. /**
  33659. * This observable will notify when one animation have ended
  33660. */
  33661. onAnimationEndObservable: Observable<TargetedAnimation>;
  33662. /**
  33663. * Observer raised when one animation loops
  33664. */
  33665. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33666. /**
  33667. * This observable will notify when all animations have ended.
  33668. */
  33669. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33670. /**
  33671. * This observable will notify when all animations have paused.
  33672. */
  33673. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33674. /**
  33675. * This observable will notify when all animations are playing.
  33676. */
  33677. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33678. /**
  33679. * Gets the first frame
  33680. */
  33681. readonly from: number;
  33682. /**
  33683. * Gets the last frame
  33684. */
  33685. readonly to: number;
  33686. /**
  33687. * Define if the animations are started
  33688. */
  33689. readonly isStarted: boolean;
  33690. /**
  33691. * Gets a value indicating that the current group is playing
  33692. */
  33693. readonly isPlaying: boolean;
  33694. /**
  33695. * Gets or sets the speed ratio to use for all animations
  33696. */
  33697. /**
  33698. * Gets or sets the speed ratio to use for all animations
  33699. */
  33700. speedRatio: number;
  33701. /**
  33702. * Gets or sets if all animations should loop or not
  33703. */
  33704. loopAnimation: boolean;
  33705. /**
  33706. * Gets the targeted animations for this animation group
  33707. */
  33708. readonly targetedAnimations: Array<TargetedAnimation>;
  33709. /**
  33710. * returning the list of animatables controlled by this animation group.
  33711. */
  33712. readonly animatables: Array<Animatable>;
  33713. /**
  33714. * Instantiates a new Animation Group.
  33715. * This helps managing several animations at once.
  33716. * @see http://doc.babylonjs.com/how_to/group
  33717. * @param name Defines the name of the group
  33718. * @param scene Defines the scene the group belongs to
  33719. */
  33720. constructor(
  33721. /** The name of the animation group */
  33722. name: string, scene?: Nullable<Scene>);
  33723. /**
  33724. * Add an animation (with its target) in the group
  33725. * @param animation defines the animation we want to add
  33726. * @param target defines the target of the animation
  33727. * @returns the TargetedAnimation object
  33728. */
  33729. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33730. /**
  33731. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33732. * It can add constant keys at begin or end
  33733. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33734. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33735. * @returns the animation group
  33736. */
  33737. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33738. /**
  33739. * Start all animations on given targets
  33740. * @param loop defines if animations must loop
  33741. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33742. * @param from defines the from key (optional)
  33743. * @param to defines the to key (optional)
  33744. * @returns the current animation group
  33745. */
  33746. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33747. /**
  33748. * Pause all animations
  33749. * @returns the animation group
  33750. */
  33751. pause(): AnimationGroup;
  33752. /**
  33753. * Play all animations to initial state
  33754. * This function will start() the animations if they were not started or will restart() them if they were paused
  33755. * @param loop defines if animations must loop
  33756. * @returns the animation group
  33757. */
  33758. play(loop?: boolean): AnimationGroup;
  33759. /**
  33760. * Reset all animations to initial state
  33761. * @returns the animation group
  33762. */
  33763. reset(): AnimationGroup;
  33764. /**
  33765. * Restart animations from key 0
  33766. * @returns the animation group
  33767. */
  33768. restart(): AnimationGroup;
  33769. /**
  33770. * Stop all animations
  33771. * @returns the animation group
  33772. */
  33773. stop(): AnimationGroup;
  33774. /**
  33775. * Set animation weight for all animatables
  33776. * @param weight defines the weight to use
  33777. * @return the animationGroup
  33778. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33779. */
  33780. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33781. /**
  33782. * Synchronize and normalize all animatables with a source animatable
  33783. * @param root defines the root animatable to synchronize with
  33784. * @return the animationGroup
  33785. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33786. */
  33787. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33788. /**
  33789. * Goes to a specific frame in this animation group
  33790. * @param frame the frame number to go to
  33791. * @return the animationGroup
  33792. */
  33793. goToFrame(frame: number): AnimationGroup;
  33794. /**
  33795. * Dispose all associated resources
  33796. */
  33797. dispose(): void;
  33798. private _checkAnimationGroupEnded;
  33799. /**
  33800. * Clone the current animation group and returns a copy
  33801. * @param newName defines the name of the new group
  33802. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33803. * @returns the new aniamtion group
  33804. */
  33805. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33806. /**
  33807. * Serializes the animationGroup to an object
  33808. * @returns Serialized object
  33809. */
  33810. serialize(): any;
  33811. /**
  33812. * Returns a new AnimationGroup object parsed from the source provided.
  33813. * @param parsedAnimationGroup defines the source
  33814. * @param scene defines the scene that will receive the animationGroup
  33815. * @returns a new AnimationGroup
  33816. */
  33817. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33818. /**
  33819. * Returns the string "AnimationGroup"
  33820. * @returns "AnimationGroup"
  33821. */
  33822. getClassName(): string;
  33823. /**
  33824. * Creates a detailled string about the object
  33825. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33826. * @returns a string representing the object
  33827. */
  33828. toString(fullDetails?: boolean): string;
  33829. }
  33830. }
  33831. declare module "babylonjs/scene" {
  33832. import { Nullable } from "babylonjs/types";
  33833. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33834. import { Observable } from "babylonjs/Misc/observable";
  33835. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33836. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33837. import { Geometry } from "babylonjs/Meshes/geometry";
  33838. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33839. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33841. import { Mesh } from "babylonjs/Meshes/mesh";
  33842. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33843. import { Bone } from "babylonjs/Bones/bone";
  33844. import { Skeleton } from "babylonjs/Bones/skeleton";
  33845. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33846. import { Camera } from "babylonjs/Cameras/camera";
  33847. import { AbstractScene } from "babylonjs/abstractScene";
  33848. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33849. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33850. import { Material } from "babylonjs/Materials/material";
  33851. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33852. import { Effect } from "babylonjs/Materials/effect";
  33853. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33854. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33855. import { Light } from "babylonjs/Lights/light";
  33856. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33857. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33858. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33859. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33860. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33861. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33862. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33863. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33864. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33865. import { Engine } from "babylonjs/Engines/engine";
  33866. import { Node } from "babylonjs/node";
  33867. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33868. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33869. import { WebRequest } from "babylonjs/Misc/webRequest";
  33870. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33871. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33872. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33873. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33874. import { Plane } from "babylonjs/Maths/math.plane";
  33875. import { Ray } from "babylonjs/Culling/ray";
  33876. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33877. import { Animation } from "babylonjs/Animations/animation";
  33878. import { Animatable } from "babylonjs/Animations/animatable";
  33879. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33880. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33881. import { Collider } from "babylonjs/Collisions/collider";
  33882. /**
  33883. * Define an interface for all classes that will hold resources
  33884. */
  33885. export interface IDisposable {
  33886. /**
  33887. * Releases all held resources
  33888. */
  33889. dispose(): void;
  33890. }
  33891. /** Interface defining initialization parameters for Scene class */
  33892. export interface SceneOptions {
  33893. /**
  33894. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33895. * It will improve performance when the number of geometries becomes important.
  33896. */
  33897. useGeometryUniqueIdsMap?: boolean;
  33898. /**
  33899. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33900. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33901. */
  33902. useMaterialMeshMap?: boolean;
  33903. /**
  33904. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33905. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33906. */
  33907. useClonedMeshhMap?: boolean;
  33908. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33909. virtual?: boolean;
  33910. }
  33911. /**
  33912. * Represents a scene to be rendered by the engine.
  33913. * @see http://doc.babylonjs.com/features/scene
  33914. */
  33915. export class Scene extends AbstractScene implements IAnimatable {
  33916. /** The fog is deactivated */
  33917. static readonly FOGMODE_NONE: number;
  33918. /** The fog density is following an exponential function */
  33919. static readonly FOGMODE_EXP: number;
  33920. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33921. static readonly FOGMODE_EXP2: number;
  33922. /** The fog density is following a linear function. */
  33923. static readonly FOGMODE_LINEAR: number;
  33924. /**
  33925. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33926. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33927. */
  33928. static MinDeltaTime: number;
  33929. /**
  33930. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33931. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33932. */
  33933. static MaxDeltaTime: number;
  33934. /**
  33935. * Factory used to create the default material.
  33936. * @param name The name of the material to create
  33937. * @param scene The scene to create the material for
  33938. * @returns The default material
  33939. */
  33940. static DefaultMaterialFactory(scene: Scene): Material;
  33941. /**
  33942. * Factory used to create the a collision coordinator.
  33943. * @returns The collision coordinator
  33944. */
  33945. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33946. /** @hidden */
  33947. _inputManager: InputManager;
  33948. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33949. cameraToUseForPointers: Nullable<Camera>;
  33950. /** @hidden */
  33951. readonly _isScene: boolean;
  33952. /**
  33953. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33954. */
  33955. autoClear: boolean;
  33956. /**
  33957. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33958. */
  33959. autoClearDepthAndStencil: boolean;
  33960. /**
  33961. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33962. */
  33963. clearColor: Color4;
  33964. /**
  33965. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33966. */
  33967. ambientColor: Color3;
  33968. /**
  33969. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33970. * It should only be one of the following (if not the default embedded one):
  33971. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33972. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33973. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33974. * The material properties need to be setup according to the type of texture in use.
  33975. */
  33976. environmentBRDFTexture: BaseTexture;
  33977. /** @hidden */
  33978. protected _environmentTexture: Nullable<BaseTexture>;
  33979. /**
  33980. * Texture used in all pbr material as the reflection texture.
  33981. * As in the majority of the scene they are the same (exception for multi room and so on),
  33982. * this is easier to reference from here than from all the materials.
  33983. */
  33984. /**
  33985. * Texture used in all pbr material as the reflection texture.
  33986. * As in the majority of the scene they are the same (exception for multi room and so on),
  33987. * this is easier to set here than in all the materials.
  33988. */
  33989. environmentTexture: Nullable<BaseTexture>;
  33990. /** @hidden */
  33991. protected _environmentIntensity: number;
  33992. /**
  33993. * Intensity of the environment in all pbr material.
  33994. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33995. * As in the majority of the scene they are the same (exception for multi room and so on),
  33996. * this is easier to reference from here than from all the materials.
  33997. */
  33998. /**
  33999. * Intensity of the environment in all pbr material.
  34000. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34001. * As in the majority of the scene they are the same (exception for multi room and so on),
  34002. * this is easier to set here than in all the materials.
  34003. */
  34004. environmentIntensity: number;
  34005. /** @hidden */
  34006. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34007. /**
  34008. * Default image processing configuration used either in the rendering
  34009. * Forward main pass or through the imageProcessingPostProcess if present.
  34010. * As in the majority of the scene they are the same (exception for multi camera),
  34011. * this is easier to reference from here than from all the materials and post process.
  34012. *
  34013. * No setter as we it is a shared configuration, you can set the values instead.
  34014. */
  34015. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34016. private _forceWireframe;
  34017. /**
  34018. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34019. */
  34020. forceWireframe: boolean;
  34021. private _forcePointsCloud;
  34022. /**
  34023. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34024. */
  34025. forcePointsCloud: boolean;
  34026. /**
  34027. * Gets or sets the active clipplane 1
  34028. */
  34029. clipPlane: Nullable<Plane>;
  34030. /**
  34031. * Gets or sets the active clipplane 2
  34032. */
  34033. clipPlane2: Nullable<Plane>;
  34034. /**
  34035. * Gets or sets the active clipplane 3
  34036. */
  34037. clipPlane3: Nullable<Plane>;
  34038. /**
  34039. * Gets or sets the active clipplane 4
  34040. */
  34041. clipPlane4: Nullable<Plane>;
  34042. /**
  34043. * Gets or sets a boolean indicating if animations are enabled
  34044. */
  34045. animationsEnabled: boolean;
  34046. private _animationPropertiesOverride;
  34047. /**
  34048. * Gets or sets the animation properties override
  34049. */
  34050. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34051. /**
  34052. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34053. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34054. */
  34055. useConstantAnimationDeltaTime: boolean;
  34056. /**
  34057. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34058. * Please note that it requires to run a ray cast through the scene on every frame
  34059. */
  34060. constantlyUpdateMeshUnderPointer: boolean;
  34061. /**
  34062. * Defines the HTML cursor to use when hovering over interactive elements
  34063. */
  34064. hoverCursor: string;
  34065. /**
  34066. * Defines the HTML default cursor to use (empty by default)
  34067. */
  34068. defaultCursor: string;
  34069. /**
  34070. * This is used to call preventDefault() on pointer down
  34071. * in order to block unwanted artifacts like system double clicks
  34072. */
  34073. preventDefaultOnPointerDown: boolean;
  34074. /**
  34075. * This is used to call preventDefault() on pointer up
  34076. * in order to block unwanted artifacts like system double clicks
  34077. */
  34078. preventDefaultOnPointerUp: boolean;
  34079. /**
  34080. * Gets or sets user defined metadata
  34081. */
  34082. metadata: any;
  34083. /**
  34084. * For internal use only. Please do not use.
  34085. */
  34086. reservedDataStore: any;
  34087. /**
  34088. * Gets the name of the plugin used to load this scene (null by default)
  34089. */
  34090. loadingPluginName: string;
  34091. /**
  34092. * Use this array to add regular expressions used to disable offline support for specific urls
  34093. */
  34094. disableOfflineSupportExceptionRules: RegExp[];
  34095. /**
  34096. * An event triggered when the scene is disposed.
  34097. */
  34098. onDisposeObservable: Observable<Scene>;
  34099. private _onDisposeObserver;
  34100. /** Sets a function to be executed when this scene is disposed. */
  34101. onDispose: () => void;
  34102. /**
  34103. * An event triggered before rendering the scene (right after animations and physics)
  34104. */
  34105. onBeforeRenderObservable: Observable<Scene>;
  34106. private _onBeforeRenderObserver;
  34107. /** Sets a function to be executed before rendering this scene */
  34108. beforeRender: Nullable<() => void>;
  34109. /**
  34110. * An event triggered after rendering the scene
  34111. */
  34112. onAfterRenderObservable: Observable<Scene>;
  34113. /**
  34114. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34115. */
  34116. onAfterRenderCameraObservable: Observable<Camera>;
  34117. private _onAfterRenderObserver;
  34118. /** Sets a function to be executed after rendering this scene */
  34119. afterRender: Nullable<() => void>;
  34120. /**
  34121. * An event triggered before animating the scene
  34122. */
  34123. onBeforeAnimationsObservable: Observable<Scene>;
  34124. /**
  34125. * An event triggered after animations processing
  34126. */
  34127. onAfterAnimationsObservable: Observable<Scene>;
  34128. /**
  34129. * An event triggered before draw calls are ready to be sent
  34130. */
  34131. onBeforeDrawPhaseObservable: Observable<Scene>;
  34132. /**
  34133. * An event triggered after draw calls have been sent
  34134. */
  34135. onAfterDrawPhaseObservable: Observable<Scene>;
  34136. /**
  34137. * An event triggered when the scene is ready
  34138. */
  34139. onReadyObservable: Observable<Scene>;
  34140. /**
  34141. * An event triggered before rendering a camera
  34142. */
  34143. onBeforeCameraRenderObservable: Observable<Camera>;
  34144. private _onBeforeCameraRenderObserver;
  34145. /** Sets a function to be executed before rendering a camera*/
  34146. beforeCameraRender: () => void;
  34147. /**
  34148. * An event triggered after rendering a camera
  34149. */
  34150. onAfterCameraRenderObservable: Observable<Camera>;
  34151. private _onAfterCameraRenderObserver;
  34152. /** Sets a function to be executed after rendering a camera*/
  34153. afterCameraRender: () => void;
  34154. /**
  34155. * An event triggered when active meshes evaluation is about to start
  34156. */
  34157. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34158. /**
  34159. * An event triggered when active meshes evaluation is done
  34160. */
  34161. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34162. /**
  34163. * An event triggered when particles rendering is about to start
  34164. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34165. */
  34166. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34167. /**
  34168. * An event triggered when particles rendering is done
  34169. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34170. */
  34171. onAfterParticlesRenderingObservable: Observable<Scene>;
  34172. /**
  34173. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34174. */
  34175. onDataLoadedObservable: Observable<Scene>;
  34176. /**
  34177. * An event triggered when a camera is created
  34178. */
  34179. onNewCameraAddedObservable: Observable<Camera>;
  34180. /**
  34181. * An event triggered when a camera is removed
  34182. */
  34183. onCameraRemovedObservable: Observable<Camera>;
  34184. /**
  34185. * An event triggered when a light is created
  34186. */
  34187. onNewLightAddedObservable: Observable<Light>;
  34188. /**
  34189. * An event triggered when a light is removed
  34190. */
  34191. onLightRemovedObservable: Observable<Light>;
  34192. /**
  34193. * An event triggered when a geometry is created
  34194. */
  34195. onNewGeometryAddedObservable: Observable<Geometry>;
  34196. /**
  34197. * An event triggered when a geometry is removed
  34198. */
  34199. onGeometryRemovedObservable: Observable<Geometry>;
  34200. /**
  34201. * An event triggered when a transform node is created
  34202. */
  34203. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34204. /**
  34205. * An event triggered when a transform node is removed
  34206. */
  34207. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34208. /**
  34209. * An event triggered when a mesh is created
  34210. */
  34211. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34212. /**
  34213. * An event triggered when a mesh is removed
  34214. */
  34215. onMeshRemovedObservable: Observable<AbstractMesh>;
  34216. /**
  34217. * An event triggered when a skeleton is created
  34218. */
  34219. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34220. /**
  34221. * An event triggered when a skeleton is removed
  34222. */
  34223. onSkeletonRemovedObservable: Observable<Skeleton>;
  34224. /**
  34225. * An event triggered when a material is created
  34226. */
  34227. onNewMaterialAddedObservable: Observable<Material>;
  34228. /**
  34229. * An event triggered when a material is removed
  34230. */
  34231. onMaterialRemovedObservable: Observable<Material>;
  34232. /**
  34233. * An event triggered when a texture is created
  34234. */
  34235. onNewTextureAddedObservable: Observable<BaseTexture>;
  34236. /**
  34237. * An event triggered when a texture is removed
  34238. */
  34239. onTextureRemovedObservable: Observable<BaseTexture>;
  34240. /**
  34241. * An event triggered when render targets are about to be rendered
  34242. * Can happen multiple times per frame.
  34243. */
  34244. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34245. /**
  34246. * An event triggered when render targets were rendered.
  34247. * Can happen multiple times per frame.
  34248. */
  34249. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34250. /**
  34251. * An event triggered before calculating deterministic simulation step
  34252. */
  34253. onBeforeStepObservable: Observable<Scene>;
  34254. /**
  34255. * An event triggered after calculating deterministic simulation step
  34256. */
  34257. onAfterStepObservable: Observable<Scene>;
  34258. /**
  34259. * An event triggered when the activeCamera property is updated
  34260. */
  34261. onActiveCameraChanged: Observable<Scene>;
  34262. /**
  34263. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34264. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34265. * 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)
  34266. */
  34267. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34268. /**
  34269. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34270. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34271. * 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)
  34272. */
  34273. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34274. /**
  34275. * This Observable will when a mesh has been imported into the scene.
  34276. */
  34277. onMeshImportedObservable: Observable<AbstractMesh>;
  34278. /**
  34279. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34280. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34281. */
  34282. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34283. /** @hidden */
  34284. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34285. /**
  34286. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34287. */
  34288. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34289. /**
  34290. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34291. */
  34292. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34293. /**
  34294. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34295. */
  34296. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34297. /** Callback called when a pointer move is detected */
  34298. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34299. /** Callback called when a pointer down is detected */
  34300. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34301. /** Callback called when a pointer up is detected */
  34302. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34303. /** Callback called when a pointer pick is detected */
  34304. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34305. /**
  34306. * 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).
  34307. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34308. */
  34309. onPrePointerObservable: Observable<PointerInfoPre>;
  34310. /**
  34311. * Observable event triggered each time an input event is received from the rendering canvas
  34312. */
  34313. onPointerObservable: Observable<PointerInfo>;
  34314. /**
  34315. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34316. */
  34317. readonly unTranslatedPointer: Vector2;
  34318. /**
  34319. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34320. */
  34321. static DragMovementThreshold: number;
  34322. /**
  34323. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34324. */
  34325. static LongPressDelay: number;
  34326. /**
  34327. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34328. */
  34329. static DoubleClickDelay: number;
  34330. /** If you need to check double click without raising a single click at first click, enable this flag */
  34331. static ExclusiveDoubleClickMode: boolean;
  34332. /** @hidden */
  34333. _mirroredCameraPosition: Nullable<Vector3>;
  34334. /**
  34335. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34336. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34337. */
  34338. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34339. /**
  34340. * Observable event triggered each time an keyboard event is received from the hosting window
  34341. */
  34342. onKeyboardObservable: Observable<KeyboardInfo>;
  34343. private _useRightHandedSystem;
  34344. /**
  34345. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34346. */
  34347. useRightHandedSystem: boolean;
  34348. private _timeAccumulator;
  34349. private _currentStepId;
  34350. private _currentInternalStep;
  34351. /**
  34352. * Sets the step Id used by deterministic lock step
  34353. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34354. * @param newStepId defines the step Id
  34355. */
  34356. setStepId(newStepId: number): void;
  34357. /**
  34358. * Gets the step Id used by deterministic lock step
  34359. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34360. * @returns the step Id
  34361. */
  34362. getStepId(): number;
  34363. /**
  34364. * Gets the internal step used by deterministic lock step
  34365. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34366. * @returns the internal step
  34367. */
  34368. getInternalStep(): number;
  34369. private _fogEnabled;
  34370. /**
  34371. * Gets or sets a boolean indicating if fog is enabled on this scene
  34372. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34373. * (Default is true)
  34374. */
  34375. fogEnabled: boolean;
  34376. private _fogMode;
  34377. /**
  34378. * Gets or sets the fog mode to use
  34379. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34380. * | mode | value |
  34381. * | --- | --- |
  34382. * | FOGMODE_NONE | 0 |
  34383. * | FOGMODE_EXP | 1 |
  34384. * | FOGMODE_EXP2 | 2 |
  34385. * | FOGMODE_LINEAR | 3 |
  34386. */
  34387. fogMode: number;
  34388. /**
  34389. * Gets or sets the fog color to use
  34390. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34391. * (Default is Color3(0.2, 0.2, 0.3))
  34392. */
  34393. fogColor: Color3;
  34394. /**
  34395. * Gets or sets the fog density to use
  34396. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34397. * (Default is 0.1)
  34398. */
  34399. fogDensity: number;
  34400. /**
  34401. * Gets or sets the fog start distance to use
  34402. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34403. * (Default is 0)
  34404. */
  34405. fogStart: number;
  34406. /**
  34407. * Gets or sets the fog end distance to use
  34408. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34409. * (Default is 1000)
  34410. */
  34411. fogEnd: number;
  34412. private _shadowsEnabled;
  34413. /**
  34414. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34415. */
  34416. shadowsEnabled: boolean;
  34417. private _lightsEnabled;
  34418. /**
  34419. * Gets or sets a boolean indicating if lights are enabled on this scene
  34420. */
  34421. lightsEnabled: boolean;
  34422. /** All of the active cameras added to this scene. */
  34423. activeCameras: Camera[];
  34424. /** @hidden */
  34425. _activeCamera: Nullable<Camera>;
  34426. /** Gets or sets the current active camera */
  34427. activeCamera: Nullable<Camera>;
  34428. private _defaultMaterial;
  34429. /** The default material used on meshes when no material is affected */
  34430. /** The default material used on meshes when no material is affected */
  34431. defaultMaterial: Material;
  34432. private _texturesEnabled;
  34433. /**
  34434. * Gets or sets a boolean indicating if textures are enabled on this scene
  34435. */
  34436. texturesEnabled: boolean;
  34437. /**
  34438. * Gets or sets a boolean indicating if particles are enabled on this scene
  34439. */
  34440. particlesEnabled: boolean;
  34441. /**
  34442. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34443. */
  34444. spritesEnabled: boolean;
  34445. private _skeletonsEnabled;
  34446. /**
  34447. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34448. */
  34449. skeletonsEnabled: boolean;
  34450. /**
  34451. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34452. */
  34453. lensFlaresEnabled: boolean;
  34454. /**
  34455. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34456. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34457. */
  34458. collisionsEnabled: boolean;
  34459. private _collisionCoordinator;
  34460. /** @hidden */
  34461. readonly collisionCoordinator: ICollisionCoordinator;
  34462. /**
  34463. * Defines the gravity applied to this scene (used only for collisions)
  34464. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34465. */
  34466. gravity: Vector3;
  34467. /**
  34468. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34469. */
  34470. postProcessesEnabled: boolean;
  34471. /**
  34472. * The list of postprocesses added to the scene
  34473. */
  34474. postProcesses: PostProcess[];
  34475. /**
  34476. * Gets the current postprocess manager
  34477. */
  34478. postProcessManager: PostProcessManager;
  34479. /**
  34480. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34481. */
  34482. renderTargetsEnabled: boolean;
  34483. /**
  34484. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34485. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34486. */
  34487. dumpNextRenderTargets: boolean;
  34488. /**
  34489. * The list of user defined render targets added to the scene
  34490. */
  34491. customRenderTargets: RenderTargetTexture[];
  34492. /**
  34493. * Defines if texture loading must be delayed
  34494. * If true, textures will only be loaded when they need to be rendered
  34495. */
  34496. useDelayedTextureLoading: boolean;
  34497. /**
  34498. * Gets the list of meshes imported to the scene through SceneLoader
  34499. */
  34500. importedMeshesFiles: String[];
  34501. /**
  34502. * Gets or sets a boolean indicating if probes are enabled on this scene
  34503. */
  34504. probesEnabled: boolean;
  34505. /**
  34506. * Gets or sets the current offline provider to use to store scene data
  34507. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34508. */
  34509. offlineProvider: IOfflineProvider;
  34510. /**
  34511. * Gets or sets the action manager associated with the scene
  34512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34513. */
  34514. actionManager: AbstractActionManager;
  34515. private _meshesForIntersections;
  34516. /**
  34517. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34518. */
  34519. proceduralTexturesEnabled: boolean;
  34520. private _engine;
  34521. private _totalVertices;
  34522. /** @hidden */
  34523. _activeIndices: PerfCounter;
  34524. /** @hidden */
  34525. _activeParticles: PerfCounter;
  34526. /** @hidden */
  34527. _activeBones: PerfCounter;
  34528. private _animationRatio;
  34529. /** @hidden */
  34530. _animationTimeLast: number;
  34531. /** @hidden */
  34532. _animationTime: number;
  34533. /**
  34534. * Gets or sets a general scale for animation speed
  34535. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34536. */
  34537. animationTimeScale: number;
  34538. /** @hidden */
  34539. _cachedMaterial: Nullable<Material>;
  34540. /** @hidden */
  34541. _cachedEffect: Nullable<Effect>;
  34542. /** @hidden */
  34543. _cachedVisibility: Nullable<number>;
  34544. private _renderId;
  34545. private _frameId;
  34546. private _executeWhenReadyTimeoutId;
  34547. private _intermediateRendering;
  34548. private _viewUpdateFlag;
  34549. private _projectionUpdateFlag;
  34550. /** @hidden */
  34551. _toBeDisposed: Nullable<IDisposable>[];
  34552. private _activeRequests;
  34553. /** @hidden */
  34554. _pendingData: any[];
  34555. private _isDisposed;
  34556. /**
  34557. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34558. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34559. */
  34560. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34561. private _activeMeshes;
  34562. private _processedMaterials;
  34563. private _renderTargets;
  34564. /** @hidden */
  34565. _activeParticleSystems: SmartArray<IParticleSystem>;
  34566. private _activeSkeletons;
  34567. private _softwareSkinnedMeshes;
  34568. private _renderingManager;
  34569. /** @hidden */
  34570. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34571. private _transformMatrix;
  34572. private _sceneUbo;
  34573. /** @hidden */
  34574. _viewMatrix: Matrix;
  34575. private _projectionMatrix;
  34576. /** @hidden */
  34577. _forcedViewPosition: Nullable<Vector3>;
  34578. /** @hidden */
  34579. _frustumPlanes: Plane[];
  34580. /**
  34581. * Gets the list of frustum planes (built from the active camera)
  34582. */
  34583. readonly frustumPlanes: Plane[];
  34584. /**
  34585. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34586. * This is useful if there are more lights that the maximum simulteanous authorized
  34587. */
  34588. requireLightSorting: boolean;
  34589. /** @hidden */
  34590. readonly useMaterialMeshMap: boolean;
  34591. /** @hidden */
  34592. readonly useClonedMeshhMap: boolean;
  34593. private _externalData;
  34594. private _uid;
  34595. /**
  34596. * @hidden
  34597. * Backing store of defined scene components.
  34598. */
  34599. _components: ISceneComponent[];
  34600. /**
  34601. * @hidden
  34602. * Backing store of defined scene components.
  34603. */
  34604. _serializableComponents: ISceneSerializableComponent[];
  34605. /**
  34606. * List of components to register on the next registration step.
  34607. */
  34608. private _transientComponents;
  34609. /**
  34610. * Registers the transient components if needed.
  34611. */
  34612. private _registerTransientComponents;
  34613. /**
  34614. * @hidden
  34615. * Add a component to the scene.
  34616. * Note that the ccomponent could be registered on th next frame if this is called after
  34617. * the register component stage.
  34618. * @param component Defines the component to add to the scene
  34619. */
  34620. _addComponent(component: ISceneComponent): void;
  34621. /**
  34622. * @hidden
  34623. * Gets a component from the scene.
  34624. * @param name defines the name of the component to retrieve
  34625. * @returns the component or null if not present
  34626. */
  34627. _getComponent(name: string): Nullable<ISceneComponent>;
  34628. /**
  34629. * @hidden
  34630. * Defines the actions happening before camera updates.
  34631. */
  34632. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34633. /**
  34634. * @hidden
  34635. * Defines the actions happening before clear the canvas.
  34636. */
  34637. _beforeClearStage: Stage<SimpleStageAction>;
  34638. /**
  34639. * @hidden
  34640. * Defines the actions when collecting render targets for the frame.
  34641. */
  34642. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34643. /**
  34644. * @hidden
  34645. * Defines the actions happening for one camera in the frame.
  34646. */
  34647. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34648. /**
  34649. * @hidden
  34650. * Defines the actions happening during the per mesh ready checks.
  34651. */
  34652. _isReadyForMeshStage: Stage<MeshStageAction>;
  34653. /**
  34654. * @hidden
  34655. * Defines the actions happening before evaluate active mesh checks.
  34656. */
  34657. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34658. /**
  34659. * @hidden
  34660. * Defines the actions happening during the evaluate sub mesh checks.
  34661. */
  34662. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34663. /**
  34664. * @hidden
  34665. * Defines the actions happening during the active mesh stage.
  34666. */
  34667. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34668. /**
  34669. * @hidden
  34670. * Defines the actions happening during the per camera render target step.
  34671. */
  34672. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34673. /**
  34674. * @hidden
  34675. * Defines the actions happening just before the active camera is drawing.
  34676. */
  34677. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34678. /**
  34679. * @hidden
  34680. * Defines the actions happening just before a render target is drawing.
  34681. */
  34682. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34683. /**
  34684. * @hidden
  34685. * Defines the actions happening just before a rendering group is drawing.
  34686. */
  34687. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34688. /**
  34689. * @hidden
  34690. * Defines the actions happening just before a mesh is drawing.
  34691. */
  34692. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34693. /**
  34694. * @hidden
  34695. * Defines the actions happening just after a mesh has been drawn.
  34696. */
  34697. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34698. /**
  34699. * @hidden
  34700. * Defines the actions happening just after a rendering group has been drawn.
  34701. */
  34702. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34703. /**
  34704. * @hidden
  34705. * Defines the actions happening just after the active camera has been drawn.
  34706. */
  34707. _afterCameraDrawStage: Stage<CameraStageAction>;
  34708. /**
  34709. * @hidden
  34710. * Defines the actions happening just after a render target has been drawn.
  34711. */
  34712. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34713. /**
  34714. * @hidden
  34715. * Defines the actions happening just after rendering all cameras and computing intersections.
  34716. */
  34717. _afterRenderStage: Stage<SimpleStageAction>;
  34718. /**
  34719. * @hidden
  34720. * Defines the actions happening when a pointer move event happens.
  34721. */
  34722. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34723. /**
  34724. * @hidden
  34725. * Defines the actions happening when a pointer down event happens.
  34726. */
  34727. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34728. /**
  34729. * @hidden
  34730. * Defines the actions happening when a pointer up event happens.
  34731. */
  34732. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34733. /**
  34734. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34735. */
  34736. private geometriesByUniqueId;
  34737. /**
  34738. * Creates a new Scene
  34739. * @param engine defines the engine to use to render this scene
  34740. * @param options defines the scene options
  34741. */
  34742. constructor(engine: Engine, options?: SceneOptions);
  34743. /**
  34744. * Gets a string idenfifying the name of the class
  34745. * @returns "Scene" string
  34746. */
  34747. getClassName(): string;
  34748. private _defaultMeshCandidates;
  34749. /**
  34750. * @hidden
  34751. */
  34752. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34753. private _defaultSubMeshCandidates;
  34754. /**
  34755. * @hidden
  34756. */
  34757. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34758. /**
  34759. * Sets the default candidate providers for the scene.
  34760. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34761. * and getCollidingSubMeshCandidates to their default function
  34762. */
  34763. setDefaultCandidateProviders(): void;
  34764. /**
  34765. * Gets the mesh that is currently under the pointer
  34766. */
  34767. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34768. /**
  34769. * Gets or sets the current on-screen X position of the pointer
  34770. */
  34771. pointerX: number;
  34772. /**
  34773. * Gets or sets the current on-screen Y position of the pointer
  34774. */
  34775. pointerY: number;
  34776. /**
  34777. * Gets the cached material (ie. the latest rendered one)
  34778. * @returns the cached material
  34779. */
  34780. getCachedMaterial(): Nullable<Material>;
  34781. /**
  34782. * Gets the cached effect (ie. the latest rendered one)
  34783. * @returns the cached effect
  34784. */
  34785. getCachedEffect(): Nullable<Effect>;
  34786. /**
  34787. * Gets the cached visibility state (ie. the latest rendered one)
  34788. * @returns the cached visibility state
  34789. */
  34790. getCachedVisibility(): Nullable<number>;
  34791. /**
  34792. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34793. * @param material defines the current material
  34794. * @param effect defines the current effect
  34795. * @param visibility defines the current visibility state
  34796. * @returns true if one parameter is not cached
  34797. */
  34798. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34799. /**
  34800. * Gets the engine associated with the scene
  34801. * @returns an Engine
  34802. */
  34803. getEngine(): Engine;
  34804. /**
  34805. * Gets the total number of vertices rendered per frame
  34806. * @returns the total number of vertices rendered per frame
  34807. */
  34808. getTotalVertices(): number;
  34809. /**
  34810. * Gets the performance counter for total vertices
  34811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34812. */
  34813. readonly totalVerticesPerfCounter: PerfCounter;
  34814. /**
  34815. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34816. * @returns the total number of active indices rendered per frame
  34817. */
  34818. getActiveIndices(): number;
  34819. /**
  34820. * Gets the performance counter for active indices
  34821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34822. */
  34823. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34824. /**
  34825. * Gets the total number of active particles rendered per frame
  34826. * @returns the total number of active particles rendered per frame
  34827. */
  34828. getActiveParticles(): number;
  34829. /**
  34830. * Gets the performance counter for active particles
  34831. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34832. */
  34833. readonly activeParticlesPerfCounter: PerfCounter;
  34834. /**
  34835. * Gets the total number of active bones rendered per frame
  34836. * @returns the total number of active bones rendered per frame
  34837. */
  34838. getActiveBones(): number;
  34839. /**
  34840. * Gets the performance counter for active bones
  34841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34842. */
  34843. readonly activeBonesPerfCounter: PerfCounter;
  34844. /**
  34845. * Gets the array of active meshes
  34846. * @returns an array of AbstractMesh
  34847. */
  34848. getActiveMeshes(): SmartArray<AbstractMesh>;
  34849. /**
  34850. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34851. * @returns a number
  34852. */
  34853. getAnimationRatio(): number;
  34854. /**
  34855. * Gets an unique Id for the current render phase
  34856. * @returns a number
  34857. */
  34858. getRenderId(): number;
  34859. /**
  34860. * Gets an unique Id for the current frame
  34861. * @returns a number
  34862. */
  34863. getFrameId(): number;
  34864. /** Call this function if you want to manually increment the render Id*/
  34865. incrementRenderId(): void;
  34866. private _createUbo;
  34867. /**
  34868. * Use this method to simulate a pointer move on a mesh
  34869. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34870. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34871. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34872. * @returns the current scene
  34873. */
  34874. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34875. /**
  34876. * Use this method to simulate a pointer down on a mesh
  34877. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34878. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34879. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34880. * @returns the current scene
  34881. */
  34882. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34883. /**
  34884. * Use this method to simulate a pointer up on a mesh
  34885. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34886. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34887. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34888. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34889. * @returns the current scene
  34890. */
  34891. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34892. /**
  34893. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34894. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34895. * @returns true if the pointer was captured
  34896. */
  34897. isPointerCaptured(pointerId?: number): boolean;
  34898. /**
  34899. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34900. * @param attachUp defines if you want to attach events to pointerup
  34901. * @param attachDown defines if you want to attach events to pointerdown
  34902. * @param attachMove defines if you want to attach events to pointermove
  34903. */
  34904. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34905. /** Detaches all event handlers*/
  34906. detachControl(): void;
  34907. /**
  34908. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34909. * Delay loaded resources are not taking in account
  34910. * @return true if all required resources are ready
  34911. */
  34912. isReady(): boolean;
  34913. /** Resets all cached information relative to material (including effect and visibility) */
  34914. resetCachedMaterial(): void;
  34915. /**
  34916. * Registers a function to be called before every frame render
  34917. * @param func defines the function to register
  34918. */
  34919. registerBeforeRender(func: () => void): void;
  34920. /**
  34921. * Unregisters a function called before every frame render
  34922. * @param func defines the function to unregister
  34923. */
  34924. unregisterBeforeRender(func: () => void): void;
  34925. /**
  34926. * Registers a function to be called after every frame render
  34927. * @param func defines the function to register
  34928. */
  34929. registerAfterRender(func: () => void): void;
  34930. /**
  34931. * Unregisters a function called after every frame render
  34932. * @param func defines the function to unregister
  34933. */
  34934. unregisterAfterRender(func: () => void): void;
  34935. private _executeOnceBeforeRender;
  34936. /**
  34937. * The provided function will run before render once and will be disposed afterwards.
  34938. * A timeout delay can be provided so that the function will be executed in N ms.
  34939. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34940. * @param func The function to be executed.
  34941. * @param timeout optional delay in ms
  34942. */
  34943. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34944. /** @hidden */
  34945. _addPendingData(data: any): void;
  34946. /** @hidden */
  34947. _removePendingData(data: any): void;
  34948. /**
  34949. * Returns the number of items waiting to be loaded
  34950. * @returns the number of items waiting to be loaded
  34951. */
  34952. getWaitingItemsCount(): number;
  34953. /**
  34954. * Returns a boolean indicating if the scene is still loading data
  34955. */
  34956. readonly isLoading: boolean;
  34957. /**
  34958. * Registers a function to be executed when the scene is ready
  34959. * @param {Function} func - the function to be executed
  34960. */
  34961. executeWhenReady(func: () => void): void;
  34962. /**
  34963. * Returns a promise that resolves when the scene is ready
  34964. * @returns A promise that resolves when the scene is ready
  34965. */
  34966. whenReadyAsync(): Promise<void>;
  34967. /** @hidden */
  34968. _checkIsReady(): void;
  34969. /**
  34970. * Gets all animatable attached to the scene
  34971. */
  34972. readonly animatables: Animatable[];
  34973. /**
  34974. * Resets the last animation time frame.
  34975. * Useful to override when animations start running when loading a scene for the first time.
  34976. */
  34977. resetLastAnimationTimeFrame(): void;
  34978. /**
  34979. * Gets the current view matrix
  34980. * @returns a Matrix
  34981. */
  34982. getViewMatrix(): Matrix;
  34983. /**
  34984. * Gets the current projection matrix
  34985. * @returns a Matrix
  34986. */
  34987. getProjectionMatrix(): Matrix;
  34988. /**
  34989. * Gets the current transform matrix
  34990. * @returns a Matrix made of View * Projection
  34991. */
  34992. getTransformMatrix(): Matrix;
  34993. /**
  34994. * Sets the current transform matrix
  34995. * @param viewL defines the View matrix to use
  34996. * @param projectionL defines the Projection matrix to use
  34997. * @param viewR defines the right View matrix to use (if provided)
  34998. * @param projectionR defines the right Projection matrix to use (if provided)
  34999. */
  35000. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35001. /**
  35002. * Gets the uniform buffer used to store scene data
  35003. * @returns a UniformBuffer
  35004. */
  35005. getSceneUniformBuffer(): UniformBuffer;
  35006. /**
  35007. * Gets an unique (relatively to the current scene) Id
  35008. * @returns an unique number for the scene
  35009. */
  35010. getUniqueId(): number;
  35011. /**
  35012. * Add a mesh to the list of scene's meshes
  35013. * @param newMesh defines the mesh to add
  35014. * @param recursive if all child meshes should also be added to the scene
  35015. */
  35016. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35017. /**
  35018. * Remove a mesh for the list of scene's meshes
  35019. * @param toRemove defines the mesh to remove
  35020. * @param recursive if all child meshes should also be removed from the scene
  35021. * @returns the index where the mesh was in the mesh list
  35022. */
  35023. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35024. /**
  35025. * Add a transform node to the list of scene's transform nodes
  35026. * @param newTransformNode defines the transform node to add
  35027. */
  35028. addTransformNode(newTransformNode: TransformNode): void;
  35029. /**
  35030. * Remove a transform node for the list of scene's transform nodes
  35031. * @param toRemove defines the transform node to remove
  35032. * @returns the index where the transform node was in the transform node list
  35033. */
  35034. removeTransformNode(toRemove: TransformNode): number;
  35035. /**
  35036. * Remove a skeleton for the list of scene's skeletons
  35037. * @param toRemove defines the skeleton to remove
  35038. * @returns the index where the skeleton was in the skeleton list
  35039. */
  35040. removeSkeleton(toRemove: Skeleton): number;
  35041. /**
  35042. * Remove a morph target for the list of scene's morph targets
  35043. * @param toRemove defines the morph target to remove
  35044. * @returns the index where the morph target was in the morph target list
  35045. */
  35046. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35047. /**
  35048. * Remove a light for the list of scene's lights
  35049. * @param toRemove defines the light to remove
  35050. * @returns the index where the light was in the light list
  35051. */
  35052. removeLight(toRemove: Light): number;
  35053. /**
  35054. * Remove a camera for the list of scene's cameras
  35055. * @param toRemove defines the camera to remove
  35056. * @returns the index where the camera was in the camera list
  35057. */
  35058. removeCamera(toRemove: Camera): number;
  35059. /**
  35060. * Remove a particle system for the list of scene's particle systems
  35061. * @param toRemove defines the particle system to remove
  35062. * @returns the index where the particle system was in the particle system list
  35063. */
  35064. removeParticleSystem(toRemove: IParticleSystem): number;
  35065. /**
  35066. * Remove a animation for the list of scene's animations
  35067. * @param toRemove defines the animation to remove
  35068. * @returns the index where the animation was in the animation list
  35069. */
  35070. removeAnimation(toRemove: Animation): number;
  35071. /**
  35072. * Will stop the animation of the given target
  35073. * @param target - the target
  35074. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35075. * @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)
  35076. */
  35077. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35078. /**
  35079. * Removes the given animation group from this scene.
  35080. * @param toRemove The animation group to remove
  35081. * @returns The index of the removed animation group
  35082. */
  35083. removeAnimationGroup(toRemove: AnimationGroup): number;
  35084. /**
  35085. * Removes the given multi-material from this scene.
  35086. * @param toRemove The multi-material to remove
  35087. * @returns The index of the removed multi-material
  35088. */
  35089. removeMultiMaterial(toRemove: MultiMaterial): number;
  35090. /**
  35091. * Removes the given material from this scene.
  35092. * @param toRemove The material to remove
  35093. * @returns The index of the removed material
  35094. */
  35095. removeMaterial(toRemove: Material): number;
  35096. /**
  35097. * Removes the given action manager from this scene.
  35098. * @param toRemove The action manager to remove
  35099. * @returns The index of the removed action manager
  35100. */
  35101. removeActionManager(toRemove: AbstractActionManager): number;
  35102. /**
  35103. * Removes the given texture from this scene.
  35104. * @param toRemove The texture to remove
  35105. * @returns The index of the removed texture
  35106. */
  35107. removeTexture(toRemove: BaseTexture): number;
  35108. /**
  35109. * Adds the given light to this scene
  35110. * @param newLight The light to add
  35111. */
  35112. addLight(newLight: Light): void;
  35113. /**
  35114. * Sorts the list list based on light priorities
  35115. */
  35116. sortLightsByPriority(): void;
  35117. /**
  35118. * Adds the given camera to this scene
  35119. * @param newCamera The camera to add
  35120. */
  35121. addCamera(newCamera: Camera): void;
  35122. /**
  35123. * Adds the given skeleton to this scene
  35124. * @param newSkeleton The skeleton to add
  35125. */
  35126. addSkeleton(newSkeleton: Skeleton): void;
  35127. /**
  35128. * Adds the given particle system to this scene
  35129. * @param newParticleSystem The particle system to add
  35130. */
  35131. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35132. /**
  35133. * Adds the given animation to this scene
  35134. * @param newAnimation The animation to add
  35135. */
  35136. addAnimation(newAnimation: Animation): void;
  35137. /**
  35138. * Adds the given animation group to this scene.
  35139. * @param newAnimationGroup The animation group to add
  35140. */
  35141. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35142. /**
  35143. * Adds the given multi-material to this scene
  35144. * @param newMultiMaterial The multi-material to add
  35145. */
  35146. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35147. /**
  35148. * Adds the given material to this scene
  35149. * @param newMaterial The material to add
  35150. */
  35151. addMaterial(newMaterial: Material): void;
  35152. /**
  35153. * Adds the given morph target to this scene
  35154. * @param newMorphTargetManager The morph target to add
  35155. */
  35156. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35157. /**
  35158. * Adds the given geometry to this scene
  35159. * @param newGeometry The geometry to add
  35160. */
  35161. addGeometry(newGeometry: Geometry): void;
  35162. /**
  35163. * Adds the given action manager to this scene
  35164. * @param newActionManager The action manager to add
  35165. */
  35166. addActionManager(newActionManager: AbstractActionManager): void;
  35167. /**
  35168. * Adds the given texture to this scene.
  35169. * @param newTexture The texture to add
  35170. */
  35171. addTexture(newTexture: BaseTexture): void;
  35172. /**
  35173. * Switch active camera
  35174. * @param newCamera defines the new active camera
  35175. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35176. */
  35177. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35178. /**
  35179. * sets the active camera of the scene using its ID
  35180. * @param id defines the camera's ID
  35181. * @return the new active camera or null if none found.
  35182. */
  35183. setActiveCameraByID(id: string): Nullable<Camera>;
  35184. /**
  35185. * sets the active camera of the scene using its name
  35186. * @param name defines the camera's name
  35187. * @returns the new active camera or null if none found.
  35188. */
  35189. setActiveCameraByName(name: string): Nullable<Camera>;
  35190. /**
  35191. * get an animation group using its name
  35192. * @param name defines the material's name
  35193. * @return the animation group or null if none found.
  35194. */
  35195. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35196. /**
  35197. * Get a material using its unique id
  35198. * @param uniqueId defines the material's unique id
  35199. * @return the material or null if none found.
  35200. */
  35201. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35202. /**
  35203. * get a material using its id
  35204. * @param id defines the material's ID
  35205. * @return the material or null if none found.
  35206. */
  35207. getMaterialByID(id: string): Nullable<Material>;
  35208. /**
  35209. * Gets a the last added material using a given id
  35210. * @param id defines the material's ID
  35211. * @return the last material with the given id or null if none found.
  35212. */
  35213. getLastMaterialByID(id: string): Nullable<Material>;
  35214. /**
  35215. * Gets a material using its name
  35216. * @param name defines the material's name
  35217. * @return the material or null if none found.
  35218. */
  35219. getMaterialByName(name: string): Nullable<Material>;
  35220. /**
  35221. * Get a texture using its unique id
  35222. * @param uniqueId defines the texture's unique id
  35223. * @return the texture or null if none found.
  35224. */
  35225. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35226. /**
  35227. * Gets a camera using its id
  35228. * @param id defines the id to look for
  35229. * @returns the camera or null if not found
  35230. */
  35231. getCameraByID(id: string): Nullable<Camera>;
  35232. /**
  35233. * Gets a camera using its unique id
  35234. * @param uniqueId defines the unique id to look for
  35235. * @returns the camera or null if not found
  35236. */
  35237. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35238. /**
  35239. * Gets a camera using its name
  35240. * @param name defines the camera's name
  35241. * @return the camera or null if none found.
  35242. */
  35243. getCameraByName(name: string): Nullable<Camera>;
  35244. /**
  35245. * Gets a bone using its id
  35246. * @param id defines the bone's id
  35247. * @return the bone or null if not found
  35248. */
  35249. getBoneByID(id: string): Nullable<Bone>;
  35250. /**
  35251. * Gets a bone using its id
  35252. * @param name defines the bone's name
  35253. * @return the bone or null if not found
  35254. */
  35255. getBoneByName(name: string): Nullable<Bone>;
  35256. /**
  35257. * Gets a light node using its name
  35258. * @param name defines the the light's name
  35259. * @return the light or null if none found.
  35260. */
  35261. getLightByName(name: string): Nullable<Light>;
  35262. /**
  35263. * Gets a light node using its id
  35264. * @param id defines the light's id
  35265. * @return the light or null if none found.
  35266. */
  35267. getLightByID(id: string): Nullable<Light>;
  35268. /**
  35269. * Gets a light node using its scene-generated unique ID
  35270. * @param uniqueId defines the light's unique id
  35271. * @return the light or null if none found.
  35272. */
  35273. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35274. /**
  35275. * Gets a particle system by id
  35276. * @param id defines the particle system id
  35277. * @return the corresponding system or null if none found
  35278. */
  35279. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35280. /**
  35281. * Gets a geometry using its ID
  35282. * @param id defines the geometry's id
  35283. * @return the geometry or null if none found.
  35284. */
  35285. getGeometryByID(id: string): Nullable<Geometry>;
  35286. private _getGeometryByUniqueID;
  35287. /**
  35288. * Add a new geometry to this scene
  35289. * @param geometry defines the geometry to be added to the scene.
  35290. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35291. * @return a boolean defining if the geometry was added or not
  35292. */
  35293. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35294. /**
  35295. * Removes an existing geometry
  35296. * @param geometry defines the geometry to be removed from the scene
  35297. * @return a boolean defining if the geometry was removed or not
  35298. */
  35299. removeGeometry(geometry: Geometry): boolean;
  35300. /**
  35301. * Gets the list of geometries attached to the scene
  35302. * @returns an array of Geometry
  35303. */
  35304. getGeometries(): Geometry[];
  35305. /**
  35306. * Gets the first added mesh found of a given ID
  35307. * @param id defines the id to search for
  35308. * @return the mesh found or null if not found at all
  35309. */
  35310. getMeshByID(id: string): Nullable<AbstractMesh>;
  35311. /**
  35312. * Gets a list of meshes using their id
  35313. * @param id defines the id to search for
  35314. * @returns a list of meshes
  35315. */
  35316. getMeshesByID(id: string): Array<AbstractMesh>;
  35317. /**
  35318. * Gets the first added transform node found of a given ID
  35319. * @param id defines the id to search for
  35320. * @return the found transform node or null if not found at all.
  35321. */
  35322. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35323. /**
  35324. * Gets a transform node with its auto-generated unique id
  35325. * @param uniqueId efines the unique id to search for
  35326. * @return the found transform node or null if not found at all.
  35327. */
  35328. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35329. /**
  35330. * Gets a list of transform nodes using their id
  35331. * @param id defines the id to search for
  35332. * @returns a list of transform nodes
  35333. */
  35334. getTransformNodesByID(id: string): Array<TransformNode>;
  35335. /**
  35336. * Gets a mesh with its auto-generated unique id
  35337. * @param uniqueId defines the unique id to search for
  35338. * @return the found mesh or null if not found at all.
  35339. */
  35340. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35341. /**
  35342. * Gets a the last added mesh using a given id
  35343. * @param id defines the id to search for
  35344. * @return the found mesh or null if not found at all.
  35345. */
  35346. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35347. /**
  35348. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35349. * @param id defines the id to search for
  35350. * @return the found node or null if not found at all
  35351. */
  35352. getLastEntryByID(id: string): Nullable<Node>;
  35353. /**
  35354. * Gets a node (Mesh, Camera, Light) using a given id
  35355. * @param id defines the id to search for
  35356. * @return the found node or null if not found at all
  35357. */
  35358. getNodeByID(id: string): Nullable<Node>;
  35359. /**
  35360. * Gets a node (Mesh, Camera, Light) using a given name
  35361. * @param name defines the name to search for
  35362. * @return the found node or null if not found at all.
  35363. */
  35364. getNodeByName(name: string): Nullable<Node>;
  35365. /**
  35366. * Gets a mesh using a given name
  35367. * @param name defines the name to search for
  35368. * @return the found mesh or null if not found at all.
  35369. */
  35370. getMeshByName(name: string): Nullable<AbstractMesh>;
  35371. /**
  35372. * Gets a transform node using a given name
  35373. * @param name defines the name to search for
  35374. * @return the found transform node or null if not found at all.
  35375. */
  35376. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35377. /**
  35378. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35379. * @param id defines the id to search for
  35380. * @return the found skeleton or null if not found at all.
  35381. */
  35382. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35383. /**
  35384. * Gets a skeleton using a given auto generated unique id
  35385. * @param uniqueId defines the unique id to search for
  35386. * @return the found skeleton or null if not found at all.
  35387. */
  35388. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35389. /**
  35390. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35391. * @param id defines the id to search for
  35392. * @return the found skeleton or null if not found at all.
  35393. */
  35394. getSkeletonById(id: string): Nullable<Skeleton>;
  35395. /**
  35396. * Gets a skeleton using a given name
  35397. * @param name defines the name to search for
  35398. * @return the found skeleton or null if not found at all.
  35399. */
  35400. getSkeletonByName(name: string): Nullable<Skeleton>;
  35401. /**
  35402. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35403. * @param id defines the id to search for
  35404. * @return the found morph target manager or null if not found at all.
  35405. */
  35406. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35407. /**
  35408. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35409. * @param id defines the id to search for
  35410. * @return the found morph target or null if not found at all.
  35411. */
  35412. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35413. /**
  35414. * Gets a boolean indicating if the given mesh is active
  35415. * @param mesh defines the mesh to look for
  35416. * @returns true if the mesh is in the active list
  35417. */
  35418. isActiveMesh(mesh: AbstractMesh): boolean;
  35419. /**
  35420. * Return a unique id as a string which can serve as an identifier for the scene
  35421. */
  35422. readonly uid: string;
  35423. /**
  35424. * Add an externaly attached data from its key.
  35425. * This method call will fail and return false, if such key already exists.
  35426. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35427. * @param key the unique key that identifies the data
  35428. * @param data the data object to associate to the key for this Engine instance
  35429. * @return true if no such key were already present and the data was added successfully, false otherwise
  35430. */
  35431. addExternalData<T>(key: string, data: T): boolean;
  35432. /**
  35433. * Get an externaly attached data from its key
  35434. * @param key the unique key that identifies the data
  35435. * @return the associated data, if present (can be null), or undefined if not present
  35436. */
  35437. getExternalData<T>(key: string): Nullable<T>;
  35438. /**
  35439. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35440. * @param key the unique key that identifies the data
  35441. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35442. * @return the associated data, can be null if the factory returned null.
  35443. */
  35444. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35445. /**
  35446. * Remove an externaly attached data from the Engine instance
  35447. * @param key the unique key that identifies the data
  35448. * @return true if the data was successfully removed, false if it doesn't exist
  35449. */
  35450. removeExternalData(key: string): boolean;
  35451. private _evaluateSubMesh;
  35452. /**
  35453. * Clear the processed materials smart array preventing retention point in material dispose.
  35454. */
  35455. freeProcessedMaterials(): void;
  35456. private _preventFreeActiveMeshesAndRenderingGroups;
  35457. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35458. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35459. * when disposing several meshes in a row or a hierarchy of meshes.
  35460. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35461. */
  35462. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35463. /**
  35464. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35465. */
  35466. freeActiveMeshes(): void;
  35467. /**
  35468. * Clear the info related to rendering groups preventing retention points during dispose.
  35469. */
  35470. freeRenderingGroups(): void;
  35471. /** @hidden */
  35472. _isInIntermediateRendering(): boolean;
  35473. /**
  35474. * Lambda returning the list of potentially active meshes.
  35475. */
  35476. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35477. /**
  35478. * Lambda returning the list of potentially active sub meshes.
  35479. */
  35480. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35481. /**
  35482. * Lambda returning the list of potentially intersecting sub meshes.
  35483. */
  35484. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35485. /**
  35486. * Lambda returning the list of potentially colliding sub meshes.
  35487. */
  35488. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35489. private _activeMeshesFrozen;
  35490. /**
  35491. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35492. * @returns the current scene
  35493. */
  35494. freezeActiveMeshes(): Scene;
  35495. /**
  35496. * Use this function to restart evaluating active meshes on every frame
  35497. * @returns the current scene
  35498. */
  35499. unfreezeActiveMeshes(): Scene;
  35500. private _evaluateActiveMeshes;
  35501. private _activeMesh;
  35502. /**
  35503. * Update the transform matrix to update from the current active camera
  35504. * @param force defines a boolean used to force the update even if cache is up to date
  35505. */
  35506. updateTransformMatrix(force?: boolean): void;
  35507. private _bindFrameBuffer;
  35508. /** @hidden */
  35509. _allowPostProcessClearColor: boolean;
  35510. /** @hidden */
  35511. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35512. private _processSubCameras;
  35513. private _checkIntersections;
  35514. /** @hidden */
  35515. _advancePhysicsEngineStep(step: number): void;
  35516. /**
  35517. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35518. */
  35519. getDeterministicFrameTime: () => number;
  35520. /** @hidden */
  35521. _animate(): void;
  35522. /** Execute all animations (for a frame) */
  35523. animate(): void;
  35524. /**
  35525. * Render the scene
  35526. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35527. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35528. */
  35529. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35530. /**
  35531. * Freeze all materials
  35532. * A frozen material will not be updatable but should be faster to render
  35533. */
  35534. freezeMaterials(): void;
  35535. /**
  35536. * Unfreeze all materials
  35537. * A frozen material will not be updatable but should be faster to render
  35538. */
  35539. unfreezeMaterials(): void;
  35540. /**
  35541. * Releases all held ressources
  35542. */
  35543. dispose(): void;
  35544. /**
  35545. * Gets if the scene is already disposed
  35546. */
  35547. readonly isDisposed: boolean;
  35548. /**
  35549. * Call this function to reduce memory footprint of the scene.
  35550. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35551. */
  35552. clearCachedVertexData(): void;
  35553. /**
  35554. * This function will remove the local cached buffer data from texture.
  35555. * It will save memory but will prevent the texture from being rebuilt
  35556. */
  35557. cleanCachedTextureBuffer(): void;
  35558. /**
  35559. * Get the world extend vectors with an optional filter
  35560. *
  35561. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35562. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35563. */
  35564. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35565. min: Vector3;
  35566. max: Vector3;
  35567. };
  35568. /**
  35569. * Creates a ray that can be used to pick in the scene
  35570. * @param x defines the x coordinate of the origin (on-screen)
  35571. * @param y defines the y coordinate of the origin (on-screen)
  35572. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35573. * @param camera defines the camera to use for the picking
  35574. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35575. * @returns a Ray
  35576. */
  35577. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35578. /**
  35579. * Creates a ray that can be used to pick in the scene
  35580. * @param x defines the x coordinate of the origin (on-screen)
  35581. * @param y defines the y coordinate of the origin (on-screen)
  35582. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35583. * @param result defines the ray where to store the picking ray
  35584. * @param camera defines the camera to use for the picking
  35585. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35586. * @returns the current scene
  35587. */
  35588. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35589. /**
  35590. * Creates a ray that can be used to pick in the scene
  35591. * @param x defines the x coordinate of the origin (on-screen)
  35592. * @param y defines the y coordinate of the origin (on-screen)
  35593. * @param camera defines the camera to use for the picking
  35594. * @returns a Ray
  35595. */
  35596. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35597. /**
  35598. * Creates a ray that can be used to pick in the scene
  35599. * @param x defines the x coordinate of the origin (on-screen)
  35600. * @param y defines the y coordinate of the origin (on-screen)
  35601. * @param result defines the ray where to store the picking ray
  35602. * @param camera defines the camera to use for the picking
  35603. * @returns the current scene
  35604. */
  35605. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35606. /** Launch a ray to try to pick a mesh in the scene
  35607. * @param x position on screen
  35608. * @param y position on screen
  35609. * @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
  35610. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35611. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35612. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35613. * @returns a PickingInfo
  35614. */
  35615. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35616. /** Use the given ray to pick a mesh in the scene
  35617. * @param ray The ray to use to pick meshes
  35618. * @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
  35619. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35620. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35621. * @returns a PickingInfo
  35622. */
  35623. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35624. /**
  35625. * Launch a ray to try to pick a mesh in the scene
  35626. * @param x X position on screen
  35627. * @param y Y position on screen
  35628. * @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
  35629. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35630. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35631. * @returns an array of PickingInfo
  35632. */
  35633. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35634. /**
  35635. * Launch a ray to try to pick a mesh in the scene
  35636. * @param ray Ray to use
  35637. * @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
  35638. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35639. * @returns an array of PickingInfo
  35640. */
  35641. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35642. /**
  35643. * Force the value of meshUnderPointer
  35644. * @param mesh defines the mesh to use
  35645. */
  35646. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35647. /**
  35648. * Gets the mesh under the pointer
  35649. * @returns a Mesh or null if no mesh is under the pointer
  35650. */
  35651. getPointerOverMesh(): Nullable<AbstractMesh>;
  35652. /** @hidden */
  35653. _rebuildGeometries(): void;
  35654. /** @hidden */
  35655. _rebuildTextures(): void;
  35656. private _getByTags;
  35657. /**
  35658. * Get a list of meshes by tags
  35659. * @param tagsQuery defines the tags query to use
  35660. * @param forEach defines a predicate used to filter results
  35661. * @returns an array of Mesh
  35662. */
  35663. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35664. /**
  35665. * Get a list of cameras by tags
  35666. * @param tagsQuery defines the tags query to use
  35667. * @param forEach defines a predicate used to filter results
  35668. * @returns an array of Camera
  35669. */
  35670. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35671. /**
  35672. * Get a list of lights by tags
  35673. * @param tagsQuery defines the tags query to use
  35674. * @param forEach defines a predicate used to filter results
  35675. * @returns an array of Light
  35676. */
  35677. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35678. /**
  35679. * Get a list of materials by tags
  35680. * @param tagsQuery defines the tags query to use
  35681. * @param forEach defines a predicate used to filter results
  35682. * @returns an array of Material
  35683. */
  35684. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35685. /**
  35686. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35687. * This allowed control for front to back rendering or reversly depending of the special needs.
  35688. *
  35689. * @param renderingGroupId The rendering group id corresponding to its index
  35690. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35691. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35692. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35693. */
  35694. 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;
  35695. /**
  35696. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35697. *
  35698. * @param renderingGroupId The rendering group id corresponding to its index
  35699. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35700. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35701. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35702. */
  35703. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35704. /**
  35705. * Gets the current auto clear configuration for one rendering group of the rendering
  35706. * manager.
  35707. * @param index the rendering group index to get the information for
  35708. * @returns The auto clear setup for the requested rendering group
  35709. */
  35710. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35711. private _blockMaterialDirtyMechanism;
  35712. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35713. blockMaterialDirtyMechanism: boolean;
  35714. /**
  35715. * Will flag all materials as dirty to trigger new shader compilation
  35716. * @param flag defines the flag used to specify which material part must be marked as dirty
  35717. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35718. */
  35719. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35720. /** @hidden */
  35721. _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;
  35722. /** @hidden */
  35723. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35724. }
  35725. }
  35726. declare module "babylonjs/assetContainer" {
  35727. import { AbstractScene } from "babylonjs/abstractScene";
  35728. import { Scene } from "babylonjs/scene";
  35729. import { Mesh } from "babylonjs/Meshes/mesh";
  35730. /**
  35731. * Set of assets to keep when moving a scene into an asset container.
  35732. */
  35733. export class KeepAssets extends AbstractScene {
  35734. }
  35735. /**
  35736. * Container with a set of assets that can be added or removed from a scene.
  35737. */
  35738. export class AssetContainer extends AbstractScene {
  35739. /**
  35740. * The scene the AssetContainer belongs to.
  35741. */
  35742. scene: Scene;
  35743. /**
  35744. * Instantiates an AssetContainer.
  35745. * @param scene The scene the AssetContainer belongs to.
  35746. */
  35747. constructor(scene: Scene);
  35748. /**
  35749. * Adds all the assets from the container to the scene.
  35750. */
  35751. addAllToScene(): void;
  35752. /**
  35753. * Removes all the assets in the container from the scene
  35754. */
  35755. removeAllFromScene(): void;
  35756. /**
  35757. * Disposes all the assets in the container
  35758. */
  35759. dispose(): void;
  35760. private _moveAssets;
  35761. /**
  35762. * Removes all the assets contained in the scene and adds them to the container.
  35763. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35764. */
  35765. moveAllFromScene(keepAssets?: KeepAssets): void;
  35766. /**
  35767. * 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.
  35768. * @returns the root mesh
  35769. */
  35770. createRootMesh(): Mesh;
  35771. }
  35772. }
  35773. declare module "babylonjs/abstractScene" {
  35774. import { Scene } from "babylonjs/scene";
  35775. import { Nullable } from "babylonjs/types";
  35776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35777. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35778. import { Geometry } from "babylonjs/Meshes/geometry";
  35779. import { Skeleton } from "babylonjs/Bones/skeleton";
  35780. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35781. import { AssetContainer } from "babylonjs/assetContainer";
  35782. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35783. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35784. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35785. import { Material } from "babylonjs/Materials/material";
  35786. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35787. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35788. import { Camera } from "babylonjs/Cameras/camera";
  35789. import { Light } from "babylonjs/Lights/light";
  35790. import { Node } from "babylonjs/node";
  35791. import { Animation } from "babylonjs/Animations/animation";
  35792. /**
  35793. * Defines how the parser contract is defined.
  35794. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35795. */
  35796. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35797. /**
  35798. * Defines how the individual parser contract is defined.
  35799. * These parser can parse an individual asset
  35800. */
  35801. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35802. /**
  35803. * Base class of the scene acting as a container for the different elements composing a scene.
  35804. * This class is dynamically extended by the different components of the scene increasing
  35805. * flexibility and reducing coupling
  35806. */
  35807. export abstract class AbstractScene {
  35808. /**
  35809. * Stores the list of available parsers in the application.
  35810. */
  35811. private static _BabylonFileParsers;
  35812. /**
  35813. * Stores the list of available individual parsers in the application.
  35814. */
  35815. private static _IndividualBabylonFileParsers;
  35816. /**
  35817. * Adds a parser in the list of available ones
  35818. * @param name Defines the name of the parser
  35819. * @param parser Defines the parser to add
  35820. */
  35821. static AddParser(name: string, parser: BabylonFileParser): void;
  35822. /**
  35823. * Gets a general parser from the list of avaialble ones
  35824. * @param name Defines the name of the parser
  35825. * @returns the requested parser or null
  35826. */
  35827. static GetParser(name: string): Nullable<BabylonFileParser>;
  35828. /**
  35829. * Adds n individual parser in the list of available ones
  35830. * @param name Defines the name of the parser
  35831. * @param parser Defines the parser to add
  35832. */
  35833. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35834. /**
  35835. * Gets an individual parser from the list of avaialble ones
  35836. * @param name Defines the name of the parser
  35837. * @returns the requested parser or null
  35838. */
  35839. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35840. /**
  35841. * Parser json data and populate both a scene and its associated container object
  35842. * @param jsonData Defines the data to parse
  35843. * @param scene Defines the scene to parse the data for
  35844. * @param container Defines the container attached to the parsing sequence
  35845. * @param rootUrl Defines the root url of the data
  35846. */
  35847. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35848. /**
  35849. * Gets the list of root nodes (ie. nodes with no parent)
  35850. */
  35851. rootNodes: Node[];
  35852. /** All of the cameras added to this scene
  35853. * @see http://doc.babylonjs.com/babylon101/cameras
  35854. */
  35855. cameras: Camera[];
  35856. /**
  35857. * All of the lights added to this scene
  35858. * @see http://doc.babylonjs.com/babylon101/lights
  35859. */
  35860. lights: Light[];
  35861. /**
  35862. * All of the (abstract) meshes added to this scene
  35863. */
  35864. meshes: AbstractMesh[];
  35865. /**
  35866. * The list of skeletons added to the scene
  35867. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35868. */
  35869. skeletons: Skeleton[];
  35870. /**
  35871. * All of the particle systems added to this scene
  35872. * @see http://doc.babylonjs.com/babylon101/particles
  35873. */
  35874. particleSystems: IParticleSystem[];
  35875. /**
  35876. * Gets a list of Animations associated with the scene
  35877. */
  35878. animations: Animation[];
  35879. /**
  35880. * All of the animation groups added to this scene
  35881. * @see http://doc.babylonjs.com/how_to/group
  35882. */
  35883. animationGroups: AnimationGroup[];
  35884. /**
  35885. * All of the multi-materials added to this scene
  35886. * @see http://doc.babylonjs.com/how_to/multi_materials
  35887. */
  35888. multiMaterials: MultiMaterial[];
  35889. /**
  35890. * All of the materials added to this scene
  35891. * In the context of a Scene, it is not supposed to be modified manually.
  35892. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35893. * Note also that the order of the Material wihin the array is not significant and might change.
  35894. * @see http://doc.babylonjs.com/babylon101/materials
  35895. */
  35896. materials: Material[];
  35897. /**
  35898. * The list of morph target managers added to the scene
  35899. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35900. */
  35901. morphTargetManagers: MorphTargetManager[];
  35902. /**
  35903. * The list of geometries used in the scene.
  35904. */
  35905. geometries: Geometry[];
  35906. /**
  35907. * All of the tranform nodes added to this scene
  35908. * In the context of a Scene, it is not supposed to be modified manually.
  35909. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35910. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35911. * @see http://doc.babylonjs.com/how_to/transformnode
  35912. */
  35913. transformNodes: TransformNode[];
  35914. /**
  35915. * ActionManagers available on the scene.
  35916. */
  35917. actionManagers: AbstractActionManager[];
  35918. /**
  35919. * Textures to keep.
  35920. */
  35921. textures: BaseTexture[];
  35922. /**
  35923. * Environment texture for the scene
  35924. */
  35925. environmentTexture: Nullable<BaseTexture>;
  35926. }
  35927. }
  35928. declare module "babylonjs/Audio/sound" {
  35929. import { Observable } from "babylonjs/Misc/observable";
  35930. import { Vector3 } from "babylonjs/Maths/math.vector";
  35931. import { Nullable } from "babylonjs/types";
  35932. import { Scene } from "babylonjs/scene";
  35933. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35934. /**
  35935. * Interface used to define options for Sound class
  35936. */
  35937. export interface ISoundOptions {
  35938. /**
  35939. * Does the sound autoplay once loaded.
  35940. */
  35941. autoplay?: boolean;
  35942. /**
  35943. * Does the sound loop after it finishes playing once.
  35944. */
  35945. loop?: boolean;
  35946. /**
  35947. * Sound's volume
  35948. */
  35949. volume?: number;
  35950. /**
  35951. * Is it a spatial sound?
  35952. */
  35953. spatialSound?: boolean;
  35954. /**
  35955. * Maximum distance to hear that sound
  35956. */
  35957. maxDistance?: number;
  35958. /**
  35959. * Uses user defined attenuation function
  35960. */
  35961. useCustomAttenuation?: boolean;
  35962. /**
  35963. * Define the roll off factor of spatial sounds.
  35964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35965. */
  35966. rolloffFactor?: number;
  35967. /**
  35968. * Define the reference distance the sound should be heard perfectly.
  35969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35970. */
  35971. refDistance?: number;
  35972. /**
  35973. * Define the distance attenuation model the sound will follow.
  35974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35975. */
  35976. distanceModel?: string;
  35977. /**
  35978. * Defines the playback speed (1 by default)
  35979. */
  35980. playbackRate?: number;
  35981. /**
  35982. * Defines if the sound is from a streaming source
  35983. */
  35984. streaming?: boolean;
  35985. /**
  35986. * Defines an optional length (in seconds) inside the sound file
  35987. */
  35988. length?: number;
  35989. /**
  35990. * Defines an optional offset (in seconds) inside the sound file
  35991. */
  35992. offset?: number;
  35993. /**
  35994. * If true, URLs will not be required to state the audio file codec to use.
  35995. */
  35996. skipCodecCheck?: boolean;
  35997. }
  35998. /**
  35999. * Defines a sound that can be played in the application.
  36000. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36001. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36002. */
  36003. export class Sound {
  36004. /**
  36005. * The name of the sound in the scene.
  36006. */
  36007. name: string;
  36008. /**
  36009. * Does the sound autoplay once loaded.
  36010. */
  36011. autoplay: boolean;
  36012. /**
  36013. * Does the sound loop after it finishes playing once.
  36014. */
  36015. loop: boolean;
  36016. /**
  36017. * Does the sound use a custom attenuation curve to simulate the falloff
  36018. * happening when the source gets further away from the camera.
  36019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36020. */
  36021. useCustomAttenuation: boolean;
  36022. /**
  36023. * The sound track id this sound belongs to.
  36024. */
  36025. soundTrackId: number;
  36026. /**
  36027. * Is this sound currently played.
  36028. */
  36029. isPlaying: boolean;
  36030. /**
  36031. * Is this sound currently paused.
  36032. */
  36033. isPaused: boolean;
  36034. /**
  36035. * Does this sound enables spatial sound.
  36036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36037. */
  36038. spatialSound: boolean;
  36039. /**
  36040. * Define the reference distance the sound should be heard perfectly.
  36041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36042. */
  36043. refDistance: number;
  36044. /**
  36045. * Define the roll off factor of spatial sounds.
  36046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36047. */
  36048. rolloffFactor: number;
  36049. /**
  36050. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36052. */
  36053. maxDistance: number;
  36054. /**
  36055. * Define the distance attenuation model the sound will follow.
  36056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36057. */
  36058. distanceModel: string;
  36059. /**
  36060. * @hidden
  36061. * Back Compat
  36062. **/
  36063. onended: () => any;
  36064. /**
  36065. * Observable event when the current playing sound finishes.
  36066. */
  36067. onEndedObservable: Observable<Sound>;
  36068. private _panningModel;
  36069. private _playbackRate;
  36070. private _streaming;
  36071. private _startTime;
  36072. private _startOffset;
  36073. private _position;
  36074. /** @hidden */
  36075. _positionInEmitterSpace: boolean;
  36076. private _localDirection;
  36077. private _volume;
  36078. private _isReadyToPlay;
  36079. private _isDirectional;
  36080. private _readyToPlayCallback;
  36081. private _audioBuffer;
  36082. private _soundSource;
  36083. private _streamingSource;
  36084. private _soundPanner;
  36085. private _soundGain;
  36086. private _inputAudioNode;
  36087. private _outputAudioNode;
  36088. private _coneInnerAngle;
  36089. private _coneOuterAngle;
  36090. private _coneOuterGain;
  36091. private _scene;
  36092. private _connectedTransformNode;
  36093. private _customAttenuationFunction;
  36094. private _registerFunc;
  36095. private _isOutputConnected;
  36096. private _htmlAudioElement;
  36097. private _urlType;
  36098. private _length?;
  36099. private _offset?;
  36100. /** @hidden */
  36101. static _SceneComponentInitialization: (scene: Scene) => void;
  36102. /**
  36103. * Create a sound and attach it to a scene
  36104. * @param name Name of your sound
  36105. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36106. * @param scene defines the scene the sound belongs to
  36107. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36108. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36109. */
  36110. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36111. /**
  36112. * Release the sound and its associated resources
  36113. */
  36114. dispose(): void;
  36115. /**
  36116. * Gets if the sounds is ready to be played or not.
  36117. * @returns true if ready, otherwise false
  36118. */
  36119. isReady(): boolean;
  36120. private _soundLoaded;
  36121. /**
  36122. * Sets the data of the sound from an audiobuffer
  36123. * @param audioBuffer The audioBuffer containing the data
  36124. */
  36125. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36126. /**
  36127. * Updates the current sounds options such as maxdistance, loop...
  36128. * @param options A JSON object containing values named as the object properties
  36129. */
  36130. updateOptions(options: ISoundOptions): void;
  36131. private _createSpatialParameters;
  36132. private _updateSpatialParameters;
  36133. /**
  36134. * Switch the panning model to HRTF:
  36135. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36136. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36137. */
  36138. switchPanningModelToHRTF(): void;
  36139. /**
  36140. * Switch the panning model to Equal Power:
  36141. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36143. */
  36144. switchPanningModelToEqualPower(): void;
  36145. private _switchPanningModel;
  36146. /**
  36147. * Connect this sound to a sound track audio node like gain...
  36148. * @param soundTrackAudioNode the sound track audio node to connect to
  36149. */
  36150. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36151. /**
  36152. * Transform this sound into a directional source
  36153. * @param coneInnerAngle Size of the inner cone in degree
  36154. * @param coneOuterAngle Size of the outer cone in degree
  36155. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36156. */
  36157. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36158. /**
  36159. * Gets or sets the inner angle for the directional cone.
  36160. */
  36161. /**
  36162. * Gets or sets the inner angle for the directional cone.
  36163. */
  36164. directionalConeInnerAngle: number;
  36165. /**
  36166. * Gets or sets the outer angle for the directional cone.
  36167. */
  36168. /**
  36169. * Gets or sets the outer angle for the directional cone.
  36170. */
  36171. directionalConeOuterAngle: number;
  36172. /**
  36173. * Sets the position of the emitter if spatial sound is enabled
  36174. * @param newPosition Defines the new posisiton
  36175. */
  36176. setPosition(newPosition: Vector3): void;
  36177. /**
  36178. * Sets the local direction of the emitter if spatial sound is enabled
  36179. * @param newLocalDirection Defines the new local direction
  36180. */
  36181. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36182. private _updateDirection;
  36183. /** @hidden */
  36184. updateDistanceFromListener(): void;
  36185. /**
  36186. * Sets a new custom attenuation function for the sound.
  36187. * @param callback Defines the function used for the attenuation
  36188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36189. */
  36190. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36191. /**
  36192. * Play the sound
  36193. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36194. * @param offset (optional) Start the sound at a specific time in seconds
  36195. * @param length (optional) Sound duration (in seconds)
  36196. */
  36197. play(time?: number, offset?: number, length?: number): void;
  36198. private _onended;
  36199. /**
  36200. * Stop the sound
  36201. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36202. */
  36203. stop(time?: number): void;
  36204. /**
  36205. * Put the sound in pause
  36206. */
  36207. pause(): void;
  36208. /**
  36209. * Sets a dedicated volume for this sounds
  36210. * @param newVolume Define the new volume of the sound
  36211. * @param time Define time for gradual change to new volume
  36212. */
  36213. setVolume(newVolume: number, time?: number): void;
  36214. /**
  36215. * Set the sound play back rate
  36216. * @param newPlaybackRate Define the playback rate the sound should be played at
  36217. */
  36218. setPlaybackRate(newPlaybackRate: number): void;
  36219. /**
  36220. * Gets the volume of the sound.
  36221. * @returns the volume of the sound
  36222. */
  36223. getVolume(): number;
  36224. /**
  36225. * Attach the sound to a dedicated mesh
  36226. * @param transformNode The transform node to connect the sound with
  36227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36228. */
  36229. attachToMesh(transformNode: TransformNode): void;
  36230. /**
  36231. * Detach the sound from the previously attached mesh
  36232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36233. */
  36234. detachFromMesh(): void;
  36235. private _onRegisterAfterWorldMatrixUpdate;
  36236. /**
  36237. * Clone the current sound in the scene.
  36238. * @returns the new sound clone
  36239. */
  36240. clone(): Nullable<Sound>;
  36241. /**
  36242. * Gets the current underlying audio buffer containing the data
  36243. * @returns the audio buffer
  36244. */
  36245. getAudioBuffer(): Nullable<AudioBuffer>;
  36246. /**
  36247. * Serializes the Sound in a JSON representation
  36248. * @returns the JSON representation of the sound
  36249. */
  36250. serialize(): any;
  36251. /**
  36252. * Parse a JSON representation of a sound to innstantiate in a given scene
  36253. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36254. * @param scene Define the scene the new parsed sound should be created in
  36255. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36256. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36257. * @returns the newly parsed sound
  36258. */
  36259. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36260. }
  36261. }
  36262. declare module "babylonjs/Actions/directAudioActions" {
  36263. import { Action } from "babylonjs/Actions/action";
  36264. import { Condition } from "babylonjs/Actions/condition";
  36265. import { Sound } from "babylonjs/Audio/sound";
  36266. /**
  36267. * This defines an action helpful to play a defined sound on a triggered action.
  36268. */
  36269. export class PlaySoundAction extends Action {
  36270. private _sound;
  36271. /**
  36272. * Instantiate the action
  36273. * @param triggerOptions defines the trigger options
  36274. * @param sound defines the sound to play
  36275. * @param condition defines the trigger related conditions
  36276. */
  36277. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36278. /** @hidden */
  36279. _prepare(): void;
  36280. /**
  36281. * Execute the action and play the sound.
  36282. */
  36283. execute(): void;
  36284. /**
  36285. * Serializes the actions and its related information.
  36286. * @param parent defines the object to serialize in
  36287. * @returns the serialized object
  36288. */
  36289. serialize(parent: any): any;
  36290. }
  36291. /**
  36292. * This defines an action helpful to stop a defined sound on a triggered action.
  36293. */
  36294. export class StopSoundAction extends Action {
  36295. private _sound;
  36296. /**
  36297. * Instantiate the action
  36298. * @param triggerOptions defines the trigger options
  36299. * @param sound defines the sound to stop
  36300. * @param condition defines the trigger related conditions
  36301. */
  36302. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36303. /** @hidden */
  36304. _prepare(): void;
  36305. /**
  36306. * Execute the action and stop the sound.
  36307. */
  36308. execute(): void;
  36309. /**
  36310. * Serializes the actions and its related information.
  36311. * @param parent defines the object to serialize in
  36312. * @returns the serialized object
  36313. */
  36314. serialize(parent: any): any;
  36315. }
  36316. }
  36317. declare module "babylonjs/Actions/interpolateValueAction" {
  36318. import { Action } from "babylonjs/Actions/action";
  36319. import { Condition } from "babylonjs/Actions/condition";
  36320. import { Observable } from "babylonjs/Misc/observable";
  36321. /**
  36322. * This defines an action responsible to change the value of a property
  36323. * by interpolating between its current value and the newly set one once triggered.
  36324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36325. */
  36326. export class InterpolateValueAction extends Action {
  36327. /**
  36328. * Defines the path of the property where the value should be interpolated
  36329. */
  36330. propertyPath: string;
  36331. /**
  36332. * Defines the target value at the end of the interpolation.
  36333. */
  36334. value: any;
  36335. /**
  36336. * Defines the time it will take for the property to interpolate to the value.
  36337. */
  36338. duration: number;
  36339. /**
  36340. * Defines if the other scene animations should be stopped when the action has been triggered
  36341. */
  36342. stopOtherAnimations?: boolean;
  36343. /**
  36344. * Defines a callback raised once the interpolation animation has been done.
  36345. */
  36346. onInterpolationDone?: () => void;
  36347. /**
  36348. * Observable triggered once the interpolation animation has been done.
  36349. */
  36350. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36351. private _target;
  36352. private _effectiveTarget;
  36353. private _property;
  36354. /**
  36355. * Instantiate the action
  36356. * @param triggerOptions defines the trigger options
  36357. * @param target defines the object containing the value to interpolate
  36358. * @param propertyPath defines the path to the property in the target object
  36359. * @param value defines the target value at the end of the interpolation
  36360. * @param duration deines the time it will take for the property to interpolate to the value.
  36361. * @param condition defines the trigger related conditions
  36362. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36363. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36364. */
  36365. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36366. /** @hidden */
  36367. _prepare(): void;
  36368. /**
  36369. * Execute the action starts the value interpolation.
  36370. */
  36371. execute(): void;
  36372. /**
  36373. * Serializes the actions and its related information.
  36374. * @param parent defines the object to serialize in
  36375. * @returns the serialized object
  36376. */
  36377. serialize(parent: any): any;
  36378. }
  36379. }
  36380. declare module "babylonjs/Actions/index" {
  36381. export * from "babylonjs/Actions/abstractActionManager";
  36382. export * from "babylonjs/Actions/action";
  36383. export * from "babylonjs/Actions/actionEvent";
  36384. export * from "babylonjs/Actions/actionManager";
  36385. export * from "babylonjs/Actions/condition";
  36386. export * from "babylonjs/Actions/directActions";
  36387. export * from "babylonjs/Actions/directAudioActions";
  36388. export * from "babylonjs/Actions/interpolateValueAction";
  36389. }
  36390. declare module "babylonjs/Animations/index" {
  36391. export * from "babylonjs/Animations/animatable";
  36392. export * from "babylonjs/Animations/animation";
  36393. export * from "babylonjs/Animations/animationGroup";
  36394. export * from "babylonjs/Animations/animationPropertiesOverride";
  36395. export * from "babylonjs/Animations/easing";
  36396. export * from "babylonjs/Animations/runtimeAnimation";
  36397. export * from "babylonjs/Animations/animationEvent";
  36398. export * from "babylonjs/Animations/animationGroup";
  36399. export * from "babylonjs/Animations/animationKey";
  36400. export * from "babylonjs/Animations/animationRange";
  36401. export * from "babylonjs/Animations/animatable.interface";
  36402. }
  36403. declare module "babylonjs/Audio/soundTrack" {
  36404. import { Sound } from "babylonjs/Audio/sound";
  36405. import { Analyser } from "babylonjs/Audio/analyser";
  36406. import { Scene } from "babylonjs/scene";
  36407. /**
  36408. * Options allowed during the creation of a sound track.
  36409. */
  36410. export interface ISoundTrackOptions {
  36411. /**
  36412. * The volume the sound track should take during creation
  36413. */
  36414. volume?: number;
  36415. /**
  36416. * Define if the sound track is the main sound track of the scene
  36417. */
  36418. mainTrack?: boolean;
  36419. }
  36420. /**
  36421. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36422. * It will be also used in a future release to apply effects on a specific track.
  36423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36424. */
  36425. export class SoundTrack {
  36426. /**
  36427. * The unique identifier of the sound track in the scene.
  36428. */
  36429. id: number;
  36430. /**
  36431. * The list of sounds included in the sound track.
  36432. */
  36433. soundCollection: Array<Sound>;
  36434. private _outputAudioNode;
  36435. private _scene;
  36436. private _isMainTrack;
  36437. private _connectedAnalyser;
  36438. private _options;
  36439. private _isInitialized;
  36440. /**
  36441. * Creates a new sound track.
  36442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36443. * @param scene Define the scene the sound track belongs to
  36444. * @param options
  36445. */
  36446. constructor(scene: Scene, options?: ISoundTrackOptions);
  36447. private _initializeSoundTrackAudioGraph;
  36448. /**
  36449. * Release the sound track and its associated resources
  36450. */
  36451. dispose(): void;
  36452. /**
  36453. * Adds a sound to this sound track
  36454. * @param sound define the cound to add
  36455. * @ignoreNaming
  36456. */
  36457. AddSound(sound: Sound): void;
  36458. /**
  36459. * Removes a sound to this sound track
  36460. * @param sound define the cound to remove
  36461. * @ignoreNaming
  36462. */
  36463. RemoveSound(sound: Sound): void;
  36464. /**
  36465. * Set a global volume for the full sound track.
  36466. * @param newVolume Define the new volume of the sound track
  36467. */
  36468. setVolume(newVolume: number): void;
  36469. /**
  36470. * Switch the panning model to HRTF:
  36471. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36473. */
  36474. switchPanningModelToHRTF(): void;
  36475. /**
  36476. * Switch the panning model to Equal Power:
  36477. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36479. */
  36480. switchPanningModelToEqualPower(): void;
  36481. /**
  36482. * Connect the sound track to an audio analyser allowing some amazing
  36483. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36485. * @param analyser The analyser to connect to the engine
  36486. */
  36487. connectToAnalyser(analyser: Analyser): void;
  36488. }
  36489. }
  36490. declare module "babylonjs/Audio/audioSceneComponent" {
  36491. import { Sound } from "babylonjs/Audio/sound";
  36492. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36493. import { Nullable } from "babylonjs/types";
  36494. import { Vector3 } from "babylonjs/Maths/math.vector";
  36495. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36496. import { Scene } from "babylonjs/scene";
  36497. import { AbstractScene } from "babylonjs/abstractScene";
  36498. import "babylonjs/Audio/audioEngine";
  36499. module "babylonjs/abstractScene" {
  36500. interface AbstractScene {
  36501. /**
  36502. * The list of sounds used in the scene.
  36503. */
  36504. sounds: Nullable<Array<Sound>>;
  36505. }
  36506. }
  36507. module "babylonjs/scene" {
  36508. interface Scene {
  36509. /**
  36510. * @hidden
  36511. * Backing field
  36512. */
  36513. _mainSoundTrack: SoundTrack;
  36514. /**
  36515. * The main sound track played by the scene.
  36516. * It cotains your primary collection of sounds.
  36517. */
  36518. mainSoundTrack: SoundTrack;
  36519. /**
  36520. * The list of sound tracks added to the scene
  36521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36522. */
  36523. soundTracks: Nullable<Array<SoundTrack>>;
  36524. /**
  36525. * Gets a sound using a given name
  36526. * @param name defines the name to search for
  36527. * @return the found sound or null if not found at all.
  36528. */
  36529. getSoundByName(name: string): Nullable<Sound>;
  36530. /**
  36531. * Gets or sets if audio support is enabled
  36532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36533. */
  36534. audioEnabled: boolean;
  36535. /**
  36536. * Gets or sets if audio will be output to headphones
  36537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36538. */
  36539. headphone: boolean;
  36540. /**
  36541. * Gets or sets custom audio listener position provider
  36542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36543. */
  36544. audioListenerPositionProvider: Nullable<() => Vector3>;
  36545. }
  36546. }
  36547. /**
  36548. * Defines the sound scene component responsible to manage any sounds
  36549. * in a given scene.
  36550. */
  36551. export class AudioSceneComponent implements ISceneSerializableComponent {
  36552. /**
  36553. * The component name helpfull to identify the component in the list of scene components.
  36554. */
  36555. readonly name: string;
  36556. /**
  36557. * The scene the component belongs to.
  36558. */
  36559. scene: Scene;
  36560. private _audioEnabled;
  36561. /**
  36562. * Gets whether audio is enabled or not.
  36563. * Please use related enable/disable method to switch state.
  36564. */
  36565. readonly audioEnabled: boolean;
  36566. private _headphone;
  36567. /**
  36568. * Gets whether audio is outputing to headphone or not.
  36569. * Please use the according Switch methods to change output.
  36570. */
  36571. readonly headphone: boolean;
  36572. private _audioListenerPositionProvider;
  36573. /**
  36574. * Gets the current audio listener position provider
  36575. */
  36576. /**
  36577. * Sets a custom listener position for all sounds in the scene
  36578. * By default, this is the position of the first active camera
  36579. */
  36580. audioListenerPositionProvider: Nullable<() => Vector3>;
  36581. /**
  36582. * Creates a new instance of the component for the given scene
  36583. * @param scene Defines the scene to register the component in
  36584. */
  36585. constructor(scene: Scene);
  36586. /**
  36587. * Registers the component in a given scene
  36588. */
  36589. register(): void;
  36590. /**
  36591. * Rebuilds the elements related to this component in case of
  36592. * context lost for instance.
  36593. */
  36594. rebuild(): void;
  36595. /**
  36596. * Serializes the component data to the specified json object
  36597. * @param serializationObject The object to serialize to
  36598. */
  36599. serialize(serializationObject: any): void;
  36600. /**
  36601. * Adds all the elements from the container to the scene
  36602. * @param container the container holding the elements
  36603. */
  36604. addFromContainer(container: AbstractScene): void;
  36605. /**
  36606. * Removes all the elements in the container from the scene
  36607. * @param container contains the elements to remove
  36608. * @param dispose if the removed element should be disposed (default: false)
  36609. */
  36610. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36611. /**
  36612. * Disposes the component and the associated ressources.
  36613. */
  36614. dispose(): void;
  36615. /**
  36616. * Disables audio in the associated scene.
  36617. */
  36618. disableAudio(): void;
  36619. /**
  36620. * Enables audio in the associated scene.
  36621. */
  36622. enableAudio(): void;
  36623. /**
  36624. * Switch audio to headphone output.
  36625. */
  36626. switchAudioModeForHeadphones(): void;
  36627. /**
  36628. * Switch audio to normal speakers.
  36629. */
  36630. switchAudioModeForNormalSpeakers(): void;
  36631. private _afterRender;
  36632. }
  36633. }
  36634. declare module "babylonjs/Audio/weightedsound" {
  36635. import { Sound } from "babylonjs/Audio/sound";
  36636. /**
  36637. * Wraps one or more Sound objects and selects one with random weight for playback.
  36638. */
  36639. export class WeightedSound {
  36640. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36641. loop: boolean;
  36642. private _coneInnerAngle;
  36643. private _coneOuterAngle;
  36644. private _volume;
  36645. /** A Sound is currently playing. */
  36646. isPlaying: boolean;
  36647. /** A Sound is currently paused. */
  36648. isPaused: boolean;
  36649. private _sounds;
  36650. private _weights;
  36651. private _currentIndex?;
  36652. /**
  36653. * Creates a new WeightedSound from the list of sounds given.
  36654. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36655. * @param sounds Array of Sounds that will be selected from.
  36656. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36657. */
  36658. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36659. /**
  36660. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36661. */
  36662. /**
  36663. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36664. */
  36665. directionalConeInnerAngle: number;
  36666. /**
  36667. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36668. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36669. */
  36670. /**
  36671. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36672. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36673. */
  36674. directionalConeOuterAngle: number;
  36675. /**
  36676. * Playback volume.
  36677. */
  36678. /**
  36679. * Playback volume.
  36680. */
  36681. volume: number;
  36682. private _onended;
  36683. /**
  36684. * Suspend playback
  36685. */
  36686. pause(): void;
  36687. /**
  36688. * Stop playback
  36689. */
  36690. stop(): void;
  36691. /**
  36692. * Start playback.
  36693. * @param startOffset Position the clip head at a specific time in seconds.
  36694. */
  36695. play(startOffset?: number): void;
  36696. }
  36697. }
  36698. declare module "babylonjs/Audio/index" {
  36699. export * from "babylonjs/Audio/analyser";
  36700. export * from "babylonjs/Audio/audioEngine";
  36701. export * from "babylonjs/Audio/audioSceneComponent";
  36702. export * from "babylonjs/Audio/sound";
  36703. export * from "babylonjs/Audio/soundTrack";
  36704. export * from "babylonjs/Audio/weightedsound";
  36705. }
  36706. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36707. import { Behavior } from "babylonjs/Behaviors/behavior";
  36708. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36709. import { BackEase } from "babylonjs/Animations/easing";
  36710. /**
  36711. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36712. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36713. */
  36714. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36715. /**
  36716. * Gets the name of the behavior.
  36717. */
  36718. readonly name: string;
  36719. /**
  36720. * The easing function used by animations
  36721. */
  36722. static EasingFunction: BackEase;
  36723. /**
  36724. * The easing mode used by animations
  36725. */
  36726. static EasingMode: number;
  36727. /**
  36728. * The duration of the animation, in milliseconds
  36729. */
  36730. transitionDuration: number;
  36731. /**
  36732. * Length of the distance animated by the transition when lower radius is reached
  36733. */
  36734. lowerRadiusTransitionRange: number;
  36735. /**
  36736. * Length of the distance animated by the transition when upper radius is reached
  36737. */
  36738. upperRadiusTransitionRange: number;
  36739. private _autoTransitionRange;
  36740. /**
  36741. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36742. */
  36743. /**
  36744. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36745. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36746. */
  36747. autoTransitionRange: boolean;
  36748. private _attachedCamera;
  36749. private _onAfterCheckInputsObserver;
  36750. private _onMeshTargetChangedObserver;
  36751. /**
  36752. * Initializes the behavior.
  36753. */
  36754. init(): void;
  36755. /**
  36756. * Attaches the behavior to its arc rotate camera.
  36757. * @param camera Defines the camera to attach the behavior to
  36758. */
  36759. attach(camera: ArcRotateCamera): void;
  36760. /**
  36761. * Detaches the behavior from its current arc rotate camera.
  36762. */
  36763. detach(): void;
  36764. private _radiusIsAnimating;
  36765. private _radiusBounceTransition;
  36766. private _animatables;
  36767. private _cachedWheelPrecision;
  36768. /**
  36769. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36770. * @param radiusLimit The limit to check against.
  36771. * @return Bool to indicate if at limit.
  36772. */
  36773. private _isRadiusAtLimit;
  36774. /**
  36775. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36776. * @param radiusDelta The delta by which to animate to. Can be negative.
  36777. */
  36778. private _applyBoundRadiusAnimation;
  36779. /**
  36780. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36781. */
  36782. protected _clearAnimationLocks(): void;
  36783. /**
  36784. * Stops and removes all animations that have been applied to the camera
  36785. */
  36786. stopAllAnimations(): void;
  36787. }
  36788. }
  36789. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36790. import { Behavior } from "babylonjs/Behaviors/behavior";
  36791. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36792. import { ExponentialEase } from "babylonjs/Animations/easing";
  36793. import { Nullable } from "babylonjs/types";
  36794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36795. import { Vector3 } from "babylonjs/Maths/math.vector";
  36796. /**
  36797. * 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.
  36798. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36799. */
  36800. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36801. /**
  36802. * Gets the name of the behavior.
  36803. */
  36804. readonly name: string;
  36805. private _mode;
  36806. private _radiusScale;
  36807. private _positionScale;
  36808. private _defaultElevation;
  36809. private _elevationReturnTime;
  36810. private _elevationReturnWaitTime;
  36811. private _zoomStopsAnimation;
  36812. private _framingTime;
  36813. /**
  36814. * The easing function used by animations
  36815. */
  36816. static EasingFunction: ExponentialEase;
  36817. /**
  36818. * The easing mode used by animations
  36819. */
  36820. static EasingMode: number;
  36821. /**
  36822. * Sets the current mode used by the behavior
  36823. */
  36824. /**
  36825. * Gets current mode used by the behavior.
  36826. */
  36827. mode: number;
  36828. /**
  36829. * Sets the scale applied to the radius (1 by default)
  36830. */
  36831. /**
  36832. * Gets the scale applied to the radius
  36833. */
  36834. radiusScale: number;
  36835. /**
  36836. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36837. */
  36838. /**
  36839. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36840. */
  36841. positionScale: number;
  36842. /**
  36843. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36844. * behaviour is triggered, in radians.
  36845. */
  36846. /**
  36847. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36848. * behaviour is triggered, in radians.
  36849. */
  36850. defaultElevation: number;
  36851. /**
  36852. * Sets the time (in milliseconds) taken to return to the default beta position.
  36853. * Negative value indicates camera should not return to default.
  36854. */
  36855. /**
  36856. * Gets the time (in milliseconds) taken to return to the default beta position.
  36857. * Negative value indicates camera should not return to default.
  36858. */
  36859. elevationReturnTime: number;
  36860. /**
  36861. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36862. */
  36863. /**
  36864. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36865. */
  36866. elevationReturnWaitTime: number;
  36867. /**
  36868. * Sets the flag that indicates if user zooming should stop animation.
  36869. */
  36870. /**
  36871. * Gets the flag that indicates if user zooming should stop animation.
  36872. */
  36873. zoomStopsAnimation: boolean;
  36874. /**
  36875. * Sets the transition time when framing the mesh, in milliseconds
  36876. */
  36877. /**
  36878. * Gets the transition time when framing the mesh, in milliseconds
  36879. */
  36880. framingTime: number;
  36881. /**
  36882. * Define if the behavior should automatically change the configured
  36883. * camera limits and sensibilities.
  36884. */
  36885. autoCorrectCameraLimitsAndSensibility: boolean;
  36886. private _onPrePointerObservableObserver;
  36887. private _onAfterCheckInputsObserver;
  36888. private _onMeshTargetChangedObserver;
  36889. private _attachedCamera;
  36890. private _isPointerDown;
  36891. private _lastInteractionTime;
  36892. /**
  36893. * Initializes the behavior.
  36894. */
  36895. init(): void;
  36896. /**
  36897. * Attaches the behavior to its arc rotate camera.
  36898. * @param camera Defines the camera to attach the behavior to
  36899. */
  36900. attach(camera: ArcRotateCamera): void;
  36901. /**
  36902. * Detaches the behavior from its current arc rotate camera.
  36903. */
  36904. detach(): void;
  36905. private _animatables;
  36906. private _betaIsAnimating;
  36907. private _betaTransition;
  36908. private _radiusTransition;
  36909. private _vectorTransition;
  36910. /**
  36911. * Targets the given mesh and updates zoom level accordingly.
  36912. * @param mesh The mesh to target.
  36913. * @param radius Optional. If a cached radius position already exists, overrides default.
  36914. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36915. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36916. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36917. */
  36918. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36919. /**
  36920. * Targets the given mesh with its children and updates zoom level accordingly.
  36921. * @param mesh The mesh to target.
  36922. * @param radius Optional. If a cached radius position already exists, overrides default.
  36923. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36924. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36925. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36926. */
  36927. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36928. /**
  36929. * Targets the given meshes with their children and updates zoom level accordingly.
  36930. * @param meshes The mesh to target.
  36931. * @param radius Optional. If a cached radius position already exists, overrides default.
  36932. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36933. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36934. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36935. */
  36936. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36937. /**
  36938. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36939. * @param minimumWorld Determines the smaller position of the bounding box extend
  36940. * @param maximumWorld Determines the bigger position of the bounding box extend
  36941. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36942. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36943. */
  36944. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36945. /**
  36946. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36947. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36948. * frustum width.
  36949. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36950. * to fully enclose the mesh in the viewing frustum.
  36951. */
  36952. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36953. /**
  36954. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36955. * is automatically returned to its default position (expected to be above ground plane).
  36956. */
  36957. private _maintainCameraAboveGround;
  36958. /**
  36959. * Returns the frustum slope based on the canvas ratio and camera FOV
  36960. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36961. */
  36962. private _getFrustumSlope;
  36963. /**
  36964. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36965. */
  36966. private _clearAnimationLocks;
  36967. /**
  36968. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36969. */
  36970. private _applyUserInteraction;
  36971. /**
  36972. * Stops and removes all animations that have been applied to the camera
  36973. */
  36974. stopAllAnimations(): void;
  36975. /**
  36976. * Gets a value indicating if the user is moving the camera
  36977. */
  36978. readonly isUserIsMoving: boolean;
  36979. /**
  36980. * The camera can move all the way towards the mesh.
  36981. */
  36982. static IgnoreBoundsSizeMode: number;
  36983. /**
  36984. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36985. */
  36986. static FitFrustumSidesMode: number;
  36987. }
  36988. }
  36989. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36990. import { Nullable } from "babylonjs/types";
  36991. import { Camera } from "babylonjs/Cameras/camera";
  36992. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36993. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36994. /**
  36995. * Base class for Camera Pointer Inputs.
  36996. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36997. * for example usage.
  36998. */
  36999. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37000. /**
  37001. * Defines the camera the input is attached to.
  37002. */
  37003. abstract camera: Camera;
  37004. /**
  37005. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37006. */
  37007. protected _altKey: boolean;
  37008. protected _ctrlKey: boolean;
  37009. protected _metaKey: boolean;
  37010. protected _shiftKey: boolean;
  37011. /**
  37012. * Which mouse buttons were pressed at time of last mouse event.
  37013. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37014. */
  37015. protected _buttonsPressed: number;
  37016. /**
  37017. * Defines the buttons associated with the input to handle camera move.
  37018. */
  37019. buttons: number[];
  37020. /**
  37021. * Attach the input controls to a specific dom element to get the input from.
  37022. * @param element Defines the element the controls should be listened from
  37023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37024. */
  37025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37026. /**
  37027. * Detach the current controls from the specified dom element.
  37028. * @param element Defines the element to stop listening the inputs from
  37029. */
  37030. detachControl(element: Nullable<HTMLElement>): void;
  37031. /**
  37032. * Gets the class name of the current input.
  37033. * @returns the class name
  37034. */
  37035. getClassName(): string;
  37036. /**
  37037. * Get the friendly name associated with the input class.
  37038. * @returns the input friendly name
  37039. */
  37040. getSimpleName(): string;
  37041. /**
  37042. * Called on pointer POINTERDOUBLETAP event.
  37043. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37044. */
  37045. protected onDoubleTap(type: string): void;
  37046. /**
  37047. * Called on pointer POINTERMOVE event if only a single touch is active.
  37048. * Override this method to provide functionality.
  37049. */
  37050. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37051. /**
  37052. * Called on pointer POINTERMOVE event if multiple touches are active.
  37053. * Override this method to provide functionality.
  37054. */
  37055. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37056. /**
  37057. * Called on JS contextmenu event.
  37058. * Override this method to provide functionality.
  37059. */
  37060. protected onContextMenu(evt: PointerEvent): void;
  37061. /**
  37062. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37063. * press.
  37064. * Override this method to provide functionality.
  37065. */
  37066. protected onButtonDown(evt: PointerEvent): void;
  37067. /**
  37068. * Called each time a new POINTERUP event occurs. Ie, for each button
  37069. * release.
  37070. * Override this method to provide functionality.
  37071. */
  37072. protected onButtonUp(evt: PointerEvent): void;
  37073. /**
  37074. * Called when window becomes inactive.
  37075. * Override this method to provide functionality.
  37076. */
  37077. protected onLostFocus(): void;
  37078. private _pointerInput;
  37079. private _observer;
  37080. private _onLostFocus;
  37081. private pointA;
  37082. private pointB;
  37083. }
  37084. }
  37085. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37086. import { Nullable } from "babylonjs/types";
  37087. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37088. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37089. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37090. /**
  37091. * Manage the pointers inputs to control an arc rotate camera.
  37092. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37093. */
  37094. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37095. /**
  37096. * Defines the camera the input is attached to.
  37097. */
  37098. camera: ArcRotateCamera;
  37099. /**
  37100. * Gets the class name of the current input.
  37101. * @returns the class name
  37102. */
  37103. getClassName(): string;
  37104. /**
  37105. * Defines the buttons associated with the input to handle camera move.
  37106. */
  37107. buttons: number[];
  37108. /**
  37109. * Defines the pointer angular sensibility along the X axis or how fast is
  37110. * the camera rotating.
  37111. */
  37112. angularSensibilityX: number;
  37113. /**
  37114. * Defines the pointer angular sensibility along the Y axis or how fast is
  37115. * the camera rotating.
  37116. */
  37117. angularSensibilityY: number;
  37118. /**
  37119. * Defines the pointer pinch precision or how fast is the camera zooming.
  37120. */
  37121. pinchPrecision: number;
  37122. /**
  37123. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37124. * from 0.
  37125. * It defines the percentage of current camera.radius to use as delta when
  37126. * pinch zoom is used.
  37127. */
  37128. pinchDeltaPercentage: number;
  37129. /**
  37130. * Defines the pointer panning sensibility or how fast is the camera moving.
  37131. */
  37132. panningSensibility: number;
  37133. /**
  37134. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37135. */
  37136. multiTouchPanning: boolean;
  37137. /**
  37138. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37139. * zoom (pinch) through multitouch.
  37140. */
  37141. multiTouchPanAndZoom: boolean;
  37142. /**
  37143. * Revers pinch action direction.
  37144. */
  37145. pinchInwards: boolean;
  37146. private _isPanClick;
  37147. private _twoFingerActivityCount;
  37148. private _isPinching;
  37149. /**
  37150. * Called on pointer POINTERMOVE event if only a single touch is active.
  37151. */
  37152. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37153. /**
  37154. * Called on pointer POINTERDOUBLETAP event.
  37155. */
  37156. protected onDoubleTap(type: string): void;
  37157. /**
  37158. * Called on pointer POINTERMOVE event if multiple touches are active.
  37159. */
  37160. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37161. /**
  37162. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37163. * press.
  37164. */
  37165. protected onButtonDown(evt: PointerEvent): void;
  37166. /**
  37167. * Called each time a new POINTERUP event occurs. Ie, for each button
  37168. * release.
  37169. */
  37170. protected onButtonUp(evt: PointerEvent): void;
  37171. /**
  37172. * Called when window becomes inactive.
  37173. */
  37174. protected onLostFocus(): void;
  37175. }
  37176. }
  37177. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37178. import { Nullable } from "babylonjs/types";
  37179. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37180. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37181. /**
  37182. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37184. */
  37185. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37186. /**
  37187. * Defines the camera the input is attached to.
  37188. */
  37189. camera: ArcRotateCamera;
  37190. /**
  37191. * Defines the list of key codes associated with the up action (increase alpha)
  37192. */
  37193. keysUp: number[];
  37194. /**
  37195. * Defines the list of key codes associated with the down action (decrease alpha)
  37196. */
  37197. keysDown: number[];
  37198. /**
  37199. * Defines the list of key codes associated with the left action (increase beta)
  37200. */
  37201. keysLeft: number[];
  37202. /**
  37203. * Defines the list of key codes associated with the right action (decrease beta)
  37204. */
  37205. keysRight: number[];
  37206. /**
  37207. * Defines the list of key codes associated with the reset action.
  37208. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37209. */
  37210. keysReset: number[];
  37211. /**
  37212. * Defines the panning sensibility of the inputs.
  37213. * (How fast is the camera paning)
  37214. */
  37215. panningSensibility: number;
  37216. /**
  37217. * Defines the zooming sensibility of the inputs.
  37218. * (How fast is the camera zooming)
  37219. */
  37220. zoomingSensibility: number;
  37221. /**
  37222. * Defines wether maintaining the alt key down switch the movement mode from
  37223. * orientation to zoom.
  37224. */
  37225. useAltToZoom: boolean;
  37226. /**
  37227. * Rotation speed of the camera
  37228. */
  37229. angularSpeed: number;
  37230. private _keys;
  37231. private _ctrlPressed;
  37232. private _altPressed;
  37233. private _onCanvasBlurObserver;
  37234. private _onKeyboardObserver;
  37235. private _engine;
  37236. private _scene;
  37237. /**
  37238. * Attach the input controls to a specific dom element to get the input from.
  37239. * @param element Defines the element the controls should be listened from
  37240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37241. */
  37242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37243. /**
  37244. * Detach the current controls from the specified dom element.
  37245. * @param element Defines the element to stop listening the inputs from
  37246. */
  37247. detachControl(element: Nullable<HTMLElement>): void;
  37248. /**
  37249. * Update the current camera state depending on the inputs that have been used this frame.
  37250. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37251. */
  37252. checkInputs(): void;
  37253. /**
  37254. * Gets the class name of the current intput.
  37255. * @returns the class name
  37256. */
  37257. getClassName(): string;
  37258. /**
  37259. * Get the friendly name associated with the input class.
  37260. * @returns the input friendly name
  37261. */
  37262. getSimpleName(): string;
  37263. }
  37264. }
  37265. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37266. import { Nullable } from "babylonjs/types";
  37267. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37268. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37269. /**
  37270. * Manage the mouse wheel inputs to control an arc rotate camera.
  37271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37272. */
  37273. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37274. /**
  37275. * Defines the camera the input is attached to.
  37276. */
  37277. camera: ArcRotateCamera;
  37278. /**
  37279. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37280. */
  37281. wheelPrecision: number;
  37282. /**
  37283. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37284. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37285. */
  37286. wheelDeltaPercentage: number;
  37287. private _wheel;
  37288. private _observer;
  37289. private computeDeltaFromMouseWheelLegacyEvent;
  37290. /**
  37291. * Attach the input controls to a specific dom element to get the input from.
  37292. * @param element Defines the element the controls should be listened from
  37293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37294. */
  37295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37296. /**
  37297. * Detach the current controls from the specified dom element.
  37298. * @param element Defines the element to stop listening the inputs from
  37299. */
  37300. detachControl(element: Nullable<HTMLElement>): void;
  37301. /**
  37302. * Gets the class name of the current intput.
  37303. * @returns the class name
  37304. */
  37305. getClassName(): string;
  37306. /**
  37307. * Get the friendly name associated with the input class.
  37308. * @returns the input friendly name
  37309. */
  37310. getSimpleName(): string;
  37311. }
  37312. }
  37313. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37314. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37315. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37316. /**
  37317. * Default Inputs manager for the ArcRotateCamera.
  37318. * It groups all the default supported inputs for ease of use.
  37319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37320. */
  37321. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37322. /**
  37323. * Instantiates a new ArcRotateCameraInputsManager.
  37324. * @param camera Defines the camera the inputs belong to
  37325. */
  37326. constructor(camera: ArcRotateCamera);
  37327. /**
  37328. * Add mouse wheel input support to the input manager.
  37329. * @returns the current input manager
  37330. */
  37331. addMouseWheel(): ArcRotateCameraInputsManager;
  37332. /**
  37333. * Add pointers input support to the input manager.
  37334. * @returns the current input manager
  37335. */
  37336. addPointers(): ArcRotateCameraInputsManager;
  37337. /**
  37338. * Add keyboard input support to the input manager.
  37339. * @returns the current input manager
  37340. */
  37341. addKeyboard(): ArcRotateCameraInputsManager;
  37342. }
  37343. }
  37344. declare module "babylonjs/Cameras/arcRotateCamera" {
  37345. import { Observable } from "babylonjs/Misc/observable";
  37346. import { Nullable } from "babylonjs/types";
  37347. import { Scene } from "babylonjs/scene";
  37348. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37350. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37351. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37352. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37353. import { Camera } from "babylonjs/Cameras/camera";
  37354. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37355. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37356. import { Collider } from "babylonjs/Collisions/collider";
  37357. /**
  37358. * This represents an orbital type of camera.
  37359. *
  37360. * 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.
  37361. * 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.
  37362. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37363. */
  37364. export class ArcRotateCamera extends TargetCamera {
  37365. /**
  37366. * Defines the rotation angle of the camera along the longitudinal axis.
  37367. */
  37368. alpha: number;
  37369. /**
  37370. * Defines the rotation angle of the camera along the latitudinal axis.
  37371. */
  37372. beta: number;
  37373. /**
  37374. * Defines the radius of the camera from it s target point.
  37375. */
  37376. radius: number;
  37377. protected _target: Vector3;
  37378. protected _targetHost: Nullable<AbstractMesh>;
  37379. /**
  37380. * Defines the target point of the camera.
  37381. * The camera looks towards it form the radius distance.
  37382. */
  37383. target: Vector3;
  37384. /**
  37385. * Define the current local position of the camera in the scene
  37386. */
  37387. position: Vector3;
  37388. protected _upVector: Vector3;
  37389. protected _upToYMatrix: Matrix;
  37390. protected _YToUpMatrix: Matrix;
  37391. /**
  37392. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37393. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37394. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37395. */
  37396. upVector: Vector3;
  37397. /**
  37398. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37399. */
  37400. setMatUp(): void;
  37401. /**
  37402. * Current inertia value on the longitudinal axis.
  37403. * The bigger this number the longer it will take for the camera to stop.
  37404. */
  37405. inertialAlphaOffset: number;
  37406. /**
  37407. * Current inertia value on the latitudinal axis.
  37408. * The bigger this number the longer it will take for the camera to stop.
  37409. */
  37410. inertialBetaOffset: number;
  37411. /**
  37412. * Current inertia value on the radius axis.
  37413. * The bigger this number the longer it will take for the camera to stop.
  37414. */
  37415. inertialRadiusOffset: number;
  37416. /**
  37417. * Minimum allowed angle on the longitudinal axis.
  37418. * This can help limiting how the Camera is able to move in the scene.
  37419. */
  37420. lowerAlphaLimit: Nullable<number>;
  37421. /**
  37422. * Maximum allowed angle on the longitudinal axis.
  37423. * This can help limiting how the Camera is able to move in the scene.
  37424. */
  37425. upperAlphaLimit: Nullable<number>;
  37426. /**
  37427. * Minimum allowed angle on the latitudinal axis.
  37428. * This can help limiting how the Camera is able to move in the scene.
  37429. */
  37430. lowerBetaLimit: number;
  37431. /**
  37432. * Maximum allowed angle on the latitudinal axis.
  37433. * This can help limiting how the Camera is able to move in the scene.
  37434. */
  37435. upperBetaLimit: number;
  37436. /**
  37437. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37438. * This can help limiting how the Camera is able to move in the scene.
  37439. */
  37440. lowerRadiusLimit: Nullable<number>;
  37441. /**
  37442. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37443. * This can help limiting how the Camera is able to move in the scene.
  37444. */
  37445. upperRadiusLimit: Nullable<number>;
  37446. /**
  37447. * Defines the current inertia value used during panning of the camera along the X axis.
  37448. */
  37449. inertialPanningX: number;
  37450. /**
  37451. * Defines the current inertia value used during panning of the camera along the Y axis.
  37452. */
  37453. inertialPanningY: number;
  37454. /**
  37455. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37456. * Basically if your fingers moves away from more than this distance you will be considered
  37457. * in pinch mode.
  37458. */
  37459. pinchToPanMaxDistance: number;
  37460. /**
  37461. * Defines the maximum distance the camera can pan.
  37462. * This could help keeping the cammera always in your scene.
  37463. */
  37464. panningDistanceLimit: Nullable<number>;
  37465. /**
  37466. * Defines the target of the camera before paning.
  37467. */
  37468. panningOriginTarget: Vector3;
  37469. /**
  37470. * Defines the value of the inertia used during panning.
  37471. * 0 would mean stop inertia and one would mean no decelleration at all.
  37472. */
  37473. panningInertia: number;
  37474. /**
  37475. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37476. */
  37477. angularSensibilityX: number;
  37478. /**
  37479. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37480. */
  37481. angularSensibilityY: number;
  37482. /**
  37483. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37484. */
  37485. pinchPrecision: number;
  37486. /**
  37487. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37488. * It will be used instead of pinchDeltaPrecision if different from 0.
  37489. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37490. */
  37491. pinchDeltaPercentage: number;
  37492. /**
  37493. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37494. */
  37495. panningSensibility: number;
  37496. /**
  37497. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37498. */
  37499. keysUp: number[];
  37500. /**
  37501. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37502. */
  37503. keysDown: number[];
  37504. /**
  37505. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37506. */
  37507. keysLeft: number[];
  37508. /**
  37509. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37510. */
  37511. keysRight: number[];
  37512. /**
  37513. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37514. */
  37515. wheelPrecision: number;
  37516. /**
  37517. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37518. * It will be used instead of pinchDeltaPrecision if different from 0.
  37519. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37520. */
  37521. wheelDeltaPercentage: number;
  37522. /**
  37523. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37524. */
  37525. zoomOnFactor: number;
  37526. /**
  37527. * Defines a screen offset for the camera position.
  37528. */
  37529. targetScreenOffset: Vector2;
  37530. /**
  37531. * Allows the camera to be completely reversed.
  37532. * If false the camera can not arrive upside down.
  37533. */
  37534. allowUpsideDown: boolean;
  37535. /**
  37536. * Define if double tap/click is used to restore the previously saved state of the camera.
  37537. */
  37538. useInputToRestoreState: boolean;
  37539. /** @hidden */
  37540. _viewMatrix: Matrix;
  37541. /** @hidden */
  37542. _useCtrlForPanning: boolean;
  37543. /** @hidden */
  37544. _panningMouseButton: number;
  37545. /**
  37546. * Defines the input associated to the camera.
  37547. */
  37548. inputs: ArcRotateCameraInputsManager;
  37549. /** @hidden */
  37550. _reset: () => void;
  37551. /**
  37552. * Defines the allowed panning axis.
  37553. */
  37554. panningAxis: Vector3;
  37555. protected _localDirection: Vector3;
  37556. protected _transformedDirection: Vector3;
  37557. private _bouncingBehavior;
  37558. /**
  37559. * Gets the bouncing behavior of the camera if it has been enabled.
  37560. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37561. */
  37562. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37563. /**
  37564. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37565. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37566. */
  37567. useBouncingBehavior: boolean;
  37568. private _framingBehavior;
  37569. /**
  37570. * Gets the framing behavior of the camera if it has been enabled.
  37571. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37572. */
  37573. readonly framingBehavior: Nullable<FramingBehavior>;
  37574. /**
  37575. * Defines if the framing behavior of the camera is enabled on the camera.
  37576. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37577. */
  37578. useFramingBehavior: boolean;
  37579. private _autoRotationBehavior;
  37580. /**
  37581. * Gets the auto rotation behavior of the camera if it has been enabled.
  37582. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37583. */
  37584. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37585. /**
  37586. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37587. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37588. */
  37589. useAutoRotationBehavior: boolean;
  37590. /**
  37591. * Observable triggered when the mesh target has been changed on the camera.
  37592. */
  37593. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37594. /**
  37595. * Event raised when the camera is colliding with a mesh.
  37596. */
  37597. onCollide: (collidedMesh: AbstractMesh) => void;
  37598. /**
  37599. * Defines whether the camera should check collision with the objects oh the scene.
  37600. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37601. */
  37602. checkCollisions: boolean;
  37603. /**
  37604. * Defines the collision radius of the camera.
  37605. * This simulates a sphere around the camera.
  37606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37607. */
  37608. collisionRadius: Vector3;
  37609. protected _collider: Collider;
  37610. protected _previousPosition: Vector3;
  37611. protected _collisionVelocity: Vector3;
  37612. protected _newPosition: Vector3;
  37613. protected _previousAlpha: number;
  37614. protected _previousBeta: number;
  37615. protected _previousRadius: number;
  37616. protected _collisionTriggered: boolean;
  37617. protected _targetBoundingCenter: Nullable<Vector3>;
  37618. private _computationVector;
  37619. /**
  37620. * Instantiates a new ArcRotateCamera in a given scene
  37621. * @param name Defines the name of the camera
  37622. * @param alpha Defines the camera rotation along the logitudinal axis
  37623. * @param beta Defines the camera rotation along the latitudinal axis
  37624. * @param radius Defines the camera distance from its target
  37625. * @param target Defines the camera target
  37626. * @param scene Defines the scene the camera belongs to
  37627. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37628. */
  37629. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37630. /** @hidden */
  37631. _initCache(): void;
  37632. /** @hidden */
  37633. _updateCache(ignoreParentClass?: boolean): void;
  37634. protected _getTargetPosition(): Vector3;
  37635. private _storedAlpha;
  37636. private _storedBeta;
  37637. private _storedRadius;
  37638. private _storedTarget;
  37639. private _storedTargetScreenOffset;
  37640. /**
  37641. * Stores the current state of the camera (alpha, beta, radius and target)
  37642. * @returns the camera itself
  37643. */
  37644. storeState(): Camera;
  37645. /**
  37646. * @hidden
  37647. * Restored camera state. You must call storeState() first
  37648. */
  37649. _restoreStateValues(): boolean;
  37650. /** @hidden */
  37651. _isSynchronizedViewMatrix(): boolean;
  37652. /**
  37653. * Attached controls to the current camera.
  37654. * @param element Defines the element the controls should be listened from
  37655. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37656. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37657. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37658. */
  37659. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37660. /**
  37661. * Detach the current controls from the camera.
  37662. * The camera will stop reacting to inputs.
  37663. * @param element Defines the element to stop listening the inputs from
  37664. */
  37665. detachControl(element: HTMLElement): void;
  37666. /** @hidden */
  37667. _checkInputs(): void;
  37668. protected _checkLimits(): void;
  37669. /**
  37670. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37671. */
  37672. rebuildAnglesAndRadius(): void;
  37673. /**
  37674. * Use a position to define the current camera related information like alpha, beta and radius
  37675. * @param position Defines the position to set the camera at
  37676. */
  37677. setPosition(position: Vector3): void;
  37678. /**
  37679. * Defines the target the camera should look at.
  37680. * This will automatically adapt alpha beta and radius to fit within the new target.
  37681. * @param target Defines the new target as a Vector or a mesh
  37682. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37683. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37684. */
  37685. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37686. /** @hidden */
  37687. _getViewMatrix(): Matrix;
  37688. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37689. /**
  37690. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37691. * @param meshes Defines the mesh to zoom on
  37692. * @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)
  37693. */
  37694. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37695. /**
  37696. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37697. * The target will be changed but the radius
  37698. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37699. * @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)
  37700. */
  37701. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37702. min: Vector3;
  37703. max: Vector3;
  37704. distance: number;
  37705. }, doNotUpdateMaxZ?: boolean): void;
  37706. /**
  37707. * @override
  37708. * Override Camera.createRigCamera
  37709. */
  37710. createRigCamera(name: string, cameraIndex: number): Camera;
  37711. /**
  37712. * @hidden
  37713. * @override
  37714. * Override Camera._updateRigCameras
  37715. */
  37716. _updateRigCameras(): void;
  37717. /**
  37718. * Destroy the camera and release the current resources hold by it.
  37719. */
  37720. dispose(): void;
  37721. /**
  37722. * Gets the current object class name.
  37723. * @return the class name
  37724. */
  37725. getClassName(): string;
  37726. }
  37727. }
  37728. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37729. import { Behavior } from "babylonjs/Behaviors/behavior";
  37730. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37731. /**
  37732. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37734. */
  37735. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37736. /**
  37737. * Gets the name of the behavior.
  37738. */
  37739. readonly name: string;
  37740. private _zoomStopsAnimation;
  37741. private _idleRotationSpeed;
  37742. private _idleRotationWaitTime;
  37743. private _idleRotationSpinupTime;
  37744. /**
  37745. * Sets the flag that indicates if user zooming should stop animation.
  37746. */
  37747. /**
  37748. * Gets the flag that indicates if user zooming should stop animation.
  37749. */
  37750. zoomStopsAnimation: boolean;
  37751. /**
  37752. * Sets the default speed at which the camera rotates around the model.
  37753. */
  37754. /**
  37755. * Gets the default speed at which the camera rotates around the model.
  37756. */
  37757. idleRotationSpeed: number;
  37758. /**
  37759. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37760. */
  37761. /**
  37762. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37763. */
  37764. idleRotationWaitTime: number;
  37765. /**
  37766. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37767. */
  37768. /**
  37769. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37770. */
  37771. idleRotationSpinupTime: number;
  37772. /**
  37773. * Gets a value indicating if the camera is currently rotating because of this behavior
  37774. */
  37775. readonly rotationInProgress: boolean;
  37776. private _onPrePointerObservableObserver;
  37777. private _onAfterCheckInputsObserver;
  37778. private _attachedCamera;
  37779. private _isPointerDown;
  37780. private _lastFrameTime;
  37781. private _lastInteractionTime;
  37782. private _cameraRotationSpeed;
  37783. /**
  37784. * Initializes the behavior.
  37785. */
  37786. init(): void;
  37787. /**
  37788. * Attaches the behavior to its arc rotate camera.
  37789. * @param camera Defines the camera to attach the behavior to
  37790. */
  37791. attach(camera: ArcRotateCamera): void;
  37792. /**
  37793. * Detaches the behavior from its current arc rotate camera.
  37794. */
  37795. detach(): void;
  37796. /**
  37797. * Returns true if user is scrolling.
  37798. * @return true if user is scrolling.
  37799. */
  37800. private _userIsZooming;
  37801. private _lastFrameRadius;
  37802. private _shouldAnimationStopForInteraction;
  37803. /**
  37804. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37805. */
  37806. private _applyUserInteraction;
  37807. private _userIsMoving;
  37808. }
  37809. }
  37810. declare module "babylonjs/Behaviors/Cameras/index" {
  37811. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37812. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37813. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37814. }
  37815. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37816. import { Mesh } from "babylonjs/Meshes/mesh";
  37817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37818. import { Behavior } from "babylonjs/Behaviors/behavior";
  37819. /**
  37820. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37821. */
  37822. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37823. private ui;
  37824. /**
  37825. * The name of the behavior
  37826. */
  37827. name: string;
  37828. /**
  37829. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37830. */
  37831. distanceAwayFromFace: number;
  37832. /**
  37833. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37834. */
  37835. distanceAwayFromBottomOfFace: number;
  37836. private _faceVectors;
  37837. private _target;
  37838. private _scene;
  37839. private _onRenderObserver;
  37840. private _tmpMatrix;
  37841. private _tmpVector;
  37842. /**
  37843. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37844. * @param ui The transform node that should be attched to the mesh
  37845. */
  37846. constructor(ui: TransformNode);
  37847. /**
  37848. * Initializes the behavior
  37849. */
  37850. init(): void;
  37851. private _closestFace;
  37852. private _zeroVector;
  37853. private _lookAtTmpMatrix;
  37854. private _lookAtToRef;
  37855. /**
  37856. * Attaches the AttachToBoxBehavior to the passed in mesh
  37857. * @param target The mesh that the specified node will be attached to
  37858. */
  37859. attach(target: Mesh): void;
  37860. /**
  37861. * Detaches the behavior from the mesh
  37862. */
  37863. detach(): void;
  37864. }
  37865. }
  37866. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37867. import { Behavior } from "babylonjs/Behaviors/behavior";
  37868. import { Mesh } from "babylonjs/Meshes/mesh";
  37869. /**
  37870. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37871. */
  37872. export class FadeInOutBehavior implements Behavior<Mesh> {
  37873. /**
  37874. * Time in milliseconds to delay before fading in (Default: 0)
  37875. */
  37876. delay: number;
  37877. /**
  37878. * Time in milliseconds for the mesh to fade in (Default: 300)
  37879. */
  37880. fadeInTime: number;
  37881. private _millisecondsPerFrame;
  37882. private _hovered;
  37883. private _hoverValue;
  37884. private _ownerNode;
  37885. /**
  37886. * Instatiates the FadeInOutBehavior
  37887. */
  37888. constructor();
  37889. /**
  37890. * The name of the behavior
  37891. */
  37892. readonly name: string;
  37893. /**
  37894. * Initializes the behavior
  37895. */
  37896. init(): void;
  37897. /**
  37898. * Attaches the fade behavior on the passed in mesh
  37899. * @param ownerNode The mesh that will be faded in/out once attached
  37900. */
  37901. attach(ownerNode: Mesh): void;
  37902. /**
  37903. * Detaches the behavior from the mesh
  37904. */
  37905. detach(): void;
  37906. /**
  37907. * Triggers the mesh to begin fading in or out
  37908. * @param value if the object should fade in or out (true to fade in)
  37909. */
  37910. fadeIn(value: boolean): void;
  37911. private _update;
  37912. private _setAllVisibility;
  37913. }
  37914. }
  37915. declare module "babylonjs/Misc/pivotTools" {
  37916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37917. /**
  37918. * Class containing a set of static utilities functions for managing Pivots
  37919. * @hidden
  37920. */
  37921. export class PivotTools {
  37922. private static _PivotCached;
  37923. private static _OldPivotPoint;
  37924. private static _PivotTranslation;
  37925. private static _PivotTmpVector;
  37926. /** @hidden */
  37927. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37928. /** @hidden */
  37929. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37930. }
  37931. }
  37932. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37933. import { Scene } from "babylonjs/scene";
  37934. import { Vector4 } from "babylonjs/Maths/math.vector";
  37935. import { Mesh } from "babylonjs/Meshes/mesh";
  37936. import { Nullable } from "babylonjs/types";
  37937. import { Plane } from "babylonjs/Maths/math.plane";
  37938. /**
  37939. * Class containing static functions to help procedurally build meshes
  37940. */
  37941. export class PlaneBuilder {
  37942. /**
  37943. * Creates a plane mesh
  37944. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37945. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37946. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37948. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37950. * @param name defines the name of the mesh
  37951. * @param options defines the options used to create the mesh
  37952. * @param scene defines the hosting scene
  37953. * @returns the plane mesh
  37954. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37955. */
  37956. static CreatePlane(name: string, options: {
  37957. size?: number;
  37958. width?: number;
  37959. height?: number;
  37960. sideOrientation?: number;
  37961. frontUVs?: Vector4;
  37962. backUVs?: Vector4;
  37963. updatable?: boolean;
  37964. sourcePlane?: Plane;
  37965. }, scene?: Nullable<Scene>): Mesh;
  37966. }
  37967. }
  37968. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37969. import { Behavior } from "babylonjs/Behaviors/behavior";
  37970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37971. import { Observable } from "babylonjs/Misc/observable";
  37972. import { Vector3 } from "babylonjs/Maths/math.vector";
  37973. import { Ray } from "babylonjs/Culling/ray";
  37974. import "babylonjs/Meshes/Builders/planeBuilder";
  37975. /**
  37976. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37977. */
  37978. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37979. private static _AnyMouseID;
  37980. /**
  37981. * Abstract mesh the behavior is set on
  37982. */
  37983. attachedNode: AbstractMesh;
  37984. private _dragPlane;
  37985. private _scene;
  37986. private _pointerObserver;
  37987. private _beforeRenderObserver;
  37988. private static _planeScene;
  37989. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37990. /**
  37991. * 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)
  37992. */
  37993. maxDragAngle: number;
  37994. /**
  37995. * @hidden
  37996. */
  37997. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37998. /**
  37999. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38000. */
  38001. currentDraggingPointerID: number;
  38002. /**
  38003. * The last position where the pointer hit the drag plane in world space
  38004. */
  38005. lastDragPosition: Vector3;
  38006. /**
  38007. * If the behavior is currently in a dragging state
  38008. */
  38009. dragging: boolean;
  38010. /**
  38011. * 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)
  38012. */
  38013. dragDeltaRatio: number;
  38014. /**
  38015. * If the drag plane orientation should be updated during the dragging (Default: true)
  38016. */
  38017. updateDragPlane: boolean;
  38018. private _debugMode;
  38019. private _moving;
  38020. /**
  38021. * Fires each time the attached mesh is dragged with the pointer
  38022. * * delta between last drag position and current drag position in world space
  38023. * * dragDistance along the drag axis
  38024. * * dragPlaneNormal normal of the current drag plane used during the drag
  38025. * * dragPlanePoint in world space where the drag intersects the drag plane
  38026. */
  38027. onDragObservable: Observable<{
  38028. delta: Vector3;
  38029. dragPlanePoint: Vector3;
  38030. dragPlaneNormal: Vector3;
  38031. dragDistance: number;
  38032. pointerId: number;
  38033. }>;
  38034. /**
  38035. * Fires each time a drag begins (eg. mouse down on mesh)
  38036. */
  38037. onDragStartObservable: Observable<{
  38038. dragPlanePoint: Vector3;
  38039. pointerId: number;
  38040. }>;
  38041. /**
  38042. * Fires each time a drag ends (eg. mouse release after drag)
  38043. */
  38044. onDragEndObservable: Observable<{
  38045. dragPlanePoint: Vector3;
  38046. pointerId: number;
  38047. }>;
  38048. /**
  38049. * If the attached mesh should be moved when dragged
  38050. */
  38051. moveAttached: boolean;
  38052. /**
  38053. * If the drag behavior will react to drag events (Default: true)
  38054. */
  38055. enabled: boolean;
  38056. /**
  38057. * If pointer events should start and release the drag (Default: true)
  38058. */
  38059. startAndReleaseDragOnPointerEvents: boolean;
  38060. /**
  38061. * If camera controls should be detached during the drag
  38062. */
  38063. detachCameraControls: boolean;
  38064. /**
  38065. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38066. */
  38067. useObjectOrienationForDragging: boolean;
  38068. private _options;
  38069. /**
  38070. * Creates a pointer drag behavior that can be attached to a mesh
  38071. * @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)
  38072. */
  38073. constructor(options?: {
  38074. dragAxis?: Vector3;
  38075. dragPlaneNormal?: Vector3;
  38076. });
  38077. /**
  38078. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38079. */
  38080. validateDrag: (targetPosition: Vector3) => boolean;
  38081. /**
  38082. * The name of the behavior
  38083. */
  38084. readonly name: string;
  38085. /**
  38086. * Initializes the behavior
  38087. */
  38088. init(): void;
  38089. private _tmpVector;
  38090. private _alternatePickedPoint;
  38091. private _worldDragAxis;
  38092. private _targetPosition;
  38093. private _attachedElement;
  38094. /**
  38095. * Attaches the drag behavior the passed in mesh
  38096. * @param ownerNode The mesh that will be dragged around once attached
  38097. * @param predicate Predicate to use for pick filtering
  38098. */
  38099. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38100. /**
  38101. * Force relase the drag action by code.
  38102. */
  38103. releaseDrag(): void;
  38104. private _startDragRay;
  38105. private _lastPointerRay;
  38106. /**
  38107. * Simulates the start of a pointer drag event on the behavior
  38108. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38109. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38110. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38111. */
  38112. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38113. private _startDrag;
  38114. private _dragDelta;
  38115. private _moveDrag;
  38116. private _pickWithRayOnDragPlane;
  38117. private _pointA;
  38118. private _pointB;
  38119. private _pointC;
  38120. private _lineA;
  38121. private _lineB;
  38122. private _localAxis;
  38123. private _lookAt;
  38124. private _updateDragPlanePosition;
  38125. /**
  38126. * Detaches the behavior from the mesh
  38127. */
  38128. detach(): void;
  38129. }
  38130. }
  38131. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38132. import { Mesh } from "babylonjs/Meshes/mesh";
  38133. import { Behavior } from "babylonjs/Behaviors/behavior";
  38134. /**
  38135. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38136. */
  38137. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38138. private _dragBehaviorA;
  38139. private _dragBehaviorB;
  38140. private _startDistance;
  38141. private _initialScale;
  38142. private _targetScale;
  38143. private _ownerNode;
  38144. private _sceneRenderObserver;
  38145. /**
  38146. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38147. */
  38148. constructor();
  38149. /**
  38150. * The name of the behavior
  38151. */
  38152. readonly name: string;
  38153. /**
  38154. * Initializes the behavior
  38155. */
  38156. init(): void;
  38157. private _getCurrentDistance;
  38158. /**
  38159. * Attaches the scale behavior the passed in mesh
  38160. * @param ownerNode The mesh that will be scaled around once attached
  38161. */
  38162. attach(ownerNode: Mesh): void;
  38163. /**
  38164. * Detaches the behavior from the mesh
  38165. */
  38166. detach(): void;
  38167. }
  38168. }
  38169. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38170. import { Behavior } from "babylonjs/Behaviors/behavior";
  38171. import { Mesh } from "babylonjs/Meshes/mesh";
  38172. import { Observable } from "babylonjs/Misc/observable";
  38173. /**
  38174. * 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
  38175. */
  38176. export class SixDofDragBehavior implements Behavior<Mesh> {
  38177. private static _virtualScene;
  38178. private _ownerNode;
  38179. private _sceneRenderObserver;
  38180. private _scene;
  38181. private _targetPosition;
  38182. private _virtualOriginMesh;
  38183. private _virtualDragMesh;
  38184. private _pointerObserver;
  38185. private _moving;
  38186. private _startingOrientation;
  38187. /**
  38188. * 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)
  38189. */
  38190. private zDragFactor;
  38191. /**
  38192. * If the object should rotate to face the drag origin
  38193. */
  38194. rotateDraggedObject: boolean;
  38195. /**
  38196. * If the behavior is currently in a dragging state
  38197. */
  38198. dragging: boolean;
  38199. /**
  38200. * 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)
  38201. */
  38202. dragDeltaRatio: number;
  38203. /**
  38204. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38205. */
  38206. currentDraggingPointerID: number;
  38207. /**
  38208. * If camera controls should be detached during the drag
  38209. */
  38210. detachCameraControls: boolean;
  38211. /**
  38212. * Fires each time a drag starts
  38213. */
  38214. onDragStartObservable: Observable<{}>;
  38215. /**
  38216. * Fires each time a drag ends (eg. mouse release after drag)
  38217. */
  38218. onDragEndObservable: Observable<{}>;
  38219. /**
  38220. * 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
  38221. */
  38222. constructor();
  38223. /**
  38224. * The name of the behavior
  38225. */
  38226. readonly name: string;
  38227. /**
  38228. * Initializes the behavior
  38229. */
  38230. init(): void;
  38231. /**
  38232. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38233. */
  38234. private readonly _pointerCamera;
  38235. /**
  38236. * Attaches the scale behavior the passed in mesh
  38237. * @param ownerNode The mesh that will be scaled around once attached
  38238. */
  38239. attach(ownerNode: Mesh): void;
  38240. /**
  38241. * Detaches the behavior from the mesh
  38242. */
  38243. detach(): void;
  38244. }
  38245. }
  38246. declare module "babylonjs/Behaviors/Meshes/index" {
  38247. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38248. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38249. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38250. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38251. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38252. }
  38253. declare module "babylonjs/Behaviors/index" {
  38254. export * from "babylonjs/Behaviors/behavior";
  38255. export * from "babylonjs/Behaviors/Cameras/index";
  38256. export * from "babylonjs/Behaviors/Meshes/index";
  38257. }
  38258. declare module "babylonjs/Bones/boneIKController" {
  38259. import { Bone } from "babylonjs/Bones/bone";
  38260. import { Vector3 } from "babylonjs/Maths/math.vector";
  38261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38262. import { Nullable } from "babylonjs/types";
  38263. /**
  38264. * Class used to apply inverse kinematics to bones
  38265. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38266. */
  38267. export class BoneIKController {
  38268. private static _tmpVecs;
  38269. private static _tmpQuat;
  38270. private static _tmpMats;
  38271. /**
  38272. * Gets or sets the target mesh
  38273. */
  38274. targetMesh: AbstractMesh;
  38275. /** Gets or sets the mesh used as pole */
  38276. poleTargetMesh: AbstractMesh;
  38277. /**
  38278. * Gets or sets the bone used as pole
  38279. */
  38280. poleTargetBone: Nullable<Bone>;
  38281. /**
  38282. * Gets or sets the target position
  38283. */
  38284. targetPosition: Vector3;
  38285. /**
  38286. * Gets or sets the pole target position
  38287. */
  38288. poleTargetPosition: Vector3;
  38289. /**
  38290. * Gets or sets the pole target local offset
  38291. */
  38292. poleTargetLocalOffset: Vector3;
  38293. /**
  38294. * Gets or sets the pole angle
  38295. */
  38296. poleAngle: number;
  38297. /**
  38298. * Gets or sets the mesh associated with the controller
  38299. */
  38300. mesh: AbstractMesh;
  38301. /**
  38302. * 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)
  38303. */
  38304. slerpAmount: number;
  38305. private _bone1Quat;
  38306. private _bone1Mat;
  38307. private _bone2Ang;
  38308. private _bone1;
  38309. private _bone2;
  38310. private _bone1Length;
  38311. private _bone2Length;
  38312. private _maxAngle;
  38313. private _maxReach;
  38314. private _rightHandedSystem;
  38315. private _bendAxis;
  38316. private _slerping;
  38317. private _adjustRoll;
  38318. /**
  38319. * Gets or sets maximum allowed angle
  38320. */
  38321. maxAngle: number;
  38322. /**
  38323. * Creates a new BoneIKController
  38324. * @param mesh defines the mesh to control
  38325. * @param bone defines the bone to control
  38326. * @param options defines options to set up the controller
  38327. */
  38328. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38329. targetMesh?: AbstractMesh;
  38330. poleTargetMesh?: AbstractMesh;
  38331. poleTargetBone?: Bone;
  38332. poleTargetLocalOffset?: Vector3;
  38333. poleAngle?: number;
  38334. bendAxis?: Vector3;
  38335. maxAngle?: number;
  38336. slerpAmount?: number;
  38337. });
  38338. private _setMaxAngle;
  38339. /**
  38340. * Force the controller to update the bones
  38341. */
  38342. update(): void;
  38343. }
  38344. }
  38345. declare module "babylonjs/Bones/boneLookController" {
  38346. import { Vector3 } from "babylonjs/Maths/math.vector";
  38347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38348. import { Bone } from "babylonjs/Bones/bone";
  38349. import { Space } from "babylonjs/Maths/math.axis";
  38350. /**
  38351. * Class used to make a bone look toward a point in space
  38352. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38353. */
  38354. export class BoneLookController {
  38355. private static _tmpVecs;
  38356. private static _tmpQuat;
  38357. private static _tmpMats;
  38358. /**
  38359. * The target Vector3 that the bone will look at
  38360. */
  38361. target: Vector3;
  38362. /**
  38363. * The mesh that the bone is attached to
  38364. */
  38365. mesh: AbstractMesh;
  38366. /**
  38367. * The bone that will be looking to the target
  38368. */
  38369. bone: Bone;
  38370. /**
  38371. * The up axis of the coordinate system that is used when the bone is rotated
  38372. */
  38373. upAxis: Vector3;
  38374. /**
  38375. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38376. */
  38377. upAxisSpace: Space;
  38378. /**
  38379. * Used to make an adjustment to the yaw of the bone
  38380. */
  38381. adjustYaw: number;
  38382. /**
  38383. * Used to make an adjustment to the pitch of the bone
  38384. */
  38385. adjustPitch: number;
  38386. /**
  38387. * Used to make an adjustment to the roll of the bone
  38388. */
  38389. adjustRoll: number;
  38390. /**
  38391. * 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)
  38392. */
  38393. slerpAmount: number;
  38394. private _minYaw;
  38395. private _maxYaw;
  38396. private _minPitch;
  38397. private _maxPitch;
  38398. private _minYawSin;
  38399. private _minYawCos;
  38400. private _maxYawSin;
  38401. private _maxYawCos;
  38402. private _midYawConstraint;
  38403. private _minPitchTan;
  38404. private _maxPitchTan;
  38405. private _boneQuat;
  38406. private _slerping;
  38407. private _transformYawPitch;
  38408. private _transformYawPitchInv;
  38409. private _firstFrameSkipped;
  38410. private _yawRange;
  38411. private _fowardAxis;
  38412. /**
  38413. * Gets or sets the minimum yaw angle that the bone can look to
  38414. */
  38415. minYaw: number;
  38416. /**
  38417. * Gets or sets the maximum yaw angle that the bone can look to
  38418. */
  38419. maxYaw: number;
  38420. /**
  38421. * Gets or sets the minimum pitch angle that the bone can look to
  38422. */
  38423. minPitch: number;
  38424. /**
  38425. * Gets or sets the maximum pitch angle that the bone can look to
  38426. */
  38427. maxPitch: number;
  38428. /**
  38429. * Create a BoneLookController
  38430. * @param mesh the mesh that the bone belongs to
  38431. * @param bone the bone that will be looking to the target
  38432. * @param target the target Vector3 to look at
  38433. * @param options optional settings:
  38434. * * maxYaw: the maximum angle the bone will yaw to
  38435. * * minYaw: the minimum angle the bone will yaw to
  38436. * * maxPitch: the maximum angle the bone will pitch to
  38437. * * minPitch: the minimum angle the bone will yaw to
  38438. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38439. * * upAxis: the up axis of the coordinate system
  38440. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38441. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38442. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38443. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38444. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38445. * * adjustRoll: used to make an adjustment to the roll of the bone
  38446. **/
  38447. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38448. maxYaw?: number;
  38449. minYaw?: number;
  38450. maxPitch?: number;
  38451. minPitch?: number;
  38452. slerpAmount?: number;
  38453. upAxis?: Vector3;
  38454. upAxisSpace?: Space;
  38455. yawAxis?: Vector3;
  38456. pitchAxis?: Vector3;
  38457. adjustYaw?: number;
  38458. adjustPitch?: number;
  38459. adjustRoll?: number;
  38460. });
  38461. /**
  38462. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38463. */
  38464. update(): void;
  38465. private _getAngleDiff;
  38466. private _getAngleBetween;
  38467. private _isAngleBetween;
  38468. }
  38469. }
  38470. declare module "babylonjs/Bones/index" {
  38471. export * from "babylonjs/Bones/bone";
  38472. export * from "babylonjs/Bones/boneIKController";
  38473. export * from "babylonjs/Bones/boneLookController";
  38474. export * from "babylonjs/Bones/skeleton";
  38475. }
  38476. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38477. import { Nullable } from "babylonjs/types";
  38478. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38479. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38480. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38481. /**
  38482. * Manage the gamepad inputs to control an arc rotate camera.
  38483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38484. */
  38485. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38486. /**
  38487. * Defines the camera the input is attached to.
  38488. */
  38489. camera: ArcRotateCamera;
  38490. /**
  38491. * Defines the gamepad the input is gathering event from.
  38492. */
  38493. gamepad: Nullable<Gamepad>;
  38494. /**
  38495. * Defines the gamepad rotation sensiblity.
  38496. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38497. */
  38498. gamepadRotationSensibility: number;
  38499. /**
  38500. * Defines the gamepad move sensiblity.
  38501. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38502. */
  38503. gamepadMoveSensibility: number;
  38504. private _yAxisScale;
  38505. /**
  38506. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38507. */
  38508. invertYAxis: boolean;
  38509. private _onGamepadConnectedObserver;
  38510. private _onGamepadDisconnectedObserver;
  38511. /**
  38512. * Attach the input controls to a specific dom element to get the input from.
  38513. * @param element Defines the element the controls should be listened from
  38514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38515. */
  38516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38517. /**
  38518. * Detach the current controls from the specified dom element.
  38519. * @param element Defines the element to stop listening the inputs from
  38520. */
  38521. detachControl(element: Nullable<HTMLElement>): void;
  38522. /**
  38523. * Update the current camera state depending on the inputs that have been used this frame.
  38524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38525. */
  38526. checkInputs(): void;
  38527. /**
  38528. * Gets the class name of the current intput.
  38529. * @returns the class name
  38530. */
  38531. getClassName(): string;
  38532. /**
  38533. * Get the friendly name associated with the input class.
  38534. * @returns the input friendly name
  38535. */
  38536. getSimpleName(): string;
  38537. }
  38538. }
  38539. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38540. import { Nullable } from "babylonjs/types";
  38541. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38542. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38543. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38544. interface ArcRotateCameraInputsManager {
  38545. /**
  38546. * Add orientation input support to the input manager.
  38547. * @returns the current input manager
  38548. */
  38549. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38550. }
  38551. }
  38552. /**
  38553. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38555. */
  38556. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38557. /**
  38558. * Defines the camera the input is attached to.
  38559. */
  38560. camera: ArcRotateCamera;
  38561. /**
  38562. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38563. */
  38564. alphaCorrection: number;
  38565. /**
  38566. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38567. */
  38568. gammaCorrection: number;
  38569. private _alpha;
  38570. private _gamma;
  38571. private _dirty;
  38572. private _deviceOrientationHandler;
  38573. /**
  38574. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38575. */
  38576. constructor();
  38577. /**
  38578. * Attach the input controls to a specific dom element to get the input from.
  38579. * @param element Defines the element the controls should be listened from
  38580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38581. */
  38582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38583. /** @hidden */
  38584. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38585. /**
  38586. * Update the current camera state depending on the inputs that have been used this frame.
  38587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38588. */
  38589. checkInputs(): void;
  38590. /**
  38591. * Detach the current controls from the specified dom element.
  38592. * @param element Defines the element to stop listening the inputs from
  38593. */
  38594. detachControl(element: Nullable<HTMLElement>): void;
  38595. /**
  38596. * Gets the class name of the current intput.
  38597. * @returns the class name
  38598. */
  38599. getClassName(): string;
  38600. /**
  38601. * Get the friendly name associated with the input class.
  38602. * @returns the input friendly name
  38603. */
  38604. getSimpleName(): string;
  38605. }
  38606. }
  38607. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38608. import { Nullable } from "babylonjs/types";
  38609. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38610. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38611. /**
  38612. * Listen to mouse events to control the camera.
  38613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38614. */
  38615. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38616. /**
  38617. * Defines the camera the input is attached to.
  38618. */
  38619. camera: FlyCamera;
  38620. /**
  38621. * Defines if touch is enabled. (Default is true.)
  38622. */
  38623. touchEnabled: boolean;
  38624. /**
  38625. * Defines the buttons associated with the input to handle camera rotation.
  38626. */
  38627. buttons: number[];
  38628. /**
  38629. * Assign buttons for Yaw control.
  38630. */
  38631. buttonsYaw: number[];
  38632. /**
  38633. * Assign buttons for Pitch control.
  38634. */
  38635. buttonsPitch: number[];
  38636. /**
  38637. * Assign buttons for Roll control.
  38638. */
  38639. buttonsRoll: number[];
  38640. /**
  38641. * Detect if any button is being pressed while mouse is moved.
  38642. * -1 = Mouse locked.
  38643. * 0 = Left button.
  38644. * 1 = Middle Button.
  38645. * 2 = Right Button.
  38646. */
  38647. activeButton: number;
  38648. /**
  38649. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38650. * Higher values reduce its sensitivity.
  38651. */
  38652. angularSensibility: number;
  38653. private _mousemoveCallback;
  38654. private _observer;
  38655. private _rollObserver;
  38656. private previousPosition;
  38657. private noPreventDefault;
  38658. private element;
  38659. /**
  38660. * Listen to mouse events to control the camera.
  38661. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38663. */
  38664. constructor(touchEnabled?: boolean);
  38665. /**
  38666. * Attach the mouse control to the HTML DOM element.
  38667. * @param element Defines the element that listens to the input events.
  38668. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38669. */
  38670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38671. /**
  38672. * Detach the current controls from the specified dom element.
  38673. * @param element Defines the element to stop listening the inputs from
  38674. */
  38675. detachControl(element: Nullable<HTMLElement>): void;
  38676. /**
  38677. * Gets the class name of the current input.
  38678. * @returns the class name.
  38679. */
  38680. getClassName(): string;
  38681. /**
  38682. * Get the friendly name associated with the input class.
  38683. * @returns the input's friendly name.
  38684. */
  38685. getSimpleName(): string;
  38686. private _pointerInput;
  38687. private _onMouseMove;
  38688. /**
  38689. * Rotate camera by mouse offset.
  38690. */
  38691. private rotateCamera;
  38692. }
  38693. }
  38694. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38695. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38696. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38697. /**
  38698. * Default Inputs manager for the FlyCamera.
  38699. * It groups all the default supported inputs for ease of use.
  38700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38701. */
  38702. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38703. /**
  38704. * Instantiates a new FlyCameraInputsManager.
  38705. * @param camera Defines the camera the inputs belong to.
  38706. */
  38707. constructor(camera: FlyCamera);
  38708. /**
  38709. * Add keyboard input support to the input manager.
  38710. * @returns the new FlyCameraKeyboardMoveInput().
  38711. */
  38712. addKeyboard(): FlyCameraInputsManager;
  38713. /**
  38714. * Add mouse input support to the input manager.
  38715. * @param touchEnabled Enable touch screen support.
  38716. * @returns the new FlyCameraMouseInput().
  38717. */
  38718. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38719. }
  38720. }
  38721. declare module "babylonjs/Cameras/flyCamera" {
  38722. import { Scene } from "babylonjs/scene";
  38723. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38725. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38726. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38727. /**
  38728. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38729. * such as in a 3D Space Shooter or a Flight Simulator.
  38730. */
  38731. export class FlyCamera extends TargetCamera {
  38732. /**
  38733. * Define the collision ellipsoid of the camera.
  38734. * This is helpful for simulating a camera body, like a player's body.
  38735. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38736. */
  38737. ellipsoid: Vector3;
  38738. /**
  38739. * Define an offset for the position of the ellipsoid around the camera.
  38740. * This can be helpful if the camera is attached away from the player's body center,
  38741. * such as at its head.
  38742. */
  38743. ellipsoidOffset: Vector3;
  38744. /**
  38745. * Enable or disable collisions of the camera with the rest of the scene objects.
  38746. */
  38747. checkCollisions: boolean;
  38748. /**
  38749. * Enable or disable gravity on the camera.
  38750. */
  38751. applyGravity: boolean;
  38752. /**
  38753. * Define the current direction the camera is moving to.
  38754. */
  38755. cameraDirection: Vector3;
  38756. /**
  38757. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38758. * This overrides and empties cameraRotation.
  38759. */
  38760. rotationQuaternion: Quaternion;
  38761. /**
  38762. * Track Roll to maintain the wanted Rolling when looking around.
  38763. */
  38764. _trackRoll: number;
  38765. /**
  38766. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38767. */
  38768. rollCorrect: number;
  38769. /**
  38770. * Mimic a banked turn, Rolling the camera when Yawing.
  38771. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38772. */
  38773. bankedTurn: boolean;
  38774. /**
  38775. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38776. */
  38777. bankedTurnLimit: number;
  38778. /**
  38779. * Value of 0 disables the banked Roll.
  38780. * Value of 1 is equal to the Yaw angle in radians.
  38781. */
  38782. bankedTurnMultiplier: number;
  38783. /**
  38784. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38785. */
  38786. inputs: FlyCameraInputsManager;
  38787. /**
  38788. * Gets the input sensibility for mouse input.
  38789. * Higher values reduce sensitivity.
  38790. */
  38791. /**
  38792. * Sets the input sensibility for a mouse input.
  38793. * Higher values reduce sensitivity.
  38794. */
  38795. angularSensibility: number;
  38796. /**
  38797. * Get the keys for camera movement forward.
  38798. */
  38799. /**
  38800. * Set the keys for camera movement forward.
  38801. */
  38802. keysForward: number[];
  38803. /**
  38804. * Get the keys for camera movement backward.
  38805. */
  38806. keysBackward: number[];
  38807. /**
  38808. * Get the keys for camera movement up.
  38809. */
  38810. /**
  38811. * Set the keys for camera movement up.
  38812. */
  38813. keysUp: number[];
  38814. /**
  38815. * Get the keys for camera movement down.
  38816. */
  38817. /**
  38818. * Set the keys for camera movement down.
  38819. */
  38820. keysDown: number[];
  38821. /**
  38822. * Get the keys for camera movement left.
  38823. */
  38824. /**
  38825. * Set the keys for camera movement left.
  38826. */
  38827. keysLeft: number[];
  38828. /**
  38829. * Set the keys for camera movement right.
  38830. */
  38831. /**
  38832. * Set the keys for camera movement right.
  38833. */
  38834. keysRight: number[];
  38835. /**
  38836. * Event raised when the camera collides with a mesh in the scene.
  38837. */
  38838. onCollide: (collidedMesh: AbstractMesh) => void;
  38839. private _collider;
  38840. private _needMoveForGravity;
  38841. private _oldPosition;
  38842. private _diffPosition;
  38843. private _newPosition;
  38844. /** @hidden */
  38845. _localDirection: Vector3;
  38846. /** @hidden */
  38847. _transformedDirection: Vector3;
  38848. /**
  38849. * Instantiates a FlyCamera.
  38850. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38851. * such as in a 3D Space Shooter or a Flight Simulator.
  38852. * @param name Define the name of the camera in the scene.
  38853. * @param position Define the starting position of the camera in the scene.
  38854. * @param scene Define the scene the camera belongs to.
  38855. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38856. */
  38857. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38858. /**
  38859. * Attach a control to the HTML DOM element.
  38860. * @param element Defines the element that listens to the input events.
  38861. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38862. */
  38863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38864. /**
  38865. * Detach a control from the HTML DOM element.
  38866. * The camera will stop reacting to that input.
  38867. * @param element Defines the element that listens to the input events.
  38868. */
  38869. detachControl(element: HTMLElement): void;
  38870. private _collisionMask;
  38871. /**
  38872. * Get the mask that the camera ignores in collision events.
  38873. */
  38874. /**
  38875. * Set the mask that the camera ignores in collision events.
  38876. */
  38877. collisionMask: number;
  38878. /** @hidden */
  38879. _collideWithWorld(displacement: Vector3): void;
  38880. /** @hidden */
  38881. private _onCollisionPositionChange;
  38882. /** @hidden */
  38883. _checkInputs(): void;
  38884. /** @hidden */
  38885. _decideIfNeedsToMove(): boolean;
  38886. /** @hidden */
  38887. _updatePosition(): void;
  38888. /**
  38889. * Restore the Roll to its target value at the rate specified.
  38890. * @param rate - Higher means slower restoring.
  38891. * @hidden
  38892. */
  38893. restoreRoll(rate: number): void;
  38894. /**
  38895. * Destroy the camera and release the current resources held by it.
  38896. */
  38897. dispose(): void;
  38898. /**
  38899. * Get the current object class name.
  38900. * @returns the class name.
  38901. */
  38902. getClassName(): string;
  38903. }
  38904. }
  38905. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38906. import { Nullable } from "babylonjs/types";
  38907. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38908. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38909. /**
  38910. * Listen to keyboard events to control the camera.
  38911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38912. */
  38913. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38914. /**
  38915. * Defines the camera the input is attached to.
  38916. */
  38917. camera: FlyCamera;
  38918. /**
  38919. * The list of keyboard keys used to control the forward move of the camera.
  38920. */
  38921. keysForward: number[];
  38922. /**
  38923. * The list of keyboard keys used to control the backward move of the camera.
  38924. */
  38925. keysBackward: number[];
  38926. /**
  38927. * The list of keyboard keys used to control the forward move of the camera.
  38928. */
  38929. keysUp: number[];
  38930. /**
  38931. * The list of keyboard keys used to control the backward move of the camera.
  38932. */
  38933. keysDown: number[];
  38934. /**
  38935. * The list of keyboard keys used to control the right strafe move of the camera.
  38936. */
  38937. keysRight: number[];
  38938. /**
  38939. * The list of keyboard keys used to control the left strafe move of the camera.
  38940. */
  38941. keysLeft: number[];
  38942. private _keys;
  38943. private _onCanvasBlurObserver;
  38944. private _onKeyboardObserver;
  38945. private _engine;
  38946. private _scene;
  38947. /**
  38948. * Attach the input controls to a specific dom element to get the input from.
  38949. * @param element Defines the element the controls should be listened from
  38950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38951. */
  38952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38953. /**
  38954. * Detach the current controls from the specified dom element.
  38955. * @param element Defines the element to stop listening the inputs from
  38956. */
  38957. detachControl(element: Nullable<HTMLElement>): void;
  38958. /**
  38959. * Gets the class name of the current intput.
  38960. * @returns the class name
  38961. */
  38962. getClassName(): string;
  38963. /** @hidden */
  38964. _onLostFocus(e: FocusEvent): void;
  38965. /**
  38966. * Get the friendly name associated with the input class.
  38967. * @returns the input friendly name
  38968. */
  38969. getSimpleName(): string;
  38970. /**
  38971. * Update the current camera state depending on the inputs that have been used this frame.
  38972. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38973. */
  38974. checkInputs(): void;
  38975. }
  38976. }
  38977. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38978. import { Nullable } from "babylonjs/types";
  38979. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38980. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38981. /**
  38982. * Manage the mouse wheel inputs to control a follow camera.
  38983. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38984. */
  38985. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38986. /**
  38987. * Defines the camera the input is attached to.
  38988. */
  38989. camera: FollowCamera;
  38990. /**
  38991. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38992. */
  38993. axisControlRadius: boolean;
  38994. /**
  38995. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38996. */
  38997. axisControlHeight: boolean;
  38998. /**
  38999. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39000. */
  39001. axisControlRotation: boolean;
  39002. /**
  39003. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39004. * relation to mouseWheel events.
  39005. */
  39006. wheelPrecision: number;
  39007. /**
  39008. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39009. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39010. */
  39011. wheelDeltaPercentage: number;
  39012. private _wheel;
  39013. private _observer;
  39014. /**
  39015. * Attach the input controls to a specific dom element to get the input from.
  39016. * @param element Defines the element the controls should be listened from
  39017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39018. */
  39019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39020. /**
  39021. * Detach the current controls from the specified dom element.
  39022. * @param element Defines the element to stop listening the inputs from
  39023. */
  39024. detachControl(element: Nullable<HTMLElement>): void;
  39025. /**
  39026. * Gets the class name of the current intput.
  39027. * @returns the class name
  39028. */
  39029. getClassName(): string;
  39030. /**
  39031. * Get the friendly name associated with the input class.
  39032. * @returns the input friendly name
  39033. */
  39034. getSimpleName(): string;
  39035. }
  39036. }
  39037. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39038. import { Nullable } from "babylonjs/types";
  39039. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39040. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39041. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39042. /**
  39043. * Manage the pointers inputs to control an follow camera.
  39044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39045. */
  39046. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39047. /**
  39048. * Defines the camera the input is attached to.
  39049. */
  39050. camera: FollowCamera;
  39051. /**
  39052. * Gets the class name of the current input.
  39053. * @returns the class name
  39054. */
  39055. getClassName(): string;
  39056. /**
  39057. * Defines the pointer angular sensibility along the X axis or how fast is
  39058. * the camera rotating.
  39059. * A negative number will reverse the axis direction.
  39060. */
  39061. angularSensibilityX: number;
  39062. /**
  39063. * Defines the pointer angular sensibility along the Y axis or how fast is
  39064. * the camera rotating.
  39065. * A negative number will reverse the axis direction.
  39066. */
  39067. angularSensibilityY: number;
  39068. /**
  39069. * Defines the pointer pinch precision or how fast is the camera zooming.
  39070. * A negative number will reverse the axis direction.
  39071. */
  39072. pinchPrecision: number;
  39073. /**
  39074. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39075. * from 0.
  39076. * It defines the percentage of current camera.radius to use as delta when
  39077. * pinch zoom is used.
  39078. */
  39079. pinchDeltaPercentage: number;
  39080. /**
  39081. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39082. */
  39083. axisXControlRadius: boolean;
  39084. /**
  39085. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39086. */
  39087. axisXControlHeight: boolean;
  39088. /**
  39089. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39090. */
  39091. axisXControlRotation: boolean;
  39092. /**
  39093. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39094. */
  39095. axisYControlRadius: boolean;
  39096. /**
  39097. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39098. */
  39099. axisYControlHeight: boolean;
  39100. /**
  39101. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39102. */
  39103. axisYControlRotation: boolean;
  39104. /**
  39105. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39106. */
  39107. axisPinchControlRadius: boolean;
  39108. /**
  39109. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39110. */
  39111. axisPinchControlHeight: boolean;
  39112. /**
  39113. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39114. */
  39115. axisPinchControlRotation: boolean;
  39116. /**
  39117. * Log error messages if basic misconfiguration has occurred.
  39118. */
  39119. warningEnable: boolean;
  39120. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39121. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39122. private _warningCounter;
  39123. private _warning;
  39124. }
  39125. }
  39126. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39127. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39128. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39129. /**
  39130. * Default Inputs manager for the FollowCamera.
  39131. * It groups all the default supported inputs for ease of use.
  39132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39133. */
  39134. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39135. /**
  39136. * Instantiates a new FollowCameraInputsManager.
  39137. * @param camera Defines the camera the inputs belong to
  39138. */
  39139. constructor(camera: FollowCamera);
  39140. /**
  39141. * Add keyboard input support to the input manager.
  39142. * @returns the current input manager
  39143. */
  39144. addKeyboard(): FollowCameraInputsManager;
  39145. /**
  39146. * Add mouse wheel input support to the input manager.
  39147. * @returns the current input manager
  39148. */
  39149. addMouseWheel(): FollowCameraInputsManager;
  39150. /**
  39151. * Add pointers input support to the input manager.
  39152. * @returns the current input manager
  39153. */
  39154. addPointers(): FollowCameraInputsManager;
  39155. /**
  39156. * Add orientation input support to the input manager.
  39157. * @returns the current input manager
  39158. */
  39159. addVRDeviceOrientation(): FollowCameraInputsManager;
  39160. }
  39161. }
  39162. declare module "babylonjs/Cameras/followCamera" {
  39163. import { Nullable } from "babylonjs/types";
  39164. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39165. import { Scene } from "babylonjs/scene";
  39166. import { Vector3 } from "babylonjs/Maths/math.vector";
  39167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39168. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39169. /**
  39170. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39171. * an arc rotate version arcFollowCamera are available.
  39172. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39173. */
  39174. export class FollowCamera extends TargetCamera {
  39175. /**
  39176. * Distance the follow camera should follow an object at
  39177. */
  39178. radius: number;
  39179. /**
  39180. * Minimum allowed distance of the camera to the axis of rotation
  39181. * (The camera can not get closer).
  39182. * This can help limiting how the Camera is able to move in the scene.
  39183. */
  39184. lowerRadiusLimit: Nullable<number>;
  39185. /**
  39186. * Maximum allowed distance of the camera to the axis of rotation
  39187. * (The camera can not get further).
  39188. * This can help limiting how the Camera is able to move in the scene.
  39189. */
  39190. upperRadiusLimit: Nullable<number>;
  39191. /**
  39192. * Define a rotation offset between the camera and the object it follows
  39193. */
  39194. rotationOffset: number;
  39195. /**
  39196. * Minimum allowed angle to camera position relative to target object.
  39197. * This can help limiting how the Camera is able to move in the scene.
  39198. */
  39199. lowerRotationOffsetLimit: Nullable<number>;
  39200. /**
  39201. * Maximum allowed angle to camera position relative to target object.
  39202. * This can help limiting how the Camera is able to move in the scene.
  39203. */
  39204. upperRotationOffsetLimit: Nullable<number>;
  39205. /**
  39206. * Define a height offset between the camera and the object it follows.
  39207. * It can help following an object from the top (like a car chaing a plane)
  39208. */
  39209. heightOffset: number;
  39210. /**
  39211. * Minimum allowed height of camera position relative to target object.
  39212. * This can help limiting how the Camera is able to move in the scene.
  39213. */
  39214. lowerHeightOffsetLimit: Nullable<number>;
  39215. /**
  39216. * Maximum allowed height of camera position relative to target object.
  39217. * This can help limiting how the Camera is able to move in the scene.
  39218. */
  39219. upperHeightOffsetLimit: Nullable<number>;
  39220. /**
  39221. * Define how fast the camera can accelerate to follow it s target.
  39222. */
  39223. cameraAcceleration: number;
  39224. /**
  39225. * Define the speed limit of the camera following an object.
  39226. */
  39227. maxCameraSpeed: number;
  39228. /**
  39229. * Define the target of the camera.
  39230. */
  39231. lockedTarget: Nullable<AbstractMesh>;
  39232. /**
  39233. * Defines the input associated with the camera.
  39234. */
  39235. inputs: FollowCameraInputsManager;
  39236. /**
  39237. * Instantiates the follow camera.
  39238. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39239. * @param name Define the name of the camera in the scene
  39240. * @param position Define the position of the camera
  39241. * @param scene Define the scene the camera belong to
  39242. * @param lockedTarget Define the target of the camera
  39243. */
  39244. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39245. private _follow;
  39246. /**
  39247. * Attached controls to the current camera.
  39248. * @param element Defines the element the controls should be listened from
  39249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39250. */
  39251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39252. /**
  39253. * Detach the current controls from the camera.
  39254. * The camera will stop reacting to inputs.
  39255. * @param element Defines the element to stop listening the inputs from
  39256. */
  39257. detachControl(element: HTMLElement): void;
  39258. /** @hidden */
  39259. _checkInputs(): void;
  39260. private _checkLimits;
  39261. /**
  39262. * Gets the camera class name.
  39263. * @returns the class name
  39264. */
  39265. getClassName(): string;
  39266. }
  39267. /**
  39268. * Arc Rotate version of the follow camera.
  39269. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39270. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39271. */
  39272. export class ArcFollowCamera extends TargetCamera {
  39273. /** The longitudinal angle of the camera */
  39274. alpha: number;
  39275. /** The latitudinal angle of the camera */
  39276. beta: number;
  39277. /** The radius of the camera from its target */
  39278. radius: number;
  39279. /** Define the camera target (the messh it should follow) */
  39280. target: Nullable<AbstractMesh>;
  39281. private _cartesianCoordinates;
  39282. /**
  39283. * Instantiates a new ArcFollowCamera
  39284. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39285. * @param name Define the name of the camera
  39286. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39287. * @param beta Define the rotation angle of the camera around the elevation axis
  39288. * @param radius Define the radius of the camera from its target point
  39289. * @param target Define the target of the camera
  39290. * @param scene Define the scene the camera belongs to
  39291. */
  39292. constructor(name: string,
  39293. /** The longitudinal angle of the camera */
  39294. alpha: number,
  39295. /** The latitudinal angle of the camera */
  39296. beta: number,
  39297. /** The radius of the camera from its target */
  39298. radius: number,
  39299. /** Define the camera target (the messh it should follow) */
  39300. target: Nullable<AbstractMesh>, scene: Scene);
  39301. private _follow;
  39302. /** @hidden */
  39303. _checkInputs(): void;
  39304. /**
  39305. * Returns the class name of the object.
  39306. * It is mostly used internally for serialization purposes.
  39307. */
  39308. getClassName(): string;
  39309. }
  39310. }
  39311. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39312. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39313. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39314. import { Nullable } from "babylonjs/types";
  39315. /**
  39316. * Manage the keyboard inputs to control the movement of a follow camera.
  39317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39318. */
  39319. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39320. /**
  39321. * Defines the camera the input is attached to.
  39322. */
  39323. camera: FollowCamera;
  39324. /**
  39325. * Defines the list of key codes associated with the up action (increase heightOffset)
  39326. */
  39327. keysHeightOffsetIncr: number[];
  39328. /**
  39329. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39330. */
  39331. keysHeightOffsetDecr: number[];
  39332. /**
  39333. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39334. */
  39335. keysHeightOffsetModifierAlt: boolean;
  39336. /**
  39337. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39338. */
  39339. keysHeightOffsetModifierCtrl: boolean;
  39340. /**
  39341. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39342. */
  39343. keysHeightOffsetModifierShift: boolean;
  39344. /**
  39345. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39346. */
  39347. keysRotationOffsetIncr: number[];
  39348. /**
  39349. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39350. */
  39351. keysRotationOffsetDecr: number[];
  39352. /**
  39353. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39354. */
  39355. keysRotationOffsetModifierAlt: boolean;
  39356. /**
  39357. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39358. */
  39359. keysRotationOffsetModifierCtrl: boolean;
  39360. /**
  39361. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39362. */
  39363. keysRotationOffsetModifierShift: boolean;
  39364. /**
  39365. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39366. */
  39367. keysRadiusIncr: number[];
  39368. /**
  39369. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39370. */
  39371. keysRadiusDecr: number[];
  39372. /**
  39373. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39374. */
  39375. keysRadiusModifierAlt: boolean;
  39376. /**
  39377. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39378. */
  39379. keysRadiusModifierCtrl: boolean;
  39380. /**
  39381. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39382. */
  39383. keysRadiusModifierShift: boolean;
  39384. /**
  39385. * Defines the rate of change of heightOffset.
  39386. */
  39387. heightSensibility: number;
  39388. /**
  39389. * Defines the rate of change of rotationOffset.
  39390. */
  39391. rotationSensibility: number;
  39392. /**
  39393. * Defines the rate of change of radius.
  39394. */
  39395. radiusSensibility: number;
  39396. private _keys;
  39397. private _ctrlPressed;
  39398. private _altPressed;
  39399. private _shiftPressed;
  39400. private _onCanvasBlurObserver;
  39401. private _onKeyboardObserver;
  39402. private _engine;
  39403. private _scene;
  39404. /**
  39405. * Attach the input controls to a specific dom element to get the input from.
  39406. * @param element Defines the element the controls should be listened from
  39407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39408. */
  39409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39410. /**
  39411. * Detach the current controls from the specified dom element.
  39412. * @param element Defines the element to stop listening the inputs from
  39413. */
  39414. detachControl(element: Nullable<HTMLElement>): void;
  39415. /**
  39416. * Update the current camera state depending on the inputs that have been used this frame.
  39417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39418. */
  39419. checkInputs(): void;
  39420. /**
  39421. * Gets the class name of the current input.
  39422. * @returns the class name
  39423. */
  39424. getClassName(): string;
  39425. /**
  39426. * Get the friendly name associated with the input class.
  39427. * @returns the input friendly name
  39428. */
  39429. getSimpleName(): string;
  39430. /**
  39431. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39432. * allow modification of the heightOffset value.
  39433. */
  39434. private _modifierHeightOffset;
  39435. /**
  39436. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39437. * allow modification of the rotationOffset value.
  39438. */
  39439. private _modifierRotationOffset;
  39440. /**
  39441. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39442. * allow modification of the radius value.
  39443. */
  39444. private _modifierRadius;
  39445. }
  39446. }
  39447. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39448. import { Nullable } from "babylonjs/types";
  39449. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39450. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39451. import { Observable } from "babylonjs/Misc/observable";
  39452. module "babylonjs/Cameras/freeCameraInputsManager" {
  39453. interface FreeCameraInputsManager {
  39454. /**
  39455. * @hidden
  39456. */
  39457. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39458. /**
  39459. * Add orientation input support to the input manager.
  39460. * @returns the current input manager
  39461. */
  39462. addDeviceOrientation(): FreeCameraInputsManager;
  39463. }
  39464. }
  39465. /**
  39466. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39467. * Screen rotation is taken into account.
  39468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39469. */
  39470. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39471. private _camera;
  39472. private _screenOrientationAngle;
  39473. private _constantTranform;
  39474. private _screenQuaternion;
  39475. private _alpha;
  39476. private _beta;
  39477. private _gamma;
  39478. /**
  39479. * Can be used to detect if a device orientation sensor is availible on a device
  39480. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39481. * @returns a promise that will resolve on orientation change
  39482. */
  39483. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39484. /**
  39485. * @hidden
  39486. */
  39487. _onDeviceOrientationChangedObservable: Observable<void>;
  39488. /**
  39489. * Instantiates a new input
  39490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39491. */
  39492. constructor();
  39493. /**
  39494. * Define the camera controlled by the input.
  39495. */
  39496. camera: FreeCamera;
  39497. /**
  39498. * Attach the input controls to a specific dom element to get the input from.
  39499. * @param element Defines the element the controls should be listened from
  39500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39501. */
  39502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39503. private _orientationChanged;
  39504. private _deviceOrientation;
  39505. /**
  39506. * Detach the current controls from the specified dom element.
  39507. * @param element Defines the element to stop listening the inputs from
  39508. */
  39509. detachControl(element: Nullable<HTMLElement>): void;
  39510. /**
  39511. * Update the current camera state depending on the inputs that have been used this frame.
  39512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39513. */
  39514. checkInputs(): void;
  39515. /**
  39516. * Gets the class name of the current intput.
  39517. * @returns the class name
  39518. */
  39519. getClassName(): string;
  39520. /**
  39521. * Get the friendly name associated with the input class.
  39522. * @returns the input friendly name
  39523. */
  39524. getSimpleName(): string;
  39525. }
  39526. }
  39527. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39528. import { Nullable } from "babylonjs/types";
  39529. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39531. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39532. /**
  39533. * Manage the gamepad inputs to control a free camera.
  39534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39535. */
  39536. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39537. /**
  39538. * Define the camera the input is attached to.
  39539. */
  39540. camera: FreeCamera;
  39541. /**
  39542. * Define the Gamepad controlling the input
  39543. */
  39544. gamepad: Nullable<Gamepad>;
  39545. /**
  39546. * Defines the gamepad rotation sensiblity.
  39547. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39548. */
  39549. gamepadAngularSensibility: number;
  39550. /**
  39551. * Defines the gamepad move sensiblity.
  39552. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39553. */
  39554. gamepadMoveSensibility: number;
  39555. private _yAxisScale;
  39556. /**
  39557. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39558. */
  39559. invertYAxis: boolean;
  39560. private _onGamepadConnectedObserver;
  39561. private _onGamepadDisconnectedObserver;
  39562. private _cameraTransform;
  39563. private _deltaTransform;
  39564. private _vector3;
  39565. private _vector2;
  39566. /**
  39567. * Attach the input controls to a specific dom element to get the input from.
  39568. * @param element Defines the element the controls should be listened from
  39569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39570. */
  39571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39572. /**
  39573. * Detach the current controls from the specified dom element.
  39574. * @param element Defines the element to stop listening the inputs from
  39575. */
  39576. detachControl(element: Nullable<HTMLElement>): void;
  39577. /**
  39578. * Update the current camera state depending on the inputs that have been used this frame.
  39579. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39580. */
  39581. checkInputs(): void;
  39582. /**
  39583. * Gets the class name of the current intput.
  39584. * @returns the class name
  39585. */
  39586. getClassName(): string;
  39587. /**
  39588. * Get the friendly name associated with the input class.
  39589. * @returns the input friendly name
  39590. */
  39591. getSimpleName(): string;
  39592. }
  39593. }
  39594. declare module "babylonjs/Misc/virtualJoystick" {
  39595. import { Nullable } from "babylonjs/types";
  39596. import { Vector3 } from "babylonjs/Maths/math.vector";
  39597. /**
  39598. * Defines the potential axis of a Joystick
  39599. */
  39600. export enum JoystickAxis {
  39601. /** X axis */
  39602. X = 0,
  39603. /** Y axis */
  39604. Y = 1,
  39605. /** Z axis */
  39606. Z = 2
  39607. }
  39608. /**
  39609. * Class used to define virtual joystick (used in touch mode)
  39610. */
  39611. export class VirtualJoystick {
  39612. /**
  39613. * Gets or sets a boolean indicating that left and right values must be inverted
  39614. */
  39615. reverseLeftRight: boolean;
  39616. /**
  39617. * Gets or sets a boolean indicating that up and down values must be inverted
  39618. */
  39619. reverseUpDown: boolean;
  39620. /**
  39621. * Gets the offset value for the position (ie. the change of the position value)
  39622. */
  39623. deltaPosition: Vector3;
  39624. /**
  39625. * Gets a boolean indicating if the virtual joystick was pressed
  39626. */
  39627. pressed: boolean;
  39628. /**
  39629. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39630. */
  39631. static Canvas: Nullable<HTMLCanvasElement>;
  39632. private static _globalJoystickIndex;
  39633. private static vjCanvasContext;
  39634. private static vjCanvasWidth;
  39635. private static vjCanvasHeight;
  39636. private static halfWidth;
  39637. private _action;
  39638. private _axisTargetedByLeftAndRight;
  39639. private _axisTargetedByUpAndDown;
  39640. private _joystickSensibility;
  39641. private _inversedSensibility;
  39642. private _joystickPointerID;
  39643. private _joystickColor;
  39644. private _joystickPointerPos;
  39645. private _joystickPreviousPointerPos;
  39646. private _joystickPointerStartPos;
  39647. private _deltaJoystickVector;
  39648. private _leftJoystick;
  39649. private _touches;
  39650. private _onPointerDownHandlerRef;
  39651. private _onPointerMoveHandlerRef;
  39652. private _onPointerUpHandlerRef;
  39653. private _onResize;
  39654. /**
  39655. * Creates a new virtual joystick
  39656. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39657. */
  39658. constructor(leftJoystick?: boolean);
  39659. /**
  39660. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39661. * @param newJoystickSensibility defines the new sensibility
  39662. */
  39663. setJoystickSensibility(newJoystickSensibility: number): void;
  39664. private _onPointerDown;
  39665. private _onPointerMove;
  39666. private _onPointerUp;
  39667. /**
  39668. * Change the color of the virtual joystick
  39669. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39670. */
  39671. setJoystickColor(newColor: string): void;
  39672. /**
  39673. * Defines a callback to call when the joystick is touched
  39674. * @param action defines the callback
  39675. */
  39676. setActionOnTouch(action: () => any): void;
  39677. /**
  39678. * Defines which axis you'd like to control for left & right
  39679. * @param axis defines the axis to use
  39680. */
  39681. setAxisForLeftRight(axis: JoystickAxis): void;
  39682. /**
  39683. * Defines which axis you'd like to control for up & down
  39684. * @param axis defines the axis to use
  39685. */
  39686. setAxisForUpDown(axis: JoystickAxis): void;
  39687. private _drawVirtualJoystick;
  39688. /**
  39689. * Release internal HTML canvas
  39690. */
  39691. releaseCanvas(): void;
  39692. }
  39693. }
  39694. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39695. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39696. import { Nullable } from "babylonjs/types";
  39697. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39698. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39699. module "babylonjs/Cameras/freeCameraInputsManager" {
  39700. interface FreeCameraInputsManager {
  39701. /**
  39702. * Add virtual joystick input support to the input manager.
  39703. * @returns the current input manager
  39704. */
  39705. addVirtualJoystick(): FreeCameraInputsManager;
  39706. }
  39707. }
  39708. /**
  39709. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39710. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39711. */
  39712. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39713. /**
  39714. * Defines the camera the input is attached to.
  39715. */
  39716. camera: FreeCamera;
  39717. private _leftjoystick;
  39718. private _rightjoystick;
  39719. /**
  39720. * Gets the left stick of the virtual joystick.
  39721. * @returns The virtual Joystick
  39722. */
  39723. getLeftJoystick(): VirtualJoystick;
  39724. /**
  39725. * Gets the right stick of the virtual joystick.
  39726. * @returns The virtual Joystick
  39727. */
  39728. getRightJoystick(): VirtualJoystick;
  39729. /**
  39730. * Update the current camera state depending on the inputs that have been used this frame.
  39731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39732. */
  39733. checkInputs(): void;
  39734. /**
  39735. * Attach the input controls to a specific dom element to get the input from.
  39736. * @param element Defines the element the controls should be listened from
  39737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39738. */
  39739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39740. /**
  39741. * Detach the current controls from the specified dom element.
  39742. * @param element Defines the element to stop listening the inputs from
  39743. */
  39744. detachControl(element: Nullable<HTMLElement>): void;
  39745. /**
  39746. * Gets the class name of the current intput.
  39747. * @returns the class name
  39748. */
  39749. getClassName(): string;
  39750. /**
  39751. * Get the friendly name associated with the input class.
  39752. * @returns the input friendly name
  39753. */
  39754. getSimpleName(): string;
  39755. }
  39756. }
  39757. declare module "babylonjs/Cameras/Inputs/index" {
  39758. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39759. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39760. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39761. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39762. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39763. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39764. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39765. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39766. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39767. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39768. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39769. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39770. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39771. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39772. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39773. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39774. }
  39775. declare module "babylonjs/Cameras/touchCamera" {
  39776. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39777. import { Scene } from "babylonjs/scene";
  39778. import { Vector3 } from "babylonjs/Maths/math.vector";
  39779. /**
  39780. * This represents a FPS type of camera controlled by touch.
  39781. * This is like a universal camera minus the Gamepad controls.
  39782. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39783. */
  39784. export class TouchCamera extends FreeCamera {
  39785. /**
  39786. * Defines the touch sensibility for rotation.
  39787. * The higher the faster.
  39788. */
  39789. touchAngularSensibility: number;
  39790. /**
  39791. * Defines the touch sensibility for move.
  39792. * The higher the faster.
  39793. */
  39794. touchMoveSensibility: number;
  39795. /**
  39796. * Instantiates a new touch camera.
  39797. * This represents a FPS type of camera controlled by touch.
  39798. * This is like a universal camera minus the Gamepad controls.
  39799. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39800. * @param name Define the name of the camera in the scene
  39801. * @param position Define the start position of the camera in the scene
  39802. * @param scene Define the scene the camera belongs to
  39803. */
  39804. constructor(name: string, position: Vector3, scene: Scene);
  39805. /**
  39806. * Gets the current object class name.
  39807. * @return the class name
  39808. */
  39809. getClassName(): string;
  39810. /** @hidden */
  39811. _setupInputs(): void;
  39812. }
  39813. }
  39814. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39815. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39816. import { Scene } from "babylonjs/scene";
  39817. import { Vector3 } from "babylonjs/Maths/math.vector";
  39818. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39819. import { Axis } from "babylonjs/Maths/math.axis";
  39820. /**
  39821. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39822. * being tilted forward or back and left or right.
  39823. */
  39824. export class DeviceOrientationCamera extends FreeCamera {
  39825. private _initialQuaternion;
  39826. private _quaternionCache;
  39827. private _tmpDragQuaternion;
  39828. private _disablePointerInputWhenUsingDeviceOrientation;
  39829. /**
  39830. * Creates a new device orientation camera
  39831. * @param name The name of the camera
  39832. * @param position The start position camera
  39833. * @param scene The scene the camera belongs to
  39834. */
  39835. constructor(name: string, position: Vector3, scene: Scene);
  39836. /**
  39837. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39838. */
  39839. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39840. private _dragFactor;
  39841. /**
  39842. * Enabled turning on the y axis when the orientation sensor is active
  39843. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39844. */
  39845. enableHorizontalDragging(dragFactor?: number): void;
  39846. /**
  39847. * Gets the current instance class name ("DeviceOrientationCamera").
  39848. * This helps avoiding instanceof at run time.
  39849. * @returns the class name
  39850. */
  39851. getClassName(): string;
  39852. /**
  39853. * @hidden
  39854. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39855. */
  39856. _checkInputs(): void;
  39857. /**
  39858. * Reset the camera to its default orientation on the specified axis only.
  39859. * @param axis The axis to reset
  39860. */
  39861. resetToCurrentRotation(axis?: Axis): void;
  39862. }
  39863. }
  39864. declare module "babylonjs/Gamepads/xboxGamepad" {
  39865. import { Observable } from "babylonjs/Misc/observable";
  39866. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39867. /**
  39868. * Defines supported buttons for XBox360 compatible gamepads
  39869. */
  39870. export enum Xbox360Button {
  39871. /** A */
  39872. A = 0,
  39873. /** B */
  39874. B = 1,
  39875. /** X */
  39876. X = 2,
  39877. /** Y */
  39878. Y = 3,
  39879. /** Start */
  39880. Start = 4,
  39881. /** Back */
  39882. Back = 5,
  39883. /** Left button */
  39884. LB = 6,
  39885. /** Right button */
  39886. RB = 7,
  39887. /** Left stick */
  39888. LeftStick = 8,
  39889. /** Right stick */
  39890. RightStick = 9
  39891. }
  39892. /** Defines values for XBox360 DPad */
  39893. export enum Xbox360Dpad {
  39894. /** Up */
  39895. Up = 0,
  39896. /** Down */
  39897. Down = 1,
  39898. /** Left */
  39899. Left = 2,
  39900. /** Right */
  39901. Right = 3
  39902. }
  39903. /**
  39904. * Defines a XBox360 gamepad
  39905. */
  39906. export class Xbox360Pad extends Gamepad {
  39907. private _leftTrigger;
  39908. private _rightTrigger;
  39909. private _onlefttriggerchanged;
  39910. private _onrighttriggerchanged;
  39911. private _onbuttondown;
  39912. private _onbuttonup;
  39913. private _ondpaddown;
  39914. private _ondpadup;
  39915. /** Observable raised when a button is pressed */
  39916. onButtonDownObservable: Observable<Xbox360Button>;
  39917. /** Observable raised when a button is released */
  39918. onButtonUpObservable: Observable<Xbox360Button>;
  39919. /** Observable raised when a pad is pressed */
  39920. onPadDownObservable: Observable<Xbox360Dpad>;
  39921. /** Observable raised when a pad is released */
  39922. onPadUpObservable: Observable<Xbox360Dpad>;
  39923. private _buttonA;
  39924. private _buttonB;
  39925. private _buttonX;
  39926. private _buttonY;
  39927. private _buttonBack;
  39928. private _buttonStart;
  39929. private _buttonLB;
  39930. private _buttonRB;
  39931. private _buttonLeftStick;
  39932. private _buttonRightStick;
  39933. private _dPadUp;
  39934. private _dPadDown;
  39935. private _dPadLeft;
  39936. private _dPadRight;
  39937. private _isXboxOnePad;
  39938. /**
  39939. * Creates a new XBox360 gamepad object
  39940. * @param id defines the id of this gamepad
  39941. * @param index defines its index
  39942. * @param gamepad defines the internal HTML gamepad object
  39943. * @param xboxOne defines if it is a XBox One gamepad
  39944. */
  39945. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39946. /**
  39947. * Defines the callback to call when left trigger is pressed
  39948. * @param callback defines the callback to use
  39949. */
  39950. onlefttriggerchanged(callback: (value: number) => void): void;
  39951. /**
  39952. * Defines the callback to call when right trigger is pressed
  39953. * @param callback defines the callback to use
  39954. */
  39955. onrighttriggerchanged(callback: (value: number) => void): void;
  39956. /**
  39957. * Gets the left trigger value
  39958. */
  39959. /**
  39960. * Sets the left trigger value
  39961. */
  39962. leftTrigger: number;
  39963. /**
  39964. * Gets the right trigger value
  39965. */
  39966. /**
  39967. * Sets the right trigger value
  39968. */
  39969. rightTrigger: number;
  39970. /**
  39971. * Defines the callback to call when a button is pressed
  39972. * @param callback defines the callback to use
  39973. */
  39974. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39975. /**
  39976. * Defines the callback to call when a button is released
  39977. * @param callback defines the callback to use
  39978. */
  39979. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39980. /**
  39981. * Defines the callback to call when a pad is pressed
  39982. * @param callback defines the callback to use
  39983. */
  39984. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39985. /**
  39986. * Defines the callback to call when a pad is released
  39987. * @param callback defines the callback to use
  39988. */
  39989. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39990. private _setButtonValue;
  39991. private _setDPadValue;
  39992. /**
  39993. * Gets the value of the `A` button
  39994. */
  39995. /**
  39996. * Sets the value of the `A` button
  39997. */
  39998. buttonA: number;
  39999. /**
  40000. * Gets the value of the `B` button
  40001. */
  40002. /**
  40003. * Sets the value of the `B` button
  40004. */
  40005. buttonB: number;
  40006. /**
  40007. * Gets the value of the `X` button
  40008. */
  40009. /**
  40010. * Sets the value of the `X` button
  40011. */
  40012. buttonX: number;
  40013. /**
  40014. * Gets the value of the `Y` button
  40015. */
  40016. /**
  40017. * Sets the value of the `Y` button
  40018. */
  40019. buttonY: number;
  40020. /**
  40021. * Gets the value of the `Start` button
  40022. */
  40023. /**
  40024. * Sets the value of the `Start` button
  40025. */
  40026. buttonStart: number;
  40027. /**
  40028. * Gets the value of the `Back` button
  40029. */
  40030. /**
  40031. * Sets the value of the `Back` button
  40032. */
  40033. buttonBack: number;
  40034. /**
  40035. * Gets the value of the `Left` button
  40036. */
  40037. /**
  40038. * Sets the value of the `Left` button
  40039. */
  40040. buttonLB: number;
  40041. /**
  40042. * Gets the value of the `Right` button
  40043. */
  40044. /**
  40045. * Sets the value of the `Right` button
  40046. */
  40047. buttonRB: number;
  40048. /**
  40049. * Gets the value of the Left joystick
  40050. */
  40051. /**
  40052. * Sets the value of the Left joystick
  40053. */
  40054. buttonLeftStick: number;
  40055. /**
  40056. * Gets the value of the Right joystick
  40057. */
  40058. /**
  40059. * Sets the value of the Right joystick
  40060. */
  40061. buttonRightStick: number;
  40062. /**
  40063. * Gets the value of D-pad up
  40064. */
  40065. /**
  40066. * Sets the value of D-pad up
  40067. */
  40068. dPadUp: number;
  40069. /**
  40070. * Gets the value of D-pad down
  40071. */
  40072. /**
  40073. * Sets the value of D-pad down
  40074. */
  40075. dPadDown: number;
  40076. /**
  40077. * Gets the value of D-pad left
  40078. */
  40079. /**
  40080. * Sets the value of D-pad left
  40081. */
  40082. dPadLeft: number;
  40083. /**
  40084. * Gets the value of D-pad right
  40085. */
  40086. /**
  40087. * Sets the value of D-pad right
  40088. */
  40089. dPadRight: number;
  40090. /**
  40091. * Force the gamepad to synchronize with device values
  40092. */
  40093. update(): void;
  40094. /**
  40095. * Disposes the gamepad
  40096. */
  40097. dispose(): void;
  40098. }
  40099. }
  40100. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40101. import { Observable } from "babylonjs/Misc/observable";
  40102. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40103. /**
  40104. * Defines supported buttons for DualShock compatible gamepads
  40105. */
  40106. export enum DualShockButton {
  40107. /** Cross */
  40108. Cross = 0,
  40109. /** Circle */
  40110. Circle = 1,
  40111. /** Square */
  40112. Square = 2,
  40113. /** Triangle */
  40114. Triangle = 3,
  40115. /** Options */
  40116. Options = 4,
  40117. /** Share */
  40118. Share = 5,
  40119. /** L1 */
  40120. L1 = 6,
  40121. /** R1 */
  40122. R1 = 7,
  40123. /** Left stick */
  40124. LeftStick = 8,
  40125. /** Right stick */
  40126. RightStick = 9
  40127. }
  40128. /** Defines values for DualShock DPad */
  40129. export enum DualShockDpad {
  40130. /** Up */
  40131. Up = 0,
  40132. /** Down */
  40133. Down = 1,
  40134. /** Left */
  40135. Left = 2,
  40136. /** Right */
  40137. Right = 3
  40138. }
  40139. /**
  40140. * Defines a DualShock gamepad
  40141. */
  40142. export class DualShockPad extends Gamepad {
  40143. private _leftTrigger;
  40144. private _rightTrigger;
  40145. private _onlefttriggerchanged;
  40146. private _onrighttriggerchanged;
  40147. private _onbuttondown;
  40148. private _onbuttonup;
  40149. private _ondpaddown;
  40150. private _ondpadup;
  40151. /** Observable raised when a button is pressed */
  40152. onButtonDownObservable: Observable<DualShockButton>;
  40153. /** Observable raised when a button is released */
  40154. onButtonUpObservable: Observable<DualShockButton>;
  40155. /** Observable raised when a pad is pressed */
  40156. onPadDownObservable: Observable<DualShockDpad>;
  40157. /** Observable raised when a pad is released */
  40158. onPadUpObservable: Observable<DualShockDpad>;
  40159. private _buttonCross;
  40160. private _buttonCircle;
  40161. private _buttonSquare;
  40162. private _buttonTriangle;
  40163. private _buttonShare;
  40164. private _buttonOptions;
  40165. private _buttonL1;
  40166. private _buttonR1;
  40167. private _buttonLeftStick;
  40168. private _buttonRightStick;
  40169. private _dPadUp;
  40170. private _dPadDown;
  40171. private _dPadLeft;
  40172. private _dPadRight;
  40173. /**
  40174. * Creates a new DualShock gamepad object
  40175. * @param id defines the id of this gamepad
  40176. * @param index defines its index
  40177. * @param gamepad defines the internal HTML gamepad object
  40178. */
  40179. constructor(id: string, index: number, gamepad: any);
  40180. /**
  40181. * Defines the callback to call when left trigger is pressed
  40182. * @param callback defines the callback to use
  40183. */
  40184. onlefttriggerchanged(callback: (value: number) => void): void;
  40185. /**
  40186. * Defines the callback to call when right trigger is pressed
  40187. * @param callback defines the callback to use
  40188. */
  40189. onrighttriggerchanged(callback: (value: number) => void): void;
  40190. /**
  40191. * Gets the left trigger value
  40192. */
  40193. /**
  40194. * Sets the left trigger value
  40195. */
  40196. leftTrigger: number;
  40197. /**
  40198. * Gets the right trigger value
  40199. */
  40200. /**
  40201. * Sets the right trigger value
  40202. */
  40203. rightTrigger: number;
  40204. /**
  40205. * Defines the callback to call when a button is pressed
  40206. * @param callback defines the callback to use
  40207. */
  40208. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40209. /**
  40210. * Defines the callback to call when a button is released
  40211. * @param callback defines the callback to use
  40212. */
  40213. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40214. /**
  40215. * Defines the callback to call when a pad is pressed
  40216. * @param callback defines the callback to use
  40217. */
  40218. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40219. /**
  40220. * Defines the callback to call when a pad is released
  40221. * @param callback defines the callback to use
  40222. */
  40223. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40224. private _setButtonValue;
  40225. private _setDPadValue;
  40226. /**
  40227. * Gets the value of the `Cross` button
  40228. */
  40229. /**
  40230. * Sets the value of the `Cross` button
  40231. */
  40232. buttonCross: number;
  40233. /**
  40234. * Gets the value of the `Circle` button
  40235. */
  40236. /**
  40237. * Sets the value of the `Circle` button
  40238. */
  40239. buttonCircle: number;
  40240. /**
  40241. * Gets the value of the `Square` button
  40242. */
  40243. /**
  40244. * Sets the value of the `Square` button
  40245. */
  40246. buttonSquare: number;
  40247. /**
  40248. * Gets the value of the `Triangle` button
  40249. */
  40250. /**
  40251. * Sets the value of the `Triangle` button
  40252. */
  40253. buttonTriangle: number;
  40254. /**
  40255. * Gets the value of the `Options` button
  40256. */
  40257. /**
  40258. * Sets the value of the `Options` button
  40259. */
  40260. buttonOptions: number;
  40261. /**
  40262. * Gets the value of the `Share` button
  40263. */
  40264. /**
  40265. * Sets the value of the `Share` button
  40266. */
  40267. buttonShare: number;
  40268. /**
  40269. * Gets the value of the `L1` button
  40270. */
  40271. /**
  40272. * Sets the value of the `L1` button
  40273. */
  40274. buttonL1: number;
  40275. /**
  40276. * Gets the value of the `R1` button
  40277. */
  40278. /**
  40279. * Sets the value of the `R1` button
  40280. */
  40281. buttonR1: number;
  40282. /**
  40283. * Gets the value of the Left joystick
  40284. */
  40285. /**
  40286. * Sets the value of the Left joystick
  40287. */
  40288. buttonLeftStick: number;
  40289. /**
  40290. * Gets the value of the Right joystick
  40291. */
  40292. /**
  40293. * Sets the value of the Right joystick
  40294. */
  40295. buttonRightStick: number;
  40296. /**
  40297. * Gets the value of D-pad up
  40298. */
  40299. /**
  40300. * Sets the value of D-pad up
  40301. */
  40302. dPadUp: number;
  40303. /**
  40304. * Gets the value of D-pad down
  40305. */
  40306. /**
  40307. * Sets the value of D-pad down
  40308. */
  40309. dPadDown: number;
  40310. /**
  40311. * Gets the value of D-pad left
  40312. */
  40313. /**
  40314. * Sets the value of D-pad left
  40315. */
  40316. dPadLeft: number;
  40317. /**
  40318. * Gets the value of D-pad right
  40319. */
  40320. /**
  40321. * Sets the value of D-pad right
  40322. */
  40323. dPadRight: number;
  40324. /**
  40325. * Force the gamepad to synchronize with device values
  40326. */
  40327. update(): void;
  40328. /**
  40329. * Disposes the gamepad
  40330. */
  40331. dispose(): void;
  40332. }
  40333. }
  40334. declare module "babylonjs/Gamepads/gamepadManager" {
  40335. import { Observable } from "babylonjs/Misc/observable";
  40336. import { Nullable } from "babylonjs/types";
  40337. import { Scene } from "babylonjs/scene";
  40338. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40339. /**
  40340. * Manager for handling gamepads
  40341. */
  40342. export class GamepadManager {
  40343. private _scene?;
  40344. private _babylonGamepads;
  40345. private _oneGamepadConnected;
  40346. /** @hidden */
  40347. _isMonitoring: boolean;
  40348. private _gamepadEventSupported;
  40349. private _gamepadSupport;
  40350. /**
  40351. * observable to be triggered when the gamepad controller has been connected
  40352. */
  40353. onGamepadConnectedObservable: Observable<Gamepad>;
  40354. /**
  40355. * observable to be triggered when the gamepad controller has been disconnected
  40356. */
  40357. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40358. private _onGamepadConnectedEvent;
  40359. private _onGamepadDisconnectedEvent;
  40360. /**
  40361. * Initializes the gamepad manager
  40362. * @param _scene BabylonJS scene
  40363. */
  40364. constructor(_scene?: Scene | undefined);
  40365. /**
  40366. * The gamepads in the game pad manager
  40367. */
  40368. readonly gamepads: Gamepad[];
  40369. /**
  40370. * Get the gamepad controllers based on type
  40371. * @param type The type of gamepad controller
  40372. * @returns Nullable gamepad
  40373. */
  40374. getGamepadByType(type?: number): Nullable<Gamepad>;
  40375. /**
  40376. * Disposes the gamepad manager
  40377. */
  40378. dispose(): void;
  40379. private _addNewGamepad;
  40380. private _startMonitoringGamepads;
  40381. private _stopMonitoringGamepads;
  40382. /** @hidden */
  40383. _checkGamepadsStatus(): void;
  40384. private _updateGamepadObjects;
  40385. }
  40386. }
  40387. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40388. import { Nullable } from "babylonjs/types";
  40389. import { Scene } from "babylonjs/scene";
  40390. import { ISceneComponent } from "babylonjs/sceneComponent";
  40391. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40392. module "babylonjs/scene" {
  40393. interface Scene {
  40394. /** @hidden */
  40395. _gamepadManager: Nullable<GamepadManager>;
  40396. /**
  40397. * Gets the gamepad manager associated with the scene
  40398. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40399. */
  40400. gamepadManager: GamepadManager;
  40401. }
  40402. }
  40403. module "babylonjs/Cameras/freeCameraInputsManager" {
  40404. /**
  40405. * Interface representing a free camera inputs manager
  40406. */
  40407. interface FreeCameraInputsManager {
  40408. /**
  40409. * Adds gamepad input support to the FreeCameraInputsManager.
  40410. * @returns the FreeCameraInputsManager
  40411. */
  40412. addGamepad(): FreeCameraInputsManager;
  40413. }
  40414. }
  40415. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40416. /**
  40417. * Interface representing an arc rotate camera inputs manager
  40418. */
  40419. interface ArcRotateCameraInputsManager {
  40420. /**
  40421. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40422. * @returns the camera inputs manager
  40423. */
  40424. addGamepad(): ArcRotateCameraInputsManager;
  40425. }
  40426. }
  40427. /**
  40428. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40429. */
  40430. export class GamepadSystemSceneComponent implements ISceneComponent {
  40431. /**
  40432. * The component name helpfull to identify the component in the list of scene components.
  40433. */
  40434. readonly name: string;
  40435. /**
  40436. * The scene the component belongs to.
  40437. */
  40438. scene: Scene;
  40439. /**
  40440. * Creates a new instance of the component for the given scene
  40441. * @param scene Defines the scene to register the component in
  40442. */
  40443. constructor(scene: Scene);
  40444. /**
  40445. * Registers the component in a given scene
  40446. */
  40447. register(): void;
  40448. /**
  40449. * Rebuilds the elements related to this component in case of
  40450. * context lost for instance.
  40451. */
  40452. rebuild(): void;
  40453. /**
  40454. * Disposes the component and the associated ressources
  40455. */
  40456. dispose(): void;
  40457. private _beforeCameraUpdate;
  40458. }
  40459. }
  40460. declare module "babylonjs/Cameras/universalCamera" {
  40461. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40462. import { Scene } from "babylonjs/scene";
  40463. import { Vector3 } from "babylonjs/Maths/math.vector";
  40464. import "babylonjs/Gamepads/gamepadSceneComponent";
  40465. /**
  40466. * 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,
  40467. * which still works and will still be found in many Playgrounds.
  40468. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40469. */
  40470. export class UniversalCamera extends TouchCamera {
  40471. /**
  40472. * Defines the gamepad rotation sensiblity.
  40473. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40474. */
  40475. gamepadAngularSensibility: number;
  40476. /**
  40477. * Defines the gamepad move sensiblity.
  40478. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40479. */
  40480. gamepadMoveSensibility: number;
  40481. /**
  40482. * 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,
  40483. * which still works and will still be found in many Playgrounds.
  40484. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40485. * @param name Define the name of the camera in the scene
  40486. * @param position Define the start position of the camera in the scene
  40487. * @param scene Define the scene the camera belongs to
  40488. */
  40489. constructor(name: string, position: Vector3, scene: Scene);
  40490. /**
  40491. * Gets the current object class name.
  40492. * @return the class name
  40493. */
  40494. getClassName(): string;
  40495. }
  40496. }
  40497. declare module "babylonjs/Cameras/gamepadCamera" {
  40498. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40499. import { Scene } from "babylonjs/scene";
  40500. import { Vector3 } from "babylonjs/Maths/math.vector";
  40501. /**
  40502. * This represents a FPS type of camera. This is only here for back compat purpose.
  40503. * Please use the UniversalCamera instead as both are identical.
  40504. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40505. */
  40506. export class GamepadCamera extends UniversalCamera {
  40507. /**
  40508. * Instantiates a new Gamepad Camera
  40509. * This represents a FPS type of camera. This is only here for back compat purpose.
  40510. * Please use the UniversalCamera instead as both are identical.
  40511. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40512. * @param name Define the name of the camera in the scene
  40513. * @param position Define the start position of the camera in the scene
  40514. * @param scene Define the scene the camera belongs to
  40515. */
  40516. constructor(name: string, position: Vector3, scene: Scene);
  40517. /**
  40518. * Gets the current object class name.
  40519. * @return the class name
  40520. */
  40521. getClassName(): string;
  40522. }
  40523. }
  40524. declare module "babylonjs/Shaders/pass.fragment" {
  40525. /** @hidden */
  40526. export var passPixelShader: {
  40527. name: string;
  40528. shader: string;
  40529. };
  40530. }
  40531. declare module "babylonjs/Shaders/passCube.fragment" {
  40532. /** @hidden */
  40533. export var passCubePixelShader: {
  40534. name: string;
  40535. shader: string;
  40536. };
  40537. }
  40538. declare module "babylonjs/PostProcesses/passPostProcess" {
  40539. import { Nullable } from "babylonjs/types";
  40540. import { Camera } from "babylonjs/Cameras/camera";
  40541. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40542. import { Engine } from "babylonjs/Engines/engine";
  40543. import "babylonjs/Shaders/pass.fragment";
  40544. import "babylonjs/Shaders/passCube.fragment";
  40545. /**
  40546. * PassPostProcess which produces an output the same as it's input
  40547. */
  40548. export class PassPostProcess extends PostProcess {
  40549. /**
  40550. * Creates the PassPostProcess
  40551. * @param name The name of the effect.
  40552. * @param options The required width/height ratio to downsize to before computing the render pass.
  40553. * @param camera The camera to apply the render pass to.
  40554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40555. * @param engine The engine which the post process will be applied. (default: current engine)
  40556. * @param reusable If the post process can be reused on the same frame. (default: false)
  40557. * @param textureType The type of texture to be used when performing the post processing.
  40558. * @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)
  40559. */
  40560. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40561. }
  40562. /**
  40563. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40564. */
  40565. export class PassCubePostProcess extends PostProcess {
  40566. private _face;
  40567. /**
  40568. * Gets or sets the cube face to display.
  40569. * * 0 is +X
  40570. * * 1 is -X
  40571. * * 2 is +Y
  40572. * * 3 is -Y
  40573. * * 4 is +Z
  40574. * * 5 is -Z
  40575. */
  40576. face: number;
  40577. /**
  40578. * Creates the PassCubePostProcess
  40579. * @param name The name of the effect.
  40580. * @param options The required width/height ratio to downsize to before computing the render pass.
  40581. * @param camera The camera to apply the render pass to.
  40582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40583. * @param engine The engine which the post process will be applied. (default: current engine)
  40584. * @param reusable If the post process can be reused on the same frame. (default: false)
  40585. * @param textureType The type of texture to be used when performing the post processing.
  40586. * @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)
  40587. */
  40588. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40589. }
  40590. }
  40591. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40592. /** @hidden */
  40593. export var anaglyphPixelShader: {
  40594. name: string;
  40595. shader: string;
  40596. };
  40597. }
  40598. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40599. import { Engine } from "babylonjs/Engines/engine";
  40600. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40601. import { Camera } from "babylonjs/Cameras/camera";
  40602. import "babylonjs/Shaders/anaglyph.fragment";
  40603. /**
  40604. * Postprocess used to generate anaglyphic rendering
  40605. */
  40606. export class AnaglyphPostProcess extends PostProcess {
  40607. private _passedProcess;
  40608. /**
  40609. * Creates a new AnaglyphPostProcess
  40610. * @param name defines postprocess name
  40611. * @param options defines creation options or target ratio scale
  40612. * @param rigCameras defines cameras using this postprocess
  40613. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40614. * @param engine defines hosting engine
  40615. * @param reusable defines if the postprocess will be reused multiple times per frame
  40616. */
  40617. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40618. }
  40619. }
  40620. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40621. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40622. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40623. import { Scene } from "babylonjs/scene";
  40624. import { Vector3 } from "babylonjs/Maths/math.vector";
  40625. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40626. /**
  40627. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40628. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40629. */
  40630. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40631. /**
  40632. * Creates a new AnaglyphArcRotateCamera
  40633. * @param name defines camera name
  40634. * @param alpha defines alpha angle (in radians)
  40635. * @param beta defines beta angle (in radians)
  40636. * @param radius defines radius
  40637. * @param target defines camera target
  40638. * @param interaxialDistance defines distance between each color axis
  40639. * @param scene defines the hosting scene
  40640. */
  40641. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40642. /**
  40643. * Gets camera class name
  40644. * @returns AnaglyphArcRotateCamera
  40645. */
  40646. getClassName(): string;
  40647. }
  40648. }
  40649. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40650. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40651. import { Scene } from "babylonjs/scene";
  40652. import { Vector3 } from "babylonjs/Maths/math.vector";
  40653. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40654. /**
  40655. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40656. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40657. */
  40658. export class AnaglyphFreeCamera extends FreeCamera {
  40659. /**
  40660. * Creates a new AnaglyphFreeCamera
  40661. * @param name defines camera name
  40662. * @param position defines initial position
  40663. * @param interaxialDistance defines distance between each color axis
  40664. * @param scene defines the hosting scene
  40665. */
  40666. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40667. /**
  40668. * Gets camera class name
  40669. * @returns AnaglyphFreeCamera
  40670. */
  40671. getClassName(): string;
  40672. }
  40673. }
  40674. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40675. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40676. import { Scene } from "babylonjs/scene";
  40677. import { Vector3 } from "babylonjs/Maths/math.vector";
  40678. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40679. /**
  40680. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40681. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40682. */
  40683. export class AnaglyphGamepadCamera extends GamepadCamera {
  40684. /**
  40685. * Creates a new AnaglyphGamepadCamera
  40686. * @param name defines camera name
  40687. * @param position defines initial position
  40688. * @param interaxialDistance defines distance between each color axis
  40689. * @param scene defines the hosting scene
  40690. */
  40691. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40692. /**
  40693. * Gets camera class name
  40694. * @returns AnaglyphGamepadCamera
  40695. */
  40696. getClassName(): string;
  40697. }
  40698. }
  40699. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40700. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40701. import { Scene } from "babylonjs/scene";
  40702. import { Vector3 } from "babylonjs/Maths/math.vector";
  40703. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40704. /**
  40705. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40706. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40707. */
  40708. export class AnaglyphUniversalCamera extends UniversalCamera {
  40709. /**
  40710. * Creates a new AnaglyphUniversalCamera
  40711. * @param name defines camera name
  40712. * @param position defines initial position
  40713. * @param interaxialDistance defines distance between each color axis
  40714. * @param scene defines the hosting scene
  40715. */
  40716. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40717. /**
  40718. * Gets camera class name
  40719. * @returns AnaglyphUniversalCamera
  40720. */
  40721. getClassName(): string;
  40722. }
  40723. }
  40724. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40725. /** @hidden */
  40726. export var stereoscopicInterlacePixelShader: {
  40727. name: string;
  40728. shader: string;
  40729. };
  40730. }
  40731. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40732. import { Camera } from "babylonjs/Cameras/camera";
  40733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40734. import { Engine } from "babylonjs/Engines/engine";
  40735. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40736. /**
  40737. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40738. */
  40739. export class StereoscopicInterlacePostProcess extends PostProcess {
  40740. private _stepSize;
  40741. private _passedProcess;
  40742. /**
  40743. * Initializes a StereoscopicInterlacePostProcess
  40744. * @param name The name of the effect.
  40745. * @param rigCameras The rig cameras to be appled to the post process
  40746. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40747. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40748. * @param engine The engine which the post process will be applied. (default: current engine)
  40749. * @param reusable If the post process can be reused on the same frame. (default: false)
  40750. */
  40751. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40752. }
  40753. }
  40754. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40755. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40756. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40757. import { Scene } from "babylonjs/scene";
  40758. import { Vector3 } from "babylonjs/Maths/math.vector";
  40759. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40760. /**
  40761. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40762. * @see http://doc.babylonjs.com/features/cameras
  40763. */
  40764. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40765. /**
  40766. * Creates a new StereoscopicArcRotateCamera
  40767. * @param name defines camera name
  40768. * @param alpha defines alpha angle (in radians)
  40769. * @param beta defines beta angle (in radians)
  40770. * @param radius defines radius
  40771. * @param target defines camera target
  40772. * @param interaxialDistance defines distance between each color axis
  40773. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40774. * @param scene defines the hosting scene
  40775. */
  40776. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40777. /**
  40778. * Gets camera class name
  40779. * @returns StereoscopicArcRotateCamera
  40780. */
  40781. getClassName(): string;
  40782. }
  40783. }
  40784. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40785. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40786. import { Scene } from "babylonjs/scene";
  40787. import { Vector3 } from "babylonjs/Maths/math.vector";
  40788. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40789. /**
  40790. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40791. * @see http://doc.babylonjs.com/features/cameras
  40792. */
  40793. export class StereoscopicFreeCamera extends FreeCamera {
  40794. /**
  40795. * Creates a new StereoscopicFreeCamera
  40796. * @param name defines camera name
  40797. * @param position defines initial position
  40798. * @param interaxialDistance defines distance between each color axis
  40799. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40800. * @param scene defines the hosting scene
  40801. */
  40802. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40803. /**
  40804. * Gets camera class name
  40805. * @returns StereoscopicFreeCamera
  40806. */
  40807. getClassName(): string;
  40808. }
  40809. }
  40810. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40811. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40812. import { Scene } from "babylonjs/scene";
  40813. import { Vector3 } from "babylonjs/Maths/math.vector";
  40814. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40815. /**
  40816. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40817. * @see http://doc.babylonjs.com/features/cameras
  40818. */
  40819. export class StereoscopicGamepadCamera extends GamepadCamera {
  40820. /**
  40821. * Creates a new StereoscopicGamepadCamera
  40822. * @param name defines camera name
  40823. * @param position defines initial position
  40824. * @param interaxialDistance defines distance between each color axis
  40825. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40826. * @param scene defines the hosting scene
  40827. */
  40828. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40829. /**
  40830. * Gets camera class name
  40831. * @returns StereoscopicGamepadCamera
  40832. */
  40833. getClassName(): string;
  40834. }
  40835. }
  40836. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40837. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40838. import { Scene } from "babylonjs/scene";
  40839. import { Vector3 } from "babylonjs/Maths/math.vector";
  40840. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40841. /**
  40842. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40843. * @see http://doc.babylonjs.com/features/cameras
  40844. */
  40845. export class StereoscopicUniversalCamera extends UniversalCamera {
  40846. /**
  40847. * Creates a new StereoscopicUniversalCamera
  40848. * @param name defines camera name
  40849. * @param position defines initial position
  40850. * @param interaxialDistance defines distance between each color axis
  40851. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40852. * @param scene defines the hosting scene
  40853. */
  40854. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40855. /**
  40856. * Gets camera class name
  40857. * @returns StereoscopicUniversalCamera
  40858. */
  40859. getClassName(): string;
  40860. }
  40861. }
  40862. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40863. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40864. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40865. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40866. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40867. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40868. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40869. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40870. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40871. }
  40872. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40873. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40874. import { Scene } from "babylonjs/scene";
  40875. import { Vector3 } from "babylonjs/Maths/math.vector";
  40876. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40877. /**
  40878. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40879. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40880. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40881. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40882. */
  40883. export class VirtualJoysticksCamera extends FreeCamera {
  40884. /**
  40885. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40886. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40887. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40888. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40889. * @param name Define the name of the camera in the scene
  40890. * @param position Define the start position of the camera in the scene
  40891. * @param scene Define the scene the camera belongs to
  40892. */
  40893. constructor(name: string, position: Vector3, scene: Scene);
  40894. /**
  40895. * Gets the current object class name.
  40896. * @return the class name
  40897. */
  40898. getClassName(): string;
  40899. }
  40900. }
  40901. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40902. import { Matrix } from "babylonjs/Maths/math.vector";
  40903. /**
  40904. * This represents all the required metrics to create a VR camera.
  40905. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40906. */
  40907. export class VRCameraMetrics {
  40908. /**
  40909. * Define the horizontal resolution off the screen.
  40910. */
  40911. hResolution: number;
  40912. /**
  40913. * Define the vertical resolution off the screen.
  40914. */
  40915. vResolution: number;
  40916. /**
  40917. * Define the horizontal screen size.
  40918. */
  40919. hScreenSize: number;
  40920. /**
  40921. * Define the vertical screen size.
  40922. */
  40923. vScreenSize: number;
  40924. /**
  40925. * Define the vertical screen center position.
  40926. */
  40927. vScreenCenter: number;
  40928. /**
  40929. * Define the distance of the eyes to the screen.
  40930. */
  40931. eyeToScreenDistance: number;
  40932. /**
  40933. * Define the distance between both lenses
  40934. */
  40935. lensSeparationDistance: number;
  40936. /**
  40937. * Define the distance between both viewer's eyes.
  40938. */
  40939. interpupillaryDistance: number;
  40940. /**
  40941. * Define the distortion factor of the VR postprocess.
  40942. * Please, touch with care.
  40943. */
  40944. distortionK: number[];
  40945. /**
  40946. * Define the chromatic aberration correction factors for the VR post process.
  40947. */
  40948. chromaAbCorrection: number[];
  40949. /**
  40950. * Define the scale factor of the post process.
  40951. * The smaller the better but the slower.
  40952. */
  40953. postProcessScaleFactor: number;
  40954. /**
  40955. * Define an offset for the lens center.
  40956. */
  40957. lensCenterOffset: number;
  40958. /**
  40959. * Define if the current vr camera should compensate the distortion of the lense or not.
  40960. */
  40961. compensateDistortion: boolean;
  40962. /**
  40963. * Defines if multiview should be enabled when rendering (Default: false)
  40964. */
  40965. multiviewEnabled: boolean;
  40966. /**
  40967. * Gets the rendering aspect ratio based on the provided resolutions.
  40968. */
  40969. readonly aspectRatio: number;
  40970. /**
  40971. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40972. */
  40973. readonly aspectRatioFov: number;
  40974. /**
  40975. * @hidden
  40976. */
  40977. readonly leftHMatrix: Matrix;
  40978. /**
  40979. * @hidden
  40980. */
  40981. readonly rightHMatrix: Matrix;
  40982. /**
  40983. * @hidden
  40984. */
  40985. readonly leftPreViewMatrix: Matrix;
  40986. /**
  40987. * @hidden
  40988. */
  40989. readonly rightPreViewMatrix: Matrix;
  40990. /**
  40991. * Get the default VRMetrics based on the most generic setup.
  40992. * @returns the default vr metrics
  40993. */
  40994. static GetDefault(): VRCameraMetrics;
  40995. }
  40996. }
  40997. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40998. /** @hidden */
  40999. export var vrDistortionCorrectionPixelShader: {
  41000. name: string;
  41001. shader: string;
  41002. };
  41003. }
  41004. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41005. import { Camera } from "babylonjs/Cameras/camera";
  41006. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41008. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41009. /**
  41010. * VRDistortionCorrectionPostProcess used for mobile VR
  41011. */
  41012. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41013. private _isRightEye;
  41014. private _distortionFactors;
  41015. private _postProcessScaleFactor;
  41016. private _lensCenterOffset;
  41017. private _scaleIn;
  41018. private _scaleFactor;
  41019. private _lensCenter;
  41020. /**
  41021. * Initializes the VRDistortionCorrectionPostProcess
  41022. * @param name The name of the effect.
  41023. * @param camera The camera to apply the render pass to.
  41024. * @param isRightEye If this is for the right eye distortion
  41025. * @param vrMetrics All the required metrics for the VR camera
  41026. */
  41027. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41028. }
  41029. }
  41030. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41031. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41032. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41033. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41034. import { Scene } from "babylonjs/scene";
  41035. import { Vector3 } from "babylonjs/Maths/math.vector";
  41036. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41037. import "babylonjs/Cameras/RigModes/vrRigMode";
  41038. /**
  41039. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41040. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41041. */
  41042. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41043. /**
  41044. * Creates a new VRDeviceOrientationArcRotateCamera
  41045. * @param name defines camera name
  41046. * @param alpha defines the camera rotation along the logitudinal axis
  41047. * @param beta defines the camera rotation along the latitudinal axis
  41048. * @param radius defines the camera distance from its target
  41049. * @param target defines the camera target
  41050. * @param scene defines the scene the camera belongs to
  41051. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41052. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41053. */
  41054. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41055. /**
  41056. * Gets camera class name
  41057. * @returns VRDeviceOrientationArcRotateCamera
  41058. */
  41059. getClassName(): string;
  41060. }
  41061. }
  41062. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41063. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41064. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41065. import { Scene } from "babylonjs/scene";
  41066. import { Vector3 } from "babylonjs/Maths/math.vector";
  41067. import "babylonjs/Cameras/RigModes/vrRigMode";
  41068. /**
  41069. * Camera used to simulate VR rendering (based on FreeCamera)
  41070. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41071. */
  41072. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41073. /**
  41074. * Creates a new VRDeviceOrientationFreeCamera
  41075. * @param name defines camera name
  41076. * @param position defines the start position of the camera
  41077. * @param scene defines the scene the camera belongs to
  41078. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41079. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41080. */
  41081. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41082. /**
  41083. * Gets camera class name
  41084. * @returns VRDeviceOrientationFreeCamera
  41085. */
  41086. getClassName(): string;
  41087. }
  41088. }
  41089. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41090. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41091. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41092. import { Scene } from "babylonjs/scene";
  41093. import { Vector3 } from "babylonjs/Maths/math.vector";
  41094. import "babylonjs/Gamepads/gamepadSceneComponent";
  41095. /**
  41096. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41097. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41098. */
  41099. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41100. /**
  41101. * Creates a new VRDeviceOrientationGamepadCamera
  41102. * @param name defines camera name
  41103. * @param position defines the start position of the camera
  41104. * @param scene defines the scene the camera belongs to
  41105. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41106. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41107. */
  41108. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41109. /**
  41110. * Gets camera class name
  41111. * @returns VRDeviceOrientationGamepadCamera
  41112. */
  41113. getClassName(): string;
  41114. }
  41115. }
  41116. declare module "babylonjs/Materials/pushMaterial" {
  41117. import { Nullable } from "babylonjs/types";
  41118. import { Scene } from "babylonjs/scene";
  41119. import { Matrix } from "babylonjs/Maths/math.vector";
  41120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41121. import { Mesh } from "babylonjs/Meshes/mesh";
  41122. import { Material } from "babylonjs/Materials/material";
  41123. import { Effect } from "babylonjs/Materials/effect";
  41124. /**
  41125. * Base class of materials working in push mode in babylon JS
  41126. * @hidden
  41127. */
  41128. export class PushMaterial extends Material {
  41129. protected _activeEffect: Effect;
  41130. protected _normalMatrix: Matrix;
  41131. /**
  41132. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41133. * This means that the material can keep using a previous shader while a new one is being compiled.
  41134. * This is mostly used when shader parallel compilation is supported (true by default)
  41135. */
  41136. allowShaderHotSwapping: boolean;
  41137. constructor(name: string, scene: Scene);
  41138. getEffect(): Effect;
  41139. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41140. /**
  41141. * Binds the given world matrix to the active effect
  41142. *
  41143. * @param world the matrix to bind
  41144. */
  41145. bindOnlyWorldMatrix(world: Matrix): void;
  41146. /**
  41147. * Binds the given normal matrix to the active effect
  41148. *
  41149. * @param normalMatrix the matrix to bind
  41150. */
  41151. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41152. bind(world: Matrix, mesh?: Mesh): void;
  41153. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41154. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41155. }
  41156. }
  41157. declare module "babylonjs/Materials/materialFlags" {
  41158. /**
  41159. * This groups all the flags used to control the materials channel.
  41160. */
  41161. export class MaterialFlags {
  41162. private static _DiffuseTextureEnabled;
  41163. /**
  41164. * Are diffuse textures enabled in the application.
  41165. */
  41166. static DiffuseTextureEnabled: boolean;
  41167. private static _AmbientTextureEnabled;
  41168. /**
  41169. * Are ambient textures enabled in the application.
  41170. */
  41171. static AmbientTextureEnabled: boolean;
  41172. private static _OpacityTextureEnabled;
  41173. /**
  41174. * Are opacity textures enabled in the application.
  41175. */
  41176. static OpacityTextureEnabled: boolean;
  41177. private static _ReflectionTextureEnabled;
  41178. /**
  41179. * Are reflection textures enabled in the application.
  41180. */
  41181. static ReflectionTextureEnabled: boolean;
  41182. private static _EmissiveTextureEnabled;
  41183. /**
  41184. * Are emissive textures enabled in the application.
  41185. */
  41186. static EmissiveTextureEnabled: boolean;
  41187. private static _SpecularTextureEnabled;
  41188. /**
  41189. * Are specular textures enabled in the application.
  41190. */
  41191. static SpecularTextureEnabled: boolean;
  41192. private static _BumpTextureEnabled;
  41193. /**
  41194. * Are bump textures enabled in the application.
  41195. */
  41196. static BumpTextureEnabled: boolean;
  41197. private static _LightmapTextureEnabled;
  41198. /**
  41199. * Are lightmap textures enabled in the application.
  41200. */
  41201. static LightmapTextureEnabled: boolean;
  41202. private static _RefractionTextureEnabled;
  41203. /**
  41204. * Are refraction textures enabled in the application.
  41205. */
  41206. static RefractionTextureEnabled: boolean;
  41207. private static _ColorGradingTextureEnabled;
  41208. /**
  41209. * Are color grading textures enabled in the application.
  41210. */
  41211. static ColorGradingTextureEnabled: boolean;
  41212. private static _FresnelEnabled;
  41213. /**
  41214. * Are fresnels enabled in the application.
  41215. */
  41216. static FresnelEnabled: boolean;
  41217. private static _ClearCoatTextureEnabled;
  41218. /**
  41219. * Are clear coat textures enabled in the application.
  41220. */
  41221. static ClearCoatTextureEnabled: boolean;
  41222. private static _ClearCoatBumpTextureEnabled;
  41223. /**
  41224. * Are clear coat bump textures enabled in the application.
  41225. */
  41226. static ClearCoatBumpTextureEnabled: boolean;
  41227. private static _ClearCoatTintTextureEnabled;
  41228. /**
  41229. * Are clear coat tint textures enabled in the application.
  41230. */
  41231. static ClearCoatTintTextureEnabled: boolean;
  41232. private static _SheenTextureEnabled;
  41233. /**
  41234. * Are sheen textures enabled in the application.
  41235. */
  41236. static SheenTextureEnabled: boolean;
  41237. private static _AnisotropicTextureEnabled;
  41238. /**
  41239. * Are anisotropic textures enabled in the application.
  41240. */
  41241. static AnisotropicTextureEnabled: boolean;
  41242. private static _ThicknessTextureEnabled;
  41243. /**
  41244. * Are thickness textures enabled in the application.
  41245. */
  41246. static ThicknessTextureEnabled: boolean;
  41247. }
  41248. }
  41249. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41250. /** @hidden */
  41251. export var defaultFragmentDeclaration: {
  41252. name: string;
  41253. shader: string;
  41254. };
  41255. }
  41256. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41257. /** @hidden */
  41258. export var defaultUboDeclaration: {
  41259. name: string;
  41260. shader: string;
  41261. };
  41262. }
  41263. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41264. /** @hidden */
  41265. export var lightFragmentDeclaration: {
  41266. name: string;
  41267. shader: string;
  41268. };
  41269. }
  41270. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41271. /** @hidden */
  41272. export var lightUboDeclaration: {
  41273. name: string;
  41274. shader: string;
  41275. };
  41276. }
  41277. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41278. /** @hidden */
  41279. export var lightsFragmentFunctions: {
  41280. name: string;
  41281. shader: string;
  41282. };
  41283. }
  41284. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41285. /** @hidden */
  41286. export var shadowsFragmentFunctions: {
  41287. name: string;
  41288. shader: string;
  41289. };
  41290. }
  41291. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41292. /** @hidden */
  41293. export var fresnelFunction: {
  41294. name: string;
  41295. shader: string;
  41296. };
  41297. }
  41298. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41299. /** @hidden */
  41300. export var reflectionFunction: {
  41301. name: string;
  41302. shader: string;
  41303. };
  41304. }
  41305. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41306. /** @hidden */
  41307. export var bumpFragmentFunctions: {
  41308. name: string;
  41309. shader: string;
  41310. };
  41311. }
  41312. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41313. /** @hidden */
  41314. export var logDepthDeclaration: {
  41315. name: string;
  41316. shader: string;
  41317. };
  41318. }
  41319. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41320. /** @hidden */
  41321. export var bumpFragment: {
  41322. name: string;
  41323. shader: string;
  41324. };
  41325. }
  41326. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41327. /** @hidden */
  41328. export var depthPrePass: {
  41329. name: string;
  41330. shader: string;
  41331. };
  41332. }
  41333. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41334. /** @hidden */
  41335. export var lightFragment: {
  41336. name: string;
  41337. shader: string;
  41338. };
  41339. }
  41340. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41341. /** @hidden */
  41342. export var logDepthFragment: {
  41343. name: string;
  41344. shader: string;
  41345. };
  41346. }
  41347. declare module "babylonjs/Shaders/default.fragment" {
  41348. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41349. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41350. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41351. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41352. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41353. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41354. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41355. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41356. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41357. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41358. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41359. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41360. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41361. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41362. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41363. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41364. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41365. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41366. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41367. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41368. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41369. /** @hidden */
  41370. export var defaultPixelShader: {
  41371. name: string;
  41372. shader: string;
  41373. };
  41374. }
  41375. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41376. /** @hidden */
  41377. export var defaultVertexDeclaration: {
  41378. name: string;
  41379. shader: string;
  41380. };
  41381. }
  41382. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41383. /** @hidden */
  41384. export var bumpVertexDeclaration: {
  41385. name: string;
  41386. shader: string;
  41387. };
  41388. }
  41389. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41390. /** @hidden */
  41391. export var bumpVertex: {
  41392. name: string;
  41393. shader: string;
  41394. };
  41395. }
  41396. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41397. /** @hidden */
  41398. export var fogVertex: {
  41399. name: string;
  41400. shader: string;
  41401. };
  41402. }
  41403. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41404. /** @hidden */
  41405. export var shadowsVertex: {
  41406. name: string;
  41407. shader: string;
  41408. };
  41409. }
  41410. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41411. /** @hidden */
  41412. export var pointCloudVertex: {
  41413. name: string;
  41414. shader: string;
  41415. };
  41416. }
  41417. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41418. /** @hidden */
  41419. export var logDepthVertex: {
  41420. name: string;
  41421. shader: string;
  41422. };
  41423. }
  41424. declare module "babylonjs/Shaders/default.vertex" {
  41425. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41426. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41427. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41428. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41429. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41430. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41431. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41432. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41433. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41434. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41435. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41436. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41437. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41438. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41439. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41440. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41441. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41442. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41443. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41444. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41445. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41446. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41447. /** @hidden */
  41448. export var defaultVertexShader: {
  41449. name: string;
  41450. shader: string;
  41451. };
  41452. }
  41453. declare module "babylonjs/Materials/standardMaterial" {
  41454. import { SmartArray } from "babylonjs/Misc/smartArray";
  41455. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41456. import { Nullable } from "babylonjs/types";
  41457. import { Scene } from "babylonjs/scene";
  41458. import { Matrix } from "babylonjs/Maths/math.vector";
  41459. import { Color3 } from "babylonjs/Maths/math.color";
  41460. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41462. import { Mesh } from "babylonjs/Meshes/mesh";
  41463. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41464. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41465. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41466. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41467. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41468. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41469. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41470. import "babylonjs/Shaders/default.fragment";
  41471. import "babylonjs/Shaders/default.vertex";
  41472. /** @hidden */
  41473. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41474. MAINUV1: boolean;
  41475. MAINUV2: boolean;
  41476. DIFFUSE: boolean;
  41477. DIFFUSEDIRECTUV: number;
  41478. AMBIENT: boolean;
  41479. AMBIENTDIRECTUV: number;
  41480. OPACITY: boolean;
  41481. OPACITYDIRECTUV: number;
  41482. OPACITYRGB: boolean;
  41483. REFLECTION: boolean;
  41484. EMISSIVE: boolean;
  41485. EMISSIVEDIRECTUV: number;
  41486. SPECULAR: boolean;
  41487. SPECULARDIRECTUV: number;
  41488. BUMP: boolean;
  41489. BUMPDIRECTUV: number;
  41490. PARALLAX: boolean;
  41491. PARALLAXOCCLUSION: boolean;
  41492. SPECULAROVERALPHA: boolean;
  41493. CLIPPLANE: boolean;
  41494. CLIPPLANE2: boolean;
  41495. CLIPPLANE3: boolean;
  41496. CLIPPLANE4: boolean;
  41497. ALPHATEST: boolean;
  41498. DEPTHPREPASS: boolean;
  41499. ALPHAFROMDIFFUSE: boolean;
  41500. POINTSIZE: boolean;
  41501. FOG: boolean;
  41502. SPECULARTERM: boolean;
  41503. DIFFUSEFRESNEL: boolean;
  41504. OPACITYFRESNEL: boolean;
  41505. REFLECTIONFRESNEL: boolean;
  41506. REFRACTIONFRESNEL: boolean;
  41507. EMISSIVEFRESNEL: boolean;
  41508. FRESNEL: boolean;
  41509. NORMAL: boolean;
  41510. UV1: boolean;
  41511. UV2: boolean;
  41512. VERTEXCOLOR: boolean;
  41513. VERTEXALPHA: boolean;
  41514. NUM_BONE_INFLUENCERS: number;
  41515. BonesPerMesh: number;
  41516. BONETEXTURE: boolean;
  41517. INSTANCES: boolean;
  41518. GLOSSINESS: boolean;
  41519. ROUGHNESS: boolean;
  41520. EMISSIVEASILLUMINATION: boolean;
  41521. LINKEMISSIVEWITHDIFFUSE: boolean;
  41522. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41523. LIGHTMAP: boolean;
  41524. LIGHTMAPDIRECTUV: number;
  41525. OBJECTSPACE_NORMALMAP: boolean;
  41526. USELIGHTMAPASSHADOWMAP: boolean;
  41527. REFLECTIONMAP_3D: boolean;
  41528. REFLECTIONMAP_SPHERICAL: boolean;
  41529. REFLECTIONMAP_PLANAR: boolean;
  41530. REFLECTIONMAP_CUBIC: boolean;
  41531. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41532. REFLECTIONMAP_PROJECTION: boolean;
  41533. REFLECTIONMAP_SKYBOX: boolean;
  41534. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41535. REFLECTIONMAP_EXPLICIT: boolean;
  41536. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41537. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41538. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41539. INVERTCUBICMAP: boolean;
  41540. LOGARITHMICDEPTH: boolean;
  41541. REFRACTION: boolean;
  41542. REFRACTIONMAP_3D: boolean;
  41543. REFLECTIONOVERALPHA: boolean;
  41544. TWOSIDEDLIGHTING: boolean;
  41545. SHADOWFLOAT: boolean;
  41546. MORPHTARGETS: boolean;
  41547. MORPHTARGETS_NORMAL: boolean;
  41548. MORPHTARGETS_TANGENT: boolean;
  41549. MORPHTARGETS_UV: boolean;
  41550. NUM_MORPH_INFLUENCERS: number;
  41551. NONUNIFORMSCALING: boolean;
  41552. PREMULTIPLYALPHA: boolean;
  41553. IMAGEPROCESSING: boolean;
  41554. VIGNETTE: boolean;
  41555. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41556. VIGNETTEBLENDMODEOPAQUE: boolean;
  41557. TONEMAPPING: boolean;
  41558. TONEMAPPING_ACES: boolean;
  41559. CONTRAST: boolean;
  41560. COLORCURVES: boolean;
  41561. COLORGRADING: boolean;
  41562. COLORGRADING3D: boolean;
  41563. SAMPLER3DGREENDEPTH: boolean;
  41564. SAMPLER3DBGRMAP: boolean;
  41565. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41566. MULTIVIEW: boolean;
  41567. /**
  41568. * If the reflection texture on this material is in linear color space
  41569. * @hidden
  41570. */
  41571. IS_REFLECTION_LINEAR: boolean;
  41572. /**
  41573. * If the refraction texture on this material is in linear color space
  41574. * @hidden
  41575. */
  41576. IS_REFRACTION_LINEAR: boolean;
  41577. EXPOSURE: boolean;
  41578. constructor();
  41579. setReflectionMode(modeToEnable: string): void;
  41580. }
  41581. /**
  41582. * This is the default material used in Babylon. It is the best trade off between quality
  41583. * and performances.
  41584. * @see http://doc.babylonjs.com/babylon101/materials
  41585. */
  41586. export class StandardMaterial extends PushMaterial {
  41587. private _diffuseTexture;
  41588. /**
  41589. * The basic texture of the material as viewed under a light.
  41590. */
  41591. diffuseTexture: Nullable<BaseTexture>;
  41592. private _ambientTexture;
  41593. /**
  41594. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41595. */
  41596. ambientTexture: Nullable<BaseTexture>;
  41597. private _opacityTexture;
  41598. /**
  41599. * Define the transparency of the material from a texture.
  41600. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41601. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41602. */
  41603. opacityTexture: Nullable<BaseTexture>;
  41604. private _reflectionTexture;
  41605. /**
  41606. * Define the texture used to display the reflection.
  41607. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41608. */
  41609. reflectionTexture: Nullable<BaseTexture>;
  41610. private _emissiveTexture;
  41611. /**
  41612. * Define texture of the material as if self lit.
  41613. * This will be mixed in the final result even in the absence of light.
  41614. */
  41615. emissiveTexture: Nullable<BaseTexture>;
  41616. private _specularTexture;
  41617. /**
  41618. * Define how the color and intensity of the highlight given by the light in the material.
  41619. */
  41620. specularTexture: Nullable<BaseTexture>;
  41621. private _bumpTexture;
  41622. /**
  41623. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41624. * 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.
  41625. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41626. */
  41627. bumpTexture: Nullable<BaseTexture>;
  41628. private _lightmapTexture;
  41629. /**
  41630. * Complex lighting can be computationally expensive to compute at runtime.
  41631. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41632. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41633. */
  41634. lightmapTexture: Nullable<BaseTexture>;
  41635. private _refractionTexture;
  41636. /**
  41637. * Define the texture used to display the refraction.
  41638. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41639. */
  41640. refractionTexture: Nullable<BaseTexture>;
  41641. /**
  41642. * The color of the material lit by the environmental background lighting.
  41643. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41644. */
  41645. ambientColor: Color3;
  41646. /**
  41647. * The basic color of the material as viewed under a light.
  41648. */
  41649. diffuseColor: Color3;
  41650. /**
  41651. * Define how the color and intensity of the highlight given by the light in the material.
  41652. */
  41653. specularColor: Color3;
  41654. /**
  41655. * Define the color of the material as if self lit.
  41656. * This will be mixed in the final result even in the absence of light.
  41657. */
  41658. emissiveColor: Color3;
  41659. /**
  41660. * Defines how sharp are the highlights in the material.
  41661. * The bigger the value the sharper giving a more glossy feeling to the result.
  41662. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41663. */
  41664. specularPower: number;
  41665. private _useAlphaFromDiffuseTexture;
  41666. /**
  41667. * Does the transparency come from the diffuse texture alpha channel.
  41668. */
  41669. useAlphaFromDiffuseTexture: boolean;
  41670. private _useEmissiveAsIllumination;
  41671. /**
  41672. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41673. */
  41674. useEmissiveAsIllumination: boolean;
  41675. private _linkEmissiveWithDiffuse;
  41676. /**
  41677. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41678. * the emissive level when the final color is close to one.
  41679. */
  41680. linkEmissiveWithDiffuse: boolean;
  41681. private _useSpecularOverAlpha;
  41682. /**
  41683. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41684. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41685. */
  41686. useSpecularOverAlpha: boolean;
  41687. private _useReflectionOverAlpha;
  41688. /**
  41689. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41690. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41691. */
  41692. useReflectionOverAlpha: boolean;
  41693. private _disableLighting;
  41694. /**
  41695. * Does lights from the scene impacts this material.
  41696. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41697. */
  41698. disableLighting: boolean;
  41699. private _useObjectSpaceNormalMap;
  41700. /**
  41701. * Allows using an object space normal map (instead of tangent space).
  41702. */
  41703. useObjectSpaceNormalMap: boolean;
  41704. private _useParallax;
  41705. /**
  41706. * Is parallax enabled or not.
  41707. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41708. */
  41709. useParallax: boolean;
  41710. private _useParallaxOcclusion;
  41711. /**
  41712. * Is parallax occlusion enabled or not.
  41713. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41714. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41715. */
  41716. useParallaxOcclusion: boolean;
  41717. /**
  41718. * 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.
  41719. */
  41720. parallaxScaleBias: number;
  41721. private _roughness;
  41722. /**
  41723. * Helps to define how blurry the reflections should appears in the material.
  41724. */
  41725. roughness: number;
  41726. /**
  41727. * In case of refraction, define the value of the index of refraction.
  41728. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41729. */
  41730. indexOfRefraction: number;
  41731. /**
  41732. * Invert the refraction texture alongside the y axis.
  41733. * It can be useful with procedural textures or probe for instance.
  41734. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41735. */
  41736. invertRefractionY: boolean;
  41737. /**
  41738. * Defines the alpha limits in alpha test mode.
  41739. */
  41740. alphaCutOff: number;
  41741. private _useLightmapAsShadowmap;
  41742. /**
  41743. * In case of light mapping, define whether the map contains light or shadow informations.
  41744. */
  41745. useLightmapAsShadowmap: boolean;
  41746. private _diffuseFresnelParameters;
  41747. /**
  41748. * Define the diffuse fresnel parameters of the material.
  41749. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41750. */
  41751. diffuseFresnelParameters: FresnelParameters;
  41752. private _opacityFresnelParameters;
  41753. /**
  41754. * Define the opacity fresnel parameters of the material.
  41755. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41756. */
  41757. opacityFresnelParameters: FresnelParameters;
  41758. private _reflectionFresnelParameters;
  41759. /**
  41760. * Define the reflection fresnel parameters of the material.
  41761. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41762. */
  41763. reflectionFresnelParameters: FresnelParameters;
  41764. private _refractionFresnelParameters;
  41765. /**
  41766. * Define the refraction fresnel parameters of the material.
  41767. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41768. */
  41769. refractionFresnelParameters: FresnelParameters;
  41770. private _emissiveFresnelParameters;
  41771. /**
  41772. * Define the emissive fresnel parameters of the material.
  41773. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41774. */
  41775. emissiveFresnelParameters: FresnelParameters;
  41776. private _useReflectionFresnelFromSpecular;
  41777. /**
  41778. * If true automatically deducts the fresnels values from the material specularity.
  41779. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41780. */
  41781. useReflectionFresnelFromSpecular: boolean;
  41782. private _useGlossinessFromSpecularMapAlpha;
  41783. /**
  41784. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41785. */
  41786. useGlossinessFromSpecularMapAlpha: boolean;
  41787. private _maxSimultaneousLights;
  41788. /**
  41789. * Defines the maximum number of lights that can be used in the material
  41790. */
  41791. maxSimultaneousLights: number;
  41792. private _invertNormalMapX;
  41793. /**
  41794. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41795. */
  41796. invertNormalMapX: boolean;
  41797. private _invertNormalMapY;
  41798. /**
  41799. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41800. */
  41801. invertNormalMapY: boolean;
  41802. private _twoSidedLighting;
  41803. /**
  41804. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41805. */
  41806. twoSidedLighting: boolean;
  41807. /**
  41808. * Default configuration related to image processing available in the standard Material.
  41809. */
  41810. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41811. /**
  41812. * Gets the image processing configuration used either in this material.
  41813. */
  41814. /**
  41815. * Sets the Default image processing configuration used either in the this material.
  41816. *
  41817. * If sets to null, the scene one is in use.
  41818. */
  41819. imageProcessingConfiguration: ImageProcessingConfiguration;
  41820. /**
  41821. * Keep track of the image processing observer to allow dispose and replace.
  41822. */
  41823. private _imageProcessingObserver;
  41824. /**
  41825. * Attaches a new image processing configuration to the Standard Material.
  41826. * @param configuration
  41827. */
  41828. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41829. /**
  41830. * Gets wether the color curves effect is enabled.
  41831. */
  41832. /**
  41833. * Sets wether the color curves effect is enabled.
  41834. */
  41835. cameraColorCurvesEnabled: boolean;
  41836. /**
  41837. * Gets wether the color grading effect is enabled.
  41838. */
  41839. /**
  41840. * Gets wether the color grading effect is enabled.
  41841. */
  41842. cameraColorGradingEnabled: boolean;
  41843. /**
  41844. * Gets wether tonemapping is enabled or not.
  41845. */
  41846. /**
  41847. * Sets wether tonemapping is enabled or not
  41848. */
  41849. cameraToneMappingEnabled: boolean;
  41850. /**
  41851. * The camera exposure used on this material.
  41852. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41853. * This corresponds to a photographic exposure.
  41854. */
  41855. /**
  41856. * The camera exposure used on this material.
  41857. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41858. * This corresponds to a photographic exposure.
  41859. */
  41860. cameraExposure: number;
  41861. /**
  41862. * Gets The camera contrast used on this material.
  41863. */
  41864. /**
  41865. * Sets The camera contrast used on this material.
  41866. */
  41867. cameraContrast: number;
  41868. /**
  41869. * Gets the Color Grading 2D Lookup Texture.
  41870. */
  41871. /**
  41872. * Sets the Color Grading 2D Lookup Texture.
  41873. */
  41874. cameraColorGradingTexture: Nullable<BaseTexture>;
  41875. /**
  41876. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41877. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41878. * 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;
  41879. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41880. */
  41881. /**
  41882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41884. * 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;
  41885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41886. */
  41887. cameraColorCurves: Nullable<ColorCurves>;
  41888. /**
  41889. * Custom callback helping to override the default shader used in the material.
  41890. */
  41891. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41892. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41893. protected _worldViewProjectionMatrix: Matrix;
  41894. protected _globalAmbientColor: Color3;
  41895. protected _useLogarithmicDepth: boolean;
  41896. protected _rebuildInParallel: boolean;
  41897. /**
  41898. * Instantiates a new standard material.
  41899. * This is the default material used in Babylon. It is the best trade off between quality
  41900. * and performances.
  41901. * @see http://doc.babylonjs.com/babylon101/materials
  41902. * @param name Define the name of the material in the scene
  41903. * @param scene Define the scene the material belong to
  41904. */
  41905. constructor(name: string, scene: Scene);
  41906. /**
  41907. * Gets a boolean indicating that current material needs to register RTT
  41908. */
  41909. readonly hasRenderTargetTextures: boolean;
  41910. /**
  41911. * Gets the current class name of the material e.g. "StandardMaterial"
  41912. * Mainly use in serialization.
  41913. * @returns the class name
  41914. */
  41915. getClassName(): string;
  41916. /**
  41917. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41918. * You can try switching to logarithmic depth.
  41919. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41920. */
  41921. useLogarithmicDepth: boolean;
  41922. /**
  41923. * Specifies if the material will require alpha blending
  41924. * @returns a boolean specifying if alpha blending is needed
  41925. */
  41926. needAlphaBlending(): boolean;
  41927. /**
  41928. * Specifies if this material should be rendered in alpha test mode
  41929. * @returns a boolean specifying if an alpha test is needed.
  41930. */
  41931. needAlphaTesting(): boolean;
  41932. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41933. /**
  41934. * Get the texture used for alpha test purpose.
  41935. * @returns the diffuse texture in case of the standard material.
  41936. */
  41937. getAlphaTestTexture(): Nullable<BaseTexture>;
  41938. /**
  41939. * Get if the submesh is ready to be used and all its information available.
  41940. * Child classes can use it to update shaders
  41941. * @param mesh defines the mesh to check
  41942. * @param subMesh defines which submesh to check
  41943. * @param useInstances specifies that instances should be used
  41944. * @returns a boolean indicating that the submesh is ready or not
  41945. */
  41946. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41947. /**
  41948. * Builds the material UBO layouts.
  41949. * Used internally during the effect preparation.
  41950. */
  41951. buildUniformLayout(): void;
  41952. /**
  41953. * Unbinds the material from the mesh
  41954. */
  41955. unbind(): void;
  41956. /**
  41957. * Binds the submesh to this material by preparing the effect and shader to draw
  41958. * @param world defines the world transformation matrix
  41959. * @param mesh defines the mesh containing the submesh
  41960. * @param subMesh defines the submesh to bind the material to
  41961. */
  41962. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41963. /**
  41964. * Get the list of animatables in the material.
  41965. * @returns the list of animatables object used in the material
  41966. */
  41967. getAnimatables(): IAnimatable[];
  41968. /**
  41969. * Gets the active textures from the material
  41970. * @returns an array of textures
  41971. */
  41972. getActiveTextures(): BaseTexture[];
  41973. /**
  41974. * Specifies if the material uses a texture
  41975. * @param texture defines the texture to check against the material
  41976. * @returns a boolean specifying if the material uses the texture
  41977. */
  41978. hasTexture(texture: BaseTexture): boolean;
  41979. /**
  41980. * Disposes the material
  41981. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41982. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41983. */
  41984. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41985. /**
  41986. * Makes a duplicate of the material, and gives it a new name
  41987. * @param name defines the new name for the duplicated material
  41988. * @returns the cloned material
  41989. */
  41990. clone(name: string): StandardMaterial;
  41991. /**
  41992. * Serializes this material in a JSON representation
  41993. * @returns the serialized material object
  41994. */
  41995. serialize(): any;
  41996. /**
  41997. * Creates a standard material from parsed material data
  41998. * @param source defines the JSON representation of the material
  41999. * @param scene defines the hosting scene
  42000. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42001. * @returns a new standard material
  42002. */
  42003. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42004. /**
  42005. * Are diffuse textures enabled in the application.
  42006. */
  42007. static DiffuseTextureEnabled: boolean;
  42008. /**
  42009. * Are ambient textures enabled in the application.
  42010. */
  42011. static AmbientTextureEnabled: boolean;
  42012. /**
  42013. * Are opacity textures enabled in the application.
  42014. */
  42015. static OpacityTextureEnabled: boolean;
  42016. /**
  42017. * Are reflection textures enabled in the application.
  42018. */
  42019. static ReflectionTextureEnabled: boolean;
  42020. /**
  42021. * Are emissive textures enabled in the application.
  42022. */
  42023. static EmissiveTextureEnabled: boolean;
  42024. /**
  42025. * Are specular textures enabled in the application.
  42026. */
  42027. static SpecularTextureEnabled: boolean;
  42028. /**
  42029. * Are bump textures enabled in the application.
  42030. */
  42031. static BumpTextureEnabled: boolean;
  42032. /**
  42033. * Are lightmap textures enabled in the application.
  42034. */
  42035. static LightmapTextureEnabled: boolean;
  42036. /**
  42037. * Are refraction textures enabled in the application.
  42038. */
  42039. static RefractionTextureEnabled: boolean;
  42040. /**
  42041. * Are color grading textures enabled in the application.
  42042. */
  42043. static ColorGradingTextureEnabled: boolean;
  42044. /**
  42045. * Are fresnels enabled in the application.
  42046. */
  42047. static FresnelEnabled: boolean;
  42048. }
  42049. }
  42050. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42051. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42052. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42053. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42054. /** @hidden */
  42055. export var imageProcessingPixelShader: {
  42056. name: string;
  42057. shader: string;
  42058. };
  42059. }
  42060. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42061. import { Nullable } from "babylonjs/types";
  42062. import { Color4 } from "babylonjs/Maths/math.color";
  42063. import { Camera } from "babylonjs/Cameras/camera";
  42064. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42065. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42066. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42067. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42068. import { Engine } from "babylonjs/Engines/engine";
  42069. import "babylonjs/Shaders/imageProcessing.fragment";
  42070. import "babylonjs/Shaders/postprocess.vertex";
  42071. /**
  42072. * ImageProcessingPostProcess
  42073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42074. */
  42075. export class ImageProcessingPostProcess extends PostProcess {
  42076. /**
  42077. * Default configuration related to image processing available in the PBR Material.
  42078. */
  42079. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42080. /**
  42081. * Gets the image processing configuration used either in this material.
  42082. */
  42083. /**
  42084. * Sets the Default image processing configuration used either in the this material.
  42085. *
  42086. * If sets to null, the scene one is in use.
  42087. */
  42088. imageProcessingConfiguration: ImageProcessingConfiguration;
  42089. /**
  42090. * Keep track of the image processing observer to allow dispose and replace.
  42091. */
  42092. private _imageProcessingObserver;
  42093. /**
  42094. * Attaches a new image processing configuration to the PBR Material.
  42095. * @param configuration
  42096. */
  42097. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42098. /**
  42099. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42100. */
  42101. /**
  42102. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42103. */
  42104. colorCurves: Nullable<ColorCurves>;
  42105. /**
  42106. * Gets wether the color curves effect is enabled.
  42107. */
  42108. /**
  42109. * Sets wether the color curves effect is enabled.
  42110. */
  42111. colorCurvesEnabled: boolean;
  42112. /**
  42113. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42114. */
  42115. /**
  42116. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42117. */
  42118. colorGradingTexture: Nullable<BaseTexture>;
  42119. /**
  42120. * Gets wether the color grading effect is enabled.
  42121. */
  42122. /**
  42123. * Gets wether the color grading effect is enabled.
  42124. */
  42125. colorGradingEnabled: boolean;
  42126. /**
  42127. * Gets exposure used in the effect.
  42128. */
  42129. /**
  42130. * Sets exposure used in the effect.
  42131. */
  42132. exposure: number;
  42133. /**
  42134. * Gets wether tonemapping is enabled or not.
  42135. */
  42136. /**
  42137. * Sets wether tonemapping is enabled or not
  42138. */
  42139. toneMappingEnabled: boolean;
  42140. /**
  42141. * Gets the type of tone mapping effect.
  42142. */
  42143. /**
  42144. * Sets the type of tone mapping effect.
  42145. */
  42146. toneMappingType: number;
  42147. /**
  42148. * Gets contrast used in the effect.
  42149. */
  42150. /**
  42151. * Sets contrast used in the effect.
  42152. */
  42153. contrast: number;
  42154. /**
  42155. * Gets Vignette stretch size.
  42156. */
  42157. /**
  42158. * Sets Vignette stretch size.
  42159. */
  42160. vignetteStretch: number;
  42161. /**
  42162. * Gets Vignette centre X Offset.
  42163. */
  42164. /**
  42165. * Sets Vignette centre X Offset.
  42166. */
  42167. vignetteCentreX: number;
  42168. /**
  42169. * Gets Vignette centre Y Offset.
  42170. */
  42171. /**
  42172. * Sets Vignette centre Y Offset.
  42173. */
  42174. vignetteCentreY: number;
  42175. /**
  42176. * Gets Vignette weight or intensity of the vignette effect.
  42177. */
  42178. /**
  42179. * Sets Vignette weight or intensity of the vignette effect.
  42180. */
  42181. vignetteWeight: number;
  42182. /**
  42183. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42184. * if vignetteEnabled is set to true.
  42185. */
  42186. /**
  42187. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42188. * if vignetteEnabled is set to true.
  42189. */
  42190. vignetteColor: Color4;
  42191. /**
  42192. * Gets Camera field of view used by the Vignette effect.
  42193. */
  42194. /**
  42195. * Sets Camera field of view used by the Vignette effect.
  42196. */
  42197. vignetteCameraFov: number;
  42198. /**
  42199. * Gets the vignette blend mode allowing different kind of effect.
  42200. */
  42201. /**
  42202. * Sets the vignette blend mode allowing different kind of effect.
  42203. */
  42204. vignetteBlendMode: number;
  42205. /**
  42206. * Gets wether the vignette effect is enabled.
  42207. */
  42208. /**
  42209. * Sets wether the vignette effect is enabled.
  42210. */
  42211. vignetteEnabled: boolean;
  42212. private _fromLinearSpace;
  42213. /**
  42214. * Gets wether the input of the processing is in Gamma or Linear Space.
  42215. */
  42216. /**
  42217. * Sets wether the input of the processing is in Gamma or Linear Space.
  42218. */
  42219. fromLinearSpace: boolean;
  42220. /**
  42221. * Defines cache preventing GC.
  42222. */
  42223. private _defines;
  42224. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42225. /**
  42226. * "ImageProcessingPostProcess"
  42227. * @returns "ImageProcessingPostProcess"
  42228. */
  42229. getClassName(): string;
  42230. protected _updateParameters(): void;
  42231. dispose(camera?: Camera): void;
  42232. }
  42233. }
  42234. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42235. import { Scene } from "babylonjs/scene";
  42236. import { Color3 } from "babylonjs/Maths/math.color";
  42237. import { Mesh } from "babylonjs/Meshes/mesh";
  42238. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42239. import { Nullable } from "babylonjs/types";
  42240. /**
  42241. * Class containing static functions to help procedurally build meshes
  42242. */
  42243. export class GroundBuilder {
  42244. /**
  42245. * Creates a ground mesh
  42246. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42247. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42249. * @param name defines the name of the mesh
  42250. * @param options defines the options used to create the mesh
  42251. * @param scene defines the hosting scene
  42252. * @returns the ground mesh
  42253. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42254. */
  42255. static CreateGround(name: string, options: {
  42256. width?: number;
  42257. height?: number;
  42258. subdivisions?: number;
  42259. subdivisionsX?: number;
  42260. subdivisionsY?: number;
  42261. updatable?: boolean;
  42262. }, scene: any): Mesh;
  42263. /**
  42264. * Creates a tiled ground mesh
  42265. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42266. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42267. * * 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
  42268. * * 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
  42269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42270. * @param name defines the name of the mesh
  42271. * @param options defines the options used to create the mesh
  42272. * @param scene defines the hosting scene
  42273. * @returns the tiled ground mesh
  42274. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42275. */
  42276. static CreateTiledGround(name: string, options: {
  42277. xmin: number;
  42278. zmin: number;
  42279. xmax: number;
  42280. zmax: number;
  42281. subdivisions?: {
  42282. w: number;
  42283. h: number;
  42284. };
  42285. precision?: {
  42286. w: number;
  42287. h: number;
  42288. };
  42289. updatable?: boolean;
  42290. }, scene?: Nullable<Scene>): Mesh;
  42291. /**
  42292. * Creates a ground mesh from a height map
  42293. * * The parameter `url` sets the URL of the height map image resource.
  42294. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42295. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42296. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42297. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42298. * * 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.
  42299. * * 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).
  42300. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42302. * @param name defines the name of the mesh
  42303. * @param url defines the url to the height map
  42304. * @param options defines the options used to create the mesh
  42305. * @param scene defines the hosting scene
  42306. * @returns the ground mesh
  42307. * @see https://doc.babylonjs.com/babylon101/height_map
  42308. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42309. */
  42310. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42311. width?: number;
  42312. height?: number;
  42313. subdivisions?: number;
  42314. minHeight?: number;
  42315. maxHeight?: number;
  42316. colorFilter?: Color3;
  42317. alphaFilter?: number;
  42318. updatable?: boolean;
  42319. onReady?: (mesh: GroundMesh) => void;
  42320. }, scene?: Nullable<Scene>): GroundMesh;
  42321. }
  42322. }
  42323. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42324. import { Vector4 } from "babylonjs/Maths/math.vector";
  42325. import { Mesh } from "babylonjs/Meshes/mesh";
  42326. /**
  42327. * Class containing static functions to help procedurally build meshes
  42328. */
  42329. export class TorusBuilder {
  42330. /**
  42331. * Creates a torus mesh
  42332. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42333. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42334. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42338. * @param name defines the name of the mesh
  42339. * @param options defines the options used to create the mesh
  42340. * @param scene defines the hosting scene
  42341. * @returns the torus mesh
  42342. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42343. */
  42344. static CreateTorus(name: string, options: {
  42345. diameter?: number;
  42346. thickness?: number;
  42347. tessellation?: number;
  42348. updatable?: boolean;
  42349. sideOrientation?: number;
  42350. frontUVs?: Vector4;
  42351. backUVs?: Vector4;
  42352. }, scene: any): Mesh;
  42353. }
  42354. }
  42355. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42356. import { Vector4 } from "babylonjs/Maths/math.vector";
  42357. import { Color4 } from "babylonjs/Maths/math.color";
  42358. import { Mesh } from "babylonjs/Meshes/mesh";
  42359. /**
  42360. * Class containing static functions to help procedurally build meshes
  42361. */
  42362. export class CylinderBuilder {
  42363. /**
  42364. * Creates a cylinder or a cone mesh
  42365. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42366. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42367. * * 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.
  42368. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42369. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42370. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42371. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42372. * * 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).
  42373. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42374. * * 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).
  42375. * * 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
  42376. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42377. * * 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
  42378. * * 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.
  42379. * * If `enclose` is false, a ring surface is one element.
  42380. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42381. * * 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
  42382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42385. * @param name defines the name of the mesh
  42386. * @param options defines the options used to create the mesh
  42387. * @param scene defines the hosting scene
  42388. * @returns the cylinder mesh
  42389. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42390. */
  42391. static CreateCylinder(name: string, options: {
  42392. height?: number;
  42393. diameterTop?: number;
  42394. diameterBottom?: number;
  42395. diameter?: number;
  42396. tessellation?: number;
  42397. subdivisions?: number;
  42398. arc?: number;
  42399. faceColors?: Color4[];
  42400. faceUV?: Vector4[];
  42401. updatable?: boolean;
  42402. hasRings?: boolean;
  42403. enclose?: boolean;
  42404. cap?: number;
  42405. sideOrientation?: number;
  42406. frontUVs?: Vector4;
  42407. backUVs?: Vector4;
  42408. }, scene: any): Mesh;
  42409. }
  42410. }
  42411. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42412. import { Observable } from "babylonjs/Misc/observable";
  42413. import { Nullable } from "babylonjs/types";
  42414. import { Camera } from "babylonjs/Cameras/camera";
  42415. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42416. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42417. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42418. import { Scene } from "babylonjs/scene";
  42419. import { Vector3 } from "babylonjs/Maths/math.vector";
  42420. import { Color3 } from "babylonjs/Maths/math.color";
  42421. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42422. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42423. import { Mesh } from "babylonjs/Meshes/mesh";
  42424. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42425. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42426. import "babylonjs/Meshes/Builders/groundBuilder";
  42427. import "babylonjs/Meshes/Builders/torusBuilder";
  42428. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42429. import "babylonjs/Gamepads/gamepadSceneComponent";
  42430. import "babylonjs/Animations/animatable";
  42431. /**
  42432. * Options to modify the vr teleportation behavior.
  42433. */
  42434. export interface VRTeleportationOptions {
  42435. /**
  42436. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42437. */
  42438. floorMeshName?: string;
  42439. /**
  42440. * A list of meshes to be used as the teleportation floor. (default: empty)
  42441. */
  42442. floorMeshes?: Mesh[];
  42443. }
  42444. /**
  42445. * Options to modify the vr experience helper's behavior.
  42446. */
  42447. export interface VRExperienceHelperOptions extends WebVROptions {
  42448. /**
  42449. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42450. */
  42451. createDeviceOrientationCamera?: boolean;
  42452. /**
  42453. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42454. */
  42455. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42456. /**
  42457. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42458. */
  42459. laserToggle?: boolean;
  42460. /**
  42461. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42462. */
  42463. floorMeshes?: Mesh[];
  42464. /**
  42465. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42466. */
  42467. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42468. }
  42469. /**
  42470. * Event containing information after VR has been entered
  42471. */
  42472. export class OnAfterEnteringVRObservableEvent {
  42473. /**
  42474. * If entering vr was successful
  42475. */
  42476. success: boolean;
  42477. }
  42478. /**
  42479. * Helps to quickly add VR support to an existing scene.
  42480. * See http://doc.babylonjs.com/how_to/webvr_helper
  42481. */
  42482. export class VRExperienceHelper {
  42483. /** Options to modify the vr experience helper's behavior. */
  42484. webVROptions: VRExperienceHelperOptions;
  42485. private _scene;
  42486. private _position;
  42487. private _btnVR;
  42488. private _btnVRDisplayed;
  42489. private _webVRsupported;
  42490. private _webVRready;
  42491. private _webVRrequesting;
  42492. private _webVRpresenting;
  42493. private _hasEnteredVR;
  42494. private _fullscreenVRpresenting;
  42495. private _canvas;
  42496. private _webVRCamera;
  42497. private _vrDeviceOrientationCamera;
  42498. private _deviceOrientationCamera;
  42499. private _existingCamera;
  42500. private _onKeyDown;
  42501. private _onVrDisplayPresentChange;
  42502. private _onVRDisplayChanged;
  42503. private _onVRRequestPresentStart;
  42504. private _onVRRequestPresentComplete;
  42505. /**
  42506. * 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)
  42507. */
  42508. enableGazeEvenWhenNoPointerLock: boolean;
  42509. /**
  42510. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42511. */
  42512. exitVROnDoubleTap: boolean;
  42513. /**
  42514. * Observable raised right before entering VR.
  42515. */
  42516. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42517. /**
  42518. * Observable raised when entering VR has completed.
  42519. */
  42520. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42521. /**
  42522. * Observable raised when exiting VR.
  42523. */
  42524. onExitingVRObservable: Observable<VRExperienceHelper>;
  42525. /**
  42526. * Observable raised when controller mesh is loaded.
  42527. */
  42528. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42529. /** Return this.onEnteringVRObservable
  42530. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42531. */
  42532. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42533. /** Return this.onExitingVRObservable
  42534. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42535. */
  42536. readonly onExitingVR: Observable<VRExperienceHelper>;
  42537. /** Return this.onControllerMeshLoadedObservable
  42538. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42539. */
  42540. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42541. private _rayLength;
  42542. private _useCustomVRButton;
  42543. private _teleportationRequested;
  42544. private _teleportActive;
  42545. private _floorMeshName;
  42546. private _floorMeshesCollection;
  42547. private _rotationAllowed;
  42548. private _teleportBackwardsVector;
  42549. private _teleportationTarget;
  42550. private _isDefaultTeleportationTarget;
  42551. private _postProcessMove;
  42552. private _teleportationFillColor;
  42553. private _teleportationBorderColor;
  42554. private _rotationAngle;
  42555. private _haloCenter;
  42556. private _cameraGazer;
  42557. private _padSensibilityUp;
  42558. private _padSensibilityDown;
  42559. private _leftController;
  42560. private _rightController;
  42561. /**
  42562. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42563. */
  42564. onNewMeshSelected: Observable<AbstractMesh>;
  42565. /**
  42566. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42567. * This observable will provide the mesh and the controller used to select the mesh
  42568. */
  42569. onMeshSelectedWithController: Observable<{
  42570. mesh: AbstractMesh;
  42571. controller: WebVRController;
  42572. }>;
  42573. /**
  42574. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42575. */
  42576. onNewMeshPicked: Observable<PickingInfo>;
  42577. private _circleEase;
  42578. /**
  42579. * Observable raised before camera teleportation
  42580. */
  42581. onBeforeCameraTeleport: Observable<Vector3>;
  42582. /**
  42583. * Observable raised after camera teleportation
  42584. */
  42585. onAfterCameraTeleport: Observable<Vector3>;
  42586. /**
  42587. * Observable raised when current selected mesh gets unselected
  42588. */
  42589. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42590. private _raySelectionPredicate;
  42591. /**
  42592. * To be optionaly changed by user to define custom ray selection
  42593. */
  42594. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42595. /**
  42596. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42597. */
  42598. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42599. /**
  42600. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42601. */
  42602. teleportationEnabled: boolean;
  42603. private _defaultHeight;
  42604. private _teleportationInitialized;
  42605. private _interactionsEnabled;
  42606. private _interactionsRequested;
  42607. private _displayGaze;
  42608. private _displayLaserPointer;
  42609. /**
  42610. * The mesh used to display where the user is going to teleport.
  42611. */
  42612. /**
  42613. * Sets the mesh to be used to display where the user is going to teleport.
  42614. */
  42615. teleportationTarget: Mesh;
  42616. /**
  42617. * 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
  42618. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42619. * See http://doc.babylonjs.com/resources/baking_transformations
  42620. */
  42621. gazeTrackerMesh: Mesh;
  42622. /**
  42623. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42624. */
  42625. updateGazeTrackerScale: boolean;
  42626. /**
  42627. * If the gaze trackers color should be updated when selecting meshes
  42628. */
  42629. updateGazeTrackerColor: boolean;
  42630. /**
  42631. * If the controller laser color should be updated when selecting meshes
  42632. */
  42633. updateControllerLaserColor: boolean;
  42634. /**
  42635. * The gaze tracking mesh corresponding to the left controller
  42636. */
  42637. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42638. /**
  42639. * The gaze tracking mesh corresponding to the right controller
  42640. */
  42641. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42642. /**
  42643. * If the ray of the gaze should be displayed.
  42644. */
  42645. /**
  42646. * Sets if the ray of the gaze should be displayed.
  42647. */
  42648. displayGaze: boolean;
  42649. /**
  42650. * If the ray of the LaserPointer should be displayed.
  42651. */
  42652. /**
  42653. * Sets if the ray of the LaserPointer should be displayed.
  42654. */
  42655. displayLaserPointer: boolean;
  42656. /**
  42657. * The deviceOrientationCamera used as the camera when not in VR.
  42658. */
  42659. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42660. /**
  42661. * Based on the current WebVR support, returns the current VR camera used.
  42662. */
  42663. readonly currentVRCamera: Nullable<Camera>;
  42664. /**
  42665. * The webVRCamera which is used when in VR.
  42666. */
  42667. readonly webVRCamera: WebVRFreeCamera;
  42668. /**
  42669. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42670. */
  42671. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42672. /**
  42673. * The html button that is used to trigger entering into VR.
  42674. */
  42675. readonly vrButton: Nullable<HTMLButtonElement>;
  42676. private readonly _teleportationRequestInitiated;
  42677. /**
  42678. * Defines wether or not Pointer lock should be requested when switching to
  42679. * full screen.
  42680. */
  42681. requestPointerLockOnFullScreen: boolean;
  42682. /**
  42683. * Instantiates a VRExperienceHelper.
  42684. * Helps to quickly add VR support to an existing scene.
  42685. * @param scene The scene the VRExperienceHelper belongs to.
  42686. * @param webVROptions Options to modify the vr experience helper's behavior.
  42687. */
  42688. constructor(scene: Scene,
  42689. /** Options to modify the vr experience helper's behavior. */
  42690. webVROptions?: VRExperienceHelperOptions);
  42691. private _onDefaultMeshLoaded;
  42692. private _onResize;
  42693. private _onFullscreenChange;
  42694. /**
  42695. * Gets a value indicating if we are currently in VR mode.
  42696. */
  42697. readonly isInVRMode: boolean;
  42698. private onVrDisplayPresentChange;
  42699. private onVRDisplayChanged;
  42700. private moveButtonToBottomRight;
  42701. private displayVRButton;
  42702. private updateButtonVisibility;
  42703. private _cachedAngularSensibility;
  42704. /**
  42705. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42706. * Otherwise, will use the fullscreen API.
  42707. */
  42708. enterVR(): void;
  42709. /**
  42710. * Attempt to exit VR, or fullscreen.
  42711. */
  42712. exitVR(): void;
  42713. /**
  42714. * The position of the vr experience helper.
  42715. */
  42716. /**
  42717. * Sets the position of the vr experience helper.
  42718. */
  42719. position: Vector3;
  42720. /**
  42721. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42722. */
  42723. enableInteractions(): void;
  42724. private readonly _noControllerIsActive;
  42725. private beforeRender;
  42726. private _isTeleportationFloor;
  42727. /**
  42728. * Adds a floor mesh to be used for teleportation.
  42729. * @param floorMesh the mesh to be used for teleportation.
  42730. */
  42731. addFloorMesh(floorMesh: Mesh): void;
  42732. /**
  42733. * Removes a floor mesh from being used for teleportation.
  42734. * @param floorMesh the mesh to be removed.
  42735. */
  42736. removeFloorMesh(floorMesh: Mesh): void;
  42737. /**
  42738. * Enables interactions and teleportation using the VR controllers and gaze.
  42739. * @param vrTeleportationOptions options to modify teleportation behavior.
  42740. */
  42741. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42742. private _onNewGamepadConnected;
  42743. private _tryEnableInteractionOnController;
  42744. private _onNewGamepadDisconnected;
  42745. private _enableInteractionOnController;
  42746. private _checkTeleportWithRay;
  42747. private _checkRotate;
  42748. private _checkTeleportBackwards;
  42749. private _enableTeleportationOnController;
  42750. private _createTeleportationCircles;
  42751. private _displayTeleportationTarget;
  42752. private _hideTeleportationTarget;
  42753. private _rotateCamera;
  42754. private _moveTeleportationSelectorTo;
  42755. private _workingVector;
  42756. private _workingQuaternion;
  42757. private _workingMatrix;
  42758. /**
  42759. * Teleports the users feet to the desired location
  42760. * @param location The location where the user's feet should be placed
  42761. */
  42762. teleportCamera(location: Vector3): void;
  42763. private _convertNormalToDirectionOfRay;
  42764. private _castRayAndSelectObject;
  42765. private _notifySelectedMeshUnselected;
  42766. /**
  42767. * Sets the color of the laser ray from the vr controllers.
  42768. * @param color new color for the ray.
  42769. */
  42770. changeLaserColor(color: Color3): void;
  42771. /**
  42772. * Sets the color of the ray from the vr headsets gaze.
  42773. * @param color new color for the ray.
  42774. */
  42775. changeGazeColor(color: Color3): void;
  42776. /**
  42777. * Exits VR and disposes of the vr experience helper
  42778. */
  42779. dispose(): void;
  42780. /**
  42781. * Gets the name of the VRExperienceHelper class
  42782. * @returns "VRExperienceHelper"
  42783. */
  42784. getClassName(): string;
  42785. }
  42786. }
  42787. declare module "babylonjs/Cameras/VR/index" {
  42788. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42789. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42790. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42791. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42792. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42793. export * from "babylonjs/Cameras/VR/webVRCamera";
  42794. }
  42795. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42796. import { Observable } from "babylonjs/Misc/observable";
  42797. import { Nullable } from "babylonjs/types";
  42798. import { IDisposable, Scene } from "babylonjs/scene";
  42799. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42800. /**
  42801. * Manages an XRSession to work with Babylon's engine
  42802. * @see https://doc.babylonjs.com/how_to/webxr
  42803. */
  42804. export class WebXRSessionManager implements IDisposable {
  42805. private scene;
  42806. /**
  42807. * Fires every time a new xrFrame arrives which can be used to update the camera
  42808. */
  42809. onXRFrameObservable: Observable<any>;
  42810. /**
  42811. * Fires when the xr session is ended either by the device or manually done
  42812. */
  42813. onXRSessionEnded: Observable<any>;
  42814. /**
  42815. * Underlying xr session
  42816. */
  42817. session: XRSession;
  42818. /**
  42819. * Type of reference space used when creating the session
  42820. */
  42821. referenceSpace: XRReferenceSpace;
  42822. /** @hidden */
  42823. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42824. /**
  42825. * Current XR frame
  42826. */
  42827. currentFrame: Nullable<XRFrame>;
  42828. private _xrNavigator;
  42829. private baseLayer;
  42830. /**
  42831. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42832. * @param scene The scene which the session should be created for
  42833. */
  42834. constructor(scene: Scene);
  42835. /**
  42836. * Initializes the manager
  42837. * After initialization enterXR can be called to start an XR session
  42838. * @returns Promise which resolves after it is initialized
  42839. */
  42840. initializeAsync(): Promise<void>;
  42841. /**
  42842. * Initializes an xr session
  42843. * @param xrSessionMode mode to initialize
  42844. * @returns a promise which will resolve once the session has been initialized
  42845. */
  42846. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42847. /**
  42848. * Sets the reference space on the xr session
  42849. * @param referenceSpace space to set
  42850. * @returns a promise that will resolve once the reference space has been set
  42851. */
  42852. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42853. /**
  42854. * Updates the render state of the session
  42855. * @param state state to set
  42856. * @returns a promise that resolves once the render state has been updated
  42857. */
  42858. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42859. /**
  42860. * Starts rendering to the xr layer
  42861. * @returns a promise that will resolve once rendering has started
  42862. */
  42863. startRenderingToXRAsync(): Promise<void>;
  42864. /**
  42865. * Stops the xrSession and restores the renderloop
  42866. * @returns Promise which resolves after it exits XR
  42867. */
  42868. exitXRAsync(): Promise<unknown>;
  42869. /**
  42870. * Checks if a session would be supported for the creation options specified
  42871. * @param sessionMode session mode to check if supported eg. immersive-vr
  42872. * @returns true if supported
  42873. */
  42874. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42875. /**
  42876. * @hidden
  42877. * Converts the render layer of xrSession to a render target
  42878. * @param session session to create render target for
  42879. * @param scene scene the new render target should be created for
  42880. */
  42881. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42882. /**
  42883. * Disposes of the session manager
  42884. */
  42885. dispose(): void;
  42886. }
  42887. }
  42888. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42889. import { Scene } from "babylonjs/scene";
  42890. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42891. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42892. /**
  42893. * WebXR Camera which holds the views for the xrSession
  42894. * @see https://doc.babylonjs.com/how_to/webxr
  42895. */
  42896. export class WebXRCamera extends FreeCamera {
  42897. private static _TmpMatrix;
  42898. /**
  42899. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42900. * @param name the name of the camera
  42901. * @param scene the scene to add the camera to
  42902. */
  42903. constructor(name: string, scene: Scene);
  42904. private _updateNumberOfRigCameras;
  42905. /** @hidden */
  42906. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42907. /**
  42908. * Updates the cameras position from the current pose information of the XR session
  42909. * @param xrSessionManager the session containing pose information
  42910. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42911. */
  42912. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42913. }
  42914. }
  42915. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42916. import { Nullable } from "babylonjs/types";
  42917. import { IDisposable } from "babylonjs/scene";
  42918. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42919. /**
  42920. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42921. */
  42922. export class WebXRManagedOutputCanvas implements IDisposable {
  42923. private helper;
  42924. private _canvas;
  42925. /**
  42926. * xrpresent context of the canvas which can be used to display/mirror xr content
  42927. */
  42928. canvasContext: WebGLRenderingContext;
  42929. /**
  42930. * xr layer for the canvas
  42931. */
  42932. xrLayer: Nullable<XRWebGLLayer>;
  42933. /**
  42934. * Initializes the xr layer for the session
  42935. * @param xrSession xr session
  42936. * @returns a promise that will resolve once the XR Layer has been created
  42937. */
  42938. initializeXRLayerAsync(xrSession: any): any;
  42939. /**
  42940. * Initializes the canvas to be added/removed upon entering/exiting xr
  42941. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42942. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42943. */
  42944. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42945. /**
  42946. * Disposes of the object
  42947. */
  42948. dispose(): void;
  42949. private _setManagedOutputCanvas;
  42950. private _addCanvas;
  42951. private _removeCanvas;
  42952. }
  42953. }
  42954. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42955. import { Observable } from "babylonjs/Misc/observable";
  42956. import { IDisposable, Scene } from "babylonjs/scene";
  42957. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42959. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42960. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42961. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42962. /**
  42963. * States of the webXR experience
  42964. */
  42965. export enum WebXRState {
  42966. /**
  42967. * Transitioning to being in XR mode
  42968. */
  42969. ENTERING_XR = 0,
  42970. /**
  42971. * Transitioning to non XR mode
  42972. */
  42973. EXITING_XR = 1,
  42974. /**
  42975. * In XR mode and presenting
  42976. */
  42977. IN_XR = 2,
  42978. /**
  42979. * Not entered XR mode
  42980. */
  42981. NOT_IN_XR = 3
  42982. }
  42983. /**
  42984. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42985. * @see https://doc.babylonjs.com/how_to/webxr
  42986. */
  42987. export class WebXRExperienceHelper implements IDisposable {
  42988. private scene;
  42989. /**
  42990. * 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
  42991. */
  42992. container: AbstractMesh;
  42993. /**
  42994. * Camera used to render xr content
  42995. */
  42996. camera: WebXRCamera;
  42997. /**
  42998. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42999. */
  43000. state: WebXRState;
  43001. private _setState;
  43002. private static _TmpVector;
  43003. /**
  43004. * Fires when the state of the experience helper has changed
  43005. */
  43006. onStateChangedObservable: Observable<WebXRState>;
  43007. /** Session manager used to keep track of xr session */
  43008. sessionManager: WebXRSessionManager;
  43009. private _nonVRCamera;
  43010. private _originalSceneAutoClear;
  43011. private _supported;
  43012. /**
  43013. * Creates the experience helper
  43014. * @param scene the scene to attach the experience helper to
  43015. * @returns a promise for the experience helper
  43016. */
  43017. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43018. /**
  43019. * Creates a WebXRExperienceHelper
  43020. * @param scene The scene the helper should be created in
  43021. */
  43022. private constructor();
  43023. /**
  43024. * Exits XR mode and returns the scene to its original state
  43025. * @returns promise that resolves after xr mode has exited
  43026. */
  43027. exitXRAsync(): Promise<unknown>;
  43028. /**
  43029. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43030. * @param sessionCreationOptions options for the XR session
  43031. * @param referenceSpaceType frame of reference of the XR session
  43032. * @param outputCanvas the output canvas that will be used to enter XR mode
  43033. * @returns promise that resolves after xr mode has entered
  43034. */
  43035. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43036. /**
  43037. * Updates the global position of the camera by moving the camera's container
  43038. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43039. * @param position The desired global position of the camera
  43040. */
  43041. setPositionOfCameraUsingContainer(position: Vector3): void;
  43042. /**
  43043. * Rotates the xr camera by rotating the camera's container around the camera's position
  43044. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43045. * @param rotation the desired quaternion rotation to apply to the camera
  43046. */
  43047. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43048. /**
  43049. * Disposes of the experience helper
  43050. */
  43051. dispose(): void;
  43052. }
  43053. }
  43054. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43055. import { Nullable } from "babylonjs/types";
  43056. import { Observable } from "babylonjs/Misc/observable";
  43057. import { IDisposable, Scene } from "babylonjs/scene";
  43058. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43059. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43060. /**
  43061. * Button which can be used to enter a different mode of XR
  43062. */
  43063. export class WebXREnterExitUIButton {
  43064. /** button element */
  43065. element: HTMLElement;
  43066. /** XR initialization options for the button */
  43067. sessionMode: XRSessionMode;
  43068. /** Reference space type */
  43069. referenceSpaceType: XRReferenceSpaceType;
  43070. /**
  43071. * Creates a WebXREnterExitUIButton
  43072. * @param element button element
  43073. * @param sessionMode XR initialization session mode
  43074. * @param referenceSpaceType the type of reference space to be used
  43075. */
  43076. constructor(
  43077. /** button element */
  43078. element: HTMLElement,
  43079. /** XR initialization options for the button */
  43080. sessionMode: XRSessionMode,
  43081. /** Reference space type */
  43082. referenceSpaceType: XRReferenceSpaceType);
  43083. /**
  43084. * Overwritable function which can be used to update the button's visuals when the state changes
  43085. * @param activeButton the current active button in the UI
  43086. */
  43087. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43088. }
  43089. /**
  43090. * Options to create the webXR UI
  43091. */
  43092. export class WebXREnterExitUIOptions {
  43093. /**
  43094. * Context to enter xr with
  43095. */
  43096. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43097. /**
  43098. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43099. */
  43100. customButtons?: Array<WebXREnterExitUIButton>;
  43101. }
  43102. /**
  43103. * UI to allow the user to enter/exit XR mode
  43104. */
  43105. export class WebXREnterExitUI implements IDisposable {
  43106. private scene;
  43107. private _overlay;
  43108. private _buttons;
  43109. private _activeButton;
  43110. /**
  43111. * Fired every time the active button is changed.
  43112. *
  43113. * When xr is entered via a button that launches xr that button will be the callback parameter
  43114. *
  43115. * When exiting xr the callback parameter will be null)
  43116. */
  43117. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43118. /**
  43119. * Creates UI to allow the user to enter/exit XR mode
  43120. * @param scene the scene to add the ui to
  43121. * @param helper the xr experience helper to enter/exit xr with
  43122. * @param options options to configure the UI
  43123. * @returns the created ui
  43124. */
  43125. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43126. private constructor();
  43127. private _updateButtons;
  43128. /**
  43129. * Disposes of the object
  43130. */
  43131. dispose(): void;
  43132. }
  43133. }
  43134. declare module "babylonjs/Cameras/XR/webXRController" {
  43135. import { Nullable } from "babylonjs/types";
  43136. import { Observable } from "babylonjs/Misc/observable";
  43137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43138. import { Ray } from "babylonjs/Culling/ray";
  43139. import { Scene } from "babylonjs/scene";
  43140. /**
  43141. * Represents an XR input
  43142. */
  43143. export class WebXRController {
  43144. private scene;
  43145. /** The underlying input source for the controller */
  43146. inputSource: XRInputSource;
  43147. private parentContainer;
  43148. /**
  43149. * 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
  43150. */
  43151. grip?: AbstractMesh;
  43152. /**
  43153. * Pointer which can be used to select objects or attach a visible laser to
  43154. */
  43155. pointer: AbstractMesh;
  43156. /**
  43157. * Event that fires when the controller is removed/disposed
  43158. */
  43159. onDisposeObservable: Observable<{}>;
  43160. private _tmpMatrix;
  43161. private _tmpQuaternion;
  43162. private _tmpVector;
  43163. /**
  43164. * Creates the controller
  43165. * @see https://doc.babylonjs.com/how_to/webxr
  43166. * @param scene the scene which the controller should be associated to
  43167. * @param inputSource the underlying input source for the controller
  43168. * @param parentContainer parent that the controller meshes should be children of
  43169. */
  43170. constructor(scene: Scene,
  43171. /** The underlying input source for the controller */
  43172. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43173. /**
  43174. * Updates the controller pose based on the given XRFrame
  43175. * @param xrFrame xr frame to update the pose with
  43176. * @param referenceSpace reference space to use
  43177. */
  43178. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43179. /**
  43180. * Gets a world space ray coming from the controller
  43181. * @param result the resulting ray
  43182. */
  43183. getWorldPointerRayToRef(result: Ray): void;
  43184. /**
  43185. * Disposes of the object
  43186. */
  43187. dispose(): void;
  43188. }
  43189. }
  43190. declare module "babylonjs/Cameras/XR/webXRInput" {
  43191. import { Observable } from "babylonjs/Misc/observable";
  43192. import { IDisposable } from "babylonjs/scene";
  43193. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43194. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43195. /**
  43196. * XR input used to track XR inputs such as controllers/rays
  43197. */
  43198. export class WebXRInput implements IDisposable {
  43199. /**
  43200. * Base experience the input listens to
  43201. */
  43202. baseExperience: WebXRExperienceHelper;
  43203. /**
  43204. * XR controllers being tracked
  43205. */
  43206. controllers: Array<WebXRController>;
  43207. private _frameObserver;
  43208. private _stateObserver;
  43209. /**
  43210. * Event when a controller has been connected/added
  43211. */
  43212. onControllerAddedObservable: Observable<WebXRController>;
  43213. /**
  43214. * Event when a controller has been removed/disconnected
  43215. */
  43216. onControllerRemovedObservable: Observable<WebXRController>;
  43217. /**
  43218. * Initializes the WebXRInput
  43219. * @param baseExperience experience helper which the input should be created for
  43220. */
  43221. constructor(
  43222. /**
  43223. * Base experience the input listens to
  43224. */
  43225. baseExperience: WebXRExperienceHelper);
  43226. private _onInputSourcesChange;
  43227. private _addAndRemoveControllers;
  43228. /**
  43229. * Disposes of the object
  43230. */
  43231. dispose(): void;
  43232. }
  43233. }
  43234. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43236. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43237. /**
  43238. * Enables teleportation
  43239. */
  43240. export class WebXRControllerTeleportation {
  43241. private _teleportationFillColor;
  43242. private _teleportationBorderColor;
  43243. private _tmpRay;
  43244. private _tmpVector;
  43245. /**
  43246. * Creates a WebXRControllerTeleportation
  43247. * @param input input manager to add teleportation to
  43248. * @param floorMeshes floormeshes which can be teleported to
  43249. */
  43250. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43251. }
  43252. }
  43253. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43254. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43255. /**
  43256. * Handles pointer input automatically for the pointer of XR controllers
  43257. */
  43258. export class WebXRControllerPointerSelection {
  43259. private static _idCounter;
  43260. private _tmpRay;
  43261. /**
  43262. * Creates a WebXRControllerPointerSelection
  43263. * @param input input manager to setup pointer selection
  43264. */
  43265. constructor(input: WebXRInput);
  43266. private _convertNormalToDirectionOfRay;
  43267. private _updatePointerDistance;
  43268. }
  43269. }
  43270. declare module "babylonjs/Loading/sceneLoader" {
  43271. import { Observable } from "babylonjs/Misc/observable";
  43272. import { Nullable } from "babylonjs/types";
  43273. import { Scene } from "babylonjs/scene";
  43274. import { Engine } from "babylonjs/Engines/engine";
  43275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43276. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43277. import { AssetContainer } from "babylonjs/assetContainer";
  43278. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43279. import { Skeleton } from "babylonjs/Bones/skeleton";
  43280. /**
  43281. * Class used to represent data loading progression
  43282. */
  43283. export class SceneLoaderProgressEvent {
  43284. /** defines if data length to load can be evaluated */
  43285. readonly lengthComputable: boolean;
  43286. /** defines the loaded data length */
  43287. readonly loaded: number;
  43288. /** defines the data length to load */
  43289. readonly total: number;
  43290. /**
  43291. * Create a new progress event
  43292. * @param lengthComputable defines if data length to load can be evaluated
  43293. * @param loaded defines the loaded data length
  43294. * @param total defines the data length to load
  43295. */
  43296. constructor(
  43297. /** defines if data length to load can be evaluated */
  43298. lengthComputable: boolean,
  43299. /** defines the loaded data length */
  43300. loaded: number,
  43301. /** defines the data length to load */
  43302. total: number);
  43303. /**
  43304. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43305. * @param event defines the source event
  43306. * @returns a new SceneLoaderProgressEvent
  43307. */
  43308. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43309. }
  43310. /**
  43311. * Interface used by SceneLoader plugins to define supported file extensions
  43312. */
  43313. export interface ISceneLoaderPluginExtensions {
  43314. /**
  43315. * Defines the list of supported extensions
  43316. */
  43317. [extension: string]: {
  43318. isBinary: boolean;
  43319. };
  43320. }
  43321. /**
  43322. * Interface used by SceneLoader plugin factory
  43323. */
  43324. export interface ISceneLoaderPluginFactory {
  43325. /**
  43326. * Defines the name of the factory
  43327. */
  43328. name: string;
  43329. /**
  43330. * Function called to create a new plugin
  43331. * @return the new plugin
  43332. */
  43333. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43334. /**
  43335. * Boolean indicating if the plugin can direct load specific data
  43336. */
  43337. canDirectLoad?: (data: string) => boolean;
  43338. }
  43339. /**
  43340. * Interface used to define a SceneLoader plugin
  43341. */
  43342. export interface ISceneLoaderPlugin {
  43343. /**
  43344. * The friendly name of this plugin.
  43345. */
  43346. name: string;
  43347. /**
  43348. * The file extensions supported by this plugin.
  43349. */
  43350. extensions: string | ISceneLoaderPluginExtensions;
  43351. /**
  43352. * Import meshes into a scene.
  43353. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43354. * @param scene The scene to import into
  43355. * @param data The data to import
  43356. * @param rootUrl The root url for scene and resources
  43357. * @param meshes The meshes array to import into
  43358. * @param particleSystems The particle systems array to import into
  43359. * @param skeletons The skeletons array to import into
  43360. * @param onError The callback when import fails
  43361. * @returns True if successful or false otherwise
  43362. */
  43363. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43364. /**
  43365. * Load into a scene.
  43366. * @param scene The scene to load into
  43367. * @param data The data to import
  43368. * @param rootUrl The root url for scene and resources
  43369. * @param onError The callback when import fails
  43370. * @returns true if successful or false otherwise
  43371. */
  43372. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43373. /**
  43374. * The callback that returns true if the data can be directly loaded.
  43375. */
  43376. canDirectLoad?: (data: string) => boolean;
  43377. /**
  43378. * The callback that allows custom handling of the root url based on the response url.
  43379. */
  43380. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43381. /**
  43382. * Load into an asset container.
  43383. * @param scene The scene to load into
  43384. * @param data The data to import
  43385. * @param rootUrl The root url for scene and resources
  43386. * @param onError The callback when import fails
  43387. * @returns The loaded asset container
  43388. */
  43389. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43390. }
  43391. /**
  43392. * Interface used to define an async SceneLoader plugin
  43393. */
  43394. export interface ISceneLoaderPluginAsync {
  43395. /**
  43396. * The friendly name of this plugin.
  43397. */
  43398. name: string;
  43399. /**
  43400. * The file extensions supported by this plugin.
  43401. */
  43402. extensions: string | ISceneLoaderPluginExtensions;
  43403. /**
  43404. * Import meshes into a scene.
  43405. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43406. * @param scene The scene to import into
  43407. * @param data The data to import
  43408. * @param rootUrl The root url for scene and resources
  43409. * @param onProgress The callback when the load progresses
  43410. * @param fileName Defines the name of the file to load
  43411. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43412. */
  43413. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43414. meshes: AbstractMesh[];
  43415. particleSystems: IParticleSystem[];
  43416. skeletons: Skeleton[];
  43417. animationGroups: AnimationGroup[];
  43418. }>;
  43419. /**
  43420. * Load into a scene.
  43421. * @param scene The scene to load into
  43422. * @param data The data to import
  43423. * @param rootUrl The root url for scene and resources
  43424. * @param onProgress The callback when the load progresses
  43425. * @param fileName Defines the name of the file to load
  43426. * @returns Nothing
  43427. */
  43428. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43429. /**
  43430. * The callback that returns true if the data can be directly loaded.
  43431. */
  43432. canDirectLoad?: (data: string) => boolean;
  43433. /**
  43434. * The callback that allows custom handling of the root url based on the response url.
  43435. */
  43436. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43437. /**
  43438. * Load into an asset container.
  43439. * @param scene The scene to load into
  43440. * @param data The data to import
  43441. * @param rootUrl The root url for scene and resources
  43442. * @param onProgress The callback when the load progresses
  43443. * @param fileName Defines the name of the file to load
  43444. * @returns The loaded asset container
  43445. */
  43446. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43447. }
  43448. /**
  43449. * Class used to load scene from various file formats using registered plugins
  43450. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43451. */
  43452. export class SceneLoader {
  43453. /**
  43454. * No logging while loading
  43455. */
  43456. static readonly NO_LOGGING: number;
  43457. /**
  43458. * Minimal logging while loading
  43459. */
  43460. static readonly MINIMAL_LOGGING: number;
  43461. /**
  43462. * Summary logging while loading
  43463. */
  43464. static readonly SUMMARY_LOGGING: number;
  43465. /**
  43466. * Detailled logging while loading
  43467. */
  43468. static readonly DETAILED_LOGGING: number;
  43469. /**
  43470. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43471. */
  43472. static ForceFullSceneLoadingForIncremental: boolean;
  43473. /**
  43474. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43475. */
  43476. static ShowLoadingScreen: boolean;
  43477. /**
  43478. * Defines the current logging level (while loading the scene)
  43479. * @ignorenaming
  43480. */
  43481. static loggingLevel: number;
  43482. /**
  43483. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43484. */
  43485. static CleanBoneMatrixWeights: boolean;
  43486. /**
  43487. * Event raised when a plugin is used to load a scene
  43488. */
  43489. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43490. private static _registeredPlugins;
  43491. private static _getDefaultPlugin;
  43492. private static _getPluginForExtension;
  43493. private static _getPluginForDirectLoad;
  43494. private static _getPluginForFilename;
  43495. private static _getDirectLoad;
  43496. private static _loadData;
  43497. private static _getFileInfo;
  43498. /**
  43499. * Gets a plugin that can load the given extension
  43500. * @param extension defines the extension to load
  43501. * @returns a plugin or null if none works
  43502. */
  43503. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43504. /**
  43505. * Gets a boolean indicating that the given extension can be loaded
  43506. * @param extension defines the extension to load
  43507. * @returns true if the extension is supported
  43508. */
  43509. static IsPluginForExtensionAvailable(extension: string): boolean;
  43510. /**
  43511. * Adds a new plugin to the list of registered plugins
  43512. * @param plugin defines the plugin to add
  43513. */
  43514. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43515. /**
  43516. * Import meshes into a scene
  43517. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43518. * @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)
  43519. * @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)
  43520. * @param scene the instance of BABYLON.Scene to append to
  43521. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43522. * @param onProgress a callback with a progress event for each file being loaded
  43523. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43524. * @param pluginExtension the extension used to determine the plugin
  43525. * @returns The loaded plugin
  43526. */
  43527. 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>;
  43528. /**
  43529. * Import meshes into a scene
  43530. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43531. * @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)
  43532. * @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)
  43533. * @param scene the instance of BABYLON.Scene to append to
  43534. * @param onProgress a callback with a progress event for each file being loaded
  43535. * @param pluginExtension the extension used to determine the plugin
  43536. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43537. */
  43538. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43539. meshes: AbstractMesh[];
  43540. particleSystems: IParticleSystem[];
  43541. skeletons: Skeleton[];
  43542. animationGroups: AnimationGroup[];
  43543. }>;
  43544. /**
  43545. * Load a scene
  43546. * @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)
  43547. * @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)
  43548. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43549. * @param onSuccess a callback with the scene when import succeeds
  43550. * @param onProgress a callback with a progress event for each file being loaded
  43551. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43552. * @param pluginExtension the extension used to determine the plugin
  43553. * @returns The loaded plugin
  43554. */
  43555. 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>;
  43556. /**
  43557. * Load a scene
  43558. * @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)
  43559. * @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)
  43560. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43561. * @param onProgress a callback with a progress event for each file being loaded
  43562. * @param pluginExtension the extension used to determine the plugin
  43563. * @returns The loaded scene
  43564. */
  43565. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43566. /**
  43567. * Append a scene
  43568. * @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)
  43569. * @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)
  43570. * @param scene is the instance of BABYLON.Scene to append to
  43571. * @param onSuccess a callback with the scene when import succeeds
  43572. * @param onProgress a callback with a progress event for each file being loaded
  43573. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43574. * @param pluginExtension the extension used to determine the plugin
  43575. * @returns The loaded plugin
  43576. */
  43577. 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>;
  43578. /**
  43579. * Append a scene
  43580. * @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)
  43581. * @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)
  43582. * @param scene is the instance of BABYLON.Scene to append to
  43583. * @param onProgress a callback with a progress event for each file being loaded
  43584. * @param pluginExtension the extension used to determine the plugin
  43585. * @returns The given scene
  43586. */
  43587. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43588. /**
  43589. * Load a scene into an asset container
  43590. * @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)
  43591. * @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)
  43592. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43593. * @param onSuccess a callback with the scene when import succeeds
  43594. * @param onProgress a callback with a progress event for each file being loaded
  43595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43596. * @param pluginExtension the extension used to determine the plugin
  43597. * @returns The loaded plugin
  43598. */
  43599. 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>;
  43600. /**
  43601. * Load a scene into an asset container
  43602. * @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)
  43603. * @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)
  43604. * @param scene is the instance of Scene to append to
  43605. * @param onProgress a callback with a progress event for each file being loaded
  43606. * @param pluginExtension the extension used to determine the plugin
  43607. * @returns The loaded asset container
  43608. */
  43609. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43610. }
  43611. }
  43612. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43613. import { Scene } from "babylonjs/scene";
  43614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43615. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43616. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43617. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43618. /**
  43619. * Generic Controller
  43620. */
  43621. export class GenericController extends WebVRController {
  43622. /**
  43623. * Base Url for the controller model.
  43624. */
  43625. static readonly MODEL_BASE_URL: string;
  43626. /**
  43627. * File name for the controller model.
  43628. */
  43629. static readonly MODEL_FILENAME: string;
  43630. /**
  43631. * Creates a new GenericController from a gamepad
  43632. * @param vrGamepad the gamepad that the controller should be created from
  43633. */
  43634. constructor(vrGamepad: any);
  43635. /**
  43636. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43637. * @param scene scene in which to add meshes
  43638. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43639. */
  43640. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43641. /**
  43642. * Called once for each button that changed state since the last frame
  43643. * @param buttonIdx Which button index changed
  43644. * @param state New state of the button
  43645. * @param changes Which properties on the state changed since last frame
  43646. */
  43647. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43648. }
  43649. }
  43650. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43651. import { Observable } from "babylonjs/Misc/observable";
  43652. import { Scene } from "babylonjs/scene";
  43653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43654. import { Ray } from "babylonjs/Culling/ray";
  43655. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43656. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43657. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43658. /**
  43659. * Defines the WindowsMotionController object that the state of the windows motion controller
  43660. */
  43661. export class WindowsMotionController extends WebVRController {
  43662. /**
  43663. * The base url used to load the left and right controller models
  43664. */
  43665. static MODEL_BASE_URL: string;
  43666. /**
  43667. * The name of the left controller model file
  43668. */
  43669. static MODEL_LEFT_FILENAME: string;
  43670. /**
  43671. * The name of the right controller model file
  43672. */
  43673. static MODEL_RIGHT_FILENAME: string;
  43674. /**
  43675. * The controller name prefix for this controller type
  43676. */
  43677. static readonly GAMEPAD_ID_PREFIX: string;
  43678. /**
  43679. * The controller id pattern for this controller type
  43680. */
  43681. private static readonly GAMEPAD_ID_PATTERN;
  43682. private _loadedMeshInfo;
  43683. private readonly _mapping;
  43684. /**
  43685. * Fired when the trackpad on this controller is clicked
  43686. */
  43687. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43688. /**
  43689. * Fired when the trackpad on this controller is modified
  43690. */
  43691. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43692. /**
  43693. * The current x and y values of this controller's trackpad
  43694. */
  43695. trackpad: StickValues;
  43696. /**
  43697. * Creates a new WindowsMotionController from a gamepad
  43698. * @param vrGamepad the gamepad that the controller should be created from
  43699. */
  43700. constructor(vrGamepad: any);
  43701. /**
  43702. * Fired when the trigger on this controller is modified
  43703. */
  43704. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43705. /**
  43706. * Fired when the menu button on this controller is modified
  43707. */
  43708. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43709. /**
  43710. * Fired when the grip button on this controller is modified
  43711. */
  43712. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43713. /**
  43714. * Fired when the thumbstick button on this controller is modified
  43715. */
  43716. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43717. /**
  43718. * Fired when the touchpad button on this controller is modified
  43719. */
  43720. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43721. /**
  43722. * Fired when the touchpad values on this controller are modified
  43723. */
  43724. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43725. private _updateTrackpad;
  43726. /**
  43727. * Called once per frame by the engine.
  43728. */
  43729. update(): void;
  43730. /**
  43731. * Called once for each button that changed state since the last frame
  43732. * @param buttonIdx Which button index changed
  43733. * @param state New state of the button
  43734. * @param changes Which properties on the state changed since last frame
  43735. */
  43736. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43737. /**
  43738. * Moves the buttons on the controller mesh based on their current state
  43739. * @param buttonName the name of the button to move
  43740. * @param buttonValue the value of the button which determines the buttons new position
  43741. */
  43742. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43743. /**
  43744. * Moves the axis on the controller mesh based on its current state
  43745. * @param axis the index of the axis
  43746. * @param axisValue the value of the axis which determines the meshes new position
  43747. * @hidden
  43748. */
  43749. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43750. /**
  43751. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43752. * @param scene scene in which to add meshes
  43753. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43754. */
  43755. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43756. /**
  43757. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43758. * can be transformed by button presses and axes values, based on this._mapping.
  43759. *
  43760. * @param scene scene in which the meshes exist
  43761. * @param meshes list of meshes that make up the controller model to process
  43762. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43763. */
  43764. private processModel;
  43765. private createMeshInfo;
  43766. /**
  43767. * Gets the ray of the controller in the direction the controller is pointing
  43768. * @param length the length the resulting ray should be
  43769. * @returns a ray in the direction the controller is pointing
  43770. */
  43771. getForwardRay(length?: number): Ray;
  43772. /**
  43773. * Disposes of the controller
  43774. */
  43775. dispose(): void;
  43776. }
  43777. }
  43778. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43779. import { Observable } from "babylonjs/Misc/observable";
  43780. import { Scene } from "babylonjs/scene";
  43781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43782. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43783. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43784. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43785. /**
  43786. * Oculus Touch Controller
  43787. */
  43788. export class OculusTouchController extends WebVRController {
  43789. /**
  43790. * Base Url for the controller model.
  43791. */
  43792. static MODEL_BASE_URL: string;
  43793. /**
  43794. * File name for the left controller model.
  43795. */
  43796. static MODEL_LEFT_FILENAME: string;
  43797. /**
  43798. * File name for the right controller model.
  43799. */
  43800. static MODEL_RIGHT_FILENAME: string;
  43801. /**
  43802. * Base Url for the Quest controller model.
  43803. */
  43804. static QUEST_MODEL_BASE_URL: string;
  43805. /**
  43806. * @hidden
  43807. * If the controllers are running on a device that needs the updated Quest controller models
  43808. */
  43809. static _IsQuest: boolean;
  43810. /**
  43811. * Fired when the secondary trigger on this controller is modified
  43812. */
  43813. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43814. /**
  43815. * Fired when the thumb rest on this controller is modified
  43816. */
  43817. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43818. /**
  43819. * Creates a new OculusTouchController from a gamepad
  43820. * @param vrGamepad the gamepad that the controller should be created from
  43821. */
  43822. constructor(vrGamepad: any);
  43823. /**
  43824. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43825. * @param scene scene in which to add meshes
  43826. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43827. */
  43828. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43829. /**
  43830. * Fired when the A button on this controller is modified
  43831. */
  43832. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43833. /**
  43834. * Fired when the B button on this controller is modified
  43835. */
  43836. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43837. /**
  43838. * Fired when the X button on this controller is modified
  43839. */
  43840. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43841. /**
  43842. * Fired when the Y button on this controller is modified
  43843. */
  43844. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43845. /**
  43846. * Called once for each button that changed state since the last frame
  43847. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43848. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43849. * 2) secondary trigger (same)
  43850. * 3) A (right) X (left), touch, pressed = value
  43851. * 4) B / Y
  43852. * 5) thumb rest
  43853. * @param buttonIdx Which button index changed
  43854. * @param state New state of the button
  43855. * @param changes Which properties on the state changed since last frame
  43856. */
  43857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43858. }
  43859. }
  43860. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43861. import { Scene } from "babylonjs/scene";
  43862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43863. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43864. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43865. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43866. import { Observable } from "babylonjs/Misc/observable";
  43867. /**
  43868. * Vive Controller
  43869. */
  43870. export class ViveController extends WebVRController {
  43871. /**
  43872. * Base Url for the controller model.
  43873. */
  43874. static MODEL_BASE_URL: string;
  43875. /**
  43876. * File name for the controller model.
  43877. */
  43878. static MODEL_FILENAME: string;
  43879. /**
  43880. * Creates a new ViveController from a gamepad
  43881. * @param vrGamepad the gamepad that the controller should be created from
  43882. */
  43883. constructor(vrGamepad: any);
  43884. /**
  43885. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43886. * @param scene scene in which to add meshes
  43887. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43888. */
  43889. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43890. /**
  43891. * Fired when the left button on this controller is modified
  43892. */
  43893. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43894. /**
  43895. * Fired when the right button on this controller is modified
  43896. */
  43897. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43898. /**
  43899. * Fired when the menu button on this controller is modified
  43900. */
  43901. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43902. /**
  43903. * Called once for each button that changed state since the last frame
  43904. * Vive mapping:
  43905. * 0: touchpad
  43906. * 1: trigger
  43907. * 2: left AND right buttons
  43908. * 3: menu button
  43909. * @param buttonIdx Which button index changed
  43910. * @param state New state of the button
  43911. * @param changes Which properties on the state changed since last frame
  43912. */
  43913. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43914. }
  43915. }
  43916. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43917. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43918. /**
  43919. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43920. */
  43921. export class WebXRControllerModelLoader {
  43922. /**
  43923. * Creates the WebXRControllerModelLoader
  43924. * @param input xr input that creates the controllers
  43925. */
  43926. constructor(input: WebXRInput);
  43927. }
  43928. }
  43929. declare module "babylonjs/Cameras/XR/index" {
  43930. export * from "babylonjs/Cameras/XR/webXRCamera";
  43931. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43932. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43933. export * from "babylonjs/Cameras/XR/webXRInput";
  43934. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43935. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43936. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43937. export * from "babylonjs/Cameras/XR/webXRController";
  43938. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43939. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43940. }
  43941. declare module "babylonjs/Cameras/RigModes/index" {
  43942. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43943. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43944. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43945. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43946. }
  43947. declare module "babylonjs/Cameras/index" {
  43948. export * from "babylonjs/Cameras/Inputs/index";
  43949. export * from "babylonjs/Cameras/cameraInputsManager";
  43950. export * from "babylonjs/Cameras/camera";
  43951. export * from "babylonjs/Cameras/targetCamera";
  43952. export * from "babylonjs/Cameras/freeCamera";
  43953. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43954. export * from "babylonjs/Cameras/touchCamera";
  43955. export * from "babylonjs/Cameras/arcRotateCamera";
  43956. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43957. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43958. export * from "babylonjs/Cameras/flyCamera";
  43959. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43960. export * from "babylonjs/Cameras/followCamera";
  43961. export * from "babylonjs/Cameras/followCameraInputsManager";
  43962. export * from "babylonjs/Cameras/gamepadCamera";
  43963. export * from "babylonjs/Cameras/Stereoscopic/index";
  43964. export * from "babylonjs/Cameras/universalCamera";
  43965. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43966. export * from "babylonjs/Cameras/VR/index";
  43967. export * from "babylonjs/Cameras/XR/index";
  43968. export * from "babylonjs/Cameras/RigModes/index";
  43969. }
  43970. declare module "babylonjs/Collisions/index" {
  43971. export * from "babylonjs/Collisions/collider";
  43972. export * from "babylonjs/Collisions/collisionCoordinator";
  43973. export * from "babylonjs/Collisions/pickingInfo";
  43974. export * from "babylonjs/Collisions/intersectionInfo";
  43975. export * from "babylonjs/Collisions/meshCollisionData";
  43976. }
  43977. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43978. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43979. import { Vector3 } from "babylonjs/Maths/math.vector";
  43980. import { Ray } from "babylonjs/Culling/ray";
  43981. import { Plane } from "babylonjs/Maths/math.plane";
  43982. /**
  43983. * Contains an array of blocks representing the octree
  43984. */
  43985. export interface IOctreeContainer<T> {
  43986. /**
  43987. * Blocks within the octree
  43988. */
  43989. blocks: Array<OctreeBlock<T>>;
  43990. }
  43991. /**
  43992. * Class used to store a cell in an octree
  43993. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43994. */
  43995. export class OctreeBlock<T> {
  43996. /**
  43997. * Gets the content of the current block
  43998. */
  43999. entries: T[];
  44000. /**
  44001. * Gets the list of block children
  44002. */
  44003. blocks: Array<OctreeBlock<T>>;
  44004. private _depth;
  44005. private _maxDepth;
  44006. private _capacity;
  44007. private _minPoint;
  44008. private _maxPoint;
  44009. private _boundingVectors;
  44010. private _creationFunc;
  44011. /**
  44012. * Creates a new block
  44013. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44014. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44015. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44016. * @param depth defines the current depth of this block in the octree
  44017. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44018. * @param creationFunc defines a callback to call when an element is added to the block
  44019. */
  44020. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44021. /**
  44022. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44023. */
  44024. readonly capacity: number;
  44025. /**
  44026. * Gets the minimum vector (in world space) of the block's bounding box
  44027. */
  44028. readonly minPoint: Vector3;
  44029. /**
  44030. * Gets the maximum vector (in world space) of the block's bounding box
  44031. */
  44032. readonly maxPoint: Vector3;
  44033. /**
  44034. * Add a new element to this block
  44035. * @param entry defines the element to add
  44036. */
  44037. addEntry(entry: T): void;
  44038. /**
  44039. * Remove an element from this block
  44040. * @param entry defines the element to remove
  44041. */
  44042. removeEntry(entry: T): void;
  44043. /**
  44044. * Add an array of elements to this block
  44045. * @param entries defines the array of elements to add
  44046. */
  44047. addEntries(entries: T[]): void;
  44048. /**
  44049. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44050. * @param frustumPlanes defines the frustum planes to test
  44051. * @param selection defines the array to store current content if selection is positive
  44052. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44053. */
  44054. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44055. /**
  44056. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44057. * @param sphereCenter defines the bounding sphere center
  44058. * @param sphereRadius defines the bounding sphere radius
  44059. * @param selection defines the array to store current content if selection is positive
  44060. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44061. */
  44062. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44063. /**
  44064. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44065. * @param ray defines the ray to test with
  44066. * @param selection defines the array to store current content if selection is positive
  44067. */
  44068. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44069. /**
  44070. * Subdivide the content into child blocks (this block will then be empty)
  44071. */
  44072. createInnerBlocks(): void;
  44073. /**
  44074. * @hidden
  44075. */
  44076. 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;
  44077. }
  44078. }
  44079. declare module "babylonjs/Culling/Octrees/octree" {
  44080. import { SmartArray } from "babylonjs/Misc/smartArray";
  44081. import { Vector3 } from "babylonjs/Maths/math.vector";
  44082. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44083. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44084. import { Ray } from "babylonjs/Culling/ray";
  44085. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44086. import { Plane } from "babylonjs/Maths/math.plane";
  44087. /**
  44088. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44089. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44090. */
  44091. export class Octree<T> {
  44092. /** 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.) */
  44093. maxDepth: number;
  44094. /**
  44095. * Blocks within the octree containing objects
  44096. */
  44097. blocks: Array<OctreeBlock<T>>;
  44098. /**
  44099. * Content stored in the octree
  44100. */
  44101. dynamicContent: T[];
  44102. private _maxBlockCapacity;
  44103. private _selectionContent;
  44104. private _creationFunc;
  44105. /**
  44106. * Creates a octree
  44107. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44108. * @param creationFunc function to be used to instatiate the octree
  44109. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44110. * @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.)
  44111. */
  44112. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44113. /** 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.) */
  44114. maxDepth?: number);
  44115. /**
  44116. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44117. * @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);
  44118. * @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);
  44119. * @param entries meshes to be added to the octree blocks
  44120. */
  44121. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44122. /**
  44123. * Adds a mesh to the octree
  44124. * @param entry Mesh to add to the octree
  44125. */
  44126. addMesh(entry: T): void;
  44127. /**
  44128. * Remove an element from the octree
  44129. * @param entry defines the element to remove
  44130. */
  44131. removeMesh(entry: T): void;
  44132. /**
  44133. * Selects an array of meshes within the frustum
  44134. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44135. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44136. * @returns array of meshes within the frustum
  44137. */
  44138. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44139. /**
  44140. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44141. * @param sphereCenter defines the bounding sphere center
  44142. * @param sphereRadius defines the bounding sphere radius
  44143. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44144. * @returns an array of objects that intersect the sphere
  44145. */
  44146. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44147. /**
  44148. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44149. * @param ray defines the ray to test with
  44150. * @returns array of intersected objects
  44151. */
  44152. intersectsRay(ray: Ray): SmartArray<T>;
  44153. /**
  44154. * Adds a mesh into the octree block if it intersects the block
  44155. */
  44156. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44157. /**
  44158. * Adds a submesh into the octree block if it intersects the block
  44159. */
  44160. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44161. }
  44162. }
  44163. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44164. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44165. import { Scene } from "babylonjs/scene";
  44166. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44168. import { Ray } from "babylonjs/Culling/ray";
  44169. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44170. import { Collider } from "babylonjs/Collisions/collider";
  44171. module "babylonjs/scene" {
  44172. interface Scene {
  44173. /**
  44174. * @hidden
  44175. * Backing Filed
  44176. */
  44177. _selectionOctree: Octree<AbstractMesh>;
  44178. /**
  44179. * Gets the octree used to boost mesh selection (picking)
  44180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44181. */
  44182. selectionOctree: Octree<AbstractMesh>;
  44183. /**
  44184. * Creates or updates the octree used to boost selection (picking)
  44185. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44186. * @param maxCapacity defines the maximum capacity per leaf
  44187. * @param maxDepth defines the maximum depth of the octree
  44188. * @returns an octree of AbstractMesh
  44189. */
  44190. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44191. }
  44192. }
  44193. module "babylonjs/Meshes/abstractMesh" {
  44194. interface AbstractMesh {
  44195. /**
  44196. * @hidden
  44197. * Backing Field
  44198. */
  44199. _submeshesOctree: Octree<SubMesh>;
  44200. /**
  44201. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44202. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44203. * @param maxCapacity defines the maximum size of each block (64 by default)
  44204. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44205. * @returns the new octree
  44206. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44208. */
  44209. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44210. }
  44211. }
  44212. /**
  44213. * Defines the octree scene component responsible to manage any octrees
  44214. * in a given scene.
  44215. */
  44216. export class OctreeSceneComponent {
  44217. /**
  44218. * The component name help to identify the component in the list of scene components.
  44219. */
  44220. readonly name: string;
  44221. /**
  44222. * The scene the component belongs to.
  44223. */
  44224. scene: Scene;
  44225. /**
  44226. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44227. */
  44228. readonly checksIsEnabled: boolean;
  44229. /**
  44230. * Creates a new instance of the component for the given scene
  44231. * @param scene Defines the scene to register the component in
  44232. */
  44233. constructor(scene: Scene);
  44234. /**
  44235. * Registers the component in a given scene
  44236. */
  44237. register(): void;
  44238. /**
  44239. * Return the list of active meshes
  44240. * @returns the list of active meshes
  44241. */
  44242. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44243. /**
  44244. * Return the list of active sub meshes
  44245. * @param mesh The mesh to get the candidates sub meshes from
  44246. * @returns the list of active sub meshes
  44247. */
  44248. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44249. private _tempRay;
  44250. /**
  44251. * Return the list of sub meshes intersecting with a given local ray
  44252. * @param mesh defines the mesh to find the submesh for
  44253. * @param localRay defines the ray in local space
  44254. * @returns the list of intersecting sub meshes
  44255. */
  44256. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44257. /**
  44258. * Return the list of sub meshes colliding with a collider
  44259. * @param mesh defines the mesh to find the submesh for
  44260. * @param collider defines the collider to evaluate the collision against
  44261. * @returns the list of colliding sub meshes
  44262. */
  44263. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44264. /**
  44265. * Rebuilds the elements related to this component in case of
  44266. * context lost for instance.
  44267. */
  44268. rebuild(): void;
  44269. /**
  44270. * Disposes the component and the associated ressources.
  44271. */
  44272. dispose(): void;
  44273. }
  44274. }
  44275. declare module "babylonjs/Culling/Octrees/index" {
  44276. export * from "babylonjs/Culling/Octrees/octree";
  44277. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44278. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44279. }
  44280. declare module "babylonjs/Culling/index" {
  44281. export * from "babylonjs/Culling/boundingBox";
  44282. export * from "babylonjs/Culling/boundingInfo";
  44283. export * from "babylonjs/Culling/boundingSphere";
  44284. export * from "babylonjs/Culling/Octrees/index";
  44285. export * from "babylonjs/Culling/ray";
  44286. }
  44287. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44288. import { IDisposable, Scene } from "babylonjs/scene";
  44289. import { Nullable } from "babylonjs/types";
  44290. import { Observable } from "babylonjs/Misc/observable";
  44291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44292. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44293. import { Camera } from "babylonjs/Cameras/camera";
  44294. /**
  44295. * Renders a layer on top of an existing scene
  44296. */
  44297. export class UtilityLayerRenderer implements IDisposable {
  44298. /** the original scene that will be rendered on top of */
  44299. originalScene: Scene;
  44300. private _pointerCaptures;
  44301. private _lastPointerEvents;
  44302. private static _DefaultUtilityLayer;
  44303. private static _DefaultKeepDepthUtilityLayer;
  44304. private _sharedGizmoLight;
  44305. private _renderCamera;
  44306. /**
  44307. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44308. * @returns the camera that is used when rendering the utility layer
  44309. */
  44310. getRenderCamera(): Nullable<Camera>;
  44311. /**
  44312. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44313. * @param cam the camera that should be used when rendering the utility layer
  44314. */
  44315. setRenderCamera(cam: Nullable<Camera>): void;
  44316. /**
  44317. * @hidden
  44318. * Light which used by gizmos to get light shading
  44319. */
  44320. _getSharedGizmoLight(): HemisphericLight;
  44321. /**
  44322. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44323. */
  44324. pickUtilitySceneFirst: boolean;
  44325. /**
  44326. * 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)
  44327. */
  44328. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44329. /**
  44330. * 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)
  44331. */
  44332. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44333. /**
  44334. * The scene that is rendered on top of the original scene
  44335. */
  44336. utilityLayerScene: Scene;
  44337. /**
  44338. * If the utility layer should automatically be rendered on top of existing scene
  44339. */
  44340. shouldRender: boolean;
  44341. /**
  44342. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44343. */
  44344. onlyCheckPointerDownEvents: boolean;
  44345. /**
  44346. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44347. */
  44348. processAllEvents: boolean;
  44349. /**
  44350. * Observable raised when the pointer move from the utility layer scene to the main scene
  44351. */
  44352. onPointerOutObservable: Observable<number>;
  44353. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44354. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44355. private _afterRenderObserver;
  44356. private _sceneDisposeObserver;
  44357. private _originalPointerObserver;
  44358. /**
  44359. * Instantiates a UtilityLayerRenderer
  44360. * @param originalScene the original scene that will be rendered on top of
  44361. * @param handleEvents boolean indicating if the utility layer should handle events
  44362. */
  44363. constructor(
  44364. /** the original scene that will be rendered on top of */
  44365. originalScene: Scene, handleEvents?: boolean);
  44366. private _notifyObservers;
  44367. /**
  44368. * Renders the utility layers scene on top of the original scene
  44369. */
  44370. render(): void;
  44371. /**
  44372. * Disposes of the renderer
  44373. */
  44374. dispose(): void;
  44375. private _updateCamera;
  44376. }
  44377. }
  44378. declare module "babylonjs/Gizmos/gizmo" {
  44379. import { Nullable } from "babylonjs/types";
  44380. import { IDisposable } from "babylonjs/scene";
  44381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44382. import { Mesh } from "babylonjs/Meshes/mesh";
  44383. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44384. /**
  44385. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44386. */
  44387. export class Gizmo implements IDisposable {
  44388. /** The utility layer the gizmo will be added to */
  44389. gizmoLayer: UtilityLayerRenderer;
  44390. /**
  44391. * The root mesh of the gizmo
  44392. */
  44393. _rootMesh: Mesh;
  44394. private _attachedMesh;
  44395. /**
  44396. * Ratio for the scale of the gizmo (Default: 1)
  44397. */
  44398. scaleRatio: number;
  44399. /**
  44400. * If a custom mesh has been set (Default: false)
  44401. */
  44402. protected _customMeshSet: boolean;
  44403. /**
  44404. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44405. * * When set, interactions will be enabled
  44406. */
  44407. attachedMesh: Nullable<AbstractMesh>;
  44408. /**
  44409. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44410. * @param mesh The mesh to replace the default mesh of the gizmo
  44411. */
  44412. setCustomMesh(mesh: Mesh): void;
  44413. /**
  44414. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44415. */
  44416. updateGizmoRotationToMatchAttachedMesh: boolean;
  44417. /**
  44418. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44419. */
  44420. updateGizmoPositionToMatchAttachedMesh: boolean;
  44421. /**
  44422. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44423. */
  44424. updateScale: boolean;
  44425. protected _interactionsEnabled: boolean;
  44426. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44427. private _beforeRenderObserver;
  44428. private _tempVector;
  44429. /**
  44430. * Creates a gizmo
  44431. * @param gizmoLayer The utility layer the gizmo will be added to
  44432. */
  44433. constructor(
  44434. /** The utility layer the gizmo will be added to */
  44435. gizmoLayer?: UtilityLayerRenderer);
  44436. /**
  44437. * Updates the gizmo to match the attached mesh's position/rotation
  44438. */
  44439. protected _update(): void;
  44440. /**
  44441. * Disposes of the gizmo
  44442. */
  44443. dispose(): void;
  44444. }
  44445. }
  44446. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44447. import { Observable } from "babylonjs/Misc/observable";
  44448. import { Nullable } from "babylonjs/types";
  44449. import { Vector3 } from "babylonjs/Maths/math.vector";
  44450. import { Color3 } from "babylonjs/Maths/math.color";
  44451. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44453. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44454. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44455. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44456. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44457. import { Scene } from "babylonjs/scene";
  44458. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44459. /**
  44460. * Single plane drag gizmo
  44461. */
  44462. export class PlaneDragGizmo extends Gizmo {
  44463. /**
  44464. * Drag behavior responsible for the gizmos dragging interactions
  44465. */
  44466. dragBehavior: PointerDragBehavior;
  44467. private _pointerObserver;
  44468. /**
  44469. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44470. */
  44471. snapDistance: number;
  44472. /**
  44473. * Event that fires each time the gizmo snaps to a new location.
  44474. * * snapDistance is the the change in distance
  44475. */
  44476. onSnapObservable: Observable<{
  44477. snapDistance: number;
  44478. }>;
  44479. private _plane;
  44480. private _coloredMaterial;
  44481. private _hoverMaterial;
  44482. private _isEnabled;
  44483. private _parent;
  44484. /** @hidden */
  44485. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44486. /** @hidden */
  44487. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44488. /**
  44489. * Creates a PlaneDragGizmo
  44490. * @param gizmoLayer The utility layer the gizmo will be added to
  44491. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44492. * @param color The color of the gizmo
  44493. */
  44494. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44495. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44496. /**
  44497. * If the gizmo is enabled
  44498. */
  44499. isEnabled: boolean;
  44500. /**
  44501. * Disposes of the gizmo
  44502. */
  44503. dispose(): void;
  44504. }
  44505. }
  44506. declare module "babylonjs/Gizmos/positionGizmo" {
  44507. import { Observable } from "babylonjs/Misc/observable";
  44508. import { Nullable } from "babylonjs/types";
  44509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44510. import { Mesh } from "babylonjs/Meshes/mesh";
  44511. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44512. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44513. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44514. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44515. /**
  44516. * Gizmo that enables dragging a mesh along 3 axis
  44517. */
  44518. export class PositionGizmo extends Gizmo {
  44519. /**
  44520. * Internal gizmo used for interactions on the x axis
  44521. */
  44522. xGizmo: AxisDragGizmo;
  44523. /**
  44524. * Internal gizmo used for interactions on the y axis
  44525. */
  44526. yGizmo: AxisDragGizmo;
  44527. /**
  44528. * Internal gizmo used for interactions on the z axis
  44529. */
  44530. zGizmo: AxisDragGizmo;
  44531. /**
  44532. * Internal gizmo used for interactions on the yz plane
  44533. */
  44534. xPlaneGizmo: PlaneDragGizmo;
  44535. /**
  44536. * Internal gizmo used for interactions on the xz plane
  44537. */
  44538. yPlaneGizmo: PlaneDragGizmo;
  44539. /**
  44540. * Internal gizmo used for interactions on the xy plane
  44541. */
  44542. zPlaneGizmo: PlaneDragGizmo;
  44543. /**
  44544. * private variables
  44545. */
  44546. private _meshAttached;
  44547. private _updateGizmoRotationToMatchAttachedMesh;
  44548. private _snapDistance;
  44549. private _scaleRatio;
  44550. /** Fires an event when any of it's sub gizmos are dragged */
  44551. onDragStartObservable: Observable<unknown>;
  44552. /** Fires an event when any of it's sub gizmos are released from dragging */
  44553. onDragEndObservable: Observable<unknown>;
  44554. /**
  44555. * If set to true, planar drag is enabled
  44556. */
  44557. private _planarGizmoEnabled;
  44558. attachedMesh: Nullable<AbstractMesh>;
  44559. /**
  44560. * Creates a PositionGizmo
  44561. * @param gizmoLayer The utility layer the gizmo will be added to
  44562. */
  44563. constructor(gizmoLayer?: UtilityLayerRenderer);
  44564. /**
  44565. * If the planar drag gizmo is enabled
  44566. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44567. */
  44568. planarGizmoEnabled: boolean;
  44569. updateGizmoRotationToMatchAttachedMesh: boolean;
  44570. /**
  44571. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44572. */
  44573. snapDistance: number;
  44574. /**
  44575. * Ratio for the scale of the gizmo (Default: 1)
  44576. */
  44577. scaleRatio: number;
  44578. /**
  44579. * Disposes of the gizmo
  44580. */
  44581. dispose(): void;
  44582. /**
  44583. * CustomMeshes are not supported by this gizmo
  44584. * @param mesh The mesh to replace the default mesh of the gizmo
  44585. */
  44586. setCustomMesh(mesh: Mesh): void;
  44587. }
  44588. }
  44589. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44590. import { Observable } from "babylonjs/Misc/observable";
  44591. import { Nullable } from "babylonjs/types";
  44592. import { Vector3 } from "babylonjs/Maths/math.vector";
  44593. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44595. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44596. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44597. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44598. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44599. import { Scene } from "babylonjs/scene";
  44600. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44601. import { Color3 } from "babylonjs/Maths/math.color";
  44602. /**
  44603. * Single axis drag gizmo
  44604. */
  44605. export class AxisDragGizmo extends Gizmo {
  44606. /**
  44607. * Drag behavior responsible for the gizmos dragging interactions
  44608. */
  44609. dragBehavior: PointerDragBehavior;
  44610. private _pointerObserver;
  44611. /**
  44612. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44613. */
  44614. snapDistance: number;
  44615. /**
  44616. * Event that fires each time the gizmo snaps to a new location.
  44617. * * snapDistance is the the change in distance
  44618. */
  44619. onSnapObservable: Observable<{
  44620. snapDistance: number;
  44621. }>;
  44622. private _isEnabled;
  44623. private _parent;
  44624. private _arrow;
  44625. private _coloredMaterial;
  44626. private _hoverMaterial;
  44627. /** @hidden */
  44628. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44629. /** @hidden */
  44630. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44631. /**
  44632. * Creates an AxisDragGizmo
  44633. * @param gizmoLayer The utility layer the gizmo will be added to
  44634. * @param dragAxis The axis which the gizmo will be able to drag on
  44635. * @param color The color of the gizmo
  44636. */
  44637. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44638. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44639. /**
  44640. * If the gizmo is enabled
  44641. */
  44642. isEnabled: boolean;
  44643. /**
  44644. * Disposes of the gizmo
  44645. */
  44646. dispose(): void;
  44647. }
  44648. }
  44649. declare module "babylonjs/Debug/axesViewer" {
  44650. import { Vector3 } from "babylonjs/Maths/math.vector";
  44651. import { Nullable } from "babylonjs/types";
  44652. import { Scene } from "babylonjs/scene";
  44653. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44654. /**
  44655. * The Axes viewer will show 3 axes in a specific point in space
  44656. */
  44657. export class AxesViewer {
  44658. private _xAxis;
  44659. private _yAxis;
  44660. private _zAxis;
  44661. private _scaleLinesFactor;
  44662. private _instanced;
  44663. /**
  44664. * Gets the hosting scene
  44665. */
  44666. scene: Scene;
  44667. /**
  44668. * Gets or sets a number used to scale line length
  44669. */
  44670. scaleLines: number;
  44671. /** Gets the node hierarchy used to render x-axis */
  44672. readonly xAxis: TransformNode;
  44673. /** Gets the node hierarchy used to render y-axis */
  44674. readonly yAxis: TransformNode;
  44675. /** Gets the node hierarchy used to render z-axis */
  44676. readonly zAxis: TransformNode;
  44677. /**
  44678. * Creates a new AxesViewer
  44679. * @param scene defines the hosting scene
  44680. * @param scaleLines defines a number used to scale line length (1 by default)
  44681. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44682. * @param xAxis defines the node hierarchy used to render the x-axis
  44683. * @param yAxis defines the node hierarchy used to render the y-axis
  44684. * @param zAxis defines the node hierarchy used to render the z-axis
  44685. */
  44686. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44687. /**
  44688. * Force the viewer to update
  44689. * @param position defines the position of the viewer
  44690. * @param xaxis defines the x axis of the viewer
  44691. * @param yaxis defines the y axis of the viewer
  44692. * @param zaxis defines the z axis of the viewer
  44693. */
  44694. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44695. /**
  44696. * Creates an instance of this axes viewer.
  44697. * @returns a new axes viewer with instanced meshes
  44698. */
  44699. createInstance(): AxesViewer;
  44700. /** Releases resources */
  44701. dispose(): void;
  44702. private static _SetRenderingGroupId;
  44703. }
  44704. }
  44705. declare module "babylonjs/Debug/boneAxesViewer" {
  44706. import { Nullable } from "babylonjs/types";
  44707. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44708. import { Vector3 } from "babylonjs/Maths/math.vector";
  44709. import { Mesh } from "babylonjs/Meshes/mesh";
  44710. import { Bone } from "babylonjs/Bones/bone";
  44711. import { Scene } from "babylonjs/scene";
  44712. /**
  44713. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44714. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44715. */
  44716. export class BoneAxesViewer extends AxesViewer {
  44717. /**
  44718. * Gets or sets the target mesh where to display the axes viewer
  44719. */
  44720. mesh: Nullable<Mesh>;
  44721. /**
  44722. * Gets or sets the target bone where to display the axes viewer
  44723. */
  44724. bone: Nullable<Bone>;
  44725. /** Gets current position */
  44726. pos: Vector3;
  44727. /** Gets direction of X axis */
  44728. xaxis: Vector3;
  44729. /** Gets direction of Y axis */
  44730. yaxis: Vector3;
  44731. /** Gets direction of Z axis */
  44732. zaxis: Vector3;
  44733. /**
  44734. * Creates a new BoneAxesViewer
  44735. * @param scene defines the hosting scene
  44736. * @param bone defines the target bone
  44737. * @param mesh defines the target mesh
  44738. * @param scaleLines defines a scaling factor for line length (1 by default)
  44739. */
  44740. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44741. /**
  44742. * Force the viewer to update
  44743. */
  44744. update(): void;
  44745. /** Releases resources */
  44746. dispose(): void;
  44747. }
  44748. }
  44749. declare module "babylonjs/Debug/debugLayer" {
  44750. import { Scene } from "babylonjs/scene";
  44751. /**
  44752. * Interface used to define scene explorer extensibility option
  44753. */
  44754. export interface IExplorerExtensibilityOption {
  44755. /**
  44756. * Define the option label
  44757. */
  44758. label: string;
  44759. /**
  44760. * Defines the action to execute on click
  44761. */
  44762. action: (entity: any) => void;
  44763. }
  44764. /**
  44765. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44766. */
  44767. export interface IExplorerExtensibilityGroup {
  44768. /**
  44769. * Defines a predicate to test if a given type mut be extended
  44770. */
  44771. predicate: (entity: any) => boolean;
  44772. /**
  44773. * Gets the list of options added to a type
  44774. */
  44775. entries: IExplorerExtensibilityOption[];
  44776. }
  44777. /**
  44778. * Interface used to define the options to use to create the Inspector
  44779. */
  44780. export interface IInspectorOptions {
  44781. /**
  44782. * Display in overlay mode (default: false)
  44783. */
  44784. overlay?: boolean;
  44785. /**
  44786. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44787. */
  44788. globalRoot?: HTMLElement;
  44789. /**
  44790. * Display the Scene explorer
  44791. */
  44792. showExplorer?: boolean;
  44793. /**
  44794. * Display the property inspector
  44795. */
  44796. showInspector?: boolean;
  44797. /**
  44798. * Display in embed mode (both panes on the right)
  44799. */
  44800. embedMode?: boolean;
  44801. /**
  44802. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44803. */
  44804. handleResize?: boolean;
  44805. /**
  44806. * Allow the panes to popup (default: true)
  44807. */
  44808. enablePopup?: boolean;
  44809. /**
  44810. * Allow the panes to be closed by users (default: true)
  44811. */
  44812. enableClose?: boolean;
  44813. /**
  44814. * Optional list of extensibility entries
  44815. */
  44816. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44817. /**
  44818. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44819. */
  44820. inspectorURL?: string;
  44821. }
  44822. module "babylonjs/scene" {
  44823. interface Scene {
  44824. /**
  44825. * @hidden
  44826. * Backing field
  44827. */
  44828. _debugLayer: DebugLayer;
  44829. /**
  44830. * Gets the debug layer (aka Inspector) associated with the scene
  44831. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44832. */
  44833. debugLayer: DebugLayer;
  44834. }
  44835. }
  44836. /**
  44837. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44838. * what is happening in your scene
  44839. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44840. */
  44841. export class DebugLayer {
  44842. /**
  44843. * Define the url to get the inspector script from.
  44844. * By default it uses the babylonjs CDN.
  44845. * @ignoreNaming
  44846. */
  44847. static InspectorURL: string;
  44848. private _scene;
  44849. private BJSINSPECTOR;
  44850. private _onPropertyChangedObservable?;
  44851. /**
  44852. * Observable triggered when a property is changed through the inspector.
  44853. */
  44854. readonly onPropertyChangedObservable: any;
  44855. /**
  44856. * Instantiates a new debug layer.
  44857. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44858. * what is happening in your scene
  44859. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44860. * @param scene Defines the scene to inspect
  44861. */
  44862. constructor(scene: Scene);
  44863. /** Creates the inspector window. */
  44864. private _createInspector;
  44865. /**
  44866. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44867. * @param entity defines the entity to select
  44868. * @param lineContainerTitle defines the specific block to highlight
  44869. */
  44870. select(entity: any, lineContainerTitle?: string): void;
  44871. /** Get the inspector from bundle or global */
  44872. private _getGlobalInspector;
  44873. /**
  44874. * Get if the inspector is visible or not.
  44875. * @returns true if visible otherwise, false
  44876. */
  44877. isVisible(): boolean;
  44878. /**
  44879. * Hide the inspector and close its window.
  44880. */
  44881. hide(): void;
  44882. /**
  44883. * Launch the debugLayer.
  44884. * @param config Define the configuration of the inspector
  44885. * @return a promise fulfilled when the debug layer is visible
  44886. */
  44887. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44888. }
  44889. }
  44890. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44891. import { Nullable } from "babylonjs/types";
  44892. import { Scene } from "babylonjs/scene";
  44893. import { Vector4 } from "babylonjs/Maths/math.vector";
  44894. import { Color4 } from "babylonjs/Maths/math.color";
  44895. import { Mesh } from "babylonjs/Meshes/mesh";
  44896. /**
  44897. * Class containing static functions to help procedurally build meshes
  44898. */
  44899. export class BoxBuilder {
  44900. /**
  44901. * Creates a box mesh
  44902. * * The parameter `size` sets the size (float) of each box side (default 1)
  44903. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44904. * * 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)
  44905. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44909. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44910. * @param name defines the name of the mesh
  44911. * @param options defines the options used to create the mesh
  44912. * @param scene defines the hosting scene
  44913. * @returns the box mesh
  44914. */
  44915. static CreateBox(name: string, options: {
  44916. size?: number;
  44917. width?: number;
  44918. height?: number;
  44919. depth?: number;
  44920. faceUV?: Vector4[];
  44921. faceColors?: Color4[];
  44922. sideOrientation?: number;
  44923. frontUVs?: Vector4;
  44924. backUVs?: Vector4;
  44925. wrap?: boolean;
  44926. topBaseAt?: number;
  44927. bottomBaseAt?: number;
  44928. updatable?: boolean;
  44929. }, scene?: Nullable<Scene>): Mesh;
  44930. }
  44931. }
  44932. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44933. import { Vector4 } from "babylonjs/Maths/math.vector";
  44934. import { Mesh } from "babylonjs/Meshes/mesh";
  44935. import { Scene } from "babylonjs/scene";
  44936. import { Nullable } from "babylonjs/types";
  44937. /**
  44938. * Class containing static functions to help procedurally build meshes
  44939. */
  44940. export class SphereBuilder {
  44941. /**
  44942. * Creates a sphere mesh
  44943. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44944. * * 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`)
  44945. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44946. * * 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
  44947. * * 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)
  44948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44951. * @param name defines the name of the mesh
  44952. * @param options defines the options used to create the mesh
  44953. * @param scene defines the hosting scene
  44954. * @returns the sphere mesh
  44955. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44956. */
  44957. static CreateSphere(name: string, options: {
  44958. segments?: number;
  44959. diameter?: number;
  44960. diameterX?: number;
  44961. diameterY?: number;
  44962. diameterZ?: number;
  44963. arc?: number;
  44964. slice?: number;
  44965. sideOrientation?: number;
  44966. frontUVs?: Vector4;
  44967. backUVs?: Vector4;
  44968. updatable?: boolean;
  44969. }, scene?: Nullable<Scene>): Mesh;
  44970. }
  44971. }
  44972. declare module "babylonjs/Debug/physicsViewer" {
  44973. import { Nullable } from "babylonjs/types";
  44974. import { Scene } from "babylonjs/scene";
  44975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44976. import { Mesh } from "babylonjs/Meshes/mesh";
  44977. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44978. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44979. /**
  44980. * Used to show the physics impostor around the specific mesh
  44981. */
  44982. export class PhysicsViewer {
  44983. /** @hidden */
  44984. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44985. /** @hidden */
  44986. protected _meshes: Array<Nullable<AbstractMesh>>;
  44987. /** @hidden */
  44988. protected _scene: Nullable<Scene>;
  44989. /** @hidden */
  44990. protected _numMeshes: number;
  44991. /** @hidden */
  44992. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44993. private _renderFunction;
  44994. private _utilityLayer;
  44995. private _debugBoxMesh;
  44996. private _debugSphereMesh;
  44997. private _debugCylinderMesh;
  44998. private _debugMaterial;
  44999. private _debugMeshMeshes;
  45000. /**
  45001. * Creates a new PhysicsViewer
  45002. * @param scene defines the hosting scene
  45003. */
  45004. constructor(scene: Scene);
  45005. /** @hidden */
  45006. protected _updateDebugMeshes(): void;
  45007. /**
  45008. * Renders a specified physic impostor
  45009. * @param impostor defines the impostor to render
  45010. * @param targetMesh defines the mesh represented by the impostor
  45011. * @returns the new debug mesh used to render the impostor
  45012. */
  45013. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45014. /**
  45015. * Hides a specified physic impostor
  45016. * @param impostor defines the impostor to hide
  45017. */
  45018. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45019. private _getDebugMaterial;
  45020. private _getDebugBoxMesh;
  45021. private _getDebugSphereMesh;
  45022. private _getDebugCylinderMesh;
  45023. private _getDebugMeshMesh;
  45024. private _getDebugMesh;
  45025. /** Releases all resources */
  45026. dispose(): void;
  45027. }
  45028. }
  45029. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45030. import { Vector3 } from "babylonjs/Maths/math.vector";
  45031. import { Color4 } from "babylonjs/Maths/math.color";
  45032. import { Nullable } from "babylonjs/types";
  45033. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45034. import { Scene } from "babylonjs/scene";
  45035. /**
  45036. * Class containing static functions to help procedurally build meshes
  45037. */
  45038. export class LinesBuilder {
  45039. /**
  45040. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45041. * * 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
  45042. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45043. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45044. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45045. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45046. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45047. * * 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
  45048. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45050. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45051. * @param name defines the name of the new line system
  45052. * @param options defines the options used to create the line system
  45053. * @param scene defines the hosting scene
  45054. * @returns a new line system mesh
  45055. */
  45056. static CreateLineSystem(name: string, options: {
  45057. lines: Vector3[][];
  45058. updatable?: boolean;
  45059. instance?: Nullable<LinesMesh>;
  45060. colors?: Nullable<Color4[][]>;
  45061. useVertexAlpha?: boolean;
  45062. }, scene: Nullable<Scene>): LinesMesh;
  45063. /**
  45064. * Creates a line mesh
  45065. * 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
  45066. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45067. * * The parameter `points` is an array successive Vector3
  45068. * * 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
  45069. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45070. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45071. * * When updating an instance, remember that only point positions can change, not the number of points
  45072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45074. * @param name defines the name of the new line system
  45075. * @param options defines the options used to create the line system
  45076. * @param scene defines the hosting scene
  45077. * @returns a new line mesh
  45078. */
  45079. static CreateLines(name: string, options: {
  45080. points: Vector3[];
  45081. updatable?: boolean;
  45082. instance?: Nullable<LinesMesh>;
  45083. colors?: Color4[];
  45084. useVertexAlpha?: boolean;
  45085. }, scene?: Nullable<Scene>): LinesMesh;
  45086. /**
  45087. * Creates a dashed line mesh
  45088. * * 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
  45089. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45090. * * The parameter `points` is an array successive Vector3
  45091. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45092. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45093. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45094. * * 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
  45095. * * When updating an instance, remember that only point positions can change, not the number of points
  45096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45097. * @param name defines the name of the mesh
  45098. * @param options defines the options used to create the mesh
  45099. * @param scene defines the hosting scene
  45100. * @returns the dashed line mesh
  45101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45102. */
  45103. static CreateDashedLines(name: string, options: {
  45104. points: Vector3[];
  45105. dashSize?: number;
  45106. gapSize?: number;
  45107. dashNb?: number;
  45108. updatable?: boolean;
  45109. instance?: LinesMesh;
  45110. }, scene?: Nullable<Scene>): LinesMesh;
  45111. }
  45112. }
  45113. declare module "babylonjs/Debug/rayHelper" {
  45114. import { Nullable } from "babylonjs/types";
  45115. import { Ray } from "babylonjs/Culling/ray";
  45116. import { Vector3 } from "babylonjs/Maths/math.vector";
  45117. import { Color3 } from "babylonjs/Maths/math.color";
  45118. import { Scene } from "babylonjs/scene";
  45119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45120. import "babylonjs/Meshes/Builders/linesBuilder";
  45121. /**
  45122. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45123. * in order to better appreciate the issue one might have.
  45124. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45125. */
  45126. export class RayHelper {
  45127. /**
  45128. * Defines the ray we are currently tryin to visualize.
  45129. */
  45130. ray: Nullable<Ray>;
  45131. private _renderPoints;
  45132. private _renderLine;
  45133. private _renderFunction;
  45134. private _scene;
  45135. private _updateToMeshFunction;
  45136. private _attachedToMesh;
  45137. private _meshSpaceDirection;
  45138. private _meshSpaceOrigin;
  45139. /**
  45140. * Helper function to create a colored helper in a scene in one line.
  45141. * @param ray Defines the ray we are currently tryin to visualize
  45142. * @param scene Defines the scene the ray is used in
  45143. * @param color Defines the color we want to see the ray in
  45144. * @returns The newly created ray helper.
  45145. */
  45146. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45147. /**
  45148. * Instantiate a new ray helper.
  45149. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45150. * in order to better appreciate the issue one might have.
  45151. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45152. * @param ray Defines the ray we are currently tryin to visualize
  45153. */
  45154. constructor(ray: Ray);
  45155. /**
  45156. * Shows the ray we are willing to debug.
  45157. * @param scene Defines the scene the ray needs to be rendered in
  45158. * @param color Defines the color the ray needs to be rendered in
  45159. */
  45160. show(scene: Scene, color?: Color3): void;
  45161. /**
  45162. * Hides the ray we are debugging.
  45163. */
  45164. hide(): void;
  45165. private _render;
  45166. /**
  45167. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45168. * @param mesh Defines the mesh we want the helper attached to
  45169. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45170. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45171. * @param length Defines the length of the ray
  45172. */
  45173. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45174. /**
  45175. * Detach the ray helper from the mesh it has previously been attached to.
  45176. */
  45177. detachFromMesh(): void;
  45178. private _updateToMesh;
  45179. /**
  45180. * Dispose the helper and release its associated resources.
  45181. */
  45182. dispose(): void;
  45183. }
  45184. }
  45185. declare module "babylonjs/Debug/skeletonViewer" {
  45186. import { Color3 } from "babylonjs/Maths/math.color";
  45187. import { Scene } from "babylonjs/scene";
  45188. import { Nullable } from "babylonjs/types";
  45189. import { Skeleton } from "babylonjs/Bones/skeleton";
  45190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45191. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45192. /**
  45193. * Class used to render a debug view of a given skeleton
  45194. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45195. */
  45196. export class SkeletonViewer {
  45197. /** defines the skeleton to render */
  45198. skeleton: Skeleton;
  45199. /** defines the mesh attached to the skeleton */
  45200. mesh: AbstractMesh;
  45201. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45202. autoUpdateBonesMatrices: boolean;
  45203. /** defines the rendering group id to use with the viewer */
  45204. renderingGroupId: number;
  45205. /** Gets or sets the color used to render the skeleton */
  45206. color: Color3;
  45207. private _scene;
  45208. private _debugLines;
  45209. private _debugMesh;
  45210. private _isEnabled;
  45211. private _renderFunction;
  45212. private _utilityLayer;
  45213. /**
  45214. * Returns the mesh used to render the bones
  45215. */
  45216. readonly debugMesh: Nullable<LinesMesh>;
  45217. /**
  45218. * Creates a new SkeletonViewer
  45219. * @param skeleton defines the skeleton to render
  45220. * @param mesh defines the mesh attached to the skeleton
  45221. * @param scene defines the hosting scene
  45222. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45223. * @param renderingGroupId defines the rendering group id to use with the viewer
  45224. */
  45225. constructor(
  45226. /** defines the skeleton to render */
  45227. skeleton: Skeleton,
  45228. /** defines the mesh attached to the skeleton */
  45229. mesh: AbstractMesh, scene: Scene,
  45230. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45231. autoUpdateBonesMatrices?: boolean,
  45232. /** defines the rendering group id to use with the viewer */
  45233. renderingGroupId?: number);
  45234. /** Gets or sets a boolean indicating if the viewer is enabled */
  45235. isEnabled: boolean;
  45236. private _getBonePosition;
  45237. private _getLinesForBonesWithLength;
  45238. private _getLinesForBonesNoLength;
  45239. /** Update the viewer to sync with current skeleton state */
  45240. update(): void;
  45241. /** Release associated resources */
  45242. dispose(): void;
  45243. }
  45244. }
  45245. declare module "babylonjs/Debug/index" {
  45246. export * from "babylonjs/Debug/axesViewer";
  45247. export * from "babylonjs/Debug/boneAxesViewer";
  45248. export * from "babylonjs/Debug/debugLayer";
  45249. export * from "babylonjs/Debug/physicsViewer";
  45250. export * from "babylonjs/Debug/rayHelper";
  45251. export * from "babylonjs/Debug/skeletonViewer";
  45252. }
  45253. declare module "babylonjs/Engines/nullEngine" {
  45254. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45255. import { Scene } from "babylonjs/scene";
  45256. import { Engine } from "babylonjs/Engines/engine";
  45257. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45258. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45260. import { Effect } from "babylonjs/Materials/effect";
  45261. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45262. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45263. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45264. /**
  45265. * Options to create the null engine
  45266. */
  45267. export class NullEngineOptions {
  45268. /**
  45269. * Render width (Default: 512)
  45270. */
  45271. renderWidth: number;
  45272. /**
  45273. * Render height (Default: 256)
  45274. */
  45275. renderHeight: number;
  45276. /**
  45277. * Texture size (Default: 512)
  45278. */
  45279. textureSize: number;
  45280. /**
  45281. * If delta time between frames should be constant
  45282. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45283. */
  45284. deterministicLockstep: boolean;
  45285. /**
  45286. * Maximum about of steps between frames (Default: 4)
  45287. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45288. */
  45289. lockstepMaxSteps: number;
  45290. }
  45291. /**
  45292. * The null engine class provides support for headless version of babylon.js.
  45293. * This can be used in server side scenario or for testing purposes
  45294. */
  45295. export class NullEngine extends Engine {
  45296. private _options;
  45297. /**
  45298. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45299. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45300. * @returns true if engine is in deterministic lock step mode
  45301. */
  45302. isDeterministicLockStep(): boolean;
  45303. /**
  45304. * Gets the max steps when engine is running in deterministic lock step
  45305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45306. * @returns the max steps
  45307. */
  45308. getLockstepMaxSteps(): number;
  45309. /**
  45310. * Gets the current hardware scaling level.
  45311. * By default the hardware scaling level is computed from the window device ratio.
  45312. * 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.
  45313. * @returns a number indicating the current hardware scaling level
  45314. */
  45315. getHardwareScalingLevel(): number;
  45316. constructor(options?: NullEngineOptions);
  45317. /**
  45318. * Creates a vertex buffer
  45319. * @param vertices the data for the vertex buffer
  45320. * @returns the new WebGL static buffer
  45321. */
  45322. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45323. /**
  45324. * Creates a new index buffer
  45325. * @param indices defines the content of the index buffer
  45326. * @param updatable defines if the index buffer must be updatable
  45327. * @returns a new webGL buffer
  45328. */
  45329. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45330. /**
  45331. * Clear the current render buffer or the current render target (if any is set up)
  45332. * @param color defines the color to use
  45333. * @param backBuffer defines if the back buffer must be cleared
  45334. * @param depth defines if the depth buffer must be cleared
  45335. * @param stencil defines if the stencil buffer must be cleared
  45336. */
  45337. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45338. /**
  45339. * Gets the current render width
  45340. * @param useScreen defines if screen size must be used (or the current render target if any)
  45341. * @returns a number defining the current render width
  45342. */
  45343. getRenderWidth(useScreen?: boolean): number;
  45344. /**
  45345. * Gets the current render height
  45346. * @param useScreen defines if screen size must be used (or the current render target if any)
  45347. * @returns a number defining the current render height
  45348. */
  45349. getRenderHeight(useScreen?: boolean): number;
  45350. /**
  45351. * Set the WebGL's viewport
  45352. * @param viewport defines the viewport element to be used
  45353. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45354. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45355. */
  45356. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45357. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45358. /**
  45359. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45360. * @param pipelineContext defines the pipeline context to use
  45361. * @param uniformsNames defines the list of uniform names
  45362. * @returns an array of webGL uniform locations
  45363. */
  45364. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45365. /**
  45366. * Gets the lsit of active attributes for a given webGL program
  45367. * @param pipelineContext defines the pipeline context to use
  45368. * @param attributesNames defines the list of attribute names to get
  45369. * @returns an array of indices indicating the offset of each attribute
  45370. */
  45371. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45372. /**
  45373. * Binds an effect to the webGL context
  45374. * @param effect defines the effect to bind
  45375. */
  45376. bindSamplers(effect: Effect): void;
  45377. /**
  45378. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45379. * @param effect defines the effect to activate
  45380. */
  45381. enableEffect(effect: Effect): void;
  45382. /**
  45383. * Set various states to the webGL context
  45384. * @param culling defines backface culling state
  45385. * @param zOffset defines the value to apply to zOffset (0 by default)
  45386. * @param force defines if states must be applied even if cache is up to date
  45387. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45388. */
  45389. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45390. /**
  45391. * Set the value of an uniform to an array of int32
  45392. * @param uniform defines the webGL uniform location where to store the value
  45393. * @param array defines the array of int32 to store
  45394. */
  45395. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45396. /**
  45397. * Set the value of an uniform to an array of int32 (stored as vec2)
  45398. * @param uniform defines the webGL uniform location where to store the value
  45399. * @param array defines the array of int32 to store
  45400. */
  45401. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45402. /**
  45403. * Set the value of an uniform to an array of int32 (stored as vec3)
  45404. * @param uniform defines the webGL uniform location where to store the value
  45405. * @param array defines the array of int32 to store
  45406. */
  45407. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45408. /**
  45409. * Set the value of an uniform to an array of int32 (stored as vec4)
  45410. * @param uniform defines the webGL uniform location where to store the value
  45411. * @param array defines the array of int32 to store
  45412. */
  45413. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45414. /**
  45415. * Set the value of an uniform to an array of float32
  45416. * @param uniform defines the webGL uniform location where to store the value
  45417. * @param array defines the array of float32 to store
  45418. */
  45419. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45420. /**
  45421. * Set the value of an uniform to an array of float32 (stored as vec2)
  45422. * @param uniform defines the webGL uniform location where to store the value
  45423. * @param array defines the array of float32 to store
  45424. */
  45425. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45426. /**
  45427. * Set the value of an uniform to an array of float32 (stored as vec3)
  45428. * @param uniform defines the webGL uniform location where to store the value
  45429. * @param array defines the array of float32 to store
  45430. */
  45431. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45432. /**
  45433. * Set the value of an uniform to an array of float32 (stored as vec4)
  45434. * @param uniform defines the webGL uniform location where to store the value
  45435. * @param array defines the array of float32 to store
  45436. */
  45437. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45438. /**
  45439. * Set the value of an uniform to an array of number
  45440. * @param uniform defines the webGL uniform location where to store the value
  45441. * @param array defines the array of number to store
  45442. */
  45443. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45444. /**
  45445. * Set the value of an uniform to an array of number (stored as vec2)
  45446. * @param uniform defines the webGL uniform location where to store the value
  45447. * @param array defines the array of number to store
  45448. */
  45449. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45450. /**
  45451. * Set the value of an uniform to an array of number (stored as vec3)
  45452. * @param uniform defines the webGL uniform location where to store the value
  45453. * @param array defines the array of number to store
  45454. */
  45455. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45456. /**
  45457. * Set the value of an uniform to an array of number (stored as vec4)
  45458. * @param uniform defines the webGL uniform location where to store the value
  45459. * @param array defines the array of number to store
  45460. */
  45461. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45462. /**
  45463. * Set the value of an uniform to an array of float32 (stored as matrices)
  45464. * @param uniform defines the webGL uniform location where to store the value
  45465. * @param matrices defines the array of float32 to store
  45466. */
  45467. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45468. /**
  45469. * Set the value of an uniform to a matrix (3x3)
  45470. * @param uniform defines the webGL uniform location where to store the value
  45471. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45472. */
  45473. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45474. /**
  45475. * Set the value of an uniform to a matrix (2x2)
  45476. * @param uniform defines the webGL uniform location where to store the value
  45477. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45478. */
  45479. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45480. /**
  45481. * Set the value of an uniform to a number (float)
  45482. * @param uniform defines the webGL uniform location where to store the value
  45483. * @param value defines the float number to store
  45484. */
  45485. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45486. /**
  45487. * Set the value of an uniform to a vec2
  45488. * @param uniform defines the webGL uniform location where to store the value
  45489. * @param x defines the 1st component of the value
  45490. * @param y defines the 2nd component of the value
  45491. */
  45492. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45493. /**
  45494. * Set the value of an uniform to a vec3
  45495. * @param uniform defines the webGL uniform location where to store the value
  45496. * @param x defines the 1st component of the value
  45497. * @param y defines the 2nd component of the value
  45498. * @param z defines the 3rd component of the value
  45499. */
  45500. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45501. /**
  45502. * Set the value of an uniform to a boolean
  45503. * @param uniform defines the webGL uniform location where to store the value
  45504. * @param bool defines the boolean to store
  45505. */
  45506. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45507. /**
  45508. * Set the value of an uniform to a vec4
  45509. * @param uniform defines the webGL uniform location where to store the value
  45510. * @param x defines the 1st component of the value
  45511. * @param y defines the 2nd component of the value
  45512. * @param z defines the 3rd component of the value
  45513. * @param w defines the 4th component of the value
  45514. */
  45515. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45516. /**
  45517. * Sets the current alpha mode
  45518. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45519. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45520. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45521. */
  45522. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45523. /**
  45524. * Bind webGl buffers directly to the webGL context
  45525. * @param vertexBuffers defines the vertex buffer to bind
  45526. * @param indexBuffer defines the index buffer to bind
  45527. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45528. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45529. * @param effect defines the effect associated with the vertex buffer
  45530. */
  45531. bindBuffers(vertexBuffers: {
  45532. [key: string]: VertexBuffer;
  45533. }, indexBuffer: DataBuffer, effect: Effect): void;
  45534. /**
  45535. * Force the entire cache to be cleared
  45536. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45537. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45538. */
  45539. wipeCaches(bruteForce?: boolean): void;
  45540. /**
  45541. * Send a draw order
  45542. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45543. * @param indexStart defines the starting index
  45544. * @param indexCount defines the number of index to draw
  45545. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45546. */
  45547. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45548. /**
  45549. * Draw a list of indexed primitives
  45550. * @param fillMode defines the primitive to use
  45551. * @param indexStart defines the starting index
  45552. * @param indexCount defines the number of index to draw
  45553. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45554. */
  45555. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45556. /**
  45557. * Draw a list of unindexed primitives
  45558. * @param fillMode defines the primitive to use
  45559. * @param verticesStart defines the index of first vertex to draw
  45560. * @param verticesCount defines the count of vertices to draw
  45561. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45562. */
  45563. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45564. /** @hidden */
  45565. _createTexture(): WebGLTexture;
  45566. /** @hidden */
  45567. _releaseTexture(texture: InternalTexture): void;
  45568. /**
  45569. * Usually called from Texture.ts.
  45570. * Passed information to create a WebGLTexture
  45571. * @param urlArg defines a value which contains one of the following:
  45572. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45573. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45574. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45575. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45576. * @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)
  45577. * @param scene needed for loading to the correct scene
  45578. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45579. * @param onLoad optional callback to be called upon successful completion
  45580. * @param onError optional callback to be called upon failure
  45581. * @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
  45582. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45583. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45584. * @param forcedExtension defines the extension to use to pick the right loader
  45585. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45586. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45587. */
  45588. 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;
  45589. /**
  45590. * Creates a new render target texture
  45591. * @param size defines the size of the texture
  45592. * @param options defines the options used to create the texture
  45593. * @returns a new render target texture stored in an InternalTexture
  45594. */
  45595. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45596. /**
  45597. * Update the sampling mode of a given texture
  45598. * @param samplingMode defines the required sampling mode
  45599. * @param texture defines the texture to update
  45600. */
  45601. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45602. /**
  45603. * Binds the frame buffer to the specified texture.
  45604. * @param texture The texture to render to or null for the default canvas
  45605. * @param faceIndex The face of the texture to render to in case of cube texture
  45606. * @param requiredWidth The width of the target to render to
  45607. * @param requiredHeight The height of the target to render to
  45608. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45609. * @param depthStencilTexture The depth stencil texture to use to render
  45610. * @param lodLevel defines le lod level to bind to the frame buffer
  45611. */
  45612. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45613. /**
  45614. * Unbind the current render target texture from the webGL context
  45615. * @param texture defines the render target texture to unbind
  45616. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45617. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45618. */
  45619. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45620. /**
  45621. * Creates a dynamic vertex buffer
  45622. * @param vertices the data for the dynamic vertex buffer
  45623. * @returns the new WebGL dynamic buffer
  45624. */
  45625. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45626. /**
  45627. * Update the content of a dynamic texture
  45628. * @param texture defines the texture to update
  45629. * @param canvas defines the canvas containing the source
  45630. * @param invertY defines if data must be stored with Y axis inverted
  45631. * @param premulAlpha defines if alpha is stored as premultiplied
  45632. * @param format defines the format of the data
  45633. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45634. */
  45635. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45636. /**
  45637. * Gets a boolean indicating if all created effects are ready
  45638. * @returns true if all effects are ready
  45639. */
  45640. areAllEffectsReady(): boolean;
  45641. /**
  45642. * @hidden
  45643. * Get the current error code of the webGL context
  45644. * @returns the error code
  45645. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45646. */
  45647. getError(): number;
  45648. /** @hidden */
  45649. _getUnpackAlignement(): number;
  45650. /** @hidden */
  45651. _unpackFlipY(value: boolean): void;
  45652. /**
  45653. * Update a dynamic index buffer
  45654. * @param indexBuffer defines the target index buffer
  45655. * @param indices defines the data to update
  45656. * @param offset defines the offset in the target index buffer where update should start
  45657. */
  45658. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45659. /**
  45660. * Updates a dynamic vertex buffer.
  45661. * @param vertexBuffer the vertex buffer to update
  45662. * @param vertices the data used to update the vertex buffer
  45663. * @param byteOffset the byte offset of the data (optional)
  45664. * @param byteLength the byte length of the data (optional)
  45665. */
  45666. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45667. /** @hidden */
  45668. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45669. /** @hidden */
  45670. _bindTexture(channel: number, texture: InternalTexture): void;
  45671. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45672. /**
  45673. * 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
  45674. */
  45675. releaseEffects(): void;
  45676. displayLoadingUI(): void;
  45677. hideLoadingUI(): void;
  45678. /** @hidden */
  45679. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45680. /** @hidden */
  45681. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45682. /** @hidden */
  45683. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45684. /** @hidden */
  45685. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45686. }
  45687. }
  45688. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45689. import { Nullable, int } from "babylonjs/types";
  45690. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45691. /** @hidden */
  45692. export class _OcclusionDataStorage {
  45693. /** @hidden */
  45694. occlusionInternalRetryCounter: number;
  45695. /** @hidden */
  45696. isOcclusionQueryInProgress: boolean;
  45697. /** @hidden */
  45698. isOccluded: boolean;
  45699. /** @hidden */
  45700. occlusionRetryCount: number;
  45701. /** @hidden */
  45702. occlusionType: number;
  45703. /** @hidden */
  45704. occlusionQueryAlgorithmType: number;
  45705. }
  45706. module "babylonjs/Engines/engine" {
  45707. interface Engine {
  45708. /**
  45709. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45710. * @return the new query
  45711. */
  45712. createQuery(): WebGLQuery;
  45713. /**
  45714. * Delete and release a webGL query
  45715. * @param query defines the query to delete
  45716. * @return the current engine
  45717. */
  45718. deleteQuery(query: WebGLQuery): Engine;
  45719. /**
  45720. * Check if a given query has resolved and got its value
  45721. * @param query defines the query to check
  45722. * @returns true if the query got its value
  45723. */
  45724. isQueryResultAvailable(query: WebGLQuery): boolean;
  45725. /**
  45726. * Gets the value of a given query
  45727. * @param query defines the query to check
  45728. * @returns the value of the query
  45729. */
  45730. getQueryResult(query: WebGLQuery): number;
  45731. /**
  45732. * Initiates an occlusion query
  45733. * @param algorithmType defines the algorithm to use
  45734. * @param query defines the query to use
  45735. * @returns the current engine
  45736. * @see http://doc.babylonjs.com/features/occlusionquery
  45737. */
  45738. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45739. /**
  45740. * Ends an occlusion query
  45741. * @see http://doc.babylonjs.com/features/occlusionquery
  45742. * @param algorithmType defines the algorithm to use
  45743. * @returns the current engine
  45744. */
  45745. endOcclusionQuery(algorithmType: number): Engine;
  45746. /**
  45747. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45748. * Please note that only one query can be issued at a time
  45749. * @returns a time token used to track the time span
  45750. */
  45751. startTimeQuery(): Nullable<_TimeToken>;
  45752. /**
  45753. * Ends a time query
  45754. * @param token defines the token used to measure the time span
  45755. * @returns the time spent (in ns)
  45756. */
  45757. endTimeQuery(token: _TimeToken): int;
  45758. /** @hidden */
  45759. _currentNonTimestampToken: Nullable<_TimeToken>;
  45760. /** @hidden */
  45761. _createTimeQuery(): WebGLQuery;
  45762. /** @hidden */
  45763. _deleteTimeQuery(query: WebGLQuery): void;
  45764. /** @hidden */
  45765. _getGlAlgorithmType(algorithmType: number): number;
  45766. /** @hidden */
  45767. _getTimeQueryResult(query: WebGLQuery): any;
  45768. /** @hidden */
  45769. _getTimeQueryAvailability(query: WebGLQuery): any;
  45770. }
  45771. }
  45772. module "babylonjs/Meshes/abstractMesh" {
  45773. interface AbstractMesh {
  45774. /**
  45775. * Backing filed
  45776. * @hidden
  45777. */
  45778. __occlusionDataStorage: _OcclusionDataStorage;
  45779. /**
  45780. * Access property
  45781. * @hidden
  45782. */
  45783. _occlusionDataStorage: _OcclusionDataStorage;
  45784. /**
  45785. * 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.
  45786. * The default value is -1 which means don't break the query and wait till the result
  45787. * @see http://doc.babylonjs.com/features/occlusionquery
  45788. */
  45789. occlusionRetryCount: number;
  45790. /**
  45791. * 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:
  45792. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45793. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45794. * * 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.
  45795. * @see http://doc.babylonjs.com/features/occlusionquery
  45796. */
  45797. occlusionType: number;
  45798. /**
  45799. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45800. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45801. * * 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.
  45802. * @see http://doc.babylonjs.com/features/occlusionquery
  45803. */
  45804. occlusionQueryAlgorithmType: number;
  45805. /**
  45806. * 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
  45807. * @see http://doc.babylonjs.com/features/occlusionquery
  45808. */
  45809. isOccluded: boolean;
  45810. /**
  45811. * Flag to check the progress status of the query
  45812. * @see http://doc.babylonjs.com/features/occlusionquery
  45813. */
  45814. isOcclusionQueryInProgress: boolean;
  45815. }
  45816. }
  45817. }
  45818. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45819. import { Nullable } from "babylonjs/types";
  45820. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45821. /** @hidden */
  45822. export var _forceTransformFeedbackToBundle: boolean;
  45823. module "babylonjs/Engines/engine" {
  45824. interface Engine {
  45825. /**
  45826. * Creates a webGL transform feedback object
  45827. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45828. * @returns the webGL transform feedback object
  45829. */
  45830. createTransformFeedback(): WebGLTransformFeedback;
  45831. /**
  45832. * Delete a webGL transform feedback object
  45833. * @param value defines the webGL transform feedback object to delete
  45834. */
  45835. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45836. /**
  45837. * Bind a webGL transform feedback object to the webgl context
  45838. * @param value defines the webGL transform feedback object to bind
  45839. */
  45840. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45841. /**
  45842. * Begins a transform feedback operation
  45843. * @param usePoints defines if points or triangles must be used
  45844. */
  45845. beginTransformFeedback(usePoints: boolean): void;
  45846. /**
  45847. * Ends a transform feedback operation
  45848. */
  45849. endTransformFeedback(): void;
  45850. /**
  45851. * Specify the varyings to use with transform feedback
  45852. * @param program defines the associated webGL program
  45853. * @param value defines the list of strings representing the varying names
  45854. */
  45855. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45856. /**
  45857. * Bind a webGL buffer for a transform feedback operation
  45858. * @param value defines the webGL buffer to bind
  45859. */
  45860. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45861. }
  45862. }
  45863. }
  45864. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45865. import { Scene } from "babylonjs/scene";
  45866. import { Engine } from "babylonjs/Engines/engine";
  45867. import { Texture } from "babylonjs/Materials/Textures/texture";
  45868. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45869. import "babylonjs/Engines/Extensions/engine.multiRender";
  45870. /**
  45871. * Creation options of the multi render target texture.
  45872. */
  45873. export interface IMultiRenderTargetOptions {
  45874. /**
  45875. * Define if the texture needs to create mip maps after render.
  45876. */
  45877. generateMipMaps?: boolean;
  45878. /**
  45879. * Define the types of all the draw buffers we want to create
  45880. */
  45881. types?: number[];
  45882. /**
  45883. * Define the sampling modes of all the draw buffers we want to create
  45884. */
  45885. samplingModes?: number[];
  45886. /**
  45887. * Define if a depth buffer is required
  45888. */
  45889. generateDepthBuffer?: boolean;
  45890. /**
  45891. * Define if a stencil buffer is required
  45892. */
  45893. generateStencilBuffer?: boolean;
  45894. /**
  45895. * Define if a depth texture is required instead of a depth buffer
  45896. */
  45897. generateDepthTexture?: boolean;
  45898. /**
  45899. * Define the number of desired draw buffers
  45900. */
  45901. textureCount?: number;
  45902. /**
  45903. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45904. */
  45905. doNotChangeAspectRatio?: boolean;
  45906. /**
  45907. * Define the default type of the buffers we are creating
  45908. */
  45909. defaultType?: number;
  45910. }
  45911. /**
  45912. * A multi render target, like a render target provides the ability to render to a texture.
  45913. * Unlike the render target, it can render to several draw buffers in one draw.
  45914. * This is specially interesting in deferred rendering or for any effects requiring more than
  45915. * just one color from a single pass.
  45916. */
  45917. export class MultiRenderTarget extends RenderTargetTexture {
  45918. private _internalTextures;
  45919. private _textures;
  45920. private _multiRenderTargetOptions;
  45921. /**
  45922. * Get if draw buffers are currently supported by the used hardware and browser.
  45923. */
  45924. readonly isSupported: boolean;
  45925. /**
  45926. * Get the list of textures generated by the multi render target.
  45927. */
  45928. readonly textures: Texture[];
  45929. /**
  45930. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45931. */
  45932. readonly depthTexture: Texture;
  45933. /**
  45934. * Set the wrapping mode on U of all the textures we are rendering to.
  45935. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45936. */
  45937. wrapU: number;
  45938. /**
  45939. * Set the wrapping mode on V of all the textures we are rendering to.
  45940. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45941. */
  45942. wrapV: number;
  45943. /**
  45944. * Instantiate a new multi render target texture.
  45945. * A multi render target, like a render target provides the ability to render to a texture.
  45946. * Unlike the render target, it can render to several draw buffers in one draw.
  45947. * This is specially interesting in deferred rendering or for any effects requiring more than
  45948. * just one color from a single pass.
  45949. * @param name Define the name of the texture
  45950. * @param size Define the size of the buffers to render to
  45951. * @param count Define the number of target we are rendering into
  45952. * @param scene Define the scene the texture belongs to
  45953. * @param options Define the options used to create the multi render target
  45954. */
  45955. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45956. /** @hidden */
  45957. _rebuild(): void;
  45958. private _createInternalTextures;
  45959. private _createTextures;
  45960. /**
  45961. * Define the number of samples used if MSAA is enabled.
  45962. */
  45963. samples: number;
  45964. /**
  45965. * Resize all the textures in the multi render target.
  45966. * Be carrefull as it will recreate all the data in the new texture.
  45967. * @param size Define the new size
  45968. */
  45969. resize(size: any): void;
  45970. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45971. /**
  45972. * Dispose the render targets and their associated resources
  45973. */
  45974. dispose(): void;
  45975. /**
  45976. * Release all the underlying texture used as draw buffers.
  45977. */
  45978. releaseInternalTextures(): void;
  45979. }
  45980. }
  45981. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45982. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45983. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45984. import { Nullable } from "babylonjs/types";
  45985. module "babylonjs/Engines/thinEngine" {
  45986. interface ThinEngine {
  45987. /**
  45988. * Unbind a list of render target textures from the webGL context
  45989. * This is used only when drawBuffer extension or webGL2 are active
  45990. * @param textures defines the render target textures to unbind
  45991. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45992. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45993. */
  45994. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45995. /**
  45996. * Create a multi render target texture
  45997. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45998. * @param size defines the size of the texture
  45999. * @param options defines the creation options
  46000. * @returns the cube texture as an InternalTexture
  46001. */
  46002. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46003. /**
  46004. * Update the sample count for a given multiple render target texture
  46005. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46006. * @param textures defines the textures to update
  46007. * @param samples defines the sample count to set
  46008. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46009. */
  46010. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46011. }
  46012. }
  46013. }
  46014. declare module "babylonjs/Engines/Extensions/index" {
  46015. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46016. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46017. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46018. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46019. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46020. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46021. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46022. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46023. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46024. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46025. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46026. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46027. }
  46028. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46029. import { Nullable } from "babylonjs/types";
  46030. /**
  46031. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46032. */
  46033. export interface CubeMapInfo {
  46034. /**
  46035. * The pixel array for the front face.
  46036. * This is stored in format, left to right, up to down format.
  46037. */
  46038. front: Nullable<ArrayBufferView>;
  46039. /**
  46040. * The pixel array for the back face.
  46041. * This is stored in format, left to right, up to down format.
  46042. */
  46043. back: Nullable<ArrayBufferView>;
  46044. /**
  46045. * The pixel array for the left face.
  46046. * This is stored in format, left to right, up to down format.
  46047. */
  46048. left: Nullable<ArrayBufferView>;
  46049. /**
  46050. * The pixel array for the right face.
  46051. * This is stored in format, left to right, up to down format.
  46052. */
  46053. right: Nullable<ArrayBufferView>;
  46054. /**
  46055. * The pixel array for the up face.
  46056. * This is stored in format, left to right, up to down format.
  46057. */
  46058. up: Nullable<ArrayBufferView>;
  46059. /**
  46060. * The pixel array for the down face.
  46061. * This is stored in format, left to right, up to down format.
  46062. */
  46063. down: Nullable<ArrayBufferView>;
  46064. /**
  46065. * The size of the cubemap stored.
  46066. *
  46067. * Each faces will be size * size pixels.
  46068. */
  46069. size: number;
  46070. /**
  46071. * The format of the texture.
  46072. *
  46073. * RGBA, RGB.
  46074. */
  46075. format: number;
  46076. /**
  46077. * The type of the texture data.
  46078. *
  46079. * UNSIGNED_INT, FLOAT.
  46080. */
  46081. type: number;
  46082. /**
  46083. * Specifies whether the texture is in gamma space.
  46084. */
  46085. gammaSpace: boolean;
  46086. }
  46087. /**
  46088. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46089. */
  46090. export class PanoramaToCubeMapTools {
  46091. private static FACE_FRONT;
  46092. private static FACE_BACK;
  46093. private static FACE_RIGHT;
  46094. private static FACE_LEFT;
  46095. private static FACE_DOWN;
  46096. private static FACE_UP;
  46097. /**
  46098. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46099. *
  46100. * @param float32Array The source data.
  46101. * @param inputWidth The width of the input panorama.
  46102. * @param inputHeight The height of the input panorama.
  46103. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46104. * @return The cubemap data
  46105. */
  46106. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46107. private static CreateCubemapTexture;
  46108. private static CalcProjectionSpherical;
  46109. }
  46110. }
  46111. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46112. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46113. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46114. import { Nullable } from "babylonjs/types";
  46115. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46116. /**
  46117. * Helper class dealing with the extraction of spherical polynomial dataArray
  46118. * from a cube map.
  46119. */
  46120. export class CubeMapToSphericalPolynomialTools {
  46121. private static FileFaces;
  46122. /**
  46123. * Converts a texture to the according Spherical Polynomial data.
  46124. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46125. *
  46126. * @param texture The texture to extract the information from.
  46127. * @return The Spherical Polynomial data.
  46128. */
  46129. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46130. /**
  46131. * Converts a cubemap to the according Spherical Polynomial data.
  46132. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46133. *
  46134. * @param cubeInfo The Cube map to extract the information from.
  46135. * @return The Spherical Polynomial data.
  46136. */
  46137. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46138. }
  46139. }
  46140. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46141. import { Nullable } from "babylonjs/types";
  46142. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46143. module "babylonjs/Materials/Textures/baseTexture" {
  46144. interface BaseTexture {
  46145. /**
  46146. * Get the polynomial representation of the texture data.
  46147. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46148. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46149. */
  46150. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46151. }
  46152. }
  46153. }
  46154. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46155. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46156. /** @hidden */
  46157. export var rgbdEncodePixelShader: {
  46158. name: string;
  46159. shader: string;
  46160. };
  46161. }
  46162. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46163. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46164. /** @hidden */
  46165. export var rgbdDecodePixelShader: {
  46166. name: string;
  46167. shader: string;
  46168. };
  46169. }
  46170. declare module "babylonjs/Misc/environmentTextureTools" {
  46171. import { Nullable } from "babylonjs/types";
  46172. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46173. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46174. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46175. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46176. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46177. import "babylonjs/Shaders/rgbdEncode.fragment";
  46178. import "babylonjs/Shaders/rgbdDecode.fragment";
  46179. /**
  46180. * Raw texture data and descriptor sufficient for WebGL texture upload
  46181. */
  46182. export interface EnvironmentTextureInfo {
  46183. /**
  46184. * Version of the environment map
  46185. */
  46186. version: number;
  46187. /**
  46188. * Width of image
  46189. */
  46190. width: number;
  46191. /**
  46192. * Irradiance information stored in the file.
  46193. */
  46194. irradiance: any;
  46195. /**
  46196. * Specular information stored in the file.
  46197. */
  46198. specular: any;
  46199. }
  46200. /**
  46201. * Defines One Image in the file. It requires only the position in the file
  46202. * as well as the length.
  46203. */
  46204. interface BufferImageData {
  46205. /**
  46206. * Length of the image data.
  46207. */
  46208. length: number;
  46209. /**
  46210. * Position of the data from the null terminator delimiting the end of the JSON.
  46211. */
  46212. position: number;
  46213. }
  46214. /**
  46215. * Defines the specular data enclosed in the file.
  46216. * This corresponds to the version 1 of the data.
  46217. */
  46218. export interface EnvironmentTextureSpecularInfoV1 {
  46219. /**
  46220. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46221. */
  46222. specularDataPosition?: number;
  46223. /**
  46224. * This contains all the images data needed to reconstruct the cubemap.
  46225. */
  46226. mipmaps: Array<BufferImageData>;
  46227. /**
  46228. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46229. */
  46230. lodGenerationScale: number;
  46231. }
  46232. /**
  46233. * Sets of helpers addressing the serialization and deserialization of environment texture
  46234. * stored in a BabylonJS env file.
  46235. * Those files are usually stored as .env files.
  46236. */
  46237. export class EnvironmentTextureTools {
  46238. /**
  46239. * Magic number identifying the env file.
  46240. */
  46241. private static _MagicBytes;
  46242. /**
  46243. * Gets the environment info from an env file.
  46244. * @param data The array buffer containing the .env bytes.
  46245. * @returns the environment file info (the json header) if successfully parsed.
  46246. */
  46247. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46248. /**
  46249. * Creates an environment texture from a loaded cube texture.
  46250. * @param texture defines the cube texture to convert in env file
  46251. * @return a promise containing the environment data if succesfull.
  46252. */
  46253. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46254. /**
  46255. * Creates a JSON representation of the spherical data.
  46256. * @param texture defines the texture containing the polynomials
  46257. * @return the JSON representation of the spherical info
  46258. */
  46259. private static _CreateEnvTextureIrradiance;
  46260. /**
  46261. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46262. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46263. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46264. * @return the views described by info providing access to the underlying buffer
  46265. */
  46266. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46267. /**
  46268. * Uploads the texture info contained in the env file to the GPU.
  46269. * @param texture defines the internal texture to upload to
  46270. * @param arrayBuffer defines the buffer cotaining the data to load
  46271. * @param info defines the texture info retrieved through the GetEnvInfo method
  46272. * @returns a promise
  46273. */
  46274. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46275. /**
  46276. * Uploads the levels of image data to the GPU.
  46277. * @param texture defines the internal texture to upload to
  46278. * @param imageData defines the array buffer views of image data [mipmap][face]
  46279. * @returns a promise
  46280. */
  46281. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46282. /**
  46283. * Uploads spherical polynomials information to the texture.
  46284. * @param texture defines the texture we are trying to upload the information to
  46285. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46286. */
  46287. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46288. /** @hidden */
  46289. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46290. }
  46291. }
  46292. declare module "babylonjs/Maths/math.vertexFormat" {
  46293. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46294. /**
  46295. * Contains position and normal vectors for a vertex
  46296. */
  46297. export class PositionNormalVertex {
  46298. /** the position of the vertex (defaut: 0,0,0) */
  46299. position: Vector3;
  46300. /** the normal of the vertex (defaut: 0,1,0) */
  46301. normal: Vector3;
  46302. /**
  46303. * Creates a PositionNormalVertex
  46304. * @param position the position of the vertex (defaut: 0,0,0)
  46305. * @param normal the normal of the vertex (defaut: 0,1,0)
  46306. */
  46307. constructor(
  46308. /** the position of the vertex (defaut: 0,0,0) */
  46309. position?: Vector3,
  46310. /** the normal of the vertex (defaut: 0,1,0) */
  46311. normal?: Vector3);
  46312. /**
  46313. * Clones the PositionNormalVertex
  46314. * @returns the cloned PositionNormalVertex
  46315. */
  46316. clone(): PositionNormalVertex;
  46317. }
  46318. /**
  46319. * Contains position, normal and uv vectors for a vertex
  46320. */
  46321. export class PositionNormalTextureVertex {
  46322. /** the position of the vertex (defaut: 0,0,0) */
  46323. position: Vector3;
  46324. /** the normal of the vertex (defaut: 0,1,0) */
  46325. normal: Vector3;
  46326. /** the uv of the vertex (default: 0,0) */
  46327. uv: Vector2;
  46328. /**
  46329. * Creates a PositionNormalTextureVertex
  46330. * @param position the position of the vertex (defaut: 0,0,0)
  46331. * @param normal the normal of the vertex (defaut: 0,1,0)
  46332. * @param uv the uv of the vertex (default: 0,0)
  46333. */
  46334. constructor(
  46335. /** the position of the vertex (defaut: 0,0,0) */
  46336. position?: Vector3,
  46337. /** the normal of the vertex (defaut: 0,1,0) */
  46338. normal?: Vector3,
  46339. /** the uv of the vertex (default: 0,0) */
  46340. uv?: Vector2);
  46341. /**
  46342. * Clones the PositionNormalTextureVertex
  46343. * @returns the cloned PositionNormalTextureVertex
  46344. */
  46345. clone(): PositionNormalTextureVertex;
  46346. }
  46347. }
  46348. declare module "babylonjs/Maths/math" {
  46349. export * from "babylonjs/Maths/math.axis";
  46350. export * from "babylonjs/Maths/math.color";
  46351. export * from "babylonjs/Maths/math.constants";
  46352. export * from "babylonjs/Maths/math.frustum";
  46353. export * from "babylonjs/Maths/math.path";
  46354. export * from "babylonjs/Maths/math.plane";
  46355. export * from "babylonjs/Maths/math.size";
  46356. export * from "babylonjs/Maths/math.vector";
  46357. export * from "babylonjs/Maths/math.vertexFormat";
  46358. export * from "babylonjs/Maths/math.viewport";
  46359. }
  46360. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46361. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46362. /** @hidden */
  46363. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46364. private _genericAttributeLocation;
  46365. private _varyingLocationCount;
  46366. private _varyingLocationMap;
  46367. private _replacements;
  46368. private _textureCount;
  46369. private _uniforms;
  46370. lineProcessor(line: string): string;
  46371. attributeProcessor(attribute: string): string;
  46372. varyingProcessor(varying: string, isFragment: boolean): string;
  46373. uniformProcessor(uniform: string): string;
  46374. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46375. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46376. }
  46377. }
  46378. declare module "babylonjs/Engines/nativeEngine" {
  46379. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46380. import { Engine } from "babylonjs/Engines/engine";
  46381. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46382. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46384. import { Effect } from "babylonjs/Materials/effect";
  46385. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46386. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46387. import { Scene } from "babylonjs/scene";
  46388. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46389. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46390. /**
  46391. * Container for accessors for natively-stored mesh data buffers.
  46392. */
  46393. class NativeDataBuffer extends DataBuffer {
  46394. /**
  46395. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46396. */
  46397. nativeIndexBuffer?: any;
  46398. /**
  46399. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46400. */
  46401. nativeVertexBuffer?: any;
  46402. }
  46403. /** @hidden */
  46404. export class NativeEngine extends Engine {
  46405. private readonly _native;
  46406. getHardwareScalingLevel(): number;
  46407. constructor();
  46408. /**
  46409. * Can be used to override the current requestAnimationFrame requester.
  46410. * @hidden
  46411. */
  46412. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46413. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46414. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46415. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46416. recordVertexArrayObject(vertexBuffers: {
  46417. [key: string]: VertexBuffer;
  46418. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46419. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46420. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46421. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46422. /**
  46423. * Draw a list of indexed primitives
  46424. * @param fillMode defines the primitive to use
  46425. * @param indexStart defines the starting index
  46426. * @param indexCount defines the number of index to draw
  46427. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46428. */
  46429. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46430. /**
  46431. * Draw a list of unindexed primitives
  46432. * @param fillMode defines the primitive to use
  46433. * @param verticesStart defines the index of first vertex to draw
  46434. * @param verticesCount defines the count of vertices to draw
  46435. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46436. */
  46437. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46438. createPipelineContext(): IPipelineContext;
  46439. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46440. /** @hidden */
  46441. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46442. /** @hidden */
  46443. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46444. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46445. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46446. protected _setProgram(program: WebGLProgram): void;
  46447. _releaseEffect(effect: Effect): void;
  46448. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46449. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46450. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46451. bindSamplers(effect: Effect): void;
  46452. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46453. getRenderWidth(useScreen?: boolean): number;
  46454. getRenderHeight(useScreen?: boolean): number;
  46455. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46456. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46457. /**
  46458. * Set the z offset to apply to current rendering
  46459. * @param value defines the offset to apply
  46460. */
  46461. setZOffset(value: number): void;
  46462. /**
  46463. * Gets the current value of the zOffset
  46464. * @returns the current zOffset state
  46465. */
  46466. getZOffset(): number;
  46467. /**
  46468. * Enable or disable depth buffering
  46469. * @param enable defines the state to set
  46470. */
  46471. setDepthBuffer(enable: boolean): void;
  46472. /**
  46473. * Gets a boolean indicating if depth writing is enabled
  46474. * @returns the current depth writing state
  46475. */
  46476. getDepthWrite(): boolean;
  46477. /**
  46478. * Enable or disable depth writing
  46479. * @param enable defines the state to set
  46480. */
  46481. setDepthWrite(enable: boolean): void;
  46482. /**
  46483. * Enable or disable color writing
  46484. * @param enable defines the state to set
  46485. */
  46486. setColorWrite(enable: boolean): void;
  46487. /**
  46488. * Gets a boolean indicating if color writing is enabled
  46489. * @returns the current color writing state
  46490. */
  46491. getColorWrite(): boolean;
  46492. /**
  46493. * Sets alpha constants used by some alpha blending modes
  46494. * @param r defines the red component
  46495. * @param g defines the green component
  46496. * @param b defines the blue component
  46497. * @param a defines the alpha component
  46498. */
  46499. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46500. /**
  46501. * Sets the current alpha mode
  46502. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46503. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46504. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46505. */
  46506. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46507. /**
  46508. * Gets the current alpha mode
  46509. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46510. * @returns the current alpha mode
  46511. */
  46512. getAlphaMode(): number;
  46513. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46514. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46515. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46516. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46517. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46518. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46519. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46520. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46521. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46522. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46523. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46524. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46525. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46526. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46527. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46528. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46529. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46530. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46531. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46532. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46533. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46534. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46535. wipeCaches(bruteForce?: boolean): void;
  46536. _createTexture(): WebGLTexture;
  46537. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46538. /**
  46539. * Usually called from BABYLON.Texture.ts.
  46540. * Passed information to create a WebGLTexture
  46541. * @param urlArg defines a value which contains one of the following:
  46542. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46543. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46544. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46545. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46546. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46547. * @param scene needed for loading to the correct scene
  46548. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46549. * @param onLoad optional callback to be called upon successful completion
  46550. * @param onError optional callback to be called upon failure
  46551. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46552. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46553. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46554. * @param forcedExtension defines the extension to use to pick the right loader
  46555. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46556. */
  46557. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  46558. /**
  46559. * Creates a cube texture
  46560. * @param rootUrl defines the url where the files to load is located
  46561. * @param scene defines the current scene
  46562. * @param files defines the list of files to load (1 per face)
  46563. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46564. * @param onLoad defines an optional callback raised when the texture is loaded
  46565. * @param onError defines an optional callback raised if there is an issue to load the texture
  46566. * @param format defines the format of the data
  46567. * @param forcedExtension defines the extension to use to pick the right loader
  46568. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46569. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46570. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46571. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46572. * @returns the cube texture as an InternalTexture
  46573. */
  46574. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  46575. private _getSamplingFilter;
  46576. private static _GetNativeTextureFormat;
  46577. createRenderTargetTexture(size: number | {
  46578. width: number;
  46579. height: number;
  46580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46581. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46582. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46583. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46584. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46585. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46586. /**
  46587. * Updates a dynamic vertex buffer.
  46588. * @param vertexBuffer the vertex buffer to update
  46589. * @param data the data used to update the vertex buffer
  46590. * @param byteOffset the byte offset of the data (optional)
  46591. * @param byteLength the byte length of the data (optional)
  46592. */
  46593. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46594. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46595. private _updateAnisotropicLevel;
  46596. private _getAddressMode;
  46597. /** @hidden */
  46598. _bindTexture(channel: number, texture: InternalTexture): void;
  46599. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46600. releaseEffects(): void;
  46601. /** @hidden */
  46602. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46603. /** @hidden */
  46604. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46605. /** @hidden */
  46606. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46607. /** @hidden */
  46608. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46609. }
  46610. }
  46611. declare module "babylonjs/Engines/index" {
  46612. export * from "babylonjs/Engines/constants";
  46613. export * from "babylonjs/Engines/engineCapabilities";
  46614. export * from "babylonjs/Engines/instancingAttributeInfo";
  46615. export * from "babylonjs/Engines/thinEngine";
  46616. export * from "babylonjs/Engines/engine";
  46617. export * from "babylonjs/Engines/engineStore";
  46618. export * from "babylonjs/Engines/nullEngine";
  46619. export * from "babylonjs/Engines/Extensions/index";
  46620. export * from "babylonjs/Engines/IPipelineContext";
  46621. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46622. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46623. export * from "babylonjs/Engines/nativeEngine";
  46624. }
  46625. declare module "babylonjs/Events/clipboardEvents" {
  46626. /**
  46627. * Gather the list of clipboard event types as constants.
  46628. */
  46629. export class ClipboardEventTypes {
  46630. /**
  46631. * The clipboard event is fired when a copy command is active (pressed).
  46632. */
  46633. static readonly COPY: number;
  46634. /**
  46635. * The clipboard event is fired when a cut command is active (pressed).
  46636. */
  46637. static readonly CUT: number;
  46638. /**
  46639. * The clipboard event is fired when a paste command is active (pressed).
  46640. */
  46641. static readonly PASTE: number;
  46642. }
  46643. /**
  46644. * This class is used to store clipboard related info for the onClipboardObservable event.
  46645. */
  46646. export class ClipboardInfo {
  46647. /**
  46648. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46649. */
  46650. type: number;
  46651. /**
  46652. * Defines the related dom event
  46653. */
  46654. event: ClipboardEvent;
  46655. /**
  46656. *Creates an instance of ClipboardInfo.
  46657. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46658. * @param event Defines the related dom event
  46659. */
  46660. constructor(
  46661. /**
  46662. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46663. */
  46664. type: number,
  46665. /**
  46666. * Defines the related dom event
  46667. */
  46668. event: ClipboardEvent);
  46669. /**
  46670. * Get the clipboard event's type from the keycode.
  46671. * @param keyCode Defines the keyCode for the current keyboard event.
  46672. * @return {number}
  46673. */
  46674. static GetTypeFromCharacter(keyCode: number): number;
  46675. }
  46676. }
  46677. declare module "babylonjs/Events/index" {
  46678. export * from "babylonjs/Events/keyboardEvents";
  46679. export * from "babylonjs/Events/pointerEvents";
  46680. export * from "babylonjs/Events/clipboardEvents";
  46681. }
  46682. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46683. import { Scene } from "babylonjs/scene";
  46684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46685. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46686. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46687. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46688. /**
  46689. * Google Daydream controller
  46690. */
  46691. export class DaydreamController extends WebVRController {
  46692. /**
  46693. * Base Url for the controller model.
  46694. */
  46695. static MODEL_BASE_URL: string;
  46696. /**
  46697. * File name for the controller model.
  46698. */
  46699. static MODEL_FILENAME: string;
  46700. /**
  46701. * Gamepad Id prefix used to identify Daydream Controller.
  46702. */
  46703. static readonly GAMEPAD_ID_PREFIX: string;
  46704. /**
  46705. * Creates a new DaydreamController from a gamepad
  46706. * @param vrGamepad the gamepad that the controller should be created from
  46707. */
  46708. constructor(vrGamepad: any);
  46709. /**
  46710. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46711. * @param scene scene in which to add meshes
  46712. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46713. */
  46714. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46715. /**
  46716. * Called once for each button that changed state since the last frame
  46717. * @param buttonIdx Which button index changed
  46718. * @param state New state of the button
  46719. * @param changes Which properties on the state changed since last frame
  46720. */
  46721. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46722. }
  46723. }
  46724. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46725. import { Scene } from "babylonjs/scene";
  46726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46727. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46728. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46729. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46730. /**
  46731. * Gear VR Controller
  46732. */
  46733. export class GearVRController extends WebVRController {
  46734. /**
  46735. * Base Url for the controller model.
  46736. */
  46737. static MODEL_BASE_URL: string;
  46738. /**
  46739. * File name for the controller model.
  46740. */
  46741. static MODEL_FILENAME: string;
  46742. /**
  46743. * Gamepad Id prefix used to identify this controller.
  46744. */
  46745. static readonly GAMEPAD_ID_PREFIX: string;
  46746. private readonly _buttonIndexToObservableNameMap;
  46747. /**
  46748. * Creates a new GearVRController from a gamepad
  46749. * @param vrGamepad the gamepad that the controller should be created from
  46750. */
  46751. constructor(vrGamepad: any);
  46752. /**
  46753. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46754. * @param scene scene in which to add meshes
  46755. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46756. */
  46757. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46758. /**
  46759. * Called once for each button that changed state since the last frame
  46760. * @param buttonIdx Which button index changed
  46761. * @param state New state of the button
  46762. * @param changes Which properties on the state changed since last frame
  46763. */
  46764. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46765. }
  46766. }
  46767. declare module "babylonjs/Gamepads/Controllers/index" {
  46768. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46769. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46770. export * from "babylonjs/Gamepads/Controllers/genericController";
  46771. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46772. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46773. export * from "babylonjs/Gamepads/Controllers/viveController";
  46774. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46775. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46776. }
  46777. declare module "babylonjs/Gamepads/index" {
  46778. export * from "babylonjs/Gamepads/Controllers/index";
  46779. export * from "babylonjs/Gamepads/gamepad";
  46780. export * from "babylonjs/Gamepads/gamepadManager";
  46781. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46782. export * from "babylonjs/Gamepads/xboxGamepad";
  46783. export * from "babylonjs/Gamepads/dualShockGamepad";
  46784. }
  46785. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46786. import { Scene } from "babylonjs/scene";
  46787. import { Vector4 } from "babylonjs/Maths/math.vector";
  46788. import { Color4 } from "babylonjs/Maths/math.color";
  46789. import { Mesh } from "babylonjs/Meshes/mesh";
  46790. import { Nullable } from "babylonjs/types";
  46791. /**
  46792. * Class containing static functions to help procedurally build meshes
  46793. */
  46794. export class PolyhedronBuilder {
  46795. /**
  46796. * Creates a polyhedron mesh
  46797. * * 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
  46798. * * The parameter `size` (positive float, default 1) sets the polygon size
  46799. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46800. * * 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`
  46801. * * 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
  46802. * * 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)`)
  46803. * * 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
  46804. * * 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
  46805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46808. * @param name defines the name of the mesh
  46809. * @param options defines the options used to create the mesh
  46810. * @param scene defines the hosting scene
  46811. * @returns the polyhedron mesh
  46812. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46813. */
  46814. static CreatePolyhedron(name: string, options: {
  46815. type?: number;
  46816. size?: number;
  46817. sizeX?: number;
  46818. sizeY?: number;
  46819. sizeZ?: number;
  46820. custom?: any;
  46821. faceUV?: Vector4[];
  46822. faceColors?: Color4[];
  46823. flat?: boolean;
  46824. updatable?: boolean;
  46825. sideOrientation?: number;
  46826. frontUVs?: Vector4;
  46827. backUVs?: Vector4;
  46828. }, scene?: Nullable<Scene>): Mesh;
  46829. }
  46830. }
  46831. declare module "babylonjs/Gizmos/scaleGizmo" {
  46832. import { Observable } from "babylonjs/Misc/observable";
  46833. import { Nullable } from "babylonjs/types";
  46834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46835. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46836. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46837. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46838. /**
  46839. * Gizmo that enables scaling a mesh along 3 axis
  46840. */
  46841. export class ScaleGizmo extends Gizmo {
  46842. /**
  46843. * Internal gizmo used for interactions on the x axis
  46844. */
  46845. xGizmo: AxisScaleGizmo;
  46846. /**
  46847. * Internal gizmo used for interactions on the y axis
  46848. */
  46849. yGizmo: AxisScaleGizmo;
  46850. /**
  46851. * Internal gizmo used for interactions on the z axis
  46852. */
  46853. zGizmo: AxisScaleGizmo;
  46854. /**
  46855. * Internal gizmo used to scale all axis equally
  46856. */
  46857. uniformScaleGizmo: AxisScaleGizmo;
  46858. private _meshAttached;
  46859. private _updateGizmoRotationToMatchAttachedMesh;
  46860. private _snapDistance;
  46861. private _scaleRatio;
  46862. private _uniformScalingMesh;
  46863. private _octahedron;
  46864. /** Fires an event when any of it's sub gizmos are dragged */
  46865. onDragStartObservable: Observable<unknown>;
  46866. /** Fires an event when any of it's sub gizmos are released from dragging */
  46867. onDragEndObservable: Observable<unknown>;
  46868. attachedMesh: Nullable<AbstractMesh>;
  46869. /**
  46870. * Creates a ScaleGizmo
  46871. * @param gizmoLayer The utility layer the gizmo will be added to
  46872. */
  46873. constructor(gizmoLayer?: UtilityLayerRenderer);
  46874. updateGizmoRotationToMatchAttachedMesh: boolean;
  46875. /**
  46876. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46877. */
  46878. snapDistance: number;
  46879. /**
  46880. * Ratio for the scale of the gizmo (Default: 1)
  46881. */
  46882. scaleRatio: number;
  46883. /**
  46884. * Disposes of the gizmo
  46885. */
  46886. dispose(): void;
  46887. }
  46888. }
  46889. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46890. import { Observable } from "babylonjs/Misc/observable";
  46891. import { Nullable } from "babylonjs/types";
  46892. import { Vector3 } from "babylonjs/Maths/math.vector";
  46893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46894. import { Mesh } from "babylonjs/Meshes/mesh";
  46895. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46896. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46897. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46898. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46899. import { Color3 } from "babylonjs/Maths/math.color";
  46900. /**
  46901. * Single axis scale gizmo
  46902. */
  46903. export class AxisScaleGizmo extends Gizmo {
  46904. /**
  46905. * Drag behavior responsible for the gizmos dragging interactions
  46906. */
  46907. dragBehavior: PointerDragBehavior;
  46908. private _pointerObserver;
  46909. /**
  46910. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46911. */
  46912. snapDistance: number;
  46913. /**
  46914. * Event that fires each time the gizmo snaps to a new location.
  46915. * * snapDistance is the the change in distance
  46916. */
  46917. onSnapObservable: Observable<{
  46918. snapDistance: number;
  46919. }>;
  46920. /**
  46921. * If the scaling operation should be done on all axis (default: false)
  46922. */
  46923. uniformScaling: boolean;
  46924. private _isEnabled;
  46925. private _parent;
  46926. private _arrow;
  46927. private _coloredMaterial;
  46928. private _hoverMaterial;
  46929. /**
  46930. * Creates an AxisScaleGizmo
  46931. * @param gizmoLayer The utility layer the gizmo will be added to
  46932. * @param dragAxis The axis which the gizmo will be able to scale on
  46933. * @param color The color of the gizmo
  46934. */
  46935. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46936. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46937. /**
  46938. * If the gizmo is enabled
  46939. */
  46940. isEnabled: boolean;
  46941. /**
  46942. * Disposes of the gizmo
  46943. */
  46944. dispose(): void;
  46945. /**
  46946. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46947. * @param mesh The mesh to replace the default mesh of the gizmo
  46948. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46949. */
  46950. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46951. }
  46952. }
  46953. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46954. import { Observable } from "babylonjs/Misc/observable";
  46955. import { Nullable } from "babylonjs/types";
  46956. import { Vector3 } from "babylonjs/Maths/math.vector";
  46957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46958. import { Mesh } from "babylonjs/Meshes/mesh";
  46959. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46960. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46961. import { Color3 } from "babylonjs/Maths/math.color";
  46962. import "babylonjs/Meshes/Builders/boxBuilder";
  46963. /**
  46964. * Bounding box gizmo
  46965. */
  46966. export class BoundingBoxGizmo extends Gizmo {
  46967. private _lineBoundingBox;
  46968. private _rotateSpheresParent;
  46969. private _scaleBoxesParent;
  46970. private _boundingDimensions;
  46971. private _renderObserver;
  46972. private _pointerObserver;
  46973. private _scaleDragSpeed;
  46974. private _tmpQuaternion;
  46975. private _tmpVector;
  46976. private _tmpRotationMatrix;
  46977. /**
  46978. * 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)
  46979. */
  46980. ignoreChildren: boolean;
  46981. /**
  46982. * 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)
  46983. */
  46984. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46985. /**
  46986. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46987. */
  46988. rotationSphereSize: number;
  46989. /**
  46990. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46991. */
  46992. scaleBoxSize: number;
  46993. /**
  46994. * 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)
  46995. */
  46996. fixedDragMeshScreenSize: boolean;
  46997. /**
  46998. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46999. */
  47000. fixedDragMeshScreenSizeDistanceFactor: number;
  47001. /**
  47002. * Fired when a rotation sphere or scale box is dragged
  47003. */
  47004. onDragStartObservable: Observable<{}>;
  47005. /**
  47006. * Fired when a scale box is dragged
  47007. */
  47008. onScaleBoxDragObservable: Observable<{}>;
  47009. /**
  47010. * Fired when a scale box drag is ended
  47011. */
  47012. onScaleBoxDragEndObservable: Observable<{}>;
  47013. /**
  47014. * Fired when a rotation sphere is dragged
  47015. */
  47016. onRotationSphereDragObservable: Observable<{}>;
  47017. /**
  47018. * Fired when a rotation sphere drag is ended
  47019. */
  47020. onRotationSphereDragEndObservable: Observable<{}>;
  47021. /**
  47022. * 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)
  47023. */
  47024. scalePivot: Nullable<Vector3>;
  47025. /**
  47026. * Mesh used as a pivot to rotate the attached mesh
  47027. */
  47028. private _anchorMesh;
  47029. private _existingMeshScale;
  47030. private _dragMesh;
  47031. private pointerDragBehavior;
  47032. private coloredMaterial;
  47033. private hoverColoredMaterial;
  47034. /**
  47035. * Sets the color of the bounding box gizmo
  47036. * @param color the color to set
  47037. */
  47038. setColor(color: Color3): void;
  47039. /**
  47040. * Creates an BoundingBoxGizmo
  47041. * @param gizmoLayer The utility layer the gizmo will be added to
  47042. * @param color The color of the gizmo
  47043. */
  47044. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47045. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47046. private _selectNode;
  47047. /**
  47048. * Updates the bounding box information for the Gizmo
  47049. */
  47050. updateBoundingBox(): void;
  47051. private _updateRotationSpheres;
  47052. private _updateScaleBoxes;
  47053. /**
  47054. * Enables rotation on the specified axis and disables rotation on the others
  47055. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47056. */
  47057. setEnabledRotationAxis(axis: string): void;
  47058. /**
  47059. * Enables/disables scaling
  47060. * @param enable if scaling should be enabled
  47061. */
  47062. setEnabledScaling(enable: boolean): void;
  47063. private _updateDummy;
  47064. /**
  47065. * Enables a pointer drag behavior on the bounding box of the gizmo
  47066. */
  47067. enableDragBehavior(): void;
  47068. /**
  47069. * Disposes of the gizmo
  47070. */
  47071. dispose(): void;
  47072. /**
  47073. * 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)
  47074. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47075. * @returns the bounding box mesh with the passed in mesh as a child
  47076. */
  47077. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47078. /**
  47079. * CustomMeshes are not supported by this gizmo
  47080. * @param mesh The mesh to replace the default mesh of the gizmo
  47081. */
  47082. setCustomMesh(mesh: Mesh): void;
  47083. }
  47084. }
  47085. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47086. import { Observable } from "babylonjs/Misc/observable";
  47087. import { Nullable } from "babylonjs/types";
  47088. import { Vector3 } from "babylonjs/Maths/math.vector";
  47089. import { Color3 } from "babylonjs/Maths/math.color";
  47090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47091. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47092. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47093. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47094. import "babylonjs/Meshes/Builders/linesBuilder";
  47095. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47096. /**
  47097. * Single plane rotation gizmo
  47098. */
  47099. export class PlaneRotationGizmo extends Gizmo {
  47100. /**
  47101. * Drag behavior responsible for the gizmos dragging interactions
  47102. */
  47103. dragBehavior: PointerDragBehavior;
  47104. private _pointerObserver;
  47105. /**
  47106. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47107. */
  47108. snapDistance: number;
  47109. /**
  47110. * Event that fires each time the gizmo snaps to a new location.
  47111. * * snapDistance is the the change in distance
  47112. */
  47113. onSnapObservable: Observable<{
  47114. snapDistance: number;
  47115. }>;
  47116. private _isEnabled;
  47117. private _parent;
  47118. /**
  47119. * Creates a PlaneRotationGizmo
  47120. * @param gizmoLayer The utility layer the gizmo will be added to
  47121. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47122. * @param color The color of the gizmo
  47123. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47124. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47125. */
  47126. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47127. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47128. /**
  47129. * If the gizmo is enabled
  47130. */
  47131. isEnabled: boolean;
  47132. /**
  47133. * Disposes of the gizmo
  47134. */
  47135. dispose(): void;
  47136. }
  47137. }
  47138. declare module "babylonjs/Gizmos/rotationGizmo" {
  47139. import { Observable } from "babylonjs/Misc/observable";
  47140. import { Nullable } from "babylonjs/types";
  47141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47142. import { Mesh } from "babylonjs/Meshes/mesh";
  47143. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47144. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47145. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47146. /**
  47147. * Gizmo that enables rotating a mesh along 3 axis
  47148. */
  47149. export class RotationGizmo extends Gizmo {
  47150. /**
  47151. * Internal gizmo used for interactions on the x axis
  47152. */
  47153. xGizmo: PlaneRotationGizmo;
  47154. /**
  47155. * Internal gizmo used for interactions on the y axis
  47156. */
  47157. yGizmo: PlaneRotationGizmo;
  47158. /**
  47159. * Internal gizmo used for interactions on the z axis
  47160. */
  47161. zGizmo: PlaneRotationGizmo;
  47162. /** Fires an event when any of it's sub gizmos are dragged */
  47163. onDragStartObservable: Observable<unknown>;
  47164. /** Fires an event when any of it's sub gizmos are released from dragging */
  47165. onDragEndObservable: Observable<unknown>;
  47166. private _meshAttached;
  47167. attachedMesh: Nullable<AbstractMesh>;
  47168. /**
  47169. * Creates a RotationGizmo
  47170. * @param gizmoLayer The utility layer the gizmo will be added to
  47171. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47172. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47173. */
  47174. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47175. updateGizmoRotationToMatchAttachedMesh: boolean;
  47176. /**
  47177. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47178. */
  47179. snapDistance: number;
  47180. /**
  47181. * Ratio for the scale of the gizmo (Default: 1)
  47182. */
  47183. scaleRatio: number;
  47184. /**
  47185. * Disposes of the gizmo
  47186. */
  47187. dispose(): void;
  47188. /**
  47189. * CustomMeshes are not supported by this gizmo
  47190. * @param mesh The mesh to replace the default mesh of the gizmo
  47191. */
  47192. setCustomMesh(mesh: Mesh): void;
  47193. }
  47194. }
  47195. declare module "babylonjs/Gizmos/gizmoManager" {
  47196. import { Observable } from "babylonjs/Misc/observable";
  47197. import { Nullable } from "babylonjs/types";
  47198. import { Scene, IDisposable } from "babylonjs/scene";
  47199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47200. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47201. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47202. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47203. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47204. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47205. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47206. /**
  47207. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47208. */
  47209. export class GizmoManager implements IDisposable {
  47210. private scene;
  47211. /**
  47212. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47213. */
  47214. gizmos: {
  47215. positionGizmo: Nullable<PositionGizmo>;
  47216. rotationGizmo: Nullable<RotationGizmo>;
  47217. scaleGizmo: Nullable<ScaleGizmo>;
  47218. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47219. };
  47220. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47221. clearGizmoOnEmptyPointerEvent: boolean;
  47222. /** Fires an event when the manager is attached to a mesh */
  47223. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47224. private _gizmosEnabled;
  47225. private _pointerObserver;
  47226. private _attachedMesh;
  47227. private _boundingBoxColor;
  47228. private _defaultUtilityLayer;
  47229. private _defaultKeepDepthUtilityLayer;
  47230. /**
  47231. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47232. */
  47233. boundingBoxDragBehavior: SixDofDragBehavior;
  47234. /**
  47235. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47236. */
  47237. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47238. /**
  47239. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47240. */
  47241. usePointerToAttachGizmos: boolean;
  47242. /**
  47243. * Utility layer that the bounding box gizmo belongs to
  47244. */
  47245. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47246. /**
  47247. * Utility layer that all gizmos besides bounding box belong to
  47248. */
  47249. readonly utilityLayer: UtilityLayerRenderer;
  47250. /**
  47251. * Instatiates a gizmo manager
  47252. * @param scene the scene to overlay the gizmos on top of
  47253. */
  47254. constructor(scene: Scene);
  47255. /**
  47256. * Attaches a set of gizmos to the specified mesh
  47257. * @param mesh The mesh the gizmo's should be attached to
  47258. */
  47259. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47260. /**
  47261. * If the position gizmo is enabled
  47262. */
  47263. positionGizmoEnabled: boolean;
  47264. /**
  47265. * If the rotation gizmo is enabled
  47266. */
  47267. rotationGizmoEnabled: boolean;
  47268. /**
  47269. * If the scale gizmo is enabled
  47270. */
  47271. scaleGizmoEnabled: boolean;
  47272. /**
  47273. * If the boundingBox gizmo is enabled
  47274. */
  47275. boundingBoxGizmoEnabled: boolean;
  47276. /**
  47277. * Disposes of the gizmo manager
  47278. */
  47279. dispose(): void;
  47280. }
  47281. }
  47282. declare module "babylonjs/Lights/directionalLight" {
  47283. import { Camera } from "babylonjs/Cameras/camera";
  47284. import { Scene } from "babylonjs/scene";
  47285. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47287. import { Light } from "babylonjs/Lights/light";
  47288. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47289. import { Effect } from "babylonjs/Materials/effect";
  47290. /**
  47291. * A directional light is defined by a direction (what a surprise!).
  47292. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47293. * 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.
  47294. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47295. */
  47296. export class DirectionalLight extends ShadowLight {
  47297. private _shadowFrustumSize;
  47298. /**
  47299. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47300. */
  47301. /**
  47302. * Specifies a fix frustum size for the shadow generation.
  47303. */
  47304. shadowFrustumSize: number;
  47305. private _shadowOrthoScale;
  47306. /**
  47307. * Gets the shadow projection scale against the optimal computed one.
  47308. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47309. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47310. */
  47311. /**
  47312. * Sets the shadow projection scale against the optimal computed one.
  47313. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47314. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47315. */
  47316. shadowOrthoScale: number;
  47317. /**
  47318. * Automatically compute the projection matrix to best fit (including all the casters)
  47319. * on each frame.
  47320. */
  47321. autoUpdateExtends: boolean;
  47322. private _orthoLeft;
  47323. private _orthoRight;
  47324. private _orthoTop;
  47325. private _orthoBottom;
  47326. /**
  47327. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47328. * The directional light is emitted from everywhere in the given direction.
  47329. * It can cast shadows.
  47330. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47331. * @param name The friendly name of the light
  47332. * @param direction The direction of the light
  47333. * @param scene The scene the light belongs to
  47334. */
  47335. constructor(name: string, direction: Vector3, scene: Scene);
  47336. /**
  47337. * Returns the string "DirectionalLight".
  47338. * @return The class name
  47339. */
  47340. getClassName(): string;
  47341. /**
  47342. * Returns the integer 1.
  47343. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47344. */
  47345. getTypeID(): number;
  47346. /**
  47347. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47348. * Returns the DirectionalLight Shadow projection matrix.
  47349. */
  47350. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47351. /**
  47352. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47353. * Returns the DirectionalLight Shadow projection matrix.
  47354. */
  47355. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47356. /**
  47357. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47358. * Returns the DirectionalLight Shadow projection matrix.
  47359. */
  47360. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47361. protected _buildUniformLayout(): void;
  47362. /**
  47363. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47364. * @param effect The effect to update
  47365. * @param lightIndex The index of the light in the effect to update
  47366. * @returns The directional light
  47367. */
  47368. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47369. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47370. /**
  47371. * Gets the minZ used for shadow according to both the scene and the light.
  47372. *
  47373. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47374. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47375. * @param activeCamera The camera we are returning the min for
  47376. * @returns the depth min z
  47377. */
  47378. getDepthMinZ(activeCamera: Camera): number;
  47379. /**
  47380. * Gets the maxZ used for shadow according to both the scene and the light.
  47381. *
  47382. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47383. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47384. * @param activeCamera The camera we are returning the max for
  47385. * @returns the depth max z
  47386. */
  47387. getDepthMaxZ(activeCamera: Camera): number;
  47388. /**
  47389. * Prepares the list of defines specific to the light type.
  47390. * @param defines the list of defines
  47391. * @param lightIndex defines the index of the light for the effect
  47392. */
  47393. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47394. }
  47395. }
  47396. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47397. import { Mesh } from "babylonjs/Meshes/mesh";
  47398. /**
  47399. * Class containing static functions to help procedurally build meshes
  47400. */
  47401. export class HemisphereBuilder {
  47402. /**
  47403. * Creates a hemisphere mesh
  47404. * @param name defines the name of the mesh
  47405. * @param options defines the options used to create the mesh
  47406. * @param scene defines the hosting scene
  47407. * @returns the hemisphere mesh
  47408. */
  47409. static CreateHemisphere(name: string, options: {
  47410. segments?: number;
  47411. diameter?: number;
  47412. sideOrientation?: number;
  47413. }, scene: any): Mesh;
  47414. }
  47415. }
  47416. declare module "babylonjs/Lights/spotLight" {
  47417. import { Nullable } from "babylonjs/types";
  47418. import { Scene } from "babylonjs/scene";
  47419. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47421. import { Effect } from "babylonjs/Materials/effect";
  47422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47423. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47424. /**
  47425. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47426. * These values define a cone of light starting from the position, emitting toward the direction.
  47427. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47428. * and the exponent defines the speed of the decay of the light with distance (reach).
  47429. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47430. */
  47431. export class SpotLight extends ShadowLight {
  47432. private _angle;
  47433. private _innerAngle;
  47434. private _cosHalfAngle;
  47435. private _lightAngleScale;
  47436. private _lightAngleOffset;
  47437. /**
  47438. * Gets the cone angle of the spot light in Radians.
  47439. */
  47440. /**
  47441. * Sets the cone angle of the spot light in Radians.
  47442. */
  47443. angle: number;
  47444. /**
  47445. * Only used in gltf falloff mode, this defines the angle where
  47446. * the directional falloff will start before cutting at angle which could be seen
  47447. * as outer angle.
  47448. */
  47449. /**
  47450. * Only used in gltf falloff mode, this defines the angle where
  47451. * the directional falloff will start before cutting at angle which could be seen
  47452. * as outer angle.
  47453. */
  47454. innerAngle: number;
  47455. private _shadowAngleScale;
  47456. /**
  47457. * Allows scaling the angle of the light for shadow generation only.
  47458. */
  47459. /**
  47460. * Allows scaling the angle of the light for shadow generation only.
  47461. */
  47462. shadowAngleScale: number;
  47463. /**
  47464. * The light decay speed with the distance from the emission spot.
  47465. */
  47466. exponent: number;
  47467. private _projectionTextureMatrix;
  47468. /**
  47469. * Allows reading the projecton texture
  47470. */
  47471. readonly projectionTextureMatrix: Matrix;
  47472. protected _projectionTextureLightNear: number;
  47473. /**
  47474. * Gets the near clip of the Spotlight for texture projection.
  47475. */
  47476. /**
  47477. * Sets the near clip of the Spotlight for texture projection.
  47478. */
  47479. projectionTextureLightNear: number;
  47480. protected _projectionTextureLightFar: number;
  47481. /**
  47482. * Gets the far clip of the Spotlight for texture projection.
  47483. */
  47484. /**
  47485. * Sets the far clip of the Spotlight for texture projection.
  47486. */
  47487. projectionTextureLightFar: number;
  47488. protected _projectionTextureUpDirection: Vector3;
  47489. /**
  47490. * Gets the Up vector of the Spotlight for texture projection.
  47491. */
  47492. /**
  47493. * Sets the Up vector of the Spotlight for texture projection.
  47494. */
  47495. projectionTextureUpDirection: Vector3;
  47496. private _projectionTexture;
  47497. /**
  47498. * Gets the projection texture of the light.
  47499. */
  47500. /**
  47501. * Sets the projection texture of the light.
  47502. */
  47503. projectionTexture: Nullable<BaseTexture>;
  47504. private _projectionTextureViewLightDirty;
  47505. private _projectionTextureProjectionLightDirty;
  47506. private _projectionTextureDirty;
  47507. private _projectionTextureViewTargetVector;
  47508. private _projectionTextureViewLightMatrix;
  47509. private _projectionTextureProjectionLightMatrix;
  47510. private _projectionTextureScalingMatrix;
  47511. /**
  47512. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47513. * It can cast shadows.
  47514. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47515. * @param name The light friendly name
  47516. * @param position The position of the spot light in the scene
  47517. * @param direction The direction of the light in the scene
  47518. * @param angle The cone angle of the light in Radians
  47519. * @param exponent The light decay speed with the distance from the emission spot
  47520. * @param scene The scene the lights belongs to
  47521. */
  47522. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47523. /**
  47524. * Returns the string "SpotLight".
  47525. * @returns the class name
  47526. */
  47527. getClassName(): string;
  47528. /**
  47529. * Returns the integer 2.
  47530. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47531. */
  47532. getTypeID(): number;
  47533. /**
  47534. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47535. */
  47536. protected _setDirection(value: Vector3): void;
  47537. /**
  47538. * Overrides the position setter to recompute the projection texture view light Matrix.
  47539. */
  47540. protected _setPosition(value: Vector3): void;
  47541. /**
  47542. * 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.
  47543. * Returns the SpotLight.
  47544. */
  47545. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47546. protected _computeProjectionTextureViewLightMatrix(): void;
  47547. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47548. /**
  47549. * Main function for light texture projection matrix computing.
  47550. */
  47551. protected _computeProjectionTextureMatrix(): void;
  47552. protected _buildUniformLayout(): void;
  47553. private _computeAngleValues;
  47554. /**
  47555. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47556. * @param effect The effect to update
  47557. * @param lightIndex The index of the light in the effect to update
  47558. * @returns The spot light
  47559. */
  47560. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47561. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47562. /**
  47563. * Disposes the light and the associated resources.
  47564. */
  47565. dispose(): void;
  47566. /**
  47567. * Prepares the list of defines specific to the light type.
  47568. * @param defines the list of defines
  47569. * @param lightIndex defines the index of the light for the effect
  47570. */
  47571. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47572. }
  47573. }
  47574. declare module "babylonjs/Gizmos/lightGizmo" {
  47575. import { Nullable } from "babylonjs/types";
  47576. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47577. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47578. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47579. import { Light } from "babylonjs/Lights/light";
  47580. /**
  47581. * Gizmo that enables viewing a light
  47582. */
  47583. export class LightGizmo extends Gizmo {
  47584. private _lightMesh;
  47585. private _material;
  47586. private cachedPosition;
  47587. private cachedForward;
  47588. /**
  47589. * Creates a LightGizmo
  47590. * @param gizmoLayer The utility layer the gizmo will be added to
  47591. */
  47592. constructor(gizmoLayer?: UtilityLayerRenderer);
  47593. private _light;
  47594. /**
  47595. * The light that the gizmo is attached to
  47596. */
  47597. light: Nullable<Light>;
  47598. /**
  47599. * Gets the material used to render the light gizmo
  47600. */
  47601. readonly material: StandardMaterial;
  47602. /**
  47603. * @hidden
  47604. * Updates the gizmo to match the attached mesh's position/rotation
  47605. */
  47606. protected _update(): void;
  47607. private static _Scale;
  47608. /**
  47609. * Creates the lines for a light mesh
  47610. */
  47611. private static _createLightLines;
  47612. /**
  47613. * Disposes of the light gizmo
  47614. */
  47615. dispose(): void;
  47616. private static _CreateHemisphericLightMesh;
  47617. private static _CreatePointLightMesh;
  47618. private static _CreateSpotLightMesh;
  47619. private static _CreateDirectionalLightMesh;
  47620. }
  47621. }
  47622. declare module "babylonjs/Gizmos/index" {
  47623. export * from "babylonjs/Gizmos/axisDragGizmo";
  47624. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47625. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47626. export * from "babylonjs/Gizmos/gizmo";
  47627. export * from "babylonjs/Gizmos/gizmoManager";
  47628. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47629. export * from "babylonjs/Gizmos/positionGizmo";
  47630. export * from "babylonjs/Gizmos/rotationGizmo";
  47631. export * from "babylonjs/Gizmos/scaleGizmo";
  47632. export * from "babylonjs/Gizmos/lightGizmo";
  47633. export * from "babylonjs/Gizmos/planeDragGizmo";
  47634. }
  47635. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47636. /** @hidden */
  47637. export var backgroundFragmentDeclaration: {
  47638. name: string;
  47639. shader: string;
  47640. };
  47641. }
  47642. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47643. /** @hidden */
  47644. export var backgroundUboDeclaration: {
  47645. name: string;
  47646. shader: string;
  47647. };
  47648. }
  47649. declare module "babylonjs/Shaders/background.fragment" {
  47650. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47651. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47652. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47653. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47654. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47655. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47656. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47657. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47658. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47659. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47660. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47661. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47662. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47663. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47664. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47665. /** @hidden */
  47666. export var backgroundPixelShader: {
  47667. name: string;
  47668. shader: string;
  47669. };
  47670. }
  47671. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47672. /** @hidden */
  47673. export var backgroundVertexDeclaration: {
  47674. name: string;
  47675. shader: string;
  47676. };
  47677. }
  47678. declare module "babylonjs/Shaders/background.vertex" {
  47679. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47680. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47681. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47682. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47683. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47684. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47685. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47686. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47687. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47688. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47689. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47690. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47691. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47692. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47693. /** @hidden */
  47694. export var backgroundVertexShader: {
  47695. name: string;
  47696. shader: string;
  47697. };
  47698. }
  47699. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47700. import { Nullable, int, float } from "babylonjs/types";
  47701. import { Scene } from "babylonjs/scene";
  47702. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47705. import { Mesh } from "babylonjs/Meshes/mesh";
  47706. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47707. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47708. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47709. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47710. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47711. import { Color3 } from "babylonjs/Maths/math.color";
  47712. import "babylonjs/Shaders/background.fragment";
  47713. import "babylonjs/Shaders/background.vertex";
  47714. /**
  47715. * Background material used to create an efficient environement around your scene.
  47716. */
  47717. export class BackgroundMaterial extends PushMaterial {
  47718. /**
  47719. * Standard reflectance value at parallel view angle.
  47720. */
  47721. static StandardReflectance0: number;
  47722. /**
  47723. * Standard reflectance value at grazing angle.
  47724. */
  47725. static StandardReflectance90: number;
  47726. protected _primaryColor: Color3;
  47727. /**
  47728. * Key light Color (multiply against the environement texture)
  47729. */
  47730. primaryColor: Color3;
  47731. protected __perceptualColor: Nullable<Color3>;
  47732. /**
  47733. * Experimental Internal Use Only.
  47734. *
  47735. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47736. * This acts as a helper to set the primary color to a more "human friendly" value.
  47737. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47738. * output color as close as possible from the chosen value.
  47739. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47740. * part of lighting setup.)
  47741. */
  47742. _perceptualColor: Nullable<Color3>;
  47743. protected _primaryColorShadowLevel: float;
  47744. /**
  47745. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47746. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47747. */
  47748. primaryColorShadowLevel: float;
  47749. protected _primaryColorHighlightLevel: float;
  47750. /**
  47751. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47752. * The primary color is used at the level chosen to define what the white area would look.
  47753. */
  47754. primaryColorHighlightLevel: float;
  47755. protected _reflectionTexture: Nullable<BaseTexture>;
  47756. /**
  47757. * Reflection Texture used in the material.
  47758. * Should be author in a specific way for the best result (refer to the documentation).
  47759. */
  47760. reflectionTexture: Nullable<BaseTexture>;
  47761. protected _reflectionBlur: float;
  47762. /**
  47763. * Reflection Texture level of blur.
  47764. *
  47765. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47766. * texture twice.
  47767. */
  47768. reflectionBlur: float;
  47769. protected _diffuseTexture: Nullable<BaseTexture>;
  47770. /**
  47771. * Diffuse Texture used in the material.
  47772. * Should be author in a specific way for the best result (refer to the documentation).
  47773. */
  47774. diffuseTexture: Nullable<BaseTexture>;
  47775. protected _shadowLights: Nullable<IShadowLight[]>;
  47776. /**
  47777. * Specify the list of lights casting shadow on the material.
  47778. * All scene shadow lights will be included if null.
  47779. */
  47780. shadowLights: Nullable<IShadowLight[]>;
  47781. protected _shadowLevel: float;
  47782. /**
  47783. * Helps adjusting the shadow to a softer level if required.
  47784. * 0 means black shadows and 1 means no shadows.
  47785. */
  47786. shadowLevel: float;
  47787. protected _sceneCenter: Vector3;
  47788. /**
  47789. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47790. * It is usually zero but might be interesting to modify according to your setup.
  47791. */
  47792. sceneCenter: Vector3;
  47793. protected _opacityFresnel: boolean;
  47794. /**
  47795. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47796. * This helps ensuring a nice transition when the camera goes under the ground.
  47797. */
  47798. opacityFresnel: boolean;
  47799. protected _reflectionFresnel: boolean;
  47800. /**
  47801. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47802. * This helps adding a mirror texture on the ground.
  47803. */
  47804. reflectionFresnel: boolean;
  47805. protected _reflectionFalloffDistance: number;
  47806. /**
  47807. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47808. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47809. */
  47810. reflectionFalloffDistance: number;
  47811. protected _reflectionAmount: number;
  47812. /**
  47813. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47814. */
  47815. reflectionAmount: number;
  47816. protected _reflectionReflectance0: number;
  47817. /**
  47818. * This specifies the weight of the reflection at grazing angle.
  47819. */
  47820. reflectionReflectance0: number;
  47821. protected _reflectionReflectance90: number;
  47822. /**
  47823. * This specifies the weight of the reflection at a perpendicular point of view.
  47824. */
  47825. reflectionReflectance90: number;
  47826. /**
  47827. * Sets the reflection reflectance fresnel values according to the default standard
  47828. * empirically know to work well :-)
  47829. */
  47830. reflectionStandardFresnelWeight: number;
  47831. protected _useRGBColor: boolean;
  47832. /**
  47833. * Helps to directly use the maps channels instead of their level.
  47834. */
  47835. useRGBColor: boolean;
  47836. protected _enableNoise: boolean;
  47837. /**
  47838. * This helps reducing the banding effect that could occur on the background.
  47839. */
  47840. enableNoise: boolean;
  47841. /**
  47842. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47843. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47844. * Recommended to be keep at 1.0 except for special cases.
  47845. */
  47846. fovMultiplier: number;
  47847. private _fovMultiplier;
  47848. /**
  47849. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47850. */
  47851. useEquirectangularFOV: boolean;
  47852. private _maxSimultaneousLights;
  47853. /**
  47854. * Number of Simultaneous lights allowed on the material.
  47855. */
  47856. maxSimultaneousLights: int;
  47857. /**
  47858. * Default configuration related to image processing available in the Background Material.
  47859. */
  47860. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47861. /**
  47862. * Keep track of the image processing observer to allow dispose and replace.
  47863. */
  47864. private _imageProcessingObserver;
  47865. /**
  47866. * Attaches a new image processing configuration to the PBR Material.
  47867. * @param configuration (if null the scene configuration will be use)
  47868. */
  47869. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47870. /**
  47871. * Gets the image processing configuration used either in this material.
  47872. */
  47873. /**
  47874. * Sets the Default image processing configuration used either in the this material.
  47875. *
  47876. * If sets to null, the scene one is in use.
  47877. */
  47878. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47879. /**
  47880. * Gets wether the color curves effect is enabled.
  47881. */
  47882. /**
  47883. * Sets wether the color curves effect is enabled.
  47884. */
  47885. cameraColorCurvesEnabled: boolean;
  47886. /**
  47887. * Gets wether the color grading effect is enabled.
  47888. */
  47889. /**
  47890. * Gets wether the color grading effect is enabled.
  47891. */
  47892. cameraColorGradingEnabled: boolean;
  47893. /**
  47894. * Gets wether tonemapping is enabled or not.
  47895. */
  47896. /**
  47897. * Sets wether tonemapping is enabled or not
  47898. */
  47899. cameraToneMappingEnabled: boolean;
  47900. /**
  47901. * The camera exposure used on this material.
  47902. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47903. * This corresponds to a photographic exposure.
  47904. */
  47905. /**
  47906. * The camera exposure used on this material.
  47907. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47908. * This corresponds to a photographic exposure.
  47909. */
  47910. cameraExposure: float;
  47911. /**
  47912. * Gets The camera contrast used on this material.
  47913. */
  47914. /**
  47915. * Sets The camera contrast used on this material.
  47916. */
  47917. cameraContrast: float;
  47918. /**
  47919. * Gets the Color Grading 2D Lookup Texture.
  47920. */
  47921. /**
  47922. * Sets the Color Grading 2D Lookup Texture.
  47923. */
  47924. cameraColorGradingTexture: Nullable<BaseTexture>;
  47925. /**
  47926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47928. * 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;
  47929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47930. */
  47931. /**
  47932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47934. * 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;
  47935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47936. */
  47937. cameraColorCurves: Nullable<ColorCurves>;
  47938. /**
  47939. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47940. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47941. */
  47942. switchToBGR: boolean;
  47943. private _renderTargets;
  47944. private _reflectionControls;
  47945. private _white;
  47946. private _primaryShadowColor;
  47947. private _primaryHighlightColor;
  47948. /**
  47949. * Instantiates a Background Material in the given scene
  47950. * @param name The friendly name of the material
  47951. * @param scene The scene to add the material to
  47952. */
  47953. constructor(name: string, scene: Scene);
  47954. /**
  47955. * Gets a boolean indicating that current material needs to register RTT
  47956. */
  47957. readonly hasRenderTargetTextures: boolean;
  47958. /**
  47959. * The entire material has been created in order to prevent overdraw.
  47960. * @returns false
  47961. */
  47962. needAlphaTesting(): boolean;
  47963. /**
  47964. * The entire material has been created in order to prevent overdraw.
  47965. * @returns true if blending is enable
  47966. */
  47967. needAlphaBlending(): boolean;
  47968. /**
  47969. * Checks wether the material is ready to be rendered for a given mesh.
  47970. * @param mesh The mesh to render
  47971. * @param subMesh The submesh to check against
  47972. * @param useInstances Specify wether or not the material is used with instances
  47973. * @returns true if all the dependencies are ready (Textures, Effects...)
  47974. */
  47975. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47976. /**
  47977. * Compute the primary color according to the chosen perceptual color.
  47978. */
  47979. private _computePrimaryColorFromPerceptualColor;
  47980. /**
  47981. * Compute the highlights and shadow colors according to their chosen levels.
  47982. */
  47983. private _computePrimaryColors;
  47984. /**
  47985. * Build the uniform buffer used in the material.
  47986. */
  47987. buildUniformLayout(): void;
  47988. /**
  47989. * Unbind the material.
  47990. */
  47991. unbind(): void;
  47992. /**
  47993. * Bind only the world matrix to the material.
  47994. * @param world The world matrix to bind.
  47995. */
  47996. bindOnlyWorldMatrix(world: Matrix): void;
  47997. /**
  47998. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47999. * @param world The world matrix to bind.
  48000. * @param subMesh The submesh to bind for.
  48001. */
  48002. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48003. /**
  48004. * Checks to see if a texture is used in the material.
  48005. * @param texture - Base texture to use.
  48006. * @returns - Boolean specifying if a texture is used in the material.
  48007. */
  48008. hasTexture(texture: BaseTexture): boolean;
  48009. /**
  48010. * Dispose the material.
  48011. * @param forceDisposeEffect Force disposal of the associated effect.
  48012. * @param forceDisposeTextures Force disposal of the associated textures.
  48013. */
  48014. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48015. /**
  48016. * Clones the material.
  48017. * @param name The cloned name.
  48018. * @returns The cloned material.
  48019. */
  48020. clone(name: string): BackgroundMaterial;
  48021. /**
  48022. * Serializes the current material to its JSON representation.
  48023. * @returns The JSON representation.
  48024. */
  48025. serialize(): any;
  48026. /**
  48027. * Gets the class name of the material
  48028. * @returns "BackgroundMaterial"
  48029. */
  48030. getClassName(): string;
  48031. /**
  48032. * Parse a JSON input to create back a background material.
  48033. * @param source The JSON data to parse
  48034. * @param scene The scene to create the parsed material in
  48035. * @param rootUrl The root url of the assets the material depends upon
  48036. * @returns the instantiated BackgroundMaterial.
  48037. */
  48038. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48039. }
  48040. }
  48041. declare module "babylonjs/Helpers/environmentHelper" {
  48042. import { Observable } from "babylonjs/Misc/observable";
  48043. import { Nullable } from "babylonjs/types";
  48044. import { Scene } from "babylonjs/scene";
  48045. import { Vector3 } from "babylonjs/Maths/math.vector";
  48046. import { Color3 } from "babylonjs/Maths/math.color";
  48047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48048. import { Mesh } from "babylonjs/Meshes/mesh";
  48049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48050. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48051. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48052. import "babylonjs/Meshes/Builders/planeBuilder";
  48053. import "babylonjs/Meshes/Builders/boxBuilder";
  48054. /**
  48055. * Represents the different options available during the creation of
  48056. * a Environment helper.
  48057. *
  48058. * This can control the default ground, skybox and image processing setup of your scene.
  48059. */
  48060. export interface IEnvironmentHelperOptions {
  48061. /**
  48062. * Specifies wether or not to create a ground.
  48063. * True by default.
  48064. */
  48065. createGround: boolean;
  48066. /**
  48067. * Specifies the ground size.
  48068. * 15 by default.
  48069. */
  48070. groundSize: number;
  48071. /**
  48072. * The texture used on the ground for the main color.
  48073. * Comes from the BabylonJS CDN by default.
  48074. *
  48075. * Remarks: Can be either a texture or a url.
  48076. */
  48077. groundTexture: string | BaseTexture;
  48078. /**
  48079. * The color mixed in the ground texture by default.
  48080. * BabylonJS clearColor by default.
  48081. */
  48082. groundColor: Color3;
  48083. /**
  48084. * Specifies the ground opacity.
  48085. * 1 by default.
  48086. */
  48087. groundOpacity: number;
  48088. /**
  48089. * Enables the ground to receive shadows.
  48090. * True by default.
  48091. */
  48092. enableGroundShadow: boolean;
  48093. /**
  48094. * Helps preventing the shadow to be fully black on the ground.
  48095. * 0.5 by default.
  48096. */
  48097. groundShadowLevel: number;
  48098. /**
  48099. * Creates a mirror texture attach to the ground.
  48100. * false by default.
  48101. */
  48102. enableGroundMirror: boolean;
  48103. /**
  48104. * Specifies the ground mirror size ratio.
  48105. * 0.3 by default as the default kernel is 64.
  48106. */
  48107. groundMirrorSizeRatio: number;
  48108. /**
  48109. * Specifies the ground mirror blur kernel size.
  48110. * 64 by default.
  48111. */
  48112. groundMirrorBlurKernel: number;
  48113. /**
  48114. * Specifies the ground mirror visibility amount.
  48115. * 1 by default
  48116. */
  48117. groundMirrorAmount: number;
  48118. /**
  48119. * Specifies the ground mirror reflectance weight.
  48120. * This uses the standard weight of the background material to setup the fresnel effect
  48121. * of the mirror.
  48122. * 1 by default.
  48123. */
  48124. groundMirrorFresnelWeight: number;
  48125. /**
  48126. * Specifies the ground mirror Falloff distance.
  48127. * This can helps reducing the size of the reflection.
  48128. * 0 by Default.
  48129. */
  48130. groundMirrorFallOffDistance: number;
  48131. /**
  48132. * Specifies the ground mirror texture type.
  48133. * Unsigned Int by Default.
  48134. */
  48135. groundMirrorTextureType: number;
  48136. /**
  48137. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48138. * the shown objects.
  48139. */
  48140. groundYBias: number;
  48141. /**
  48142. * Specifies wether or not to create a skybox.
  48143. * True by default.
  48144. */
  48145. createSkybox: boolean;
  48146. /**
  48147. * Specifies the skybox size.
  48148. * 20 by default.
  48149. */
  48150. skyboxSize: number;
  48151. /**
  48152. * The texture used on the skybox for the main color.
  48153. * Comes from the BabylonJS CDN by default.
  48154. *
  48155. * Remarks: Can be either a texture or a url.
  48156. */
  48157. skyboxTexture: string | BaseTexture;
  48158. /**
  48159. * The color mixed in the skybox texture by default.
  48160. * BabylonJS clearColor by default.
  48161. */
  48162. skyboxColor: Color3;
  48163. /**
  48164. * The background rotation around the Y axis of the scene.
  48165. * This helps aligning the key lights of your scene with the background.
  48166. * 0 by default.
  48167. */
  48168. backgroundYRotation: number;
  48169. /**
  48170. * Compute automatically the size of the elements to best fit with the scene.
  48171. */
  48172. sizeAuto: boolean;
  48173. /**
  48174. * Default position of the rootMesh if autoSize is not true.
  48175. */
  48176. rootPosition: Vector3;
  48177. /**
  48178. * Sets up the image processing in the scene.
  48179. * true by default.
  48180. */
  48181. setupImageProcessing: boolean;
  48182. /**
  48183. * The texture used as your environment texture in the scene.
  48184. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48185. *
  48186. * Remarks: Can be either a texture or a url.
  48187. */
  48188. environmentTexture: string | BaseTexture;
  48189. /**
  48190. * The value of the exposure to apply to the scene.
  48191. * 0.6 by default if setupImageProcessing is true.
  48192. */
  48193. cameraExposure: number;
  48194. /**
  48195. * The value of the contrast to apply to the scene.
  48196. * 1.6 by default if setupImageProcessing is true.
  48197. */
  48198. cameraContrast: number;
  48199. /**
  48200. * Specifies wether or not tonemapping should be enabled in the scene.
  48201. * true by default if setupImageProcessing is true.
  48202. */
  48203. toneMappingEnabled: boolean;
  48204. }
  48205. /**
  48206. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48207. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48208. * It also helps with the default setup of your imageProcessing configuration.
  48209. */
  48210. export class EnvironmentHelper {
  48211. /**
  48212. * Default ground texture URL.
  48213. */
  48214. private static _groundTextureCDNUrl;
  48215. /**
  48216. * Default skybox texture URL.
  48217. */
  48218. private static _skyboxTextureCDNUrl;
  48219. /**
  48220. * Default environment texture URL.
  48221. */
  48222. private static _environmentTextureCDNUrl;
  48223. /**
  48224. * Creates the default options for the helper.
  48225. */
  48226. private static _getDefaultOptions;
  48227. private _rootMesh;
  48228. /**
  48229. * Gets the root mesh created by the helper.
  48230. */
  48231. readonly rootMesh: Mesh;
  48232. private _skybox;
  48233. /**
  48234. * Gets the skybox created by the helper.
  48235. */
  48236. readonly skybox: Nullable<Mesh>;
  48237. private _skyboxTexture;
  48238. /**
  48239. * Gets the skybox texture created by the helper.
  48240. */
  48241. readonly skyboxTexture: Nullable<BaseTexture>;
  48242. private _skyboxMaterial;
  48243. /**
  48244. * Gets the skybox material created by the helper.
  48245. */
  48246. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48247. private _ground;
  48248. /**
  48249. * Gets the ground mesh created by the helper.
  48250. */
  48251. readonly ground: Nullable<Mesh>;
  48252. private _groundTexture;
  48253. /**
  48254. * Gets the ground texture created by the helper.
  48255. */
  48256. readonly groundTexture: Nullable<BaseTexture>;
  48257. private _groundMirror;
  48258. /**
  48259. * Gets the ground mirror created by the helper.
  48260. */
  48261. readonly groundMirror: Nullable<MirrorTexture>;
  48262. /**
  48263. * Gets the ground mirror render list to helps pushing the meshes
  48264. * you wish in the ground reflection.
  48265. */
  48266. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48267. private _groundMaterial;
  48268. /**
  48269. * Gets the ground material created by the helper.
  48270. */
  48271. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48272. /**
  48273. * Stores the creation options.
  48274. */
  48275. private readonly _scene;
  48276. private _options;
  48277. /**
  48278. * This observable will be notified with any error during the creation of the environment,
  48279. * mainly texture creation errors.
  48280. */
  48281. onErrorObservable: Observable<{
  48282. message?: string;
  48283. exception?: any;
  48284. }>;
  48285. /**
  48286. * constructor
  48287. * @param options Defines the options we want to customize the helper
  48288. * @param scene The scene to add the material to
  48289. */
  48290. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48291. /**
  48292. * Updates the background according to the new options
  48293. * @param options
  48294. */
  48295. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48296. /**
  48297. * Sets the primary color of all the available elements.
  48298. * @param color the main color to affect to the ground and the background
  48299. */
  48300. setMainColor(color: Color3): void;
  48301. /**
  48302. * Setup the image processing according to the specified options.
  48303. */
  48304. private _setupImageProcessing;
  48305. /**
  48306. * Setup the environment texture according to the specified options.
  48307. */
  48308. private _setupEnvironmentTexture;
  48309. /**
  48310. * Setup the background according to the specified options.
  48311. */
  48312. private _setupBackground;
  48313. /**
  48314. * Get the scene sizes according to the setup.
  48315. */
  48316. private _getSceneSize;
  48317. /**
  48318. * Setup the ground according to the specified options.
  48319. */
  48320. private _setupGround;
  48321. /**
  48322. * Setup the ground material according to the specified options.
  48323. */
  48324. private _setupGroundMaterial;
  48325. /**
  48326. * Setup the ground diffuse texture according to the specified options.
  48327. */
  48328. private _setupGroundDiffuseTexture;
  48329. /**
  48330. * Setup the ground mirror texture according to the specified options.
  48331. */
  48332. private _setupGroundMirrorTexture;
  48333. /**
  48334. * Setup the ground to receive the mirror texture.
  48335. */
  48336. private _setupMirrorInGroundMaterial;
  48337. /**
  48338. * Setup the skybox according to the specified options.
  48339. */
  48340. private _setupSkybox;
  48341. /**
  48342. * Setup the skybox material according to the specified options.
  48343. */
  48344. private _setupSkyboxMaterial;
  48345. /**
  48346. * Setup the skybox reflection texture according to the specified options.
  48347. */
  48348. private _setupSkyboxReflectionTexture;
  48349. private _errorHandler;
  48350. /**
  48351. * Dispose all the elements created by the Helper.
  48352. */
  48353. dispose(): void;
  48354. }
  48355. }
  48356. declare module "babylonjs/Helpers/photoDome" {
  48357. import { Observable } from "babylonjs/Misc/observable";
  48358. import { Nullable } from "babylonjs/types";
  48359. import { Scene } from "babylonjs/scene";
  48360. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48361. import { Mesh } from "babylonjs/Meshes/mesh";
  48362. import { Texture } from "babylonjs/Materials/Textures/texture";
  48363. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48364. import "babylonjs/Meshes/Builders/sphereBuilder";
  48365. /**
  48366. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48367. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48368. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48369. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48370. */
  48371. export class PhotoDome extends TransformNode {
  48372. /**
  48373. * Define the image as a Monoscopic panoramic 360 image.
  48374. */
  48375. static readonly MODE_MONOSCOPIC: number;
  48376. /**
  48377. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48378. */
  48379. static readonly MODE_TOPBOTTOM: number;
  48380. /**
  48381. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48382. */
  48383. static readonly MODE_SIDEBYSIDE: number;
  48384. private _useDirectMapping;
  48385. /**
  48386. * The texture being displayed on the sphere
  48387. */
  48388. protected _photoTexture: Texture;
  48389. /**
  48390. * Gets or sets the texture being displayed on the sphere
  48391. */
  48392. photoTexture: Texture;
  48393. /**
  48394. * Observable raised when an error occured while loading the 360 image
  48395. */
  48396. onLoadErrorObservable: Observable<string>;
  48397. /**
  48398. * The skybox material
  48399. */
  48400. protected _material: BackgroundMaterial;
  48401. /**
  48402. * The surface used for the skybox
  48403. */
  48404. protected _mesh: Mesh;
  48405. /**
  48406. * Gets the mesh used for the skybox.
  48407. */
  48408. readonly mesh: Mesh;
  48409. /**
  48410. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48411. * Also see the options.resolution property.
  48412. */
  48413. fovMultiplier: number;
  48414. private _imageMode;
  48415. /**
  48416. * Gets or set the current video mode for the video. It can be:
  48417. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48418. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48419. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48420. */
  48421. imageMode: number;
  48422. /**
  48423. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48424. * @param name Element's name, child elements will append suffixes for their own names.
  48425. * @param urlsOfPhoto defines the url of the photo to display
  48426. * @param options defines an object containing optional or exposed sub element properties
  48427. * @param onError defines a callback called when an error occured while loading the texture
  48428. */
  48429. constructor(name: string, urlOfPhoto: string, options: {
  48430. resolution?: number;
  48431. size?: number;
  48432. useDirectMapping?: boolean;
  48433. faceForward?: boolean;
  48434. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48435. private _onBeforeCameraRenderObserver;
  48436. private _changeImageMode;
  48437. /**
  48438. * Releases resources associated with this node.
  48439. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48440. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48441. */
  48442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48443. }
  48444. }
  48445. declare module "babylonjs/Misc/rgbdTextureTools" {
  48446. import "babylonjs/Shaders/rgbdDecode.fragment";
  48447. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48448. import { Texture } from "babylonjs/Materials/Textures/texture";
  48449. /**
  48450. * Class used to host RGBD texture specific utilities
  48451. */
  48452. export class RGBDTextureTools {
  48453. /**
  48454. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48455. * @param texture the texture to expand.
  48456. */
  48457. static ExpandRGBDTexture(texture: Texture): void;
  48458. }
  48459. }
  48460. declare module "babylonjs/Misc/brdfTextureTools" {
  48461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48462. import { Scene } from "babylonjs/scene";
  48463. /**
  48464. * Class used to host texture specific utilities
  48465. */
  48466. export class BRDFTextureTools {
  48467. /**
  48468. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48469. * @param scene defines the hosting scene
  48470. * @returns the environment BRDF texture
  48471. */
  48472. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48473. private static _environmentBRDFBase64Texture;
  48474. }
  48475. }
  48476. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48477. import { Nullable } from "babylonjs/types";
  48478. import { Color3 } from "babylonjs/Maths/math.color";
  48479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48480. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48481. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48482. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48483. import { Engine } from "babylonjs/Engines/engine";
  48484. import { Scene } from "babylonjs/scene";
  48485. /**
  48486. * @hidden
  48487. */
  48488. export interface IMaterialClearCoatDefines {
  48489. CLEARCOAT: boolean;
  48490. CLEARCOAT_DEFAULTIOR: boolean;
  48491. CLEARCOAT_TEXTURE: boolean;
  48492. CLEARCOAT_TEXTUREDIRECTUV: number;
  48493. CLEARCOAT_BUMP: boolean;
  48494. CLEARCOAT_BUMPDIRECTUV: number;
  48495. CLEARCOAT_TINT: boolean;
  48496. CLEARCOAT_TINT_TEXTURE: boolean;
  48497. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48498. /** @hidden */
  48499. _areTexturesDirty: boolean;
  48500. }
  48501. /**
  48502. * Define the code related to the clear coat parameters of the pbr material.
  48503. */
  48504. export class PBRClearCoatConfiguration {
  48505. /**
  48506. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48507. * The default fits with a polyurethane material.
  48508. */
  48509. private static readonly _DefaultIndexOfRefraction;
  48510. private _isEnabled;
  48511. /**
  48512. * Defines if the clear coat is enabled in the material.
  48513. */
  48514. isEnabled: boolean;
  48515. /**
  48516. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48517. */
  48518. intensity: number;
  48519. /**
  48520. * Defines the clear coat layer roughness.
  48521. */
  48522. roughness: number;
  48523. private _indexOfRefraction;
  48524. /**
  48525. * Defines the index of refraction of the clear coat.
  48526. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48527. * The default fits with a polyurethane material.
  48528. * Changing the default value is more performance intensive.
  48529. */
  48530. indexOfRefraction: number;
  48531. private _texture;
  48532. /**
  48533. * Stores the clear coat values in a texture.
  48534. */
  48535. texture: Nullable<BaseTexture>;
  48536. private _bumpTexture;
  48537. /**
  48538. * Define the clear coat specific bump texture.
  48539. */
  48540. bumpTexture: Nullable<BaseTexture>;
  48541. private _isTintEnabled;
  48542. /**
  48543. * Defines if the clear coat tint is enabled in the material.
  48544. */
  48545. isTintEnabled: boolean;
  48546. /**
  48547. * Defines the clear coat tint of the material.
  48548. * This is only use if tint is enabled
  48549. */
  48550. tintColor: Color3;
  48551. /**
  48552. * Defines the distance at which the tint color should be found in the
  48553. * clear coat media.
  48554. * This is only use if tint is enabled
  48555. */
  48556. tintColorAtDistance: number;
  48557. /**
  48558. * Defines the clear coat layer thickness.
  48559. * This is only use if tint is enabled
  48560. */
  48561. tintThickness: number;
  48562. private _tintTexture;
  48563. /**
  48564. * Stores the clear tint values in a texture.
  48565. * rgb is tint
  48566. * a is a thickness factor
  48567. */
  48568. tintTexture: Nullable<BaseTexture>;
  48569. /** @hidden */
  48570. private _internalMarkAllSubMeshesAsTexturesDirty;
  48571. /** @hidden */
  48572. _markAllSubMeshesAsTexturesDirty(): void;
  48573. /**
  48574. * Instantiate a new istance of clear coat configuration.
  48575. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48576. */
  48577. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48578. /**
  48579. * Gets wehter the submesh is ready to be used or not.
  48580. * @param defines the list of "defines" to update.
  48581. * @param scene defines the scene the material belongs to.
  48582. * @param engine defines the engine the material belongs to.
  48583. * @param disableBumpMap defines wether the material disables bump or not.
  48584. * @returns - boolean indicating that the submesh is ready or not.
  48585. */
  48586. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48587. /**
  48588. * Checks to see if a texture is used in the material.
  48589. * @param defines the list of "defines" to update.
  48590. * @param scene defines the scene to the material belongs to.
  48591. */
  48592. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48593. /**
  48594. * Binds the material data.
  48595. * @param uniformBuffer defines the Uniform buffer to fill in.
  48596. * @param scene defines the scene the material belongs to.
  48597. * @param engine defines the engine the material belongs to.
  48598. * @param disableBumpMap defines wether the material disables bump or not.
  48599. * @param isFrozen defines wether the material is frozen or not.
  48600. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48601. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48602. */
  48603. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48604. /**
  48605. * Checks to see if a texture is used in the material.
  48606. * @param texture - Base texture to use.
  48607. * @returns - Boolean specifying if a texture is used in the material.
  48608. */
  48609. hasTexture(texture: BaseTexture): boolean;
  48610. /**
  48611. * Returns an array of the actively used textures.
  48612. * @param activeTextures Array of BaseTextures
  48613. */
  48614. getActiveTextures(activeTextures: BaseTexture[]): void;
  48615. /**
  48616. * Returns the animatable textures.
  48617. * @param animatables Array of animatable textures.
  48618. */
  48619. getAnimatables(animatables: IAnimatable[]): void;
  48620. /**
  48621. * Disposes the resources of the material.
  48622. * @param forceDisposeTextures - Forces the disposal of all textures.
  48623. */
  48624. dispose(forceDisposeTextures?: boolean): void;
  48625. /**
  48626. * Get the current class name of the texture useful for serialization or dynamic coding.
  48627. * @returns "PBRClearCoatConfiguration"
  48628. */
  48629. getClassName(): string;
  48630. /**
  48631. * Add fallbacks to the effect fallbacks list.
  48632. * @param defines defines the Base texture to use.
  48633. * @param fallbacks defines the current fallback list.
  48634. * @param currentRank defines the current fallback rank.
  48635. * @returns the new fallback rank.
  48636. */
  48637. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48638. /**
  48639. * Add the required uniforms to the current list.
  48640. * @param uniforms defines the current uniform list.
  48641. */
  48642. static AddUniforms(uniforms: string[]): void;
  48643. /**
  48644. * Add the required samplers to the current list.
  48645. * @param samplers defines the current sampler list.
  48646. */
  48647. static AddSamplers(samplers: string[]): void;
  48648. /**
  48649. * Add the required uniforms to the current buffer.
  48650. * @param uniformBuffer defines the current uniform buffer.
  48651. */
  48652. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48653. /**
  48654. * Makes a duplicate of the current configuration into another one.
  48655. * @param clearCoatConfiguration define the config where to copy the info
  48656. */
  48657. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48658. /**
  48659. * Serializes this clear coat configuration.
  48660. * @returns - An object with the serialized config.
  48661. */
  48662. serialize(): any;
  48663. /**
  48664. * Parses a anisotropy Configuration from a serialized object.
  48665. * @param source - Serialized object.
  48666. * @param scene Defines the scene we are parsing for
  48667. * @param rootUrl Defines the rootUrl to load from
  48668. */
  48669. parse(source: any, scene: Scene, rootUrl: string): void;
  48670. }
  48671. }
  48672. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48673. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48675. import { Vector2 } from "babylonjs/Maths/math.vector";
  48676. import { Scene } from "babylonjs/scene";
  48677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48678. import { Nullable } from "babylonjs/types";
  48679. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48680. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48681. /**
  48682. * @hidden
  48683. */
  48684. export interface IMaterialAnisotropicDefines {
  48685. ANISOTROPIC: boolean;
  48686. ANISOTROPIC_TEXTURE: boolean;
  48687. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48688. MAINUV1: boolean;
  48689. _areTexturesDirty: boolean;
  48690. _needUVs: boolean;
  48691. }
  48692. /**
  48693. * Define the code related to the anisotropic parameters of the pbr material.
  48694. */
  48695. export class PBRAnisotropicConfiguration {
  48696. private _isEnabled;
  48697. /**
  48698. * Defines if the anisotropy is enabled in the material.
  48699. */
  48700. isEnabled: boolean;
  48701. /**
  48702. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48703. */
  48704. intensity: number;
  48705. /**
  48706. * Defines if the effect is along the tangents, bitangents or in between.
  48707. * By default, the effect is "strectching" the highlights along the tangents.
  48708. */
  48709. direction: Vector2;
  48710. private _texture;
  48711. /**
  48712. * Stores the anisotropy values in a texture.
  48713. * rg is direction (like normal from -1 to 1)
  48714. * b is a intensity
  48715. */
  48716. texture: Nullable<BaseTexture>;
  48717. /** @hidden */
  48718. private _internalMarkAllSubMeshesAsTexturesDirty;
  48719. /** @hidden */
  48720. _markAllSubMeshesAsTexturesDirty(): void;
  48721. /**
  48722. * Instantiate a new istance of anisotropy configuration.
  48723. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48724. */
  48725. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48726. /**
  48727. * Specifies that the submesh is ready to be used.
  48728. * @param defines the list of "defines" to update.
  48729. * @param scene defines the scene the material belongs to.
  48730. * @returns - boolean indicating that the submesh is ready or not.
  48731. */
  48732. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48733. /**
  48734. * Checks to see if a texture is used in the material.
  48735. * @param defines the list of "defines" to update.
  48736. * @param mesh the mesh we are preparing the defines for.
  48737. * @param scene defines the scene the material belongs to.
  48738. */
  48739. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48740. /**
  48741. * Binds the material data.
  48742. * @param uniformBuffer defines the Uniform buffer to fill in.
  48743. * @param scene defines the scene the material belongs to.
  48744. * @param isFrozen defines wether the material is frozen or not.
  48745. */
  48746. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48747. /**
  48748. * Checks to see if a texture is used in the material.
  48749. * @param texture - Base texture to use.
  48750. * @returns - Boolean specifying if a texture is used in the material.
  48751. */
  48752. hasTexture(texture: BaseTexture): boolean;
  48753. /**
  48754. * Returns an array of the actively used textures.
  48755. * @param activeTextures Array of BaseTextures
  48756. */
  48757. getActiveTextures(activeTextures: BaseTexture[]): void;
  48758. /**
  48759. * Returns the animatable textures.
  48760. * @param animatables Array of animatable textures.
  48761. */
  48762. getAnimatables(animatables: IAnimatable[]): void;
  48763. /**
  48764. * Disposes the resources of the material.
  48765. * @param forceDisposeTextures - Forces the disposal of all textures.
  48766. */
  48767. dispose(forceDisposeTextures?: boolean): void;
  48768. /**
  48769. * Get the current class name of the texture useful for serialization or dynamic coding.
  48770. * @returns "PBRAnisotropicConfiguration"
  48771. */
  48772. getClassName(): string;
  48773. /**
  48774. * Add fallbacks to the effect fallbacks list.
  48775. * @param defines defines the Base texture to use.
  48776. * @param fallbacks defines the current fallback list.
  48777. * @param currentRank defines the current fallback rank.
  48778. * @returns the new fallback rank.
  48779. */
  48780. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48781. /**
  48782. * Add the required uniforms to the current list.
  48783. * @param uniforms defines the current uniform list.
  48784. */
  48785. static AddUniforms(uniforms: string[]): void;
  48786. /**
  48787. * Add the required uniforms to the current buffer.
  48788. * @param uniformBuffer defines the current uniform buffer.
  48789. */
  48790. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48791. /**
  48792. * Add the required samplers to the current list.
  48793. * @param samplers defines the current sampler list.
  48794. */
  48795. static AddSamplers(samplers: string[]): void;
  48796. /**
  48797. * Makes a duplicate of the current configuration into another one.
  48798. * @param anisotropicConfiguration define the config where to copy the info
  48799. */
  48800. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48801. /**
  48802. * Serializes this anisotropy configuration.
  48803. * @returns - An object with the serialized config.
  48804. */
  48805. serialize(): any;
  48806. /**
  48807. * Parses a anisotropy Configuration from a serialized object.
  48808. * @param source - Serialized object.
  48809. * @param scene Defines the scene we are parsing for
  48810. * @param rootUrl Defines the rootUrl to load from
  48811. */
  48812. parse(source: any, scene: Scene, rootUrl: string): void;
  48813. }
  48814. }
  48815. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48816. import { Scene } from "babylonjs/scene";
  48817. /**
  48818. * @hidden
  48819. */
  48820. export interface IMaterialBRDFDefines {
  48821. BRDF_V_HEIGHT_CORRELATED: boolean;
  48822. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48823. SPHERICAL_HARMONICS: boolean;
  48824. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48825. /** @hidden */
  48826. _areMiscDirty: boolean;
  48827. }
  48828. /**
  48829. * Define the code related to the BRDF parameters of the pbr material.
  48830. */
  48831. export class PBRBRDFConfiguration {
  48832. /**
  48833. * Default value used for the energy conservation.
  48834. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48835. */
  48836. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48837. /**
  48838. * Default value used for the Smith Visibility Height Correlated mode.
  48839. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48840. */
  48841. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48842. /**
  48843. * Default value used for the IBL diffuse part.
  48844. * This can help switching back to the polynomials mode globally which is a tiny bit
  48845. * less GPU intensive at the drawback of a lower quality.
  48846. */
  48847. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48848. /**
  48849. * Default value used for activating energy conservation for the specular workflow.
  48850. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48851. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48852. */
  48853. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48854. private _useEnergyConservation;
  48855. /**
  48856. * Defines if the material uses energy conservation.
  48857. */
  48858. useEnergyConservation: boolean;
  48859. private _useSmithVisibilityHeightCorrelated;
  48860. /**
  48861. * LEGACY Mode set to false
  48862. * Defines if the material uses height smith correlated visibility term.
  48863. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48864. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48865. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48866. * Not relying on height correlated will also disable energy conservation.
  48867. */
  48868. useSmithVisibilityHeightCorrelated: boolean;
  48869. private _useSphericalHarmonics;
  48870. /**
  48871. * LEGACY Mode set to false
  48872. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48873. * diffuse part of the IBL.
  48874. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48875. * to the ground truth.
  48876. */
  48877. useSphericalHarmonics: boolean;
  48878. private _useSpecularGlossinessInputEnergyConservation;
  48879. /**
  48880. * Defines if the material uses energy conservation, when the specular workflow is active.
  48881. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48882. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48883. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48884. */
  48885. useSpecularGlossinessInputEnergyConservation: boolean;
  48886. /** @hidden */
  48887. private _internalMarkAllSubMeshesAsMiscDirty;
  48888. /** @hidden */
  48889. _markAllSubMeshesAsMiscDirty(): void;
  48890. /**
  48891. * Instantiate a new istance of clear coat configuration.
  48892. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48893. */
  48894. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48895. /**
  48896. * Checks to see if a texture is used in the material.
  48897. * @param defines the list of "defines" to update.
  48898. */
  48899. prepareDefines(defines: IMaterialBRDFDefines): void;
  48900. /**
  48901. * Get the current class name of the texture useful for serialization or dynamic coding.
  48902. * @returns "PBRClearCoatConfiguration"
  48903. */
  48904. getClassName(): string;
  48905. /**
  48906. * Makes a duplicate of the current configuration into another one.
  48907. * @param brdfConfiguration define the config where to copy the info
  48908. */
  48909. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48910. /**
  48911. * Serializes this BRDF configuration.
  48912. * @returns - An object with the serialized config.
  48913. */
  48914. serialize(): any;
  48915. /**
  48916. * Parses a anisotropy Configuration from a serialized object.
  48917. * @param source - Serialized object.
  48918. * @param scene Defines the scene we are parsing for
  48919. * @param rootUrl Defines the rootUrl to load from
  48920. */
  48921. parse(source: any, scene: Scene, rootUrl: string): void;
  48922. }
  48923. }
  48924. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48925. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48926. import { Color3 } from "babylonjs/Maths/math.color";
  48927. import { Scene } from "babylonjs/scene";
  48928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48929. import { Nullable } from "babylonjs/types";
  48930. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48931. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48932. /**
  48933. * @hidden
  48934. */
  48935. export interface IMaterialSheenDefines {
  48936. SHEEN: boolean;
  48937. SHEEN_TEXTURE: boolean;
  48938. SHEEN_TEXTUREDIRECTUV: number;
  48939. SHEEN_LINKWITHALBEDO: boolean;
  48940. /** @hidden */
  48941. _areTexturesDirty: boolean;
  48942. }
  48943. /**
  48944. * Define the code related to the Sheen parameters of the pbr material.
  48945. */
  48946. export class PBRSheenConfiguration {
  48947. private _isEnabled;
  48948. /**
  48949. * Defines if the material uses sheen.
  48950. */
  48951. isEnabled: boolean;
  48952. private _linkSheenWithAlbedo;
  48953. /**
  48954. * Defines if the sheen is linked to the sheen color.
  48955. */
  48956. linkSheenWithAlbedo: boolean;
  48957. /**
  48958. * Defines the sheen intensity.
  48959. */
  48960. intensity: number;
  48961. /**
  48962. * Defines the sheen color.
  48963. */
  48964. color: Color3;
  48965. private _texture;
  48966. /**
  48967. * Stores the sheen tint values in a texture.
  48968. * rgb is tint
  48969. * a is a intensity
  48970. */
  48971. texture: Nullable<BaseTexture>;
  48972. /** @hidden */
  48973. private _internalMarkAllSubMeshesAsTexturesDirty;
  48974. /** @hidden */
  48975. _markAllSubMeshesAsTexturesDirty(): void;
  48976. /**
  48977. * Instantiate a new istance of clear coat configuration.
  48978. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48979. */
  48980. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48981. /**
  48982. * Specifies that the submesh is ready to be used.
  48983. * @param defines the list of "defines" to update.
  48984. * @param scene defines the scene the material belongs to.
  48985. * @returns - boolean indicating that the submesh is ready or not.
  48986. */
  48987. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48988. /**
  48989. * Checks to see if a texture is used in the material.
  48990. * @param defines the list of "defines" to update.
  48991. * @param scene defines the scene the material belongs to.
  48992. */
  48993. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48994. /**
  48995. * Binds the material data.
  48996. * @param uniformBuffer defines the Uniform buffer to fill in.
  48997. * @param scene defines the scene the material belongs to.
  48998. * @param isFrozen defines wether the material is frozen or not.
  48999. */
  49000. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49001. /**
  49002. * Checks to see if a texture is used in the material.
  49003. * @param texture - Base texture to use.
  49004. * @returns - Boolean specifying if a texture is used in the material.
  49005. */
  49006. hasTexture(texture: BaseTexture): boolean;
  49007. /**
  49008. * Returns an array of the actively used textures.
  49009. * @param activeTextures Array of BaseTextures
  49010. */
  49011. getActiveTextures(activeTextures: BaseTexture[]): void;
  49012. /**
  49013. * Returns the animatable textures.
  49014. * @param animatables Array of animatable textures.
  49015. */
  49016. getAnimatables(animatables: IAnimatable[]): void;
  49017. /**
  49018. * Disposes the resources of the material.
  49019. * @param forceDisposeTextures - Forces the disposal of all textures.
  49020. */
  49021. dispose(forceDisposeTextures?: boolean): void;
  49022. /**
  49023. * Get the current class name of the texture useful for serialization or dynamic coding.
  49024. * @returns "PBRSheenConfiguration"
  49025. */
  49026. getClassName(): string;
  49027. /**
  49028. * Add fallbacks to the effect fallbacks list.
  49029. * @param defines defines the Base texture to use.
  49030. * @param fallbacks defines the current fallback list.
  49031. * @param currentRank defines the current fallback rank.
  49032. * @returns the new fallback rank.
  49033. */
  49034. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49035. /**
  49036. * Add the required uniforms to the current list.
  49037. * @param uniforms defines the current uniform list.
  49038. */
  49039. static AddUniforms(uniforms: string[]): void;
  49040. /**
  49041. * Add the required uniforms to the current buffer.
  49042. * @param uniformBuffer defines the current uniform buffer.
  49043. */
  49044. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49045. /**
  49046. * Add the required samplers to the current list.
  49047. * @param samplers defines the current sampler list.
  49048. */
  49049. static AddSamplers(samplers: string[]): void;
  49050. /**
  49051. * Makes a duplicate of the current configuration into another one.
  49052. * @param sheenConfiguration define the config where to copy the info
  49053. */
  49054. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49055. /**
  49056. * Serializes this BRDF configuration.
  49057. * @returns - An object with the serialized config.
  49058. */
  49059. serialize(): any;
  49060. /**
  49061. * Parses a anisotropy Configuration from a serialized object.
  49062. * @param source - Serialized object.
  49063. * @param scene Defines the scene we are parsing for
  49064. * @param rootUrl Defines the rootUrl to load from
  49065. */
  49066. parse(source: any, scene: Scene, rootUrl: string): void;
  49067. }
  49068. }
  49069. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49070. import { Nullable } from "babylonjs/types";
  49071. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49072. import { Color3 } from "babylonjs/Maths/math.color";
  49073. import { SmartArray } from "babylonjs/Misc/smartArray";
  49074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49075. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49076. import { Effect } from "babylonjs/Materials/effect";
  49077. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49078. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49079. import { Engine } from "babylonjs/Engines/engine";
  49080. import { Scene } from "babylonjs/scene";
  49081. /**
  49082. * @hidden
  49083. */
  49084. export interface IMaterialSubSurfaceDefines {
  49085. SUBSURFACE: boolean;
  49086. SS_REFRACTION: boolean;
  49087. SS_TRANSLUCENCY: boolean;
  49088. SS_SCATERRING: boolean;
  49089. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49090. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49091. SS_REFRACTIONMAP_3D: boolean;
  49092. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49093. SS_LODINREFRACTIONALPHA: boolean;
  49094. SS_GAMMAREFRACTION: boolean;
  49095. SS_RGBDREFRACTION: boolean;
  49096. SS_LINEARSPECULARREFRACTION: boolean;
  49097. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49098. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49099. /** @hidden */
  49100. _areTexturesDirty: boolean;
  49101. }
  49102. /**
  49103. * Define the code related to the sub surface parameters of the pbr material.
  49104. */
  49105. export class PBRSubSurfaceConfiguration {
  49106. private _isRefractionEnabled;
  49107. /**
  49108. * Defines if the refraction is enabled in the material.
  49109. */
  49110. isRefractionEnabled: boolean;
  49111. private _isTranslucencyEnabled;
  49112. /**
  49113. * Defines if the translucency is enabled in the material.
  49114. */
  49115. isTranslucencyEnabled: boolean;
  49116. private _isScatteringEnabled;
  49117. /**
  49118. * Defines the refraction intensity of the material.
  49119. * The refraction when enabled replaces the Diffuse part of the material.
  49120. * The intensity helps transitionning between diffuse and refraction.
  49121. */
  49122. refractionIntensity: number;
  49123. /**
  49124. * Defines the translucency intensity of the material.
  49125. * When translucency has been enabled, this defines how much of the "translucency"
  49126. * is addded to the diffuse part of the material.
  49127. */
  49128. translucencyIntensity: number;
  49129. /**
  49130. * Defines the scattering intensity of the material.
  49131. * When scattering has been enabled, this defines how much of the "scattered light"
  49132. * is addded to the diffuse part of the material.
  49133. */
  49134. scatteringIntensity: number;
  49135. private _thicknessTexture;
  49136. /**
  49137. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49138. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49139. * 0 would mean minimumThickness
  49140. * 1 would mean maximumThickness
  49141. * The other channels might be use as a mask to vary the different effects intensity.
  49142. */
  49143. thicknessTexture: Nullable<BaseTexture>;
  49144. private _refractionTexture;
  49145. /**
  49146. * Defines the texture to use for refraction.
  49147. */
  49148. refractionTexture: Nullable<BaseTexture>;
  49149. private _indexOfRefraction;
  49150. /**
  49151. * Defines the index of refraction used in the material.
  49152. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49153. */
  49154. indexOfRefraction: number;
  49155. private _invertRefractionY;
  49156. /**
  49157. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49158. */
  49159. invertRefractionY: boolean;
  49160. private _linkRefractionWithTransparency;
  49161. /**
  49162. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49163. * Materials half opaque for instance using refraction could benefit from this control.
  49164. */
  49165. linkRefractionWithTransparency: boolean;
  49166. /**
  49167. * Defines the minimum thickness stored in the thickness map.
  49168. * If no thickness map is defined, this value will be used to simulate thickness.
  49169. */
  49170. minimumThickness: number;
  49171. /**
  49172. * Defines the maximum thickness stored in the thickness map.
  49173. */
  49174. maximumThickness: number;
  49175. /**
  49176. * Defines the volume tint of the material.
  49177. * This is used for both translucency and scattering.
  49178. */
  49179. tintColor: Color3;
  49180. /**
  49181. * Defines the distance at which the tint color should be found in the media.
  49182. * This is used for refraction only.
  49183. */
  49184. tintColorAtDistance: number;
  49185. /**
  49186. * Defines how far each channel transmit through the media.
  49187. * It is defined as a color to simplify it selection.
  49188. */
  49189. diffusionDistance: Color3;
  49190. private _useMaskFromThicknessTexture;
  49191. /**
  49192. * Stores the intensity of the different subsurface effects in the thickness texture.
  49193. * * the green channel is the translucency intensity.
  49194. * * the blue channel is the scattering intensity.
  49195. * * the alpha channel is the refraction intensity.
  49196. */
  49197. useMaskFromThicknessTexture: boolean;
  49198. /** @hidden */
  49199. private _internalMarkAllSubMeshesAsTexturesDirty;
  49200. /** @hidden */
  49201. _markAllSubMeshesAsTexturesDirty(): void;
  49202. /**
  49203. * Instantiate a new istance of sub surface configuration.
  49204. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49205. */
  49206. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49207. /**
  49208. * Gets wehter the submesh is ready to be used or not.
  49209. * @param defines the list of "defines" to update.
  49210. * @param scene defines the scene the material belongs to.
  49211. * @returns - boolean indicating that the submesh is ready or not.
  49212. */
  49213. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49214. /**
  49215. * Checks to see if a texture is used in the material.
  49216. * @param defines the list of "defines" to update.
  49217. * @param scene defines the scene to the material belongs to.
  49218. */
  49219. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49220. /**
  49221. * Binds the material data.
  49222. * @param uniformBuffer defines the Uniform buffer to fill in.
  49223. * @param scene defines the scene the material belongs to.
  49224. * @param engine defines the engine the material belongs to.
  49225. * @param isFrozen defines wether the material is frozen or not.
  49226. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49227. */
  49228. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49229. /**
  49230. * Unbinds the material from the mesh.
  49231. * @param activeEffect defines the effect that should be unbound from.
  49232. * @returns true if unbound, otherwise false
  49233. */
  49234. unbind(activeEffect: Effect): boolean;
  49235. /**
  49236. * Returns the texture used for refraction or null if none is used.
  49237. * @param scene defines the scene the material belongs to.
  49238. * @returns - Refraction texture if present. If no refraction texture and refraction
  49239. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49240. */
  49241. private _getRefractionTexture;
  49242. /**
  49243. * Returns true if alpha blending should be disabled.
  49244. */
  49245. readonly disableAlphaBlending: boolean;
  49246. /**
  49247. * Fills the list of render target textures.
  49248. * @param renderTargets the list of render targets to update
  49249. */
  49250. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49251. /**
  49252. * Checks to see if a texture is used in the material.
  49253. * @param texture - Base texture to use.
  49254. * @returns - Boolean specifying if a texture is used in the material.
  49255. */
  49256. hasTexture(texture: BaseTexture): boolean;
  49257. /**
  49258. * Gets a boolean indicating that current material needs to register RTT
  49259. * @returns true if this uses a render target otherwise false.
  49260. */
  49261. hasRenderTargetTextures(): boolean;
  49262. /**
  49263. * Returns an array of the actively used textures.
  49264. * @param activeTextures Array of BaseTextures
  49265. */
  49266. getActiveTextures(activeTextures: BaseTexture[]): void;
  49267. /**
  49268. * Returns the animatable textures.
  49269. * @param animatables Array of animatable textures.
  49270. */
  49271. getAnimatables(animatables: IAnimatable[]): void;
  49272. /**
  49273. * Disposes the resources of the material.
  49274. * @param forceDisposeTextures - Forces the disposal of all textures.
  49275. */
  49276. dispose(forceDisposeTextures?: boolean): void;
  49277. /**
  49278. * Get the current class name of the texture useful for serialization or dynamic coding.
  49279. * @returns "PBRSubSurfaceConfiguration"
  49280. */
  49281. getClassName(): string;
  49282. /**
  49283. * Add fallbacks to the effect fallbacks list.
  49284. * @param defines defines the Base texture to use.
  49285. * @param fallbacks defines the current fallback list.
  49286. * @param currentRank defines the current fallback rank.
  49287. * @returns the new fallback rank.
  49288. */
  49289. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49290. /**
  49291. * Add the required uniforms to the current list.
  49292. * @param uniforms defines the current uniform list.
  49293. */
  49294. static AddUniforms(uniforms: string[]): void;
  49295. /**
  49296. * Add the required samplers to the current list.
  49297. * @param samplers defines the current sampler list.
  49298. */
  49299. static AddSamplers(samplers: string[]): void;
  49300. /**
  49301. * Add the required uniforms to the current buffer.
  49302. * @param uniformBuffer defines the current uniform buffer.
  49303. */
  49304. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49305. /**
  49306. * Makes a duplicate of the current configuration into another one.
  49307. * @param configuration define the config where to copy the info
  49308. */
  49309. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49310. /**
  49311. * Serializes this Sub Surface configuration.
  49312. * @returns - An object with the serialized config.
  49313. */
  49314. serialize(): any;
  49315. /**
  49316. * Parses a anisotropy Configuration from a serialized object.
  49317. * @param source - Serialized object.
  49318. * @param scene Defines the scene we are parsing for
  49319. * @param rootUrl Defines the rootUrl to load from
  49320. */
  49321. parse(source: any, scene: Scene, rootUrl: string): void;
  49322. }
  49323. }
  49324. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49325. /** @hidden */
  49326. export var pbrFragmentDeclaration: {
  49327. name: string;
  49328. shader: string;
  49329. };
  49330. }
  49331. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49332. /** @hidden */
  49333. export var pbrUboDeclaration: {
  49334. name: string;
  49335. shader: string;
  49336. };
  49337. }
  49338. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49339. /** @hidden */
  49340. export var pbrFragmentExtraDeclaration: {
  49341. name: string;
  49342. shader: string;
  49343. };
  49344. }
  49345. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49346. /** @hidden */
  49347. export var pbrFragmentSamplersDeclaration: {
  49348. name: string;
  49349. shader: string;
  49350. };
  49351. }
  49352. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49353. /** @hidden */
  49354. export var pbrHelperFunctions: {
  49355. name: string;
  49356. shader: string;
  49357. };
  49358. }
  49359. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49360. /** @hidden */
  49361. export var harmonicsFunctions: {
  49362. name: string;
  49363. shader: string;
  49364. };
  49365. }
  49366. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49367. /** @hidden */
  49368. export var pbrDirectLightingSetupFunctions: {
  49369. name: string;
  49370. shader: string;
  49371. };
  49372. }
  49373. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49374. /** @hidden */
  49375. export var pbrDirectLightingFalloffFunctions: {
  49376. name: string;
  49377. shader: string;
  49378. };
  49379. }
  49380. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49381. /** @hidden */
  49382. export var pbrBRDFFunctions: {
  49383. name: string;
  49384. shader: string;
  49385. };
  49386. }
  49387. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49388. /** @hidden */
  49389. export var pbrDirectLightingFunctions: {
  49390. name: string;
  49391. shader: string;
  49392. };
  49393. }
  49394. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49395. /** @hidden */
  49396. export var pbrIBLFunctions: {
  49397. name: string;
  49398. shader: string;
  49399. };
  49400. }
  49401. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49402. /** @hidden */
  49403. export var pbrDebug: {
  49404. name: string;
  49405. shader: string;
  49406. };
  49407. }
  49408. declare module "babylonjs/Shaders/pbr.fragment" {
  49409. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49410. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49411. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49412. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49413. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49414. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49415. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49416. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49417. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49418. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49420. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49421. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49422. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49423. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49424. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49425. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49426. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49427. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49428. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49429. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49430. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49431. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49432. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49433. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49434. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49435. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49436. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49437. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49438. /** @hidden */
  49439. export var pbrPixelShader: {
  49440. name: string;
  49441. shader: string;
  49442. };
  49443. }
  49444. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49445. /** @hidden */
  49446. export var pbrVertexDeclaration: {
  49447. name: string;
  49448. shader: string;
  49449. };
  49450. }
  49451. declare module "babylonjs/Shaders/pbr.vertex" {
  49452. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49453. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49454. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49456. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49457. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49458. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49459. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49460. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49461. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49462. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49464. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49465. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49466. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49467. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49468. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49469. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49470. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49471. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49472. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49473. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49474. /** @hidden */
  49475. export var pbrVertexShader: {
  49476. name: string;
  49477. shader: string;
  49478. };
  49479. }
  49480. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49481. import { Nullable } from "babylonjs/types";
  49482. import { Scene } from "babylonjs/scene";
  49483. import { Matrix } from "babylonjs/Maths/math.vector";
  49484. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49486. import { Mesh } from "babylonjs/Meshes/mesh";
  49487. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49488. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49489. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49490. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49491. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49492. import { Color3 } from "babylonjs/Maths/math.color";
  49493. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49494. import { Material } from "babylonjs/Materials/material";
  49495. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49496. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49497. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49498. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49499. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49500. import "babylonjs/Shaders/pbr.fragment";
  49501. import "babylonjs/Shaders/pbr.vertex";
  49502. /**
  49503. * Manages the defines for the PBR Material.
  49504. * @hidden
  49505. */
  49506. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49507. PBR: boolean;
  49508. MAINUV1: boolean;
  49509. MAINUV2: boolean;
  49510. UV1: boolean;
  49511. UV2: boolean;
  49512. ALBEDO: boolean;
  49513. ALBEDODIRECTUV: number;
  49514. VERTEXCOLOR: boolean;
  49515. AMBIENT: boolean;
  49516. AMBIENTDIRECTUV: number;
  49517. AMBIENTINGRAYSCALE: boolean;
  49518. OPACITY: boolean;
  49519. VERTEXALPHA: boolean;
  49520. OPACITYDIRECTUV: number;
  49521. OPACITYRGB: boolean;
  49522. ALPHATEST: boolean;
  49523. DEPTHPREPASS: boolean;
  49524. ALPHABLEND: boolean;
  49525. ALPHAFROMALBEDO: boolean;
  49526. ALPHATESTVALUE: string;
  49527. SPECULAROVERALPHA: boolean;
  49528. RADIANCEOVERALPHA: boolean;
  49529. ALPHAFRESNEL: boolean;
  49530. LINEARALPHAFRESNEL: boolean;
  49531. PREMULTIPLYALPHA: boolean;
  49532. EMISSIVE: boolean;
  49533. EMISSIVEDIRECTUV: number;
  49534. REFLECTIVITY: boolean;
  49535. REFLECTIVITYDIRECTUV: number;
  49536. SPECULARTERM: boolean;
  49537. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49538. MICROSURFACEAUTOMATIC: boolean;
  49539. LODBASEDMICROSFURACE: boolean;
  49540. MICROSURFACEMAP: boolean;
  49541. MICROSURFACEMAPDIRECTUV: number;
  49542. METALLICWORKFLOW: boolean;
  49543. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49544. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49545. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49546. AOSTOREINMETALMAPRED: boolean;
  49547. ENVIRONMENTBRDF: boolean;
  49548. ENVIRONMENTBRDF_RGBD: boolean;
  49549. NORMAL: boolean;
  49550. TANGENT: boolean;
  49551. BUMP: boolean;
  49552. BUMPDIRECTUV: number;
  49553. OBJECTSPACE_NORMALMAP: boolean;
  49554. PARALLAX: boolean;
  49555. PARALLAXOCCLUSION: boolean;
  49556. NORMALXYSCALE: boolean;
  49557. LIGHTMAP: boolean;
  49558. LIGHTMAPDIRECTUV: number;
  49559. USELIGHTMAPASSHADOWMAP: boolean;
  49560. GAMMALIGHTMAP: boolean;
  49561. RGBDLIGHTMAP: boolean;
  49562. REFLECTION: boolean;
  49563. REFLECTIONMAP_3D: boolean;
  49564. REFLECTIONMAP_SPHERICAL: boolean;
  49565. REFLECTIONMAP_PLANAR: boolean;
  49566. REFLECTIONMAP_CUBIC: boolean;
  49567. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49568. REFLECTIONMAP_PROJECTION: boolean;
  49569. REFLECTIONMAP_SKYBOX: boolean;
  49570. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49571. REFLECTIONMAP_EXPLICIT: boolean;
  49572. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49573. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49574. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49575. INVERTCUBICMAP: boolean;
  49576. USESPHERICALFROMREFLECTIONMAP: boolean;
  49577. USEIRRADIANCEMAP: boolean;
  49578. SPHERICAL_HARMONICS: boolean;
  49579. USESPHERICALINVERTEX: boolean;
  49580. REFLECTIONMAP_OPPOSITEZ: boolean;
  49581. LODINREFLECTIONALPHA: boolean;
  49582. GAMMAREFLECTION: boolean;
  49583. RGBDREFLECTION: boolean;
  49584. LINEARSPECULARREFLECTION: boolean;
  49585. RADIANCEOCCLUSION: boolean;
  49586. HORIZONOCCLUSION: boolean;
  49587. INSTANCES: boolean;
  49588. NUM_BONE_INFLUENCERS: number;
  49589. BonesPerMesh: number;
  49590. BONETEXTURE: boolean;
  49591. NONUNIFORMSCALING: boolean;
  49592. MORPHTARGETS: boolean;
  49593. MORPHTARGETS_NORMAL: boolean;
  49594. MORPHTARGETS_TANGENT: boolean;
  49595. MORPHTARGETS_UV: boolean;
  49596. NUM_MORPH_INFLUENCERS: number;
  49597. IMAGEPROCESSING: boolean;
  49598. VIGNETTE: boolean;
  49599. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49600. VIGNETTEBLENDMODEOPAQUE: boolean;
  49601. TONEMAPPING: boolean;
  49602. TONEMAPPING_ACES: boolean;
  49603. CONTRAST: boolean;
  49604. COLORCURVES: boolean;
  49605. COLORGRADING: boolean;
  49606. COLORGRADING3D: boolean;
  49607. SAMPLER3DGREENDEPTH: boolean;
  49608. SAMPLER3DBGRMAP: boolean;
  49609. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49610. EXPOSURE: boolean;
  49611. MULTIVIEW: boolean;
  49612. USEPHYSICALLIGHTFALLOFF: boolean;
  49613. USEGLTFLIGHTFALLOFF: boolean;
  49614. TWOSIDEDLIGHTING: boolean;
  49615. SHADOWFLOAT: boolean;
  49616. CLIPPLANE: boolean;
  49617. CLIPPLANE2: boolean;
  49618. CLIPPLANE3: boolean;
  49619. CLIPPLANE4: boolean;
  49620. POINTSIZE: boolean;
  49621. FOG: boolean;
  49622. LOGARITHMICDEPTH: boolean;
  49623. FORCENORMALFORWARD: boolean;
  49624. SPECULARAA: boolean;
  49625. CLEARCOAT: boolean;
  49626. CLEARCOAT_DEFAULTIOR: boolean;
  49627. CLEARCOAT_TEXTURE: boolean;
  49628. CLEARCOAT_TEXTUREDIRECTUV: number;
  49629. CLEARCOAT_BUMP: boolean;
  49630. CLEARCOAT_BUMPDIRECTUV: number;
  49631. CLEARCOAT_TINT: boolean;
  49632. CLEARCOAT_TINT_TEXTURE: boolean;
  49633. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49634. ANISOTROPIC: boolean;
  49635. ANISOTROPIC_TEXTURE: boolean;
  49636. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49637. BRDF_V_HEIGHT_CORRELATED: boolean;
  49638. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49639. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49640. SHEEN: boolean;
  49641. SHEEN_TEXTURE: boolean;
  49642. SHEEN_TEXTUREDIRECTUV: number;
  49643. SHEEN_LINKWITHALBEDO: boolean;
  49644. SUBSURFACE: boolean;
  49645. SS_REFRACTION: boolean;
  49646. SS_TRANSLUCENCY: boolean;
  49647. SS_SCATERRING: boolean;
  49648. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49649. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49650. SS_REFRACTIONMAP_3D: boolean;
  49651. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49652. SS_LODINREFRACTIONALPHA: boolean;
  49653. SS_GAMMAREFRACTION: boolean;
  49654. SS_RGBDREFRACTION: boolean;
  49655. SS_LINEARSPECULARREFRACTION: boolean;
  49656. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49657. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49658. UNLIT: boolean;
  49659. DEBUGMODE: number;
  49660. /**
  49661. * Initializes the PBR Material defines.
  49662. */
  49663. constructor();
  49664. /**
  49665. * Resets the PBR Material defines.
  49666. */
  49667. reset(): void;
  49668. }
  49669. /**
  49670. * The Physically based material base class of BJS.
  49671. *
  49672. * This offers the main features of a standard PBR material.
  49673. * For more information, please refer to the documentation :
  49674. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49675. */
  49676. export abstract class PBRBaseMaterial extends PushMaterial {
  49677. /**
  49678. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49679. */
  49680. static readonly PBRMATERIAL_OPAQUE: number;
  49681. /**
  49682. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49683. */
  49684. static readonly PBRMATERIAL_ALPHATEST: number;
  49685. /**
  49686. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49687. */
  49688. static readonly PBRMATERIAL_ALPHABLEND: number;
  49689. /**
  49690. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49691. * They are also discarded below the alpha cutoff threshold to improve performances.
  49692. */
  49693. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49694. /**
  49695. * Defines the default value of how much AO map is occluding the analytical lights
  49696. * (point spot...).
  49697. */
  49698. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49699. /**
  49700. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49701. */
  49702. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49703. /**
  49704. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49705. * to enhance interoperability with other engines.
  49706. */
  49707. static readonly LIGHTFALLOFF_GLTF: number;
  49708. /**
  49709. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49710. * to enhance interoperability with other materials.
  49711. */
  49712. static readonly LIGHTFALLOFF_STANDARD: number;
  49713. /**
  49714. * Intensity of the direct lights e.g. the four lights available in your scene.
  49715. * This impacts both the direct diffuse and specular highlights.
  49716. */
  49717. protected _directIntensity: number;
  49718. /**
  49719. * Intensity of the emissive part of the material.
  49720. * This helps controlling the emissive effect without modifying the emissive color.
  49721. */
  49722. protected _emissiveIntensity: number;
  49723. /**
  49724. * Intensity of the environment e.g. how much the environment will light the object
  49725. * either through harmonics for rough material or through the refelction for shiny ones.
  49726. */
  49727. protected _environmentIntensity: number;
  49728. /**
  49729. * This is a special control allowing the reduction of the specular highlights coming from the
  49730. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49731. */
  49732. protected _specularIntensity: number;
  49733. /**
  49734. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49735. */
  49736. private _lightingInfos;
  49737. /**
  49738. * Debug Control allowing disabling the bump map on this material.
  49739. */
  49740. protected _disableBumpMap: boolean;
  49741. /**
  49742. * AKA Diffuse Texture in standard nomenclature.
  49743. */
  49744. protected _albedoTexture: Nullable<BaseTexture>;
  49745. /**
  49746. * AKA Occlusion Texture in other nomenclature.
  49747. */
  49748. protected _ambientTexture: Nullable<BaseTexture>;
  49749. /**
  49750. * AKA Occlusion Texture Intensity in other nomenclature.
  49751. */
  49752. protected _ambientTextureStrength: number;
  49753. /**
  49754. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49755. * 1 means it completely occludes it
  49756. * 0 mean it has no impact
  49757. */
  49758. protected _ambientTextureImpactOnAnalyticalLights: number;
  49759. /**
  49760. * Stores the alpha values in a texture.
  49761. */
  49762. protected _opacityTexture: Nullable<BaseTexture>;
  49763. /**
  49764. * Stores the reflection values in a texture.
  49765. */
  49766. protected _reflectionTexture: Nullable<BaseTexture>;
  49767. /**
  49768. * Stores the emissive values in a texture.
  49769. */
  49770. protected _emissiveTexture: Nullable<BaseTexture>;
  49771. /**
  49772. * AKA Specular texture in other nomenclature.
  49773. */
  49774. protected _reflectivityTexture: Nullable<BaseTexture>;
  49775. /**
  49776. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49777. */
  49778. protected _metallicTexture: Nullable<BaseTexture>;
  49779. /**
  49780. * Specifies the metallic scalar of the metallic/roughness workflow.
  49781. * Can also be used to scale the metalness values of the metallic texture.
  49782. */
  49783. protected _metallic: Nullable<number>;
  49784. /**
  49785. * Specifies the roughness scalar of the metallic/roughness workflow.
  49786. * Can also be used to scale the roughness values of the metallic texture.
  49787. */
  49788. protected _roughness: Nullable<number>;
  49789. /**
  49790. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49791. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49792. */
  49793. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49794. /**
  49795. * Stores surface normal data used to displace a mesh in a texture.
  49796. */
  49797. protected _bumpTexture: Nullable<BaseTexture>;
  49798. /**
  49799. * Stores the pre-calculated light information of a mesh in a texture.
  49800. */
  49801. protected _lightmapTexture: Nullable<BaseTexture>;
  49802. /**
  49803. * The color of a material in ambient lighting.
  49804. */
  49805. protected _ambientColor: Color3;
  49806. /**
  49807. * AKA Diffuse Color in other nomenclature.
  49808. */
  49809. protected _albedoColor: Color3;
  49810. /**
  49811. * AKA Specular Color in other nomenclature.
  49812. */
  49813. protected _reflectivityColor: Color3;
  49814. /**
  49815. * The color applied when light is reflected from a material.
  49816. */
  49817. protected _reflectionColor: Color3;
  49818. /**
  49819. * The color applied when light is emitted from a material.
  49820. */
  49821. protected _emissiveColor: Color3;
  49822. /**
  49823. * AKA Glossiness in other nomenclature.
  49824. */
  49825. protected _microSurface: number;
  49826. /**
  49827. * Specifies that the material will use the light map as a show map.
  49828. */
  49829. protected _useLightmapAsShadowmap: boolean;
  49830. /**
  49831. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49832. * makes the reflect vector face the model (under horizon).
  49833. */
  49834. protected _useHorizonOcclusion: boolean;
  49835. /**
  49836. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49837. * too much the area relying on ambient texture to define their ambient occlusion.
  49838. */
  49839. protected _useRadianceOcclusion: boolean;
  49840. /**
  49841. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49842. */
  49843. protected _useAlphaFromAlbedoTexture: boolean;
  49844. /**
  49845. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49846. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49847. */
  49848. protected _useSpecularOverAlpha: boolean;
  49849. /**
  49850. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49851. */
  49852. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49853. /**
  49854. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49855. */
  49856. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49857. /**
  49858. * Specifies if the metallic texture contains the roughness information in its green channel.
  49859. */
  49860. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49861. /**
  49862. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49863. */
  49864. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49865. /**
  49866. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49867. */
  49868. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49869. /**
  49870. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49871. */
  49872. protected _useAmbientInGrayScale: boolean;
  49873. /**
  49874. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49875. * The material will try to infer what glossiness each pixel should be.
  49876. */
  49877. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49878. /**
  49879. * Defines the falloff type used in this material.
  49880. * It by default is Physical.
  49881. */
  49882. protected _lightFalloff: number;
  49883. /**
  49884. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49885. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49886. */
  49887. protected _useRadianceOverAlpha: boolean;
  49888. /**
  49889. * Allows using an object space normal map (instead of tangent space).
  49890. */
  49891. protected _useObjectSpaceNormalMap: boolean;
  49892. /**
  49893. * Allows using the bump map in parallax mode.
  49894. */
  49895. protected _useParallax: boolean;
  49896. /**
  49897. * Allows using the bump map in parallax occlusion mode.
  49898. */
  49899. protected _useParallaxOcclusion: boolean;
  49900. /**
  49901. * Controls the scale bias of the parallax mode.
  49902. */
  49903. protected _parallaxScaleBias: number;
  49904. /**
  49905. * If sets to true, disables all the lights affecting the material.
  49906. */
  49907. protected _disableLighting: boolean;
  49908. /**
  49909. * Number of Simultaneous lights allowed on the material.
  49910. */
  49911. protected _maxSimultaneousLights: number;
  49912. /**
  49913. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49914. */
  49915. protected _invertNormalMapX: boolean;
  49916. /**
  49917. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49918. */
  49919. protected _invertNormalMapY: boolean;
  49920. /**
  49921. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49922. */
  49923. protected _twoSidedLighting: boolean;
  49924. /**
  49925. * Defines the alpha limits in alpha test mode.
  49926. */
  49927. protected _alphaCutOff: number;
  49928. /**
  49929. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49930. */
  49931. protected _forceAlphaTest: boolean;
  49932. /**
  49933. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49934. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49935. */
  49936. protected _useAlphaFresnel: boolean;
  49937. /**
  49938. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49939. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49940. */
  49941. protected _useLinearAlphaFresnel: boolean;
  49942. /**
  49943. * The transparency mode of the material.
  49944. */
  49945. protected _transparencyMode: Nullable<number>;
  49946. /**
  49947. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49948. * from cos thetav and roughness:
  49949. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49950. */
  49951. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49952. /**
  49953. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49954. */
  49955. protected _forceIrradianceInFragment: boolean;
  49956. /**
  49957. * Force normal to face away from face.
  49958. */
  49959. protected _forceNormalForward: boolean;
  49960. /**
  49961. * Enables specular anti aliasing in the PBR shader.
  49962. * It will both interacts on the Geometry for analytical and IBL lighting.
  49963. * It also prefilter the roughness map based on the bump values.
  49964. */
  49965. protected _enableSpecularAntiAliasing: boolean;
  49966. /**
  49967. * Default configuration related to image processing available in the PBR Material.
  49968. */
  49969. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49970. /**
  49971. * Keep track of the image processing observer to allow dispose and replace.
  49972. */
  49973. private _imageProcessingObserver;
  49974. /**
  49975. * Attaches a new image processing configuration to the PBR Material.
  49976. * @param configuration
  49977. */
  49978. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49979. /**
  49980. * Stores the available render targets.
  49981. */
  49982. private _renderTargets;
  49983. /**
  49984. * Sets the global ambient color for the material used in lighting calculations.
  49985. */
  49986. private _globalAmbientColor;
  49987. /**
  49988. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49989. */
  49990. private _useLogarithmicDepth;
  49991. /**
  49992. * If set to true, no lighting calculations will be applied.
  49993. */
  49994. private _unlit;
  49995. private _debugMode;
  49996. /**
  49997. * @hidden
  49998. * This is reserved for the inspector.
  49999. * Defines the material debug mode.
  50000. * It helps seeing only some components of the material while troubleshooting.
  50001. */
  50002. debugMode: number;
  50003. /**
  50004. * @hidden
  50005. * This is reserved for the inspector.
  50006. * Specify from where on screen the debug mode should start.
  50007. * The value goes from -1 (full screen) to 1 (not visible)
  50008. * It helps with side by side comparison against the final render
  50009. * This defaults to -1
  50010. */
  50011. private debugLimit;
  50012. /**
  50013. * @hidden
  50014. * This is reserved for the inspector.
  50015. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50016. * You can use the factor to better multiply the final value.
  50017. */
  50018. private debugFactor;
  50019. /**
  50020. * Defines the clear coat layer parameters for the material.
  50021. */
  50022. readonly clearCoat: PBRClearCoatConfiguration;
  50023. /**
  50024. * Defines the anisotropic parameters for the material.
  50025. */
  50026. readonly anisotropy: PBRAnisotropicConfiguration;
  50027. /**
  50028. * Defines the BRDF parameters for the material.
  50029. */
  50030. readonly brdf: PBRBRDFConfiguration;
  50031. /**
  50032. * Defines the Sheen parameters for the material.
  50033. */
  50034. readonly sheen: PBRSheenConfiguration;
  50035. /**
  50036. * Defines the SubSurface parameters for the material.
  50037. */
  50038. readonly subSurface: PBRSubSurfaceConfiguration;
  50039. /**
  50040. * Custom callback helping to override the default shader used in the material.
  50041. */
  50042. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50043. protected _rebuildInParallel: boolean;
  50044. /**
  50045. * Instantiates a new PBRMaterial instance.
  50046. *
  50047. * @param name The material name
  50048. * @param scene The scene the material will be use in.
  50049. */
  50050. constructor(name: string, scene: Scene);
  50051. /**
  50052. * Gets a boolean indicating that current material needs to register RTT
  50053. */
  50054. readonly hasRenderTargetTextures: boolean;
  50055. /**
  50056. * Gets the name of the material class.
  50057. */
  50058. getClassName(): string;
  50059. /**
  50060. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50061. */
  50062. /**
  50063. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50064. */
  50065. useLogarithmicDepth: boolean;
  50066. /**
  50067. * Gets the current transparency mode.
  50068. */
  50069. /**
  50070. * Sets the transparency mode of the material.
  50071. *
  50072. * | Value | Type | Description |
  50073. * | ----- | ----------------------------------- | ----------- |
  50074. * | 0 | OPAQUE | |
  50075. * | 1 | ALPHATEST | |
  50076. * | 2 | ALPHABLEND | |
  50077. * | 3 | ALPHATESTANDBLEND | |
  50078. *
  50079. */
  50080. transparencyMode: Nullable<number>;
  50081. /**
  50082. * Returns true if alpha blending should be disabled.
  50083. */
  50084. private readonly _disableAlphaBlending;
  50085. /**
  50086. * Specifies whether or not this material should be rendered in alpha blend mode.
  50087. */
  50088. needAlphaBlending(): boolean;
  50089. /**
  50090. * Specifies if the mesh will require alpha blending.
  50091. * @param mesh - BJS mesh.
  50092. */
  50093. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50094. /**
  50095. * Specifies whether or not this material should be rendered in alpha test mode.
  50096. */
  50097. needAlphaTesting(): boolean;
  50098. /**
  50099. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50100. */
  50101. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50102. /**
  50103. * Gets the texture used for the alpha test.
  50104. */
  50105. getAlphaTestTexture(): Nullable<BaseTexture>;
  50106. /**
  50107. * Specifies that the submesh is ready to be used.
  50108. * @param mesh - BJS mesh.
  50109. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50110. * @param useInstances - Specifies that instances should be used.
  50111. * @returns - boolean indicating that the submesh is ready or not.
  50112. */
  50113. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50114. /**
  50115. * Specifies if the material uses metallic roughness workflow.
  50116. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50117. */
  50118. isMetallicWorkflow(): boolean;
  50119. private _prepareEffect;
  50120. private _prepareDefines;
  50121. /**
  50122. * Force shader compilation
  50123. */
  50124. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50125. clipPlane: boolean;
  50126. }>): void;
  50127. /**
  50128. * Initializes the uniform buffer layout for the shader.
  50129. */
  50130. buildUniformLayout(): void;
  50131. /**
  50132. * Unbinds the material from the mesh
  50133. */
  50134. unbind(): void;
  50135. /**
  50136. * Binds the submesh data.
  50137. * @param world - The world matrix.
  50138. * @param mesh - The BJS mesh.
  50139. * @param subMesh - A submesh of the BJS mesh.
  50140. */
  50141. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50142. /**
  50143. * Returns the animatable textures.
  50144. * @returns - Array of animatable textures.
  50145. */
  50146. getAnimatables(): IAnimatable[];
  50147. /**
  50148. * Returns the texture used for reflections.
  50149. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50150. */
  50151. private _getReflectionTexture;
  50152. /**
  50153. * Returns an array of the actively used textures.
  50154. * @returns - Array of BaseTextures
  50155. */
  50156. getActiveTextures(): BaseTexture[];
  50157. /**
  50158. * Checks to see if a texture is used in the material.
  50159. * @param texture - Base texture to use.
  50160. * @returns - Boolean specifying if a texture is used in the material.
  50161. */
  50162. hasTexture(texture: BaseTexture): boolean;
  50163. /**
  50164. * Disposes the resources of the material.
  50165. * @param forceDisposeEffect - Forces the disposal of effects.
  50166. * @param forceDisposeTextures - Forces the disposal of all textures.
  50167. */
  50168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50169. }
  50170. }
  50171. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50172. import { Nullable } from "babylonjs/types";
  50173. import { Scene } from "babylonjs/scene";
  50174. import { Color3 } from "babylonjs/Maths/math.color";
  50175. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50176. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50177. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50178. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50179. /**
  50180. * The Physically based material of BJS.
  50181. *
  50182. * This offers the main features of a standard PBR material.
  50183. * For more information, please refer to the documentation :
  50184. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50185. */
  50186. export class PBRMaterial extends PBRBaseMaterial {
  50187. /**
  50188. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50189. */
  50190. static readonly PBRMATERIAL_OPAQUE: number;
  50191. /**
  50192. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50193. */
  50194. static readonly PBRMATERIAL_ALPHATEST: number;
  50195. /**
  50196. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50197. */
  50198. static readonly PBRMATERIAL_ALPHABLEND: number;
  50199. /**
  50200. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50201. * They are also discarded below the alpha cutoff threshold to improve performances.
  50202. */
  50203. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50204. /**
  50205. * Defines the default value of how much AO map is occluding the analytical lights
  50206. * (point spot...).
  50207. */
  50208. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50209. /**
  50210. * Intensity of the direct lights e.g. the four lights available in your scene.
  50211. * This impacts both the direct diffuse and specular highlights.
  50212. */
  50213. directIntensity: number;
  50214. /**
  50215. * Intensity of the emissive part of the material.
  50216. * This helps controlling the emissive effect without modifying the emissive color.
  50217. */
  50218. emissiveIntensity: number;
  50219. /**
  50220. * Intensity of the environment e.g. how much the environment will light the object
  50221. * either through harmonics for rough material or through the refelction for shiny ones.
  50222. */
  50223. environmentIntensity: number;
  50224. /**
  50225. * This is a special control allowing the reduction of the specular highlights coming from the
  50226. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50227. */
  50228. specularIntensity: number;
  50229. /**
  50230. * Debug Control allowing disabling the bump map on this material.
  50231. */
  50232. disableBumpMap: boolean;
  50233. /**
  50234. * AKA Diffuse Texture in standard nomenclature.
  50235. */
  50236. albedoTexture: BaseTexture;
  50237. /**
  50238. * AKA Occlusion Texture in other nomenclature.
  50239. */
  50240. ambientTexture: BaseTexture;
  50241. /**
  50242. * AKA Occlusion Texture Intensity in other nomenclature.
  50243. */
  50244. ambientTextureStrength: number;
  50245. /**
  50246. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50247. * 1 means it completely occludes it
  50248. * 0 mean it has no impact
  50249. */
  50250. ambientTextureImpactOnAnalyticalLights: number;
  50251. /**
  50252. * Stores the alpha values in a texture.
  50253. */
  50254. opacityTexture: BaseTexture;
  50255. /**
  50256. * Stores the reflection values in a texture.
  50257. */
  50258. reflectionTexture: Nullable<BaseTexture>;
  50259. /**
  50260. * Stores the emissive values in a texture.
  50261. */
  50262. emissiveTexture: BaseTexture;
  50263. /**
  50264. * AKA Specular texture in other nomenclature.
  50265. */
  50266. reflectivityTexture: BaseTexture;
  50267. /**
  50268. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50269. */
  50270. metallicTexture: BaseTexture;
  50271. /**
  50272. * Specifies the metallic scalar of the metallic/roughness workflow.
  50273. * Can also be used to scale the metalness values of the metallic texture.
  50274. */
  50275. metallic: Nullable<number>;
  50276. /**
  50277. * Specifies the roughness scalar of the metallic/roughness workflow.
  50278. * Can also be used to scale the roughness values of the metallic texture.
  50279. */
  50280. roughness: Nullable<number>;
  50281. /**
  50282. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50283. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50284. */
  50285. microSurfaceTexture: BaseTexture;
  50286. /**
  50287. * Stores surface normal data used to displace a mesh in a texture.
  50288. */
  50289. bumpTexture: BaseTexture;
  50290. /**
  50291. * Stores the pre-calculated light information of a mesh in a texture.
  50292. */
  50293. lightmapTexture: BaseTexture;
  50294. /**
  50295. * Stores the refracted light information in a texture.
  50296. */
  50297. refractionTexture: Nullable<BaseTexture>;
  50298. /**
  50299. * The color of a material in ambient lighting.
  50300. */
  50301. ambientColor: Color3;
  50302. /**
  50303. * AKA Diffuse Color in other nomenclature.
  50304. */
  50305. albedoColor: Color3;
  50306. /**
  50307. * AKA Specular Color in other nomenclature.
  50308. */
  50309. reflectivityColor: Color3;
  50310. /**
  50311. * The color reflected from the material.
  50312. */
  50313. reflectionColor: Color3;
  50314. /**
  50315. * The color emitted from the material.
  50316. */
  50317. emissiveColor: Color3;
  50318. /**
  50319. * AKA Glossiness in other nomenclature.
  50320. */
  50321. microSurface: number;
  50322. /**
  50323. * source material index of refraction (IOR)' / 'destination material IOR.
  50324. */
  50325. indexOfRefraction: number;
  50326. /**
  50327. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50328. */
  50329. invertRefractionY: boolean;
  50330. /**
  50331. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50332. * Materials half opaque for instance using refraction could benefit from this control.
  50333. */
  50334. linkRefractionWithTransparency: boolean;
  50335. /**
  50336. * If true, the light map contains occlusion information instead of lighting info.
  50337. */
  50338. useLightmapAsShadowmap: boolean;
  50339. /**
  50340. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50341. */
  50342. useAlphaFromAlbedoTexture: boolean;
  50343. /**
  50344. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50345. */
  50346. forceAlphaTest: boolean;
  50347. /**
  50348. * Defines the alpha limits in alpha test mode.
  50349. */
  50350. alphaCutOff: number;
  50351. /**
  50352. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50353. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50354. */
  50355. useSpecularOverAlpha: boolean;
  50356. /**
  50357. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50358. */
  50359. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50360. /**
  50361. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50362. */
  50363. useRoughnessFromMetallicTextureAlpha: boolean;
  50364. /**
  50365. * Specifies if the metallic texture contains the roughness information in its green channel.
  50366. */
  50367. useRoughnessFromMetallicTextureGreen: boolean;
  50368. /**
  50369. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50370. */
  50371. useMetallnessFromMetallicTextureBlue: boolean;
  50372. /**
  50373. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50374. */
  50375. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50376. /**
  50377. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50378. */
  50379. useAmbientInGrayScale: boolean;
  50380. /**
  50381. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50382. * The material will try to infer what glossiness each pixel should be.
  50383. */
  50384. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50385. /**
  50386. * BJS is using an harcoded light falloff based on a manually sets up range.
  50387. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50388. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50389. */
  50390. /**
  50391. * BJS is using an harcoded light falloff based on a manually sets up range.
  50392. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50393. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50394. */
  50395. usePhysicalLightFalloff: boolean;
  50396. /**
  50397. * In order to support the falloff compatibility with gltf, a special mode has been added
  50398. * to reproduce the gltf light falloff.
  50399. */
  50400. /**
  50401. * In order to support the falloff compatibility with gltf, a special mode has been added
  50402. * to reproduce the gltf light falloff.
  50403. */
  50404. useGLTFLightFalloff: boolean;
  50405. /**
  50406. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50407. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50408. */
  50409. useRadianceOverAlpha: boolean;
  50410. /**
  50411. * Allows using an object space normal map (instead of tangent space).
  50412. */
  50413. useObjectSpaceNormalMap: boolean;
  50414. /**
  50415. * Allows using the bump map in parallax mode.
  50416. */
  50417. useParallax: boolean;
  50418. /**
  50419. * Allows using the bump map in parallax occlusion mode.
  50420. */
  50421. useParallaxOcclusion: boolean;
  50422. /**
  50423. * Controls the scale bias of the parallax mode.
  50424. */
  50425. parallaxScaleBias: number;
  50426. /**
  50427. * If sets to true, disables all the lights affecting the material.
  50428. */
  50429. disableLighting: boolean;
  50430. /**
  50431. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50432. */
  50433. forceIrradianceInFragment: boolean;
  50434. /**
  50435. * Number of Simultaneous lights allowed on the material.
  50436. */
  50437. maxSimultaneousLights: number;
  50438. /**
  50439. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50440. */
  50441. invertNormalMapX: boolean;
  50442. /**
  50443. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50444. */
  50445. invertNormalMapY: boolean;
  50446. /**
  50447. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50448. */
  50449. twoSidedLighting: boolean;
  50450. /**
  50451. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50452. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50453. */
  50454. useAlphaFresnel: boolean;
  50455. /**
  50456. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50457. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50458. */
  50459. useLinearAlphaFresnel: boolean;
  50460. /**
  50461. * Let user defines the brdf lookup texture used for IBL.
  50462. * A default 8bit version is embedded but you could point at :
  50463. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50464. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50465. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50466. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50467. */
  50468. environmentBRDFTexture: Nullable<BaseTexture>;
  50469. /**
  50470. * Force normal to face away from face.
  50471. */
  50472. forceNormalForward: boolean;
  50473. /**
  50474. * Enables specular anti aliasing in the PBR shader.
  50475. * It will both interacts on the Geometry for analytical and IBL lighting.
  50476. * It also prefilter the roughness map based on the bump values.
  50477. */
  50478. enableSpecularAntiAliasing: boolean;
  50479. /**
  50480. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50481. * makes the reflect vector face the model (under horizon).
  50482. */
  50483. useHorizonOcclusion: boolean;
  50484. /**
  50485. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50486. * too much the area relying on ambient texture to define their ambient occlusion.
  50487. */
  50488. useRadianceOcclusion: boolean;
  50489. /**
  50490. * If set to true, no lighting calculations will be applied.
  50491. */
  50492. unlit: boolean;
  50493. /**
  50494. * Gets the image processing configuration used either in this material.
  50495. */
  50496. /**
  50497. * Sets the Default image processing configuration used either in the this material.
  50498. *
  50499. * If sets to null, the scene one is in use.
  50500. */
  50501. imageProcessingConfiguration: ImageProcessingConfiguration;
  50502. /**
  50503. * Gets wether the color curves effect is enabled.
  50504. */
  50505. /**
  50506. * Sets wether the color curves effect is enabled.
  50507. */
  50508. cameraColorCurvesEnabled: boolean;
  50509. /**
  50510. * Gets wether the color grading effect is enabled.
  50511. */
  50512. /**
  50513. * Gets wether the color grading effect is enabled.
  50514. */
  50515. cameraColorGradingEnabled: boolean;
  50516. /**
  50517. * Gets wether tonemapping is enabled or not.
  50518. */
  50519. /**
  50520. * Sets wether tonemapping is enabled or not
  50521. */
  50522. cameraToneMappingEnabled: boolean;
  50523. /**
  50524. * The camera exposure used on this material.
  50525. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50526. * This corresponds to a photographic exposure.
  50527. */
  50528. /**
  50529. * The camera exposure used on this material.
  50530. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50531. * This corresponds to a photographic exposure.
  50532. */
  50533. cameraExposure: number;
  50534. /**
  50535. * Gets The camera contrast used on this material.
  50536. */
  50537. /**
  50538. * Sets The camera contrast used on this material.
  50539. */
  50540. cameraContrast: number;
  50541. /**
  50542. * Gets the Color Grading 2D Lookup Texture.
  50543. */
  50544. /**
  50545. * Sets the Color Grading 2D Lookup Texture.
  50546. */
  50547. cameraColorGradingTexture: Nullable<BaseTexture>;
  50548. /**
  50549. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50550. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50551. * 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;
  50552. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50553. */
  50554. /**
  50555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50557. * 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;
  50558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50559. */
  50560. cameraColorCurves: Nullable<ColorCurves>;
  50561. /**
  50562. * Instantiates a new PBRMaterial instance.
  50563. *
  50564. * @param name The material name
  50565. * @param scene The scene the material will be use in.
  50566. */
  50567. constructor(name: string, scene: Scene);
  50568. /**
  50569. * Returns the name of this material class.
  50570. */
  50571. getClassName(): string;
  50572. /**
  50573. * Makes a duplicate of the current material.
  50574. * @param name - name to use for the new material.
  50575. */
  50576. clone(name: string): PBRMaterial;
  50577. /**
  50578. * Serializes this PBR Material.
  50579. * @returns - An object with the serialized material.
  50580. */
  50581. serialize(): any;
  50582. /**
  50583. * Parses a PBR Material from a serialized object.
  50584. * @param source - Serialized object.
  50585. * @param scene - BJS scene instance.
  50586. * @param rootUrl - url for the scene object
  50587. * @returns - PBRMaterial
  50588. */
  50589. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50590. }
  50591. }
  50592. declare module "babylonjs/Misc/dds" {
  50593. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50594. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50595. import { Nullable } from "babylonjs/types";
  50596. import { Scene } from "babylonjs/scene";
  50597. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50598. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50599. /**
  50600. * Direct draw surface info
  50601. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50602. */
  50603. export interface DDSInfo {
  50604. /**
  50605. * Width of the texture
  50606. */
  50607. width: number;
  50608. /**
  50609. * Width of the texture
  50610. */
  50611. height: number;
  50612. /**
  50613. * Number of Mipmaps for the texture
  50614. * @see https://en.wikipedia.org/wiki/Mipmap
  50615. */
  50616. mipmapCount: number;
  50617. /**
  50618. * If the textures format is a known fourCC format
  50619. * @see https://www.fourcc.org/
  50620. */
  50621. isFourCC: boolean;
  50622. /**
  50623. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50624. */
  50625. isRGB: boolean;
  50626. /**
  50627. * If the texture is a lumincance format
  50628. */
  50629. isLuminance: boolean;
  50630. /**
  50631. * If this is a cube texture
  50632. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50633. */
  50634. isCube: boolean;
  50635. /**
  50636. * If the texture is a compressed format eg. FOURCC_DXT1
  50637. */
  50638. isCompressed: boolean;
  50639. /**
  50640. * The dxgiFormat of the texture
  50641. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50642. */
  50643. dxgiFormat: number;
  50644. /**
  50645. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50646. */
  50647. textureType: number;
  50648. /**
  50649. * Sphericle polynomial created for the dds texture
  50650. */
  50651. sphericalPolynomial?: SphericalPolynomial;
  50652. }
  50653. /**
  50654. * Class used to provide DDS decompression tools
  50655. */
  50656. export class DDSTools {
  50657. /**
  50658. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50659. */
  50660. static StoreLODInAlphaChannel: boolean;
  50661. /**
  50662. * Gets DDS information from an array buffer
  50663. * @param arrayBuffer defines the array buffer to read data from
  50664. * @returns the DDS information
  50665. */
  50666. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50667. private static _FloatView;
  50668. private static _Int32View;
  50669. private static _ToHalfFloat;
  50670. private static _FromHalfFloat;
  50671. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50672. private static _GetHalfFloatRGBAArrayBuffer;
  50673. private static _GetFloatRGBAArrayBuffer;
  50674. private static _GetFloatAsUIntRGBAArrayBuffer;
  50675. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50676. private static _GetRGBAArrayBuffer;
  50677. private static _ExtractLongWordOrder;
  50678. private static _GetRGBArrayBuffer;
  50679. private static _GetLuminanceArrayBuffer;
  50680. /**
  50681. * Uploads DDS Levels to a Babylon Texture
  50682. * @hidden
  50683. */
  50684. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50685. }
  50686. module "babylonjs/Engines/thinEngine" {
  50687. interface ThinEngine {
  50688. /**
  50689. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50690. * @param rootUrl defines the url where the file to load is located
  50691. * @param scene defines the current scene
  50692. * @param lodScale defines scale to apply to the mip map selection
  50693. * @param lodOffset defines offset to apply to the mip map selection
  50694. * @param onLoad defines an optional callback raised when the texture is loaded
  50695. * @param onError defines an optional callback raised if there is an issue to load the texture
  50696. * @param format defines the format of the data
  50697. * @param forcedExtension defines the extension to use to pick the right loader
  50698. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50699. * @returns the cube texture as an InternalTexture
  50700. */
  50701. 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;
  50702. }
  50703. }
  50704. }
  50705. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50706. import { Nullable } from "babylonjs/types";
  50707. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50708. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50709. /**
  50710. * Implementation of the DDS Texture Loader.
  50711. * @hidden
  50712. */
  50713. export class _DDSTextureLoader implements IInternalTextureLoader {
  50714. /**
  50715. * Defines wether the loader supports cascade loading the different faces.
  50716. */
  50717. readonly supportCascades: boolean;
  50718. /**
  50719. * This returns if the loader support the current file information.
  50720. * @param extension defines the file extension of the file being loaded
  50721. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50722. * @param fallback defines the fallback internal texture if any
  50723. * @param isBase64 defines whether the texture is encoded as a base64
  50724. * @param isBuffer defines whether the texture data are stored as a buffer
  50725. * @returns true if the loader can load the specified file
  50726. */
  50727. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50728. /**
  50729. * Transform the url before loading if required.
  50730. * @param rootUrl the url of the texture
  50731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50732. * @returns the transformed texture
  50733. */
  50734. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50735. /**
  50736. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50737. * @param rootUrl the url of the texture
  50738. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50739. * @returns the fallback texture
  50740. */
  50741. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50742. /**
  50743. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50744. * @param data contains the texture data
  50745. * @param texture defines the BabylonJS internal texture
  50746. * @param createPolynomials will be true if polynomials have been requested
  50747. * @param onLoad defines the callback to trigger once the texture is ready
  50748. * @param onError defines the callback to trigger in case of error
  50749. */
  50750. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50751. /**
  50752. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50753. * @param data contains the texture data
  50754. * @param texture defines the BabylonJS internal texture
  50755. * @param callback defines the method to call once ready to upload
  50756. */
  50757. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50758. }
  50759. }
  50760. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50761. import { Nullable } from "babylonjs/types";
  50762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50763. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50764. /**
  50765. * Implementation of the ENV Texture Loader.
  50766. * @hidden
  50767. */
  50768. export class _ENVTextureLoader implements IInternalTextureLoader {
  50769. /**
  50770. * Defines wether the loader supports cascade loading the different faces.
  50771. */
  50772. readonly supportCascades: boolean;
  50773. /**
  50774. * This returns if the loader support the current file information.
  50775. * @param extension defines the file extension of the file being loaded
  50776. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50777. * @param fallback defines the fallback internal texture if any
  50778. * @param isBase64 defines whether the texture is encoded as a base64
  50779. * @param isBuffer defines whether the texture data are stored as a buffer
  50780. * @returns true if the loader can load the specified file
  50781. */
  50782. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50783. /**
  50784. * Transform the url before loading if required.
  50785. * @param rootUrl the url of the texture
  50786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50787. * @returns the transformed texture
  50788. */
  50789. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50790. /**
  50791. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50792. * @param rootUrl the url of the texture
  50793. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50794. * @returns the fallback texture
  50795. */
  50796. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50797. /**
  50798. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50799. * @param data contains the texture data
  50800. * @param texture defines the BabylonJS internal texture
  50801. * @param createPolynomials will be true if polynomials have been requested
  50802. * @param onLoad defines the callback to trigger once the texture is ready
  50803. * @param onError defines the callback to trigger in case of error
  50804. */
  50805. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50806. /**
  50807. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50808. * @param data contains the texture data
  50809. * @param texture defines the BabylonJS internal texture
  50810. * @param callback defines the method to call once ready to upload
  50811. */
  50812. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50813. }
  50814. }
  50815. declare module "babylonjs/Misc/khronosTextureContainer" {
  50816. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50817. /**
  50818. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50819. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50820. */
  50821. export class KhronosTextureContainer {
  50822. /** contents of the KTX container file */
  50823. arrayBuffer: any;
  50824. private static HEADER_LEN;
  50825. private static COMPRESSED_2D;
  50826. private static COMPRESSED_3D;
  50827. private static TEX_2D;
  50828. private static TEX_3D;
  50829. /**
  50830. * Gets the openGL type
  50831. */
  50832. glType: number;
  50833. /**
  50834. * Gets the openGL type size
  50835. */
  50836. glTypeSize: number;
  50837. /**
  50838. * Gets the openGL format
  50839. */
  50840. glFormat: number;
  50841. /**
  50842. * Gets the openGL internal format
  50843. */
  50844. glInternalFormat: number;
  50845. /**
  50846. * Gets the base internal format
  50847. */
  50848. glBaseInternalFormat: number;
  50849. /**
  50850. * Gets image width in pixel
  50851. */
  50852. pixelWidth: number;
  50853. /**
  50854. * Gets image height in pixel
  50855. */
  50856. pixelHeight: number;
  50857. /**
  50858. * Gets image depth in pixels
  50859. */
  50860. pixelDepth: number;
  50861. /**
  50862. * Gets the number of array elements
  50863. */
  50864. numberOfArrayElements: number;
  50865. /**
  50866. * Gets the number of faces
  50867. */
  50868. numberOfFaces: number;
  50869. /**
  50870. * Gets the number of mipmap levels
  50871. */
  50872. numberOfMipmapLevels: number;
  50873. /**
  50874. * Gets the bytes of key value data
  50875. */
  50876. bytesOfKeyValueData: number;
  50877. /**
  50878. * Gets the load type
  50879. */
  50880. loadType: number;
  50881. /**
  50882. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50883. */
  50884. isInvalid: boolean;
  50885. /**
  50886. * Creates a new KhronosTextureContainer
  50887. * @param arrayBuffer contents of the KTX container file
  50888. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50889. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50890. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50891. */
  50892. constructor(
  50893. /** contents of the KTX container file */
  50894. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50895. /**
  50896. * Uploads KTX content to a Babylon Texture.
  50897. * It is assumed that the texture has already been created & is currently bound
  50898. * @hidden
  50899. */
  50900. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50901. private _upload2DCompressedLevels;
  50902. }
  50903. }
  50904. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50905. import { Nullable } from "babylonjs/types";
  50906. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50907. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50908. /**
  50909. * Implementation of the KTX Texture Loader.
  50910. * @hidden
  50911. */
  50912. export class _KTXTextureLoader implements IInternalTextureLoader {
  50913. /**
  50914. * Defines wether the loader supports cascade loading the different faces.
  50915. */
  50916. readonly supportCascades: boolean;
  50917. /**
  50918. * This returns if the loader support the current file information.
  50919. * @param extension defines the file extension of the file being loaded
  50920. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50921. * @param fallback defines the fallback internal texture if any
  50922. * @param isBase64 defines whether the texture is encoded as a base64
  50923. * @param isBuffer defines whether the texture data are stored as a buffer
  50924. * @returns true if the loader can load the specified file
  50925. */
  50926. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50927. /**
  50928. * Transform the url before loading if required.
  50929. * @param rootUrl the url of the texture
  50930. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50931. * @returns the transformed texture
  50932. */
  50933. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50934. /**
  50935. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50936. * @param rootUrl the url of the texture
  50937. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50938. * @returns the fallback texture
  50939. */
  50940. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50941. /**
  50942. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50943. * @param data contains the texture data
  50944. * @param texture defines the BabylonJS internal texture
  50945. * @param createPolynomials will be true if polynomials have been requested
  50946. * @param onLoad defines the callback to trigger once the texture is ready
  50947. * @param onError defines the callback to trigger in case of error
  50948. */
  50949. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50950. /**
  50951. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50952. * @param data contains the texture data
  50953. * @param texture defines the BabylonJS internal texture
  50954. * @param callback defines the method to call once ready to upload
  50955. */
  50956. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50957. }
  50958. }
  50959. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50960. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50961. import { Scene } from "babylonjs/scene";
  50962. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50963. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50964. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50965. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50966. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50967. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50969. /**
  50970. * Options for the default xr helper
  50971. */
  50972. export class WebXRDefaultExperienceOptions {
  50973. /**
  50974. * Floor meshes that should be used for teleporting
  50975. */
  50976. floorMeshes: Array<AbstractMesh>;
  50977. }
  50978. /**
  50979. * Default experience which provides a similar setup to the previous webVRExperience
  50980. */
  50981. export class WebXRDefaultExperience {
  50982. /**
  50983. * Base experience
  50984. */
  50985. baseExperience: WebXRExperienceHelper;
  50986. /**
  50987. * Input experience extension
  50988. */
  50989. input: WebXRInput;
  50990. /**
  50991. * Loads the controller models
  50992. */
  50993. controllerModelLoader: WebXRControllerModelLoader;
  50994. /**
  50995. * Enables laser pointer and selection
  50996. */
  50997. pointerSelection: WebXRControllerPointerSelection;
  50998. /**
  50999. * Enables teleportation
  51000. */
  51001. teleportation: WebXRControllerTeleportation;
  51002. /**
  51003. * Enables ui for enetering/exiting xr
  51004. */
  51005. enterExitUI: WebXREnterExitUI;
  51006. /**
  51007. * Default output canvas xr should render to
  51008. */
  51009. outputCanvas: WebXRManagedOutputCanvas;
  51010. /**
  51011. * Creates the default xr experience
  51012. * @param scene scene
  51013. * @param options options for basic configuration
  51014. * @returns resulting WebXRDefaultExperience
  51015. */
  51016. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51017. private constructor();
  51018. /**
  51019. * DIsposes of the experience helper
  51020. */
  51021. dispose(): void;
  51022. }
  51023. }
  51024. declare module "babylonjs/Helpers/sceneHelpers" {
  51025. import { Nullable } from "babylonjs/types";
  51026. import { Mesh } from "babylonjs/Meshes/mesh";
  51027. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51028. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51029. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51030. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51031. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51032. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51033. import "babylonjs/Meshes/Builders/boxBuilder";
  51034. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51035. /** @hidden */
  51036. export var _forceSceneHelpersToBundle: boolean;
  51037. module "babylonjs/scene" {
  51038. interface Scene {
  51039. /**
  51040. * Creates a default light for the scene.
  51041. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51042. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51043. */
  51044. createDefaultLight(replace?: boolean): void;
  51045. /**
  51046. * Creates a default camera for the scene.
  51047. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51048. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51049. * @param replace has default false, when true replaces the active camera in the scene
  51050. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51051. */
  51052. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51053. /**
  51054. * Creates a default camera and a default light.
  51055. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51056. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51057. * @param replace has the default false, when true replaces the active camera/light in the scene
  51058. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51059. */
  51060. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51061. /**
  51062. * Creates a new sky box
  51063. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51064. * @param environmentTexture defines the texture to use as environment texture
  51065. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51066. * @param scale defines the overall scale of the skybox
  51067. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51068. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51069. * @returns a new mesh holding the sky box
  51070. */
  51071. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51072. /**
  51073. * Creates a new environment
  51074. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51075. * @param options defines the options you can use to configure the environment
  51076. * @returns the new EnvironmentHelper
  51077. */
  51078. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51079. /**
  51080. * Creates a new VREXperienceHelper
  51081. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51082. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51083. * @returns a new VREXperienceHelper
  51084. */
  51085. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51086. /**
  51087. * Creates a new WebXRDefaultExperience
  51088. * @see http://doc.babylonjs.com/how_to/webxr
  51089. * @param options experience options
  51090. * @returns a promise for a new WebXRDefaultExperience
  51091. */
  51092. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51093. }
  51094. }
  51095. }
  51096. declare module "babylonjs/Helpers/videoDome" {
  51097. import { Scene } from "babylonjs/scene";
  51098. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51099. import { Mesh } from "babylonjs/Meshes/mesh";
  51100. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51101. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51102. import "babylonjs/Meshes/Builders/sphereBuilder";
  51103. /**
  51104. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51105. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51106. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51107. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51108. */
  51109. export class VideoDome extends TransformNode {
  51110. /**
  51111. * Define the video source as a Monoscopic panoramic 360 video.
  51112. */
  51113. static readonly MODE_MONOSCOPIC: number;
  51114. /**
  51115. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51116. */
  51117. static readonly MODE_TOPBOTTOM: number;
  51118. /**
  51119. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51120. */
  51121. static readonly MODE_SIDEBYSIDE: number;
  51122. private _halfDome;
  51123. private _useDirectMapping;
  51124. /**
  51125. * The video texture being displayed on the sphere
  51126. */
  51127. protected _videoTexture: VideoTexture;
  51128. /**
  51129. * Gets the video texture being displayed on the sphere
  51130. */
  51131. readonly videoTexture: VideoTexture;
  51132. /**
  51133. * The skybox material
  51134. */
  51135. protected _material: BackgroundMaterial;
  51136. /**
  51137. * The surface used for the skybox
  51138. */
  51139. protected _mesh: Mesh;
  51140. /**
  51141. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51142. */
  51143. private _halfDomeMask;
  51144. /**
  51145. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51146. * Also see the options.resolution property.
  51147. */
  51148. fovMultiplier: number;
  51149. private _videoMode;
  51150. /**
  51151. * Gets or set the current video mode for the video. It can be:
  51152. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51153. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51154. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51155. */
  51156. videoMode: number;
  51157. /**
  51158. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51159. *
  51160. */
  51161. /**
  51162. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51163. */
  51164. halfDome: boolean;
  51165. /**
  51166. * Oberserver used in Stereoscopic VR Mode.
  51167. */
  51168. private _onBeforeCameraRenderObserver;
  51169. /**
  51170. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51171. * @param name Element's name, child elements will append suffixes for their own names.
  51172. * @param urlsOrVideo defines the url(s) or the video element to use
  51173. * @param options An object containing optional or exposed sub element properties
  51174. */
  51175. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51176. resolution?: number;
  51177. clickToPlay?: boolean;
  51178. autoPlay?: boolean;
  51179. loop?: boolean;
  51180. size?: number;
  51181. poster?: string;
  51182. faceForward?: boolean;
  51183. useDirectMapping?: boolean;
  51184. halfDomeMode?: boolean;
  51185. }, scene: Scene);
  51186. private _changeVideoMode;
  51187. /**
  51188. * Releases resources associated with this node.
  51189. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51190. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51191. */
  51192. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51193. }
  51194. }
  51195. declare module "babylonjs/Helpers/index" {
  51196. export * from "babylonjs/Helpers/environmentHelper";
  51197. export * from "babylonjs/Helpers/photoDome";
  51198. export * from "babylonjs/Helpers/sceneHelpers";
  51199. export * from "babylonjs/Helpers/videoDome";
  51200. }
  51201. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51202. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51203. import { IDisposable } from "babylonjs/scene";
  51204. import { Engine } from "babylonjs/Engines/engine";
  51205. /**
  51206. * This class can be used to get instrumentation data from a Babylon engine
  51207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51208. */
  51209. export class EngineInstrumentation implements IDisposable {
  51210. /**
  51211. * Define the instrumented engine.
  51212. */
  51213. engine: Engine;
  51214. private _captureGPUFrameTime;
  51215. private _gpuFrameTimeToken;
  51216. private _gpuFrameTime;
  51217. private _captureShaderCompilationTime;
  51218. private _shaderCompilationTime;
  51219. private _onBeginFrameObserver;
  51220. private _onEndFrameObserver;
  51221. private _onBeforeShaderCompilationObserver;
  51222. private _onAfterShaderCompilationObserver;
  51223. /**
  51224. * Gets the perf counter used for GPU frame time
  51225. */
  51226. readonly gpuFrameTimeCounter: PerfCounter;
  51227. /**
  51228. * Gets the GPU frame time capture status
  51229. */
  51230. /**
  51231. * Enable or disable the GPU frame time capture
  51232. */
  51233. captureGPUFrameTime: boolean;
  51234. /**
  51235. * Gets the perf counter used for shader compilation time
  51236. */
  51237. readonly shaderCompilationTimeCounter: PerfCounter;
  51238. /**
  51239. * Gets the shader compilation time capture status
  51240. */
  51241. /**
  51242. * Enable or disable the shader compilation time capture
  51243. */
  51244. captureShaderCompilationTime: boolean;
  51245. /**
  51246. * Instantiates a new engine instrumentation.
  51247. * This class can be used to get instrumentation data from a Babylon engine
  51248. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51249. * @param engine Defines the engine to instrument
  51250. */
  51251. constructor(
  51252. /**
  51253. * Define the instrumented engine.
  51254. */
  51255. engine: Engine);
  51256. /**
  51257. * Dispose and release associated resources.
  51258. */
  51259. dispose(): void;
  51260. }
  51261. }
  51262. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51263. import { Scene, IDisposable } from "babylonjs/scene";
  51264. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51265. /**
  51266. * This class can be used to get instrumentation data from a Babylon engine
  51267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51268. */
  51269. export class SceneInstrumentation implements IDisposable {
  51270. /**
  51271. * Defines the scene to instrument
  51272. */
  51273. scene: Scene;
  51274. private _captureActiveMeshesEvaluationTime;
  51275. private _activeMeshesEvaluationTime;
  51276. private _captureRenderTargetsRenderTime;
  51277. private _renderTargetsRenderTime;
  51278. private _captureFrameTime;
  51279. private _frameTime;
  51280. private _captureRenderTime;
  51281. private _renderTime;
  51282. private _captureInterFrameTime;
  51283. private _interFrameTime;
  51284. private _captureParticlesRenderTime;
  51285. private _particlesRenderTime;
  51286. private _captureSpritesRenderTime;
  51287. private _spritesRenderTime;
  51288. private _capturePhysicsTime;
  51289. private _physicsTime;
  51290. private _captureAnimationsTime;
  51291. private _animationsTime;
  51292. private _captureCameraRenderTime;
  51293. private _cameraRenderTime;
  51294. private _onBeforeActiveMeshesEvaluationObserver;
  51295. private _onAfterActiveMeshesEvaluationObserver;
  51296. private _onBeforeRenderTargetsRenderObserver;
  51297. private _onAfterRenderTargetsRenderObserver;
  51298. private _onAfterRenderObserver;
  51299. private _onBeforeDrawPhaseObserver;
  51300. private _onAfterDrawPhaseObserver;
  51301. private _onBeforeAnimationsObserver;
  51302. private _onBeforeParticlesRenderingObserver;
  51303. private _onAfterParticlesRenderingObserver;
  51304. private _onBeforeSpritesRenderingObserver;
  51305. private _onAfterSpritesRenderingObserver;
  51306. private _onBeforePhysicsObserver;
  51307. private _onAfterPhysicsObserver;
  51308. private _onAfterAnimationsObserver;
  51309. private _onBeforeCameraRenderObserver;
  51310. private _onAfterCameraRenderObserver;
  51311. /**
  51312. * Gets the perf counter used for active meshes evaluation time
  51313. */
  51314. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51315. /**
  51316. * Gets the active meshes evaluation time capture status
  51317. */
  51318. /**
  51319. * Enable or disable the active meshes evaluation time capture
  51320. */
  51321. captureActiveMeshesEvaluationTime: boolean;
  51322. /**
  51323. * Gets the perf counter used for render targets render time
  51324. */
  51325. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51326. /**
  51327. * Gets the render targets render time capture status
  51328. */
  51329. /**
  51330. * Enable or disable the render targets render time capture
  51331. */
  51332. captureRenderTargetsRenderTime: boolean;
  51333. /**
  51334. * Gets the perf counter used for particles render time
  51335. */
  51336. readonly particlesRenderTimeCounter: PerfCounter;
  51337. /**
  51338. * Gets the particles render time capture status
  51339. */
  51340. /**
  51341. * Enable or disable the particles render time capture
  51342. */
  51343. captureParticlesRenderTime: boolean;
  51344. /**
  51345. * Gets the perf counter used for sprites render time
  51346. */
  51347. readonly spritesRenderTimeCounter: PerfCounter;
  51348. /**
  51349. * Gets the sprites render time capture status
  51350. */
  51351. /**
  51352. * Enable or disable the sprites render time capture
  51353. */
  51354. captureSpritesRenderTime: boolean;
  51355. /**
  51356. * Gets the perf counter used for physics time
  51357. */
  51358. readonly physicsTimeCounter: PerfCounter;
  51359. /**
  51360. * Gets the physics time capture status
  51361. */
  51362. /**
  51363. * Enable or disable the physics time capture
  51364. */
  51365. capturePhysicsTime: boolean;
  51366. /**
  51367. * Gets the perf counter used for animations time
  51368. */
  51369. readonly animationsTimeCounter: PerfCounter;
  51370. /**
  51371. * Gets the animations time capture status
  51372. */
  51373. /**
  51374. * Enable or disable the animations time capture
  51375. */
  51376. captureAnimationsTime: boolean;
  51377. /**
  51378. * Gets the perf counter used for frame time capture
  51379. */
  51380. readonly frameTimeCounter: PerfCounter;
  51381. /**
  51382. * Gets the frame time capture status
  51383. */
  51384. /**
  51385. * Enable or disable the frame time capture
  51386. */
  51387. captureFrameTime: boolean;
  51388. /**
  51389. * Gets the perf counter used for inter-frames time capture
  51390. */
  51391. readonly interFrameTimeCounter: PerfCounter;
  51392. /**
  51393. * Gets the inter-frames time capture status
  51394. */
  51395. /**
  51396. * Enable or disable the inter-frames time capture
  51397. */
  51398. captureInterFrameTime: boolean;
  51399. /**
  51400. * Gets the perf counter used for render time capture
  51401. */
  51402. readonly renderTimeCounter: PerfCounter;
  51403. /**
  51404. * Gets the render time capture status
  51405. */
  51406. /**
  51407. * Enable or disable the render time capture
  51408. */
  51409. captureRenderTime: boolean;
  51410. /**
  51411. * Gets the perf counter used for camera render time capture
  51412. */
  51413. readonly cameraRenderTimeCounter: PerfCounter;
  51414. /**
  51415. * Gets the camera render time capture status
  51416. */
  51417. /**
  51418. * Enable or disable the camera render time capture
  51419. */
  51420. captureCameraRenderTime: boolean;
  51421. /**
  51422. * Gets the perf counter used for draw calls
  51423. */
  51424. readonly drawCallsCounter: PerfCounter;
  51425. /**
  51426. * Instantiates a new scene instrumentation.
  51427. * This class can be used to get instrumentation data from a Babylon engine
  51428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51429. * @param scene Defines the scene to instrument
  51430. */
  51431. constructor(
  51432. /**
  51433. * Defines the scene to instrument
  51434. */
  51435. scene: Scene);
  51436. /**
  51437. * Dispose and release associated resources.
  51438. */
  51439. dispose(): void;
  51440. }
  51441. }
  51442. declare module "babylonjs/Instrumentation/index" {
  51443. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51444. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51445. export * from "babylonjs/Instrumentation/timeToken";
  51446. }
  51447. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51448. /** @hidden */
  51449. export var glowMapGenerationPixelShader: {
  51450. name: string;
  51451. shader: string;
  51452. };
  51453. }
  51454. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51456. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51458. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51459. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51460. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51461. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51462. /** @hidden */
  51463. export var glowMapGenerationVertexShader: {
  51464. name: string;
  51465. shader: string;
  51466. };
  51467. }
  51468. declare module "babylonjs/Layers/effectLayer" {
  51469. import { Observable } from "babylonjs/Misc/observable";
  51470. import { Nullable } from "babylonjs/types";
  51471. import { Camera } from "babylonjs/Cameras/camera";
  51472. import { Scene } from "babylonjs/scene";
  51473. import { ISize } from "babylonjs/Maths/math.size";
  51474. import { Color4 } from "babylonjs/Maths/math.color";
  51475. import { Engine } from "babylonjs/Engines/engine";
  51476. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51478. import { Mesh } from "babylonjs/Meshes/mesh";
  51479. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51481. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51482. import { Effect } from "babylonjs/Materials/effect";
  51483. import { Material } from "babylonjs/Materials/material";
  51484. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51485. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51486. /**
  51487. * Effect layer options. This helps customizing the behaviour
  51488. * of the effect layer.
  51489. */
  51490. export interface IEffectLayerOptions {
  51491. /**
  51492. * Multiplication factor apply to the canvas size to compute the render target size
  51493. * used to generated the objects (the smaller the faster).
  51494. */
  51495. mainTextureRatio: number;
  51496. /**
  51497. * Enforces a fixed size texture to ensure effect stability across devices.
  51498. */
  51499. mainTextureFixedSize?: number;
  51500. /**
  51501. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51502. */
  51503. alphaBlendingMode: number;
  51504. /**
  51505. * The camera attached to the layer.
  51506. */
  51507. camera: Nullable<Camera>;
  51508. /**
  51509. * The rendering group to draw the layer in.
  51510. */
  51511. renderingGroupId: number;
  51512. }
  51513. /**
  51514. * The effect layer Helps adding post process effect blended with the main pass.
  51515. *
  51516. * This can be for instance use to generate glow or higlight effects on the scene.
  51517. *
  51518. * The effect layer class can not be used directly and is intented to inherited from to be
  51519. * customized per effects.
  51520. */
  51521. export abstract class EffectLayer {
  51522. private _vertexBuffers;
  51523. private _indexBuffer;
  51524. private _cachedDefines;
  51525. private _effectLayerMapGenerationEffect;
  51526. private _effectLayerOptions;
  51527. private _mergeEffect;
  51528. protected _scene: Scene;
  51529. protected _engine: Engine;
  51530. protected _maxSize: number;
  51531. protected _mainTextureDesiredSize: ISize;
  51532. protected _mainTexture: RenderTargetTexture;
  51533. protected _shouldRender: boolean;
  51534. protected _postProcesses: PostProcess[];
  51535. protected _textures: BaseTexture[];
  51536. protected _emissiveTextureAndColor: {
  51537. texture: Nullable<BaseTexture>;
  51538. color: Color4;
  51539. };
  51540. /**
  51541. * The name of the layer
  51542. */
  51543. name: string;
  51544. /**
  51545. * The clear color of the texture used to generate the glow map.
  51546. */
  51547. neutralColor: Color4;
  51548. /**
  51549. * Specifies wether the highlight layer is enabled or not.
  51550. */
  51551. isEnabled: boolean;
  51552. /**
  51553. * Gets the camera attached to the layer.
  51554. */
  51555. readonly camera: Nullable<Camera>;
  51556. /**
  51557. * Gets the rendering group id the layer should render in.
  51558. */
  51559. renderingGroupId: number;
  51560. /**
  51561. * An event triggered when the effect layer has been disposed.
  51562. */
  51563. onDisposeObservable: Observable<EffectLayer>;
  51564. /**
  51565. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51566. */
  51567. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51568. /**
  51569. * An event triggered when the generated texture is being merged in the scene.
  51570. */
  51571. onBeforeComposeObservable: Observable<EffectLayer>;
  51572. /**
  51573. * An event triggered when the generated texture has been merged in the scene.
  51574. */
  51575. onAfterComposeObservable: Observable<EffectLayer>;
  51576. /**
  51577. * An event triggered when the efffect layer changes its size.
  51578. */
  51579. onSizeChangedObservable: Observable<EffectLayer>;
  51580. /** @hidden */
  51581. static _SceneComponentInitialization: (scene: Scene) => void;
  51582. /**
  51583. * Instantiates a new effect Layer and references it in the scene.
  51584. * @param name The name of the layer
  51585. * @param scene The scene to use the layer in
  51586. */
  51587. constructor(
  51588. /** The Friendly of the effect in the scene */
  51589. name: string, scene: Scene);
  51590. /**
  51591. * Get the effect name of the layer.
  51592. * @return The effect name
  51593. */
  51594. abstract getEffectName(): string;
  51595. /**
  51596. * Checks for the readiness of the element composing the layer.
  51597. * @param subMesh the mesh to check for
  51598. * @param useInstances specify wether or not to use instances to render the mesh
  51599. * @return true if ready otherwise, false
  51600. */
  51601. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51602. /**
  51603. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51604. * @returns true if the effect requires stencil during the main canvas render pass.
  51605. */
  51606. abstract needStencil(): boolean;
  51607. /**
  51608. * Create the merge effect. This is the shader use to blit the information back
  51609. * to the main canvas at the end of the scene rendering.
  51610. * @returns The effect containing the shader used to merge the effect on the main canvas
  51611. */
  51612. protected abstract _createMergeEffect(): Effect;
  51613. /**
  51614. * Creates the render target textures and post processes used in the effect layer.
  51615. */
  51616. protected abstract _createTextureAndPostProcesses(): void;
  51617. /**
  51618. * Implementation specific of rendering the generating effect on the main canvas.
  51619. * @param effect The effect used to render through
  51620. */
  51621. protected abstract _internalRender(effect: Effect): void;
  51622. /**
  51623. * Sets the required values for both the emissive texture and and the main color.
  51624. */
  51625. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51626. /**
  51627. * Free any resources and references associated to a mesh.
  51628. * Internal use
  51629. * @param mesh The mesh to free.
  51630. */
  51631. abstract _disposeMesh(mesh: Mesh): void;
  51632. /**
  51633. * Serializes this layer (Glow or Highlight for example)
  51634. * @returns a serialized layer object
  51635. */
  51636. abstract serialize?(): any;
  51637. /**
  51638. * Initializes the effect layer with the required options.
  51639. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51640. */
  51641. protected _init(options: Partial<IEffectLayerOptions>): void;
  51642. /**
  51643. * Generates the index buffer of the full screen quad blending to the main canvas.
  51644. */
  51645. private _generateIndexBuffer;
  51646. /**
  51647. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51648. */
  51649. private _generateVertexBuffer;
  51650. /**
  51651. * Sets the main texture desired size which is the closest power of two
  51652. * of the engine canvas size.
  51653. */
  51654. private _setMainTextureSize;
  51655. /**
  51656. * Creates the main texture for the effect layer.
  51657. */
  51658. protected _createMainTexture(): void;
  51659. /**
  51660. * Adds specific effects defines.
  51661. * @param defines The defines to add specifics to.
  51662. */
  51663. protected _addCustomEffectDefines(defines: string[]): void;
  51664. /**
  51665. * Checks for the readiness of the element composing the layer.
  51666. * @param subMesh the mesh to check for
  51667. * @param useInstances specify wether or not to use instances to render the mesh
  51668. * @param emissiveTexture the associated emissive texture used to generate the glow
  51669. * @return true if ready otherwise, false
  51670. */
  51671. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51672. /**
  51673. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51674. */
  51675. render(): void;
  51676. /**
  51677. * Determine if a given mesh will be used in the current effect.
  51678. * @param mesh mesh to test
  51679. * @returns true if the mesh will be used
  51680. */
  51681. hasMesh(mesh: AbstractMesh): boolean;
  51682. /**
  51683. * Returns true if the layer contains information to display, otherwise false.
  51684. * @returns true if the glow layer should be rendered
  51685. */
  51686. shouldRender(): boolean;
  51687. /**
  51688. * Returns true if the mesh should render, otherwise false.
  51689. * @param mesh The mesh to render
  51690. * @returns true if it should render otherwise false
  51691. */
  51692. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51693. /**
  51694. * Returns true if the mesh can be rendered, otherwise false.
  51695. * @param mesh The mesh to render
  51696. * @param material The material used on the mesh
  51697. * @returns true if it can be rendered otherwise false
  51698. */
  51699. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51700. /**
  51701. * Returns true if the mesh should render, otherwise false.
  51702. * @param mesh The mesh to render
  51703. * @returns true if it should render otherwise false
  51704. */
  51705. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51706. /**
  51707. * Renders the submesh passed in parameter to the generation map.
  51708. */
  51709. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51710. /**
  51711. * Rebuild the required buffers.
  51712. * @hidden Internal use only.
  51713. */
  51714. _rebuild(): void;
  51715. /**
  51716. * Dispose only the render target textures and post process.
  51717. */
  51718. private _disposeTextureAndPostProcesses;
  51719. /**
  51720. * Dispose the highlight layer and free resources.
  51721. */
  51722. dispose(): void;
  51723. /**
  51724. * Gets the class name of the effect layer
  51725. * @returns the string with the class name of the effect layer
  51726. */
  51727. getClassName(): string;
  51728. /**
  51729. * Creates an effect layer from parsed effect layer data
  51730. * @param parsedEffectLayer defines effect layer data
  51731. * @param scene defines the current scene
  51732. * @param rootUrl defines the root URL containing the effect layer information
  51733. * @returns a parsed effect Layer
  51734. */
  51735. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51736. }
  51737. }
  51738. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51739. import { Scene } from "babylonjs/scene";
  51740. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51741. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51742. import { AbstractScene } from "babylonjs/abstractScene";
  51743. module "babylonjs/abstractScene" {
  51744. interface AbstractScene {
  51745. /**
  51746. * The list of effect layers (highlights/glow) added to the scene
  51747. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51748. * @see http://doc.babylonjs.com/how_to/glow_layer
  51749. */
  51750. effectLayers: Array<EffectLayer>;
  51751. /**
  51752. * Removes the given effect layer from this scene.
  51753. * @param toRemove defines the effect layer to remove
  51754. * @returns the index of the removed effect layer
  51755. */
  51756. removeEffectLayer(toRemove: EffectLayer): number;
  51757. /**
  51758. * Adds the given effect layer to this scene
  51759. * @param newEffectLayer defines the effect layer to add
  51760. */
  51761. addEffectLayer(newEffectLayer: EffectLayer): void;
  51762. }
  51763. }
  51764. /**
  51765. * Defines the layer scene component responsible to manage any effect layers
  51766. * in a given scene.
  51767. */
  51768. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51769. /**
  51770. * The component name helpfull to identify the component in the list of scene components.
  51771. */
  51772. readonly name: string;
  51773. /**
  51774. * The scene the component belongs to.
  51775. */
  51776. scene: Scene;
  51777. private _engine;
  51778. private _renderEffects;
  51779. private _needStencil;
  51780. private _previousStencilState;
  51781. /**
  51782. * Creates a new instance of the component for the given scene
  51783. * @param scene Defines the scene to register the component in
  51784. */
  51785. constructor(scene: Scene);
  51786. /**
  51787. * Registers the component in a given scene
  51788. */
  51789. register(): void;
  51790. /**
  51791. * Rebuilds the elements related to this component in case of
  51792. * context lost for instance.
  51793. */
  51794. rebuild(): void;
  51795. /**
  51796. * Serializes the component data to the specified json object
  51797. * @param serializationObject The object to serialize to
  51798. */
  51799. serialize(serializationObject: any): void;
  51800. /**
  51801. * Adds all the elements from the container to the scene
  51802. * @param container the container holding the elements
  51803. */
  51804. addFromContainer(container: AbstractScene): void;
  51805. /**
  51806. * Removes all the elements in the container from the scene
  51807. * @param container contains the elements to remove
  51808. * @param dispose if the removed element should be disposed (default: false)
  51809. */
  51810. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51811. /**
  51812. * Disposes the component and the associated ressources.
  51813. */
  51814. dispose(): void;
  51815. private _isReadyForMesh;
  51816. private _renderMainTexture;
  51817. private _setStencil;
  51818. private _setStencilBack;
  51819. private _draw;
  51820. private _drawCamera;
  51821. private _drawRenderingGroup;
  51822. }
  51823. }
  51824. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51825. /** @hidden */
  51826. export var glowMapMergePixelShader: {
  51827. name: string;
  51828. shader: string;
  51829. };
  51830. }
  51831. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51832. /** @hidden */
  51833. export var glowMapMergeVertexShader: {
  51834. name: string;
  51835. shader: string;
  51836. };
  51837. }
  51838. declare module "babylonjs/Layers/glowLayer" {
  51839. import { Nullable } from "babylonjs/types";
  51840. import { Camera } from "babylonjs/Cameras/camera";
  51841. import { Scene } from "babylonjs/scene";
  51842. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51844. import { Mesh } from "babylonjs/Meshes/mesh";
  51845. import { Texture } from "babylonjs/Materials/Textures/texture";
  51846. import { Effect } from "babylonjs/Materials/effect";
  51847. import { Material } from "babylonjs/Materials/material";
  51848. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51849. import { Color4 } from "babylonjs/Maths/math.color";
  51850. import "babylonjs/Shaders/glowMapMerge.fragment";
  51851. import "babylonjs/Shaders/glowMapMerge.vertex";
  51852. import "babylonjs/Layers/effectLayerSceneComponent";
  51853. module "babylonjs/abstractScene" {
  51854. interface AbstractScene {
  51855. /**
  51856. * Return a the first highlight layer of the scene with a given name.
  51857. * @param name The name of the highlight layer to look for.
  51858. * @return The highlight layer if found otherwise null.
  51859. */
  51860. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51861. }
  51862. }
  51863. /**
  51864. * Glow layer options. This helps customizing the behaviour
  51865. * of the glow layer.
  51866. */
  51867. export interface IGlowLayerOptions {
  51868. /**
  51869. * Multiplication factor apply to the canvas size to compute the render target size
  51870. * used to generated the glowing objects (the smaller the faster).
  51871. */
  51872. mainTextureRatio: number;
  51873. /**
  51874. * Enforces a fixed size texture to ensure resize independant blur.
  51875. */
  51876. mainTextureFixedSize?: number;
  51877. /**
  51878. * How big is the kernel of the blur texture.
  51879. */
  51880. blurKernelSize: number;
  51881. /**
  51882. * The camera attached to the layer.
  51883. */
  51884. camera: Nullable<Camera>;
  51885. /**
  51886. * Enable MSAA by chosing the number of samples.
  51887. */
  51888. mainTextureSamples?: number;
  51889. /**
  51890. * The rendering group to draw the layer in.
  51891. */
  51892. renderingGroupId: number;
  51893. }
  51894. /**
  51895. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51896. *
  51897. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51898. * glowy meshes to your scene.
  51899. *
  51900. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51901. */
  51902. export class GlowLayer extends EffectLayer {
  51903. /**
  51904. * Effect Name of the layer.
  51905. */
  51906. static readonly EffectName: string;
  51907. /**
  51908. * The default blur kernel size used for the glow.
  51909. */
  51910. static DefaultBlurKernelSize: number;
  51911. /**
  51912. * The default texture size ratio used for the glow.
  51913. */
  51914. static DefaultTextureRatio: number;
  51915. /**
  51916. * Sets the kernel size of the blur.
  51917. */
  51918. /**
  51919. * Gets the kernel size of the blur.
  51920. */
  51921. blurKernelSize: number;
  51922. /**
  51923. * Sets the glow intensity.
  51924. */
  51925. /**
  51926. * Gets the glow intensity.
  51927. */
  51928. intensity: number;
  51929. private _options;
  51930. private _intensity;
  51931. private _horizontalBlurPostprocess1;
  51932. private _verticalBlurPostprocess1;
  51933. private _horizontalBlurPostprocess2;
  51934. private _verticalBlurPostprocess2;
  51935. private _blurTexture1;
  51936. private _blurTexture2;
  51937. private _postProcesses1;
  51938. private _postProcesses2;
  51939. private _includedOnlyMeshes;
  51940. private _excludedMeshes;
  51941. /**
  51942. * Callback used to let the user override the color selection on a per mesh basis
  51943. */
  51944. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51945. /**
  51946. * Callback used to let the user override the texture selection on a per mesh basis
  51947. */
  51948. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51949. /**
  51950. * Instantiates a new glow Layer and references it to the scene.
  51951. * @param name The name of the layer
  51952. * @param scene The scene to use the layer in
  51953. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51954. */
  51955. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51956. /**
  51957. * Get the effect name of the layer.
  51958. * @return The effect name
  51959. */
  51960. getEffectName(): string;
  51961. /**
  51962. * Create the merge effect. This is the shader use to blit the information back
  51963. * to the main canvas at the end of the scene rendering.
  51964. */
  51965. protected _createMergeEffect(): Effect;
  51966. /**
  51967. * Creates the render target textures and post processes used in the glow layer.
  51968. */
  51969. protected _createTextureAndPostProcesses(): void;
  51970. /**
  51971. * Checks for the readiness of the element composing the layer.
  51972. * @param subMesh the mesh to check for
  51973. * @param useInstances specify wether or not to use instances to render the mesh
  51974. * @param emissiveTexture the associated emissive texture used to generate the glow
  51975. * @return true if ready otherwise, false
  51976. */
  51977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51978. /**
  51979. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51980. */
  51981. needStencil(): boolean;
  51982. /**
  51983. * Returns true if the mesh can be rendered, otherwise false.
  51984. * @param mesh The mesh to render
  51985. * @param material The material used on the mesh
  51986. * @returns true if it can be rendered otherwise false
  51987. */
  51988. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51989. /**
  51990. * Implementation specific of rendering the generating effect on the main canvas.
  51991. * @param effect The effect used to render through
  51992. */
  51993. protected _internalRender(effect: Effect): void;
  51994. /**
  51995. * Sets the required values for both the emissive texture and and the main color.
  51996. */
  51997. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51998. /**
  51999. * Returns true if the mesh should render, otherwise false.
  52000. * @param mesh The mesh to render
  52001. * @returns true if it should render otherwise false
  52002. */
  52003. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52004. /**
  52005. * Adds specific effects defines.
  52006. * @param defines The defines to add specifics to.
  52007. */
  52008. protected _addCustomEffectDefines(defines: string[]): void;
  52009. /**
  52010. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52011. * @param mesh The mesh to exclude from the glow layer
  52012. */
  52013. addExcludedMesh(mesh: Mesh): void;
  52014. /**
  52015. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52016. * @param mesh The mesh to remove
  52017. */
  52018. removeExcludedMesh(mesh: Mesh): void;
  52019. /**
  52020. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52021. * @param mesh The mesh to include in the glow layer
  52022. */
  52023. addIncludedOnlyMesh(mesh: Mesh): void;
  52024. /**
  52025. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52026. * @param mesh The mesh to remove
  52027. */
  52028. removeIncludedOnlyMesh(mesh: Mesh): void;
  52029. /**
  52030. * Determine if a given mesh will be used in the glow layer
  52031. * @param mesh The mesh to test
  52032. * @returns true if the mesh will be highlighted by the current glow layer
  52033. */
  52034. hasMesh(mesh: AbstractMesh): boolean;
  52035. /**
  52036. * Free any resources and references associated to a mesh.
  52037. * Internal use
  52038. * @param mesh The mesh to free.
  52039. * @hidden
  52040. */
  52041. _disposeMesh(mesh: Mesh): void;
  52042. /**
  52043. * Gets the class name of the effect layer
  52044. * @returns the string with the class name of the effect layer
  52045. */
  52046. getClassName(): string;
  52047. /**
  52048. * Serializes this glow layer
  52049. * @returns a serialized glow layer object
  52050. */
  52051. serialize(): any;
  52052. /**
  52053. * Creates a Glow Layer from parsed glow layer data
  52054. * @param parsedGlowLayer defines glow layer data
  52055. * @param scene defines the current scene
  52056. * @param rootUrl defines the root URL containing the glow layer information
  52057. * @returns a parsed Glow Layer
  52058. */
  52059. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52060. }
  52061. }
  52062. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52063. /** @hidden */
  52064. export var glowBlurPostProcessPixelShader: {
  52065. name: string;
  52066. shader: string;
  52067. };
  52068. }
  52069. declare module "babylonjs/Layers/highlightLayer" {
  52070. import { Observable } from "babylonjs/Misc/observable";
  52071. import { Nullable } from "babylonjs/types";
  52072. import { Camera } from "babylonjs/Cameras/camera";
  52073. import { Scene } from "babylonjs/scene";
  52074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52076. import { Mesh } from "babylonjs/Meshes/mesh";
  52077. import { Effect } from "babylonjs/Materials/effect";
  52078. import { Material } from "babylonjs/Materials/material";
  52079. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52080. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52081. import "babylonjs/Shaders/glowMapMerge.fragment";
  52082. import "babylonjs/Shaders/glowMapMerge.vertex";
  52083. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52084. module "babylonjs/abstractScene" {
  52085. interface AbstractScene {
  52086. /**
  52087. * Return a the first highlight layer of the scene with a given name.
  52088. * @param name The name of the highlight layer to look for.
  52089. * @return The highlight layer if found otherwise null.
  52090. */
  52091. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52092. }
  52093. }
  52094. /**
  52095. * Highlight layer options. This helps customizing the behaviour
  52096. * of the highlight layer.
  52097. */
  52098. export interface IHighlightLayerOptions {
  52099. /**
  52100. * Multiplication factor apply to the canvas size to compute the render target size
  52101. * used to generated the glowing objects (the smaller the faster).
  52102. */
  52103. mainTextureRatio: number;
  52104. /**
  52105. * Enforces a fixed size texture to ensure resize independant blur.
  52106. */
  52107. mainTextureFixedSize?: number;
  52108. /**
  52109. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52110. * of the picture to blur (the smaller the faster).
  52111. */
  52112. blurTextureSizeRatio: number;
  52113. /**
  52114. * How big in texel of the blur texture is the vertical blur.
  52115. */
  52116. blurVerticalSize: number;
  52117. /**
  52118. * How big in texel of the blur texture is the horizontal blur.
  52119. */
  52120. blurHorizontalSize: number;
  52121. /**
  52122. * Alpha blending mode used to apply the blur. Default is combine.
  52123. */
  52124. alphaBlendingMode: number;
  52125. /**
  52126. * The camera attached to the layer.
  52127. */
  52128. camera: Nullable<Camera>;
  52129. /**
  52130. * Should we display highlight as a solid stroke?
  52131. */
  52132. isStroke?: boolean;
  52133. /**
  52134. * The rendering group to draw the layer in.
  52135. */
  52136. renderingGroupId: number;
  52137. }
  52138. /**
  52139. * The highlight layer Helps adding a glow effect around a mesh.
  52140. *
  52141. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52142. * glowy meshes to your scene.
  52143. *
  52144. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52145. */
  52146. export class HighlightLayer extends EffectLayer {
  52147. name: string;
  52148. /**
  52149. * Effect Name of the highlight layer.
  52150. */
  52151. static readonly EffectName: string;
  52152. /**
  52153. * The neutral color used during the preparation of the glow effect.
  52154. * This is black by default as the blend operation is a blend operation.
  52155. */
  52156. static NeutralColor: Color4;
  52157. /**
  52158. * Stencil value used for glowing meshes.
  52159. */
  52160. static GlowingMeshStencilReference: number;
  52161. /**
  52162. * Stencil value used for the other meshes in the scene.
  52163. */
  52164. static NormalMeshStencilReference: number;
  52165. /**
  52166. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52167. */
  52168. innerGlow: boolean;
  52169. /**
  52170. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52171. */
  52172. outerGlow: boolean;
  52173. /**
  52174. * Specifies the horizontal size of the blur.
  52175. */
  52176. /**
  52177. * Gets the horizontal size of the blur.
  52178. */
  52179. blurHorizontalSize: number;
  52180. /**
  52181. * Specifies the vertical size of the blur.
  52182. */
  52183. /**
  52184. * Gets the vertical size of the blur.
  52185. */
  52186. blurVerticalSize: number;
  52187. /**
  52188. * An event triggered when the highlight layer is being blurred.
  52189. */
  52190. onBeforeBlurObservable: Observable<HighlightLayer>;
  52191. /**
  52192. * An event triggered when the highlight layer has been blurred.
  52193. */
  52194. onAfterBlurObservable: Observable<HighlightLayer>;
  52195. private _instanceGlowingMeshStencilReference;
  52196. private _options;
  52197. private _downSamplePostprocess;
  52198. private _horizontalBlurPostprocess;
  52199. private _verticalBlurPostprocess;
  52200. private _blurTexture;
  52201. private _meshes;
  52202. private _excludedMeshes;
  52203. /**
  52204. * Instantiates a new highlight Layer and references it to the scene..
  52205. * @param name The name of the layer
  52206. * @param scene The scene to use the layer in
  52207. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52208. */
  52209. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52210. /**
  52211. * Get the effect name of the layer.
  52212. * @return The effect name
  52213. */
  52214. getEffectName(): string;
  52215. /**
  52216. * Create the merge effect. This is the shader use to blit the information back
  52217. * to the main canvas at the end of the scene rendering.
  52218. */
  52219. protected _createMergeEffect(): Effect;
  52220. /**
  52221. * Creates the render target textures and post processes used in the highlight layer.
  52222. */
  52223. protected _createTextureAndPostProcesses(): void;
  52224. /**
  52225. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52226. */
  52227. needStencil(): boolean;
  52228. /**
  52229. * Checks for the readiness of the element composing the layer.
  52230. * @param subMesh the mesh to check for
  52231. * @param useInstances specify wether or not to use instances to render the mesh
  52232. * @param emissiveTexture the associated emissive texture used to generate the glow
  52233. * @return true if ready otherwise, false
  52234. */
  52235. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52236. /**
  52237. * Implementation specific of rendering the generating effect on the main canvas.
  52238. * @param effect The effect used to render through
  52239. */
  52240. protected _internalRender(effect: Effect): void;
  52241. /**
  52242. * Returns true if the layer contains information to display, otherwise false.
  52243. */
  52244. shouldRender(): boolean;
  52245. /**
  52246. * Returns true if the mesh should render, otherwise false.
  52247. * @param mesh The mesh to render
  52248. * @returns true if it should render otherwise false
  52249. */
  52250. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52251. /**
  52252. * Sets the required values for both the emissive texture and and the main color.
  52253. */
  52254. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52255. /**
  52256. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52257. * @param mesh The mesh to exclude from the highlight layer
  52258. */
  52259. addExcludedMesh(mesh: Mesh): void;
  52260. /**
  52261. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52262. * @param mesh The mesh to highlight
  52263. */
  52264. removeExcludedMesh(mesh: Mesh): void;
  52265. /**
  52266. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52267. * @param mesh mesh to test
  52268. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52269. */
  52270. hasMesh(mesh: AbstractMesh): boolean;
  52271. /**
  52272. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52273. * @param mesh The mesh to highlight
  52274. * @param color The color of the highlight
  52275. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52276. */
  52277. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52278. /**
  52279. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52280. * @param mesh The mesh to highlight
  52281. */
  52282. removeMesh(mesh: Mesh): void;
  52283. /**
  52284. * Force the stencil to the normal expected value for none glowing parts
  52285. */
  52286. private _defaultStencilReference;
  52287. /**
  52288. * Free any resources and references associated to a mesh.
  52289. * Internal use
  52290. * @param mesh The mesh to free.
  52291. * @hidden
  52292. */
  52293. _disposeMesh(mesh: Mesh): void;
  52294. /**
  52295. * Dispose the highlight layer and free resources.
  52296. */
  52297. dispose(): void;
  52298. /**
  52299. * Gets the class name of the effect layer
  52300. * @returns the string with the class name of the effect layer
  52301. */
  52302. getClassName(): string;
  52303. /**
  52304. * Serializes this Highlight layer
  52305. * @returns a serialized Highlight layer object
  52306. */
  52307. serialize(): any;
  52308. /**
  52309. * Creates a Highlight layer from parsed Highlight layer data
  52310. * @param parsedHightlightLayer defines the Highlight layer data
  52311. * @param scene defines the current scene
  52312. * @param rootUrl defines the root URL containing the Highlight layer information
  52313. * @returns a parsed Highlight layer
  52314. */
  52315. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52316. }
  52317. }
  52318. declare module "babylonjs/Layers/layerSceneComponent" {
  52319. import { Scene } from "babylonjs/scene";
  52320. import { ISceneComponent } from "babylonjs/sceneComponent";
  52321. import { Layer } from "babylonjs/Layers/layer";
  52322. import { AbstractScene } from "babylonjs/abstractScene";
  52323. module "babylonjs/abstractScene" {
  52324. interface AbstractScene {
  52325. /**
  52326. * The list of layers (background and foreground) of the scene
  52327. */
  52328. layers: Array<Layer>;
  52329. }
  52330. }
  52331. /**
  52332. * Defines the layer scene component responsible to manage any layers
  52333. * in a given scene.
  52334. */
  52335. export class LayerSceneComponent implements ISceneComponent {
  52336. /**
  52337. * The component name helpfull to identify the component in the list of scene components.
  52338. */
  52339. readonly name: string;
  52340. /**
  52341. * The scene the component belongs to.
  52342. */
  52343. scene: Scene;
  52344. private _engine;
  52345. /**
  52346. * Creates a new instance of the component for the given scene
  52347. * @param scene Defines the scene to register the component in
  52348. */
  52349. constructor(scene: Scene);
  52350. /**
  52351. * Registers the component in a given scene
  52352. */
  52353. register(): void;
  52354. /**
  52355. * Rebuilds the elements related to this component in case of
  52356. * context lost for instance.
  52357. */
  52358. rebuild(): void;
  52359. /**
  52360. * Disposes the component and the associated ressources.
  52361. */
  52362. dispose(): void;
  52363. private _draw;
  52364. private _drawCameraPredicate;
  52365. private _drawCameraBackground;
  52366. private _drawCameraForeground;
  52367. private _drawRenderTargetPredicate;
  52368. private _drawRenderTargetBackground;
  52369. private _drawRenderTargetForeground;
  52370. /**
  52371. * Adds all the elements from the container to the scene
  52372. * @param container the container holding the elements
  52373. */
  52374. addFromContainer(container: AbstractScene): void;
  52375. /**
  52376. * Removes all the elements in the container from the scene
  52377. * @param container contains the elements to remove
  52378. * @param dispose if the removed element should be disposed (default: false)
  52379. */
  52380. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52381. }
  52382. }
  52383. declare module "babylonjs/Shaders/layer.fragment" {
  52384. /** @hidden */
  52385. export var layerPixelShader: {
  52386. name: string;
  52387. shader: string;
  52388. };
  52389. }
  52390. declare module "babylonjs/Shaders/layer.vertex" {
  52391. /** @hidden */
  52392. export var layerVertexShader: {
  52393. name: string;
  52394. shader: string;
  52395. };
  52396. }
  52397. declare module "babylonjs/Layers/layer" {
  52398. import { Observable } from "babylonjs/Misc/observable";
  52399. import { Nullable } from "babylonjs/types";
  52400. import { Scene } from "babylonjs/scene";
  52401. import { Vector2 } from "babylonjs/Maths/math.vector";
  52402. import { Color4 } from "babylonjs/Maths/math.color";
  52403. import { Texture } from "babylonjs/Materials/Textures/texture";
  52404. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52405. import "babylonjs/Shaders/layer.fragment";
  52406. import "babylonjs/Shaders/layer.vertex";
  52407. /**
  52408. * This represents a full screen 2d layer.
  52409. * This can be useful to display a picture in the background of your scene for instance.
  52410. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52411. */
  52412. export class Layer {
  52413. /**
  52414. * Define the name of the layer.
  52415. */
  52416. name: string;
  52417. /**
  52418. * Define the texture the layer should display.
  52419. */
  52420. texture: Nullable<Texture>;
  52421. /**
  52422. * Is the layer in background or foreground.
  52423. */
  52424. isBackground: boolean;
  52425. /**
  52426. * Define the color of the layer (instead of texture).
  52427. */
  52428. color: Color4;
  52429. /**
  52430. * Define the scale of the layer in order to zoom in out of the texture.
  52431. */
  52432. scale: Vector2;
  52433. /**
  52434. * Define an offset for the layer in order to shift the texture.
  52435. */
  52436. offset: Vector2;
  52437. /**
  52438. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52439. */
  52440. alphaBlendingMode: number;
  52441. /**
  52442. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52443. * Alpha test will not mix with the background color in case of transparency.
  52444. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52445. */
  52446. alphaTest: boolean;
  52447. /**
  52448. * Define a mask to restrict the layer to only some of the scene cameras.
  52449. */
  52450. layerMask: number;
  52451. /**
  52452. * Define the list of render target the layer is visible into.
  52453. */
  52454. renderTargetTextures: RenderTargetTexture[];
  52455. /**
  52456. * Define if the layer is only used in renderTarget or if it also
  52457. * renders in the main frame buffer of the canvas.
  52458. */
  52459. renderOnlyInRenderTargetTextures: boolean;
  52460. private _scene;
  52461. private _vertexBuffers;
  52462. private _indexBuffer;
  52463. private _effect;
  52464. private _alphaTestEffect;
  52465. /**
  52466. * An event triggered when the layer is disposed.
  52467. */
  52468. onDisposeObservable: Observable<Layer>;
  52469. private _onDisposeObserver;
  52470. /**
  52471. * Back compatibility with callback before the onDisposeObservable existed.
  52472. * The set callback will be triggered when the layer has been disposed.
  52473. */
  52474. onDispose: () => void;
  52475. /**
  52476. * An event triggered before rendering the scene
  52477. */
  52478. onBeforeRenderObservable: Observable<Layer>;
  52479. private _onBeforeRenderObserver;
  52480. /**
  52481. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52482. * The set callback will be triggered just before rendering the layer.
  52483. */
  52484. onBeforeRender: () => void;
  52485. /**
  52486. * An event triggered after rendering the scene
  52487. */
  52488. onAfterRenderObservable: Observable<Layer>;
  52489. private _onAfterRenderObserver;
  52490. /**
  52491. * Back compatibility with callback before the onAfterRenderObservable existed.
  52492. * The set callback will be triggered just after rendering the layer.
  52493. */
  52494. onAfterRender: () => void;
  52495. /**
  52496. * Instantiates a new layer.
  52497. * This represents a full screen 2d layer.
  52498. * This can be useful to display a picture in the background of your scene for instance.
  52499. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52500. * @param name Define the name of the layer in the scene
  52501. * @param imgUrl Define the url of the texture to display in the layer
  52502. * @param scene Define the scene the layer belongs to
  52503. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52504. * @param color Defines a color for the layer
  52505. */
  52506. constructor(
  52507. /**
  52508. * Define the name of the layer.
  52509. */
  52510. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52511. private _createIndexBuffer;
  52512. /** @hidden */
  52513. _rebuild(): void;
  52514. /**
  52515. * Renders the layer in the scene.
  52516. */
  52517. render(): void;
  52518. /**
  52519. * Disposes and releases the associated ressources.
  52520. */
  52521. dispose(): void;
  52522. }
  52523. }
  52524. declare module "babylonjs/Layers/index" {
  52525. export * from "babylonjs/Layers/effectLayer";
  52526. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52527. export * from "babylonjs/Layers/glowLayer";
  52528. export * from "babylonjs/Layers/highlightLayer";
  52529. export * from "babylonjs/Layers/layer";
  52530. export * from "babylonjs/Layers/layerSceneComponent";
  52531. }
  52532. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52533. /** @hidden */
  52534. export var lensFlarePixelShader: {
  52535. name: string;
  52536. shader: string;
  52537. };
  52538. }
  52539. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52540. /** @hidden */
  52541. export var lensFlareVertexShader: {
  52542. name: string;
  52543. shader: string;
  52544. };
  52545. }
  52546. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52547. import { Scene } from "babylonjs/scene";
  52548. import { Vector3 } from "babylonjs/Maths/math.vector";
  52549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52550. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52551. import "babylonjs/Shaders/lensFlare.fragment";
  52552. import "babylonjs/Shaders/lensFlare.vertex";
  52553. import { Viewport } from "babylonjs/Maths/math.viewport";
  52554. /**
  52555. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52556. * It is usually composed of several `lensFlare`.
  52557. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52558. */
  52559. export class LensFlareSystem {
  52560. /**
  52561. * Define the name of the lens flare system
  52562. */
  52563. name: string;
  52564. /**
  52565. * List of lens flares used in this system.
  52566. */
  52567. lensFlares: LensFlare[];
  52568. /**
  52569. * Define a limit from the border the lens flare can be visible.
  52570. */
  52571. borderLimit: number;
  52572. /**
  52573. * Define a viewport border we do not want to see the lens flare in.
  52574. */
  52575. viewportBorder: number;
  52576. /**
  52577. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52578. */
  52579. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52580. /**
  52581. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52582. */
  52583. layerMask: number;
  52584. /**
  52585. * Define the id of the lens flare system in the scene.
  52586. * (equal to name by default)
  52587. */
  52588. id: string;
  52589. private _scene;
  52590. private _emitter;
  52591. private _vertexBuffers;
  52592. private _indexBuffer;
  52593. private _effect;
  52594. private _positionX;
  52595. private _positionY;
  52596. private _isEnabled;
  52597. /** @hidden */
  52598. static _SceneComponentInitialization: (scene: Scene) => void;
  52599. /**
  52600. * Instantiates a lens flare system.
  52601. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52602. * It is usually composed of several `lensFlare`.
  52603. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52604. * @param name Define the name of the lens flare system in the scene
  52605. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52606. * @param scene Define the scene the lens flare system belongs to
  52607. */
  52608. constructor(
  52609. /**
  52610. * Define the name of the lens flare system
  52611. */
  52612. name: string, emitter: any, scene: Scene);
  52613. /**
  52614. * Define if the lens flare system is enabled.
  52615. */
  52616. isEnabled: boolean;
  52617. /**
  52618. * Get the scene the effects belongs to.
  52619. * @returns the scene holding the lens flare system
  52620. */
  52621. getScene(): Scene;
  52622. /**
  52623. * Get the emitter of the lens flare system.
  52624. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52625. * @returns the emitter of the lens flare system
  52626. */
  52627. getEmitter(): any;
  52628. /**
  52629. * Set the emitter of the lens flare system.
  52630. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52631. * @param newEmitter Define the new emitter of the system
  52632. */
  52633. setEmitter(newEmitter: any): void;
  52634. /**
  52635. * Get the lens flare system emitter position.
  52636. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52637. * @returns the position
  52638. */
  52639. getEmitterPosition(): Vector3;
  52640. /**
  52641. * @hidden
  52642. */
  52643. computeEffectivePosition(globalViewport: Viewport): boolean;
  52644. /** @hidden */
  52645. _isVisible(): boolean;
  52646. /**
  52647. * @hidden
  52648. */
  52649. render(): boolean;
  52650. /**
  52651. * Dispose and release the lens flare with its associated resources.
  52652. */
  52653. dispose(): void;
  52654. /**
  52655. * Parse a lens flare system from a JSON repressentation
  52656. * @param parsedLensFlareSystem Define the JSON to parse
  52657. * @param scene Define the scene the parsed system should be instantiated in
  52658. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52659. * @returns the parsed system
  52660. */
  52661. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52662. /**
  52663. * Serialize the current Lens Flare System into a JSON representation.
  52664. * @returns the serialized JSON
  52665. */
  52666. serialize(): any;
  52667. }
  52668. }
  52669. declare module "babylonjs/LensFlares/lensFlare" {
  52670. import { Nullable } from "babylonjs/types";
  52671. import { Color3 } from "babylonjs/Maths/math.color";
  52672. import { Texture } from "babylonjs/Materials/Textures/texture";
  52673. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52674. /**
  52675. * This represents one of the lens effect in a `lensFlareSystem`.
  52676. * It controls one of the indiviual texture used in the effect.
  52677. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52678. */
  52679. export class LensFlare {
  52680. /**
  52681. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52682. */
  52683. size: number;
  52684. /**
  52685. * 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.
  52686. */
  52687. position: number;
  52688. /**
  52689. * Define the lens color.
  52690. */
  52691. color: Color3;
  52692. /**
  52693. * Define the lens texture.
  52694. */
  52695. texture: Nullable<Texture>;
  52696. /**
  52697. * Define the alpha mode to render this particular lens.
  52698. */
  52699. alphaMode: number;
  52700. private _system;
  52701. /**
  52702. * Creates a new Lens Flare.
  52703. * This represents one of the lens effect in a `lensFlareSystem`.
  52704. * It controls one of the indiviual texture used in the effect.
  52705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52706. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52707. * @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.
  52708. * @param color Define the lens color
  52709. * @param imgUrl Define the lens texture url
  52710. * @param system Define the `lensFlareSystem` this flare is part of
  52711. * @returns The newly created Lens Flare
  52712. */
  52713. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52714. /**
  52715. * Instantiates a new Lens Flare.
  52716. * This represents one of the lens effect in a `lensFlareSystem`.
  52717. * It controls one of the indiviual texture used in the effect.
  52718. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52719. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52720. * @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.
  52721. * @param color Define the lens color
  52722. * @param imgUrl Define the lens texture url
  52723. * @param system Define the `lensFlareSystem` this flare is part of
  52724. */
  52725. constructor(
  52726. /**
  52727. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52728. */
  52729. size: number,
  52730. /**
  52731. * 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.
  52732. */
  52733. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52734. /**
  52735. * Dispose and release the lens flare with its associated resources.
  52736. */
  52737. dispose(): void;
  52738. }
  52739. }
  52740. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52741. import { Nullable } from "babylonjs/types";
  52742. import { Scene } from "babylonjs/scene";
  52743. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52744. import { AbstractScene } from "babylonjs/abstractScene";
  52745. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52746. module "babylonjs/abstractScene" {
  52747. interface AbstractScene {
  52748. /**
  52749. * The list of lens flare system added to the scene
  52750. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52751. */
  52752. lensFlareSystems: Array<LensFlareSystem>;
  52753. /**
  52754. * Removes the given lens flare system from this scene.
  52755. * @param toRemove The lens flare system to remove
  52756. * @returns The index of the removed lens flare system
  52757. */
  52758. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52759. /**
  52760. * Adds the given lens flare system to this scene
  52761. * @param newLensFlareSystem The lens flare system to add
  52762. */
  52763. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52764. /**
  52765. * Gets a lens flare system using its name
  52766. * @param name defines the name to look for
  52767. * @returns the lens flare system or null if not found
  52768. */
  52769. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52770. /**
  52771. * Gets a lens flare system using its id
  52772. * @param id defines the id to look for
  52773. * @returns the lens flare system or null if not found
  52774. */
  52775. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52776. }
  52777. }
  52778. /**
  52779. * Defines the lens flare scene component responsible to manage any lens flares
  52780. * in a given scene.
  52781. */
  52782. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52783. /**
  52784. * The component name helpfull to identify the component in the list of scene components.
  52785. */
  52786. readonly name: string;
  52787. /**
  52788. * The scene the component belongs to.
  52789. */
  52790. scene: Scene;
  52791. /**
  52792. * Creates a new instance of the component for the given scene
  52793. * @param scene Defines the scene to register the component in
  52794. */
  52795. constructor(scene: Scene);
  52796. /**
  52797. * Registers the component in a given scene
  52798. */
  52799. register(): void;
  52800. /**
  52801. * Rebuilds the elements related to this component in case of
  52802. * context lost for instance.
  52803. */
  52804. rebuild(): void;
  52805. /**
  52806. * Adds all the elements from the container to the scene
  52807. * @param container the container holding the elements
  52808. */
  52809. addFromContainer(container: AbstractScene): void;
  52810. /**
  52811. * Removes all the elements in the container from the scene
  52812. * @param container contains the elements to remove
  52813. * @param dispose if the removed element should be disposed (default: false)
  52814. */
  52815. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52816. /**
  52817. * Serializes the component data to the specified json object
  52818. * @param serializationObject The object to serialize to
  52819. */
  52820. serialize(serializationObject: any): void;
  52821. /**
  52822. * Disposes the component and the associated ressources.
  52823. */
  52824. dispose(): void;
  52825. private _draw;
  52826. }
  52827. }
  52828. declare module "babylonjs/LensFlares/index" {
  52829. export * from "babylonjs/LensFlares/lensFlare";
  52830. export * from "babylonjs/LensFlares/lensFlareSystem";
  52831. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52832. }
  52833. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52834. import { Scene } from "babylonjs/scene";
  52835. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52836. import { AbstractScene } from "babylonjs/abstractScene";
  52837. /**
  52838. * Defines the shadow generator component responsible to manage any shadow generators
  52839. * in a given scene.
  52840. */
  52841. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52842. /**
  52843. * The component name helpfull to identify the component in the list of scene components.
  52844. */
  52845. readonly name: string;
  52846. /**
  52847. * The scene the component belongs to.
  52848. */
  52849. scene: Scene;
  52850. /**
  52851. * Creates a new instance of the component for the given scene
  52852. * @param scene Defines the scene to register the component in
  52853. */
  52854. constructor(scene: Scene);
  52855. /**
  52856. * Registers the component in a given scene
  52857. */
  52858. register(): void;
  52859. /**
  52860. * Rebuilds the elements related to this component in case of
  52861. * context lost for instance.
  52862. */
  52863. rebuild(): void;
  52864. /**
  52865. * Serializes the component data to the specified json object
  52866. * @param serializationObject The object to serialize to
  52867. */
  52868. serialize(serializationObject: any): void;
  52869. /**
  52870. * Adds all the elements from the container to the scene
  52871. * @param container the container holding the elements
  52872. */
  52873. addFromContainer(container: AbstractScene): void;
  52874. /**
  52875. * Removes all the elements in the container from the scene
  52876. * @param container contains the elements to remove
  52877. * @param dispose if the removed element should be disposed (default: false)
  52878. */
  52879. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52880. /**
  52881. * Rebuilds the elements related to this component in case of
  52882. * context lost for instance.
  52883. */
  52884. dispose(): void;
  52885. private _gatherRenderTargets;
  52886. }
  52887. }
  52888. declare module "babylonjs/Lights/Shadows/index" {
  52889. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52890. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52891. }
  52892. declare module "babylonjs/Lights/pointLight" {
  52893. import { Scene } from "babylonjs/scene";
  52894. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52896. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52897. import { Effect } from "babylonjs/Materials/effect";
  52898. /**
  52899. * A point light is a light defined by an unique point in world space.
  52900. * The light is emitted in every direction from this point.
  52901. * A good example of a point light is a standard light bulb.
  52902. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52903. */
  52904. export class PointLight extends ShadowLight {
  52905. private _shadowAngle;
  52906. /**
  52907. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52908. * This specifies what angle the shadow will use to be created.
  52909. *
  52910. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52911. */
  52912. /**
  52913. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52914. * This specifies what angle the shadow will use to be created.
  52915. *
  52916. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52917. */
  52918. shadowAngle: number;
  52919. /**
  52920. * Gets the direction if it has been set.
  52921. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52922. */
  52923. /**
  52924. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52925. */
  52926. direction: Vector3;
  52927. /**
  52928. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52929. * A PointLight emits the light in every direction.
  52930. * It can cast shadows.
  52931. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52932. * ```javascript
  52933. * var pointLight = new PointLight("pl", camera.position, scene);
  52934. * ```
  52935. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52936. * @param name The light friendly name
  52937. * @param position The position of the point light in the scene
  52938. * @param scene The scene the lights belongs to
  52939. */
  52940. constructor(name: string, position: Vector3, scene: Scene);
  52941. /**
  52942. * Returns the string "PointLight"
  52943. * @returns the class name
  52944. */
  52945. getClassName(): string;
  52946. /**
  52947. * Returns the integer 0.
  52948. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52949. */
  52950. getTypeID(): number;
  52951. /**
  52952. * Specifies wether or not the shadowmap should be a cube texture.
  52953. * @returns true if the shadowmap needs to be a cube texture.
  52954. */
  52955. needCube(): boolean;
  52956. /**
  52957. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52958. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52959. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52960. */
  52961. getShadowDirection(faceIndex?: number): Vector3;
  52962. /**
  52963. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52964. * - fov = PI / 2
  52965. * - aspect ratio : 1.0
  52966. * - z-near and far equal to the active camera minZ and maxZ.
  52967. * Returns the PointLight.
  52968. */
  52969. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52970. protected _buildUniformLayout(): void;
  52971. /**
  52972. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52973. * @param effect The effect to update
  52974. * @param lightIndex The index of the light in the effect to update
  52975. * @returns The point light
  52976. */
  52977. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52978. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52979. /**
  52980. * Prepares the list of defines specific to the light type.
  52981. * @param defines the list of defines
  52982. * @param lightIndex defines the index of the light for the effect
  52983. */
  52984. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52985. }
  52986. }
  52987. declare module "babylonjs/Lights/index" {
  52988. export * from "babylonjs/Lights/light";
  52989. export * from "babylonjs/Lights/shadowLight";
  52990. export * from "babylonjs/Lights/Shadows/index";
  52991. export * from "babylonjs/Lights/directionalLight";
  52992. export * from "babylonjs/Lights/hemisphericLight";
  52993. export * from "babylonjs/Lights/pointLight";
  52994. export * from "babylonjs/Lights/spotLight";
  52995. }
  52996. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52997. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52998. /**
  52999. * Header information of HDR texture files.
  53000. */
  53001. export interface HDRInfo {
  53002. /**
  53003. * The height of the texture in pixels.
  53004. */
  53005. height: number;
  53006. /**
  53007. * The width of the texture in pixels.
  53008. */
  53009. width: number;
  53010. /**
  53011. * The index of the beginning of the data in the binary file.
  53012. */
  53013. dataPosition: number;
  53014. }
  53015. /**
  53016. * This groups tools to convert HDR texture to native colors array.
  53017. */
  53018. export class HDRTools {
  53019. private static Ldexp;
  53020. private static Rgbe2float;
  53021. private static readStringLine;
  53022. /**
  53023. * Reads header information from an RGBE texture stored in a native array.
  53024. * More information on this format are available here:
  53025. * https://en.wikipedia.org/wiki/RGBE_image_format
  53026. *
  53027. * @param uint8array The binary file stored in native array.
  53028. * @return The header information.
  53029. */
  53030. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53031. /**
  53032. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53033. * This RGBE texture needs to store the information as a panorama.
  53034. *
  53035. * More information on this format are available here:
  53036. * https://en.wikipedia.org/wiki/RGBE_image_format
  53037. *
  53038. * @param buffer The binary file stored in an array buffer.
  53039. * @param size The expected size of the extracted cubemap.
  53040. * @return The Cube Map information.
  53041. */
  53042. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53043. /**
  53044. * Returns the pixels data extracted from an RGBE texture.
  53045. * This pixels will be stored left to right up to down in the R G B order in one array.
  53046. *
  53047. * More information on this format are available here:
  53048. * https://en.wikipedia.org/wiki/RGBE_image_format
  53049. *
  53050. * @param uint8array The binary file stored in an array buffer.
  53051. * @param hdrInfo The header information of the file.
  53052. * @return The pixels data in RGB right to left up to down order.
  53053. */
  53054. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53055. private static RGBE_ReadPixels_RLE;
  53056. }
  53057. }
  53058. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53059. import { Nullable } from "babylonjs/types";
  53060. import { Scene } from "babylonjs/scene";
  53061. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53063. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53064. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53065. /**
  53066. * This represents a texture coming from an HDR input.
  53067. *
  53068. * The only supported format is currently panorama picture stored in RGBE format.
  53069. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53070. */
  53071. export class HDRCubeTexture extends BaseTexture {
  53072. private static _facesMapping;
  53073. private _generateHarmonics;
  53074. private _noMipmap;
  53075. private _textureMatrix;
  53076. private _size;
  53077. private _onLoad;
  53078. private _onError;
  53079. /**
  53080. * The texture URL.
  53081. */
  53082. url: string;
  53083. /**
  53084. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53085. */
  53086. coordinatesMode: number;
  53087. protected _isBlocking: boolean;
  53088. /**
  53089. * Sets wether or not the texture is blocking during loading.
  53090. */
  53091. /**
  53092. * Gets wether or not the texture is blocking during loading.
  53093. */
  53094. isBlocking: boolean;
  53095. protected _rotationY: number;
  53096. /**
  53097. * Sets texture matrix rotation angle around Y axis in radians.
  53098. */
  53099. /**
  53100. * Gets texture matrix rotation angle around Y axis radians.
  53101. */
  53102. rotationY: number;
  53103. /**
  53104. * Gets or sets the center of the bounding box associated with the cube texture
  53105. * It must define where the camera used to render the texture was set
  53106. */
  53107. boundingBoxPosition: Vector3;
  53108. private _boundingBoxSize;
  53109. /**
  53110. * Gets or sets the size of the bounding box associated with the cube texture
  53111. * When defined, the cubemap will switch to local mode
  53112. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53113. * @example https://www.babylonjs-playground.com/#RNASML
  53114. */
  53115. boundingBoxSize: Vector3;
  53116. /**
  53117. * Instantiates an HDRTexture from the following parameters.
  53118. *
  53119. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53120. * @param scene The scene the texture will be used in
  53121. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53122. * @param noMipmap Forces to not generate the mipmap if true
  53123. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53124. * @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)
  53125. * @param reserved Reserved flag for internal use.
  53126. */
  53127. 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>);
  53128. /**
  53129. * Get the current class name of the texture useful for serialization or dynamic coding.
  53130. * @returns "HDRCubeTexture"
  53131. */
  53132. getClassName(): string;
  53133. /**
  53134. * Occurs when the file is raw .hdr file.
  53135. */
  53136. private loadTexture;
  53137. clone(): HDRCubeTexture;
  53138. delayLoad(): void;
  53139. /**
  53140. * Get the texture reflection matrix used to rotate/transform the reflection.
  53141. * @returns the reflection matrix
  53142. */
  53143. getReflectionTextureMatrix(): Matrix;
  53144. /**
  53145. * Set the texture reflection matrix used to rotate/transform the reflection.
  53146. * @param value Define the reflection matrix to set
  53147. */
  53148. setReflectionTextureMatrix(value: Matrix): void;
  53149. /**
  53150. * Parses a JSON representation of an HDR Texture in order to create the texture
  53151. * @param parsedTexture Define the JSON representation
  53152. * @param scene Define the scene the texture should be created in
  53153. * @param rootUrl Define the root url in case we need to load relative dependencies
  53154. * @returns the newly created texture after parsing
  53155. */
  53156. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53157. serialize(): any;
  53158. }
  53159. }
  53160. declare module "babylonjs/Physics/physicsEngine" {
  53161. import { Nullable } from "babylonjs/types";
  53162. import { Vector3 } from "babylonjs/Maths/math.vector";
  53163. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53164. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53165. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53166. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53167. /**
  53168. * Class used to control physics engine
  53169. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53170. */
  53171. export class PhysicsEngine implements IPhysicsEngine {
  53172. private _physicsPlugin;
  53173. /**
  53174. * Global value used to control the smallest number supported by the simulation
  53175. */
  53176. static Epsilon: number;
  53177. private _impostors;
  53178. private _joints;
  53179. /**
  53180. * Gets the gravity vector used by the simulation
  53181. */
  53182. gravity: Vector3;
  53183. /**
  53184. * Factory used to create the default physics plugin.
  53185. * @returns The default physics plugin
  53186. */
  53187. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53188. /**
  53189. * Creates a new Physics Engine
  53190. * @param gravity defines the gravity vector used by the simulation
  53191. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53192. */
  53193. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53194. /**
  53195. * Sets the gravity vector used by the simulation
  53196. * @param gravity defines the gravity vector to use
  53197. */
  53198. setGravity(gravity: Vector3): void;
  53199. /**
  53200. * Set the time step of the physics engine.
  53201. * Default is 1/60.
  53202. * To slow it down, enter 1/600 for example.
  53203. * To speed it up, 1/30
  53204. * @param newTimeStep defines the new timestep to apply to this world.
  53205. */
  53206. setTimeStep(newTimeStep?: number): void;
  53207. /**
  53208. * Get the time step of the physics engine.
  53209. * @returns the current time step
  53210. */
  53211. getTimeStep(): number;
  53212. /**
  53213. * Release all resources
  53214. */
  53215. dispose(): void;
  53216. /**
  53217. * Gets the name of the current physics plugin
  53218. * @returns the name of the plugin
  53219. */
  53220. getPhysicsPluginName(): string;
  53221. /**
  53222. * Adding a new impostor for the impostor tracking.
  53223. * This will be done by the impostor itself.
  53224. * @param impostor the impostor to add
  53225. */
  53226. addImpostor(impostor: PhysicsImpostor): void;
  53227. /**
  53228. * Remove an impostor from the engine.
  53229. * This impostor and its mesh will not longer be updated by the physics engine.
  53230. * @param impostor the impostor to remove
  53231. */
  53232. removeImpostor(impostor: PhysicsImpostor): void;
  53233. /**
  53234. * Add a joint to the physics engine
  53235. * @param mainImpostor defines the main impostor to which the joint is added.
  53236. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53237. * @param joint defines the joint that will connect both impostors.
  53238. */
  53239. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53240. /**
  53241. * Removes a joint from the simulation
  53242. * @param mainImpostor defines the impostor used with the joint
  53243. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53244. * @param joint defines the joint to remove
  53245. */
  53246. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53247. /**
  53248. * Called by the scene. No need to call it.
  53249. * @param delta defines the timespam between frames
  53250. */
  53251. _step(delta: number): void;
  53252. /**
  53253. * Gets the current plugin used to run the simulation
  53254. * @returns current plugin
  53255. */
  53256. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53257. /**
  53258. * Gets the list of physic impostors
  53259. * @returns an array of PhysicsImpostor
  53260. */
  53261. getImpostors(): Array<PhysicsImpostor>;
  53262. /**
  53263. * Gets the impostor for a physics enabled object
  53264. * @param object defines the object impersonated by the impostor
  53265. * @returns the PhysicsImpostor or null if not found
  53266. */
  53267. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53268. /**
  53269. * Gets the impostor for a physics body object
  53270. * @param body defines physics body used by the impostor
  53271. * @returns the PhysicsImpostor or null if not found
  53272. */
  53273. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53274. /**
  53275. * Does a raycast in the physics world
  53276. * @param from when should the ray start?
  53277. * @param to when should the ray end?
  53278. * @returns PhysicsRaycastResult
  53279. */
  53280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53281. }
  53282. }
  53283. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53284. import { Nullable } from "babylonjs/types";
  53285. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53287. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53288. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53289. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53290. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53291. /** @hidden */
  53292. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53293. private _useDeltaForWorldStep;
  53294. world: any;
  53295. name: string;
  53296. private _physicsMaterials;
  53297. private _fixedTimeStep;
  53298. private _cannonRaycastResult;
  53299. private _raycastResult;
  53300. private _physicsBodysToRemoveAfterStep;
  53301. BJSCANNON: any;
  53302. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53303. setGravity(gravity: Vector3): void;
  53304. setTimeStep(timeStep: number): void;
  53305. getTimeStep(): number;
  53306. executeStep(delta: number): void;
  53307. private _removeMarkedPhysicsBodiesFromWorld;
  53308. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53309. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53310. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53311. private _processChildMeshes;
  53312. removePhysicsBody(impostor: PhysicsImpostor): void;
  53313. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53314. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53315. private _addMaterial;
  53316. private _checkWithEpsilon;
  53317. private _createShape;
  53318. private _createHeightmap;
  53319. private _minus90X;
  53320. private _plus90X;
  53321. private _tmpPosition;
  53322. private _tmpDeltaPosition;
  53323. private _tmpUnityRotation;
  53324. private _updatePhysicsBodyTransformation;
  53325. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53326. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53327. isSupported(): boolean;
  53328. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53329. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53330. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53331. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53332. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53333. getBodyMass(impostor: PhysicsImpostor): number;
  53334. getBodyFriction(impostor: PhysicsImpostor): number;
  53335. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53336. getBodyRestitution(impostor: PhysicsImpostor): number;
  53337. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53338. sleepBody(impostor: PhysicsImpostor): void;
  53339. wakeUpBody(impostor: PhysicsImpostor): void;
  53340. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53341. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53342. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53343. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53344. getRadius(impostor: PhysicsImpostor): number;
  53345. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53346. dispose(): void;
  53347. private _extendNamespace;
  53348. /**
  53349. * Does a raycast in the physics world
  53350. * @param from when should the ray start?
  53351. * @param to when should the ray end?
  53352. * @returns PhysicsRaycastResult
  53353. */
  53354. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53355. }
  53356. }
  53357. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53358. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53359. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53360. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53362. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53363. import { Nullable } from "babylonjs/types";
  53364. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53365. /** @hidden */
  53366. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53367. world: any;
  53368. name: string;
  53369. BJSOIMO: any;
  53370. private _raycastResult;
  53371. constructor(iterations?: number, oimoInjection?: any);
  53372. setGravity(gravity: Vector3): void;
  53373. setTimeStep(timeStep: number): void;
  53374. getTimeStep(): number;
  53375. private _tmpImpostorsArray;
  53376. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53377. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53378. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53379. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53380. private _tmpPositionVector;
  53381. removePhysicsBody(impostor: PhysicsImpostor): void;
  53382. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53383. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53384. isSupported(): boolean;
  53385. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53386. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53387. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53388. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53389. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53390. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53391. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53392. getBodyMass(impostor: PhysicsImpostor): number;
  53393. getBodyFriction(impostor: PhysicsImpostor): number;
  53394. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53395. getBodyRestitution(impostor: PhysicsImpostor): number;
  53396. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53397. sleepBody(impostor: PhysicsImpostor): void;
  53398. wakeUpBody(impostor: PhysicsImpostor): void;
  53399. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53400. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53401. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53402. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53403. getRadius(impostor: PhysicsImpostor): number;
  53404. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53405. dispose(): void;
  53406. /**
  53407. * Does a raycast in the physics world
  53408. * @param from when should the ray start?
  53409. * @param to when should the ray end?
  53410. * @returns PhysicsRaycastResult
  53411. */
  53412. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53413. }
  53414. }
  53415. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53416. import { Nullable } from "babylonjs/types";
  53417. import { Scene } from "babylonjs/scene";
  53418. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53419. import { Color4 } from "babylonjs/Maths/math.color";
  53420. import { Mesh } from "babylonjs/Meshes/mesh";
  53421. /**
  53422. * Class containing static functions to help procedurally build meshes
  53423. */
  53424. export class RibbonBuilder {
  53425. /**
  53426. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53427. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53428. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53429. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53430. * * 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
  53431. * * 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
  53432. * * 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
  53433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53435. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53436. * * 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
  53437. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53438. * * 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
  53439. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53441. * @param name defines the name of the mesh
  53442. * @param options defines the options used to create the mesh
  53443. * @param scene defines the hosting scene
  53444. * @returns the ribbon mesh
  53445. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53447. */
  53448. static CreateRibbon(name: string, options: {
  53449. pathArray: Vector3[][];
  53450. closeArray?: boolean;
  53451. closePath?: boolean;
  53452. offset?: number;
  53453. updatable?: boolean;
  53454. sideOrientation?: number;
  53455. frontUVs?: Vector4;
  53456. backUVs?: Vector4;
  53457. instance?: Mesh;
  53458. invertUV?: boolean;
  53459. uvs?: Vector2[];
  53460. colors?: Color4[];
  53461. }, scene?: Nullable<Scene>): Mesh;
  53462. }
  53463. }
  53464. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53465. import { Nullable } from "babylonjs/types";
  53466. import { Scene } from "babylonjs/scene";
  53467. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53468. import { Mesh } from "babylonjs/Meshes/mesh";
  53469. /**
  53470. * Class containing static functions to help procedurally build meshes
  53471. */
  53472. export class ShapeBuilder {
  53473. /**
  53474. * 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.
  53475. * * 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.
  53476. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53477. * * 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.
  53478. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53479. * * 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
  53480. * * 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
  53481. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53486. * @param name defines the name of the mesh
  53487. * @param options defines the options used to create the mesh
  53488. * @param scene defines the hosting scene
  53489. * @returns the extruded shape mesh
  53490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53492. */
  53493. static ExtrudeShape(name: string, options: {
  53494. shape: Vector3[];
  53495. path: Vector3[];
  53496. scale?: number;
  53497. rotation?: number;
  53498. cap?: number;
  53499. updatable?: boolean;
  53500. sideOrientation?: number;
  53501. frontUVs?: Vector4;
  53502. backUVs?: Vector4;
  53503. instance?: Mesh;
  53504. invertUV?: boolean;
  53505. }, scene?: Nullable<Scene>): Mesh;
  53506. /**
  53507. * Creates an custom extruded shape mesh.
  53508. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53509. * * 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.
  53510. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53511. * * 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
  53512. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53513. * * 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
  53514. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53515. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53516. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53517. * * 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
  53518. * * 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
  53519. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53520. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53521. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53522. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53524. * @param name defines the name of the mesh
  53525. * @param options defines the options used to create the mesh
  53526. * @param scene defines the hosting scene
  53527. * @returns the custom extruded shape mesh
  53528. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53529. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53530. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53531. */
  53532. static ExtrudeShapeCustom(name: string, options: {
  53533. shape: Vector3[];
  53534. path: Vector3[];
  53535. scaleFunction?: any;
  53536. rotationFunction?: any;
  53537. ribbonCloseArray?: boolean;
  53538. ribbonClosePath?: boolean;
  53539. cap?: number;
  53540. updatable?: boolean;
  53541. sideOrientation?: number;
  53542. frontUVs?: Vector4;
  53543. backUVs?: Vector4;
  53544. instance?: Mesh;
  53545. invertUV?: boolean;
  53546. }, scene?: Nullable<Scene>): Mesh;
  53547. private static _ExtrudeShapeGeneric;
  53548. }
  53549. }
  53550. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53551. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53552. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53553. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53554. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53555. import { Nullable } from "babylonjs/types";
  53556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53557. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53558. /**
  53559. * AmmoJS Physics plugin
  53560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53561. * @see https://github.com/kripken/ammo.js/
  53562. */
  53563. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53564. private _useDeltaForWorldStep;
  53565. /**
  53566. * Reference to the Ammo library
  53567. */
  53568. bjsAMMO: any;
  53569. /**
  53570. * Created ammoJS world which physics bodies are added to
  53571. */
  53572. world: any;
  53573. /**
  53574. * Name of the plugin
  53575. */
  53576. name: string;
  53577. private _timeStep;
  53578. private _fixedTimeStep;
  53579. private _maxSteps;
  53580. private _tmpQuaternion;
  53581. private _tmpAmmoTransform;
  53582. private _tmpAmmoQuaternion;
  53583. private _tmpAmmoConcreteContactResultCallback;
  53584. private _collisionConfiguration;
  53585. private _dispatcher;
  53586. private _overlappingPairCache;
  53587. private _solver;
  53588. private _softBodySolver;
  53589. private _tmpAmmoVectorA;
  53590. private _tmpAmmoVectorB;
  53591. private _tmpAmmoVectorC;
  53592. private _tmpAmmoVectorD;
  53593. private _tmpContactCallbackResult;
  53594. private _tmpAmmoVectorRCA;
  53595. private _tmpAmmoVectorRCB;
  53596. private _raycastResult;
  53597. private static readonly DISABLE_COLLISION_FLAG;
  53598. private static readonly KINEMATIC_FLAG;
  53599. private static readonly DISABLE_DEACTIVATION_FLAG;
  53600. /**
  53601. * Initializes the ammoJS plugin
  53602. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53603. * @param ammoInjection can be used to inject your own ammo reference
  53604. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53605. */
  53606. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53607. /**
  53608. * Sets the gravity of the physics world (m/(s^2))
  53609. * @param gravity Gravity to set
  53610. */
  53611. setGravity(gravity: Vector3): void;
  53612. /**
  53613. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53614. * @param timeStep timestep to use in seconds
  53615. */
  53616. setTimeStep(timeStep: number): void;
  53617. /**
  53618. * 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)
  53619. * @param fixedTimeStep fixedTimeStep to use in seconds
  53620. */
  53621. setFixedTimeStep(fixedTimeStep: number): void;
  53622. /**
  53623. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53624. * @param maxSteps the maximum number of steps by the physics engine per frame
  53625. */
  53626. setMaxSteps(maxSteps: number): void;
  53627. /**
  53628. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53629. * @returns the current timestep in seconds
  53630. */
  53631. getTimeStep(): number;
  53632. private _isImpostorInContact;
  53633. private _isImpostorPairInContact;
  53634. private _stepSimulation;
  53635. /**
  53636. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53637. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53638. * After the step the babylon meshes are set to the position of the physics imposters
  53639. * @param delta amount of time to step forward
  53640. * @param impostors array of imposters to update before/after the step
  53641. */
  53642. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53643. /**
  53644. * Update babylon mesh to match physics world object
  53645. * @param impostor imposter to match
  53646. */
  53647. private _afterSoftStep;
  53648. /**
  53649. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53650. * @param impostor imposter to match
  53651. */
  53652. private _ropeStep;
  53653. /**
  53654. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53655. * @param impostor imposter to match
  53656. */
  53657. private _softbodyOrClothStep;
  53658. private _tmpVector;
  53659. private _tmpMatrix;
  53660. /**
  53661. * Applies an impulse on the imposter
  53662. * @param impostor imposter to apply impulse to
  53663. * @param force amount of force to be applied to the imposter
  53664. * @param contactPoint the location to apply the impulse on the imposter
  53665. */
  53666. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53667. /**
  53668. * Applies a force on the imposter
  53669. * @param impostor imposter to apply force
  53670. * @param force amount of force to be applied to the imposter
  53671. * @param contactPoint the location to apply the force on the imposter
  53672. */
  53673. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53674. /**
  53675. * Creates a physics body using the plugin
  53676. * @param impostor the imposter to create the physics body on
  53677. */
  53678. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53679. /**
  53680. * Removes the physics body from the imposter and disposes of the body's memory
  53681. * @param impostor imposter to remove the physics body from
  53682. */
  53683. removePhysicsBody(impostor: PhysicsImpostor): void;
  53684. /**
  53685. * Generates a joint
  53686. * @param impostorJoint the imposter joint to create the joint with
  53687. */
  53688. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53689. /**
  53690. * Removes a joint
  53691. * @param impostorJoint the imposter joint to remove the joint from
  53692. */
  53693. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53694. private _addMeshVerts;
  53695. /**
  53696. * Initialise the soft body vertices to match its object's (mesh) vertices
  53697. * Softbody vertices (nodes) are in world space and to match this
  53698. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53699. * @param impostor to create the softbody for
  53700. */
  53701. private _softVertexData;
  53702. /**
  53703. * Create an impostor's soft body
  53704. * @param impostor to create the softbody for
  53705. */
  53706. private _createSoftbody;
  53707. /**
  53708. * Create cloth for an impostor
  53709. * @param impostor to create the softbody for
  53710. */
  53711. private _createCloth;
  53712. /**
  53713. * Create rope for an impostor
  53714. * @param impostor to create the softbody for
  53715. */
  53716. private _createRope;
  53717. private _addHullVerts;
  53718. private _createShape;
  53719. /**
  53720. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53721. * @param impostor imposter containing the physics body and babylon object
  53722. */
  53723. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53724. /**
  53725. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53726. * @param impostor imposter containing the physics body and babylon object
  53727. * @param newPosition new position
  53728. * @param newRotation new rotation
  53729. */
  53730. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53731. /**
  53732. * If this plugin is supported
  53733. * @returns true if its supported
  53734. */
  53735. isSupported(): boolean;
  53736. /**
  53737. * Sets the linear velocity of the physics body
  53738. * @param impostor imposter to set the velocity on
  53739. * @param velocity velocity to set
  53740. */
  53741. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53742. /**
  53743. * Sets the angular velocity of the physics body
  53744. * @param impostor imposter to set the velocity on
  53745. * @param velocity velocity to set
  53746. */
  53747. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53748. /**
  53749. * gets the linear velocity
  53750. * @param impostor imposter to get linear velocity from
  53751. * @returns linear velocity
  53752. */
  53753. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53754. /**
  53755. * gets the angular velocity
  53756. * @param impostor imposter to get angular velocity from
  53757. * @returns angular velocity
  53758. */
  53759. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53760. /**
  53761. * Sets the mass of physics body
  53762. * @param impostor imposter to set the mass on
  53763. * @param mass mass to set
  53764. */
  53765. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53766. /**
  53767. * Gets the mass of the physics body
  53768. * @param impostor imposter to get the mass from
  53769. * @returns mass
  53770. */
  53771. getBodyMass(impostor: PhysicsImpostor): number;
  53772. /**
  53773. * Gets friction of the impostor
  53774. * @param impostor impostor to get friction from
  53775. * @returns friction value
  53776. */
  53777. getBodyFriction(impostor: PhysicsImpostor): number;
  53778. /**
  53779. * Sets friction of the impostor
  53780. * @param impostor impostor to set friction on
  53781. * @param friction friction value
  53782. */
  53783. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53784. /**
  53785. * Gets restitution of the impostor
  53786. * @param impostor impostor to get restitution from
  53787. * @returns restitution value
  53788. */
  53789. getBodyRestitution(impostor: PhysicsImpostor): number;
  53790. /**
  53791. * Sets resitution of the impostor
  53792. * @param impostor impostor to set resitution on
  53793. * @param restitution resitution value
  53794. */
  53795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53796. /**
  53797. * Gets pressure inside the impostor
  53798. * @param impostor impostor to get pressure from
  53799. * @returns pressure value
  53800. */
  53801. getBodyPressure(impostor: PhysicsImpostor): number;
  53802. /**
  53803. * Sets pressure inside a soft body impostor
  53804. * Cloth and rope must remain 0 pressure
  53805. * @param impostor impostor to set pressure on
  53806. * @param pressure pressure value
  53807. */
  53808. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53809. /**
  53810. * Gets stiffness of the impostor
  53811. * @param impostor impostor to get stiffness from
  53812. * @returns pressure value
  53813. */
  53814. getBodyStiffness(impostor: PhysicsImpostor): number;
  53815. /**
  53816. * Sets stiffness of the impostor
  53817. * @param impostor impostor to set stiffness on
  53818. * @param stiffness stiffness value from 0 to 1
  53819. */
  53820. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53821. /**
  53822. * Gets velocityIterations of the impostor
  53823. * @param impostor impostor to get velocity iterations from
  53824. * @returns velocityIterations value
  53825. */
  53826. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53827. /**
  53828. * Sets velocityIterations of the impostor
  53829. * @param impostor impostor to set velocity iterations on
  53830. * @param velocityIterations velocityIterations value
  53831. */
  53832. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53833. /**
  53834. * Gets positionIterations of the impostor
  53835. * @param impostor impostor to get position iterations from
  53836. * @returns positionIterations value
  53837. */
  53838. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53839. /**
  53840. * Sets positionIterations of the impostor
  53841. * @param impostor impostor to set position on
  53842. * @param positionIterations positionIterations value
  53843. */
  53844. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53845. /**
  53846. * Append an anchor to a cloth object
  53847. * @param impostor is the cloth impostor to add anchor to
  53848. * @param otherImpostor is the rigid impostor to anchor to
  53849. * @param width ratio across width from 0 to 1
  53850. * @param height ratio up height from 0 to 1
  53851. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53852. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53853. */
  53854. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53855. /**
  53856. * Append an hook to a rope object
  53857. * @param impostor is the rope impostor to add hook to
  53858. * @param otherImpostor is the rigid impostor to hook to
  53859. * @param length ratio along the rope from 0 to 1
  53860. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53861. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53862. */
  53863. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53864. /**
  53865. * Sleeps the physics body and stops it from being active
  53866. * @param impostor impostor to sleep
  53867. */
  53868. sleepBody(impostor: PhysicsImpostor): void;
  53869. /**
  53870. * Activates the physics body
  53871. * @param impostor impostor to activate
  53872. */
  53873. wakeUpBody(impostor: PhysicsImpostor): void;
  53874. /**
  53875. * Updates the distance parameters of the joint
  53876. * @param joint joint to update
  53877. * @param maxDistance maximum distance of the joint
  53878. * @param minDistance minimum distance of the joint
  53879. */
  53880. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53881. /**
  53882. * Sets a motor on the joint
  53883. * @param joint joint to set motor on
  53884. * @param speed speed of the motor
  53885. * @param maxForce maximum force of the motor
  53886. * @param motorIndex index of the motor
  53887. */
  53888. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53889. /**
  53890. * Sets the motors limit
  53891. * @param joint joint to set limit on
  53892. * @param upperLimit upper limit
  53893. * @param lowerLimit lower limit
  53894. */
  53895. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53896. /**
  53897. * Syncs the position and rotation of a mesh with the impostor
  53898. * @param mesh mesh to sync
  53899. * @param impostor impostor to update the mesh with
  53900. */
  53901. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53902. /**
  53903. * Gets the radius of the impostor
  53904. * @param impostor impostor to get radius from
  53905. * @returns the radius
  53906. */
  53907. getRadius(impostor: PhysicsImpostor): number;
  53908. /**
  53909. * Gets the box size of the impostor
  53910. * @param impostor impostor to get box size from
  53911. * @param result the resulting box size
  53912. */
  53913. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53914. /**
  53915. * Disposes of the impostor
  53916. */
  53917. dispose(): void;
  53918. /**
  53919. * Does a raycast in the physics world
  53920. * @param from when should the ray start?
  53921. * @param to when should the ray end?
  53922. * @returns PhysicsRaycastResult
  53923. */
  53924. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53925. }
  53926. }
  53927. declare module "babylonjs/Probes/reflectionProbe" {
  53928. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53929. import { Vector3 } from "babylonjs/Maths/math.vector";
  53930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53931. import { Nullable } from "babylonjs/types";
  53932. import { Scene } from "babylonjs/scene";
  53933. module "babylonjs/abstractScene" {
  53934. interface AbstractScene {
  53935. /**
  53936. * The list of reflection probes added to the scene
  53937. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53938. */
  53939. reflectionProbes: Array<ReflectionProbe>;
  53940. /**
  53941. * Removes the given reflection probe from this scene.
  53942. * @param toRemove The reflection probe to remove
  53943. * @returns The index of the removed reflection probe
  53944. */
  53945. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53946. /**
  53947. * Adds the given reflection probe to this scene.
  53948. * @param newReflectionProbe The reflection probe to add
  53949. */
  53950. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53951. }
  53952. }
  53953. /**
  53954. * Class used to generate realtime reflection / refraction cube textures
  53955. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53956. */
  53957. export class ReflectionProbe {
  53958. /** defines the name of the probe */
  53959. name: string;
  53960. private _scene;
  53961. private _renderTargetTexture;
  53962. private _projectionMatrix;
  53963. private _viewMatrix;
  53964. private _target;
  53965. private _add;
  53966. private _attachedMesh;
  53967. private _invertYAxis;
  53968. /** Gets or sets probe position (center of the cube map) */
  53969. position: Vector3;
  53970. /**
  53971. * Creates a new reflection probe
  53972. * @param name defines the name of the probe
  53973. * @param size defines the texture resolution (for each face)
  53974. * @param scene defines the hosting scene
  53975. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53976. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53977. */
  53978. constructor(
  53979. /** defines the name of the probe */
  53980. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53981. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53982. samples: number;
  53983. /** Gets or sets the refresh rate to use (on every frame by default) */
  53984. refreshRate: number;
  53985. /**
  53986. * Gets the hosting scene
  53987. * @returns a Scene
  53988. */
  53989. getScene(): Scene;
  53990. /** Gets the internal CubeTexture used to render to */
  53991. readonly cubeTexture: RenderTargetTexture;
  53992. /** Gets the list of meshes to render */
  53993. readonly renderList: Nullable<AbstractMesh[]>;
  53994. /**
  53995. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53996. * @param mesh defines the mesh to attach to
  53997. */
  53998. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53999. /**
  54000. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54001. * @param renderingGroupId The rendering group id corresponding to its index
  54002. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54003. */
  54004. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54005. /**
  54006. * Clean all associated resources
  54007. */
  54008. dispose(): void;
  54009. /**
  54010. * Converts the reflection probe information to a readable string for debug purpose.
  54011. * @param fullDetails Supports for multiple levels of logging within scene loading
  54012. * @returns the human readable reflection probe info
  54013. */
  54014. toString(fullDetails?: boolean): string;
  54015. /**
  54016. * Get the class name of the relfection probe.
  54017. * @returns "ReflectionProbe"
  54018. */
  54019. getClassName(): string;
  54020. /**
  54021. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54022. * @returns The JSON representation of the texture
  54023. */
  54024. serialize(): any;
  54025. /**
  54026. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54027. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54028. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54029. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54030. * @returns The parsed reflection probe if successful
  54031. */
  54032. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54033. }
  54034. }
  54035. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54036. /** @hidden */
  54037. export var _BabylonLoaderRegistered: boolean;
  54038. }
  54039. declare module "babylonjs/Loading/Plugins/index" {
  54040. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54041. }
  54042. declare module "babylonjs/Loading/index" {
  54043. export * from "babylonjs/Loading/loadingScreen";
  54044. export * from "babylonjs/Loading/Plugins/index";
  54045. export * from "babylonjs/Loading/sceneLoader";
  54046. export * from "babylonjs/Loading/sceneLoaderFlags";
  54047. }
  54048. declare module "babylonjs/Materials/Background/index" {
  54049. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54050. }
  54051. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54052. import { Scene } from "babylonjs/scene";
  54053. import { Color3 } from "babylonjs/Maths/math.color";
  54054. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54056. /**
  54057. * The Physically based simple base material of BJS.
  54058. *
  54059. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54060. * It is used as the base class for both the specGloss and metalRough conventions.
  54061. */
  54062. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54063. /**
  54064. * Number of Simultaneous lights allowed on the material.
  54065. */
  54066. maxSimultaneousLights: number;
  54067. /**
  54068. * If sets to true, disables all the lights affecting the material.
  54069. */
  54070. disableLighting: boolean;
  54071. /**
  54072. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54073. */
  54074. environmentTexture: BaseTexture;
  54075. /**
  54076. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54077. */
  54078. invertNormalMapX: boolean;
  54079. /**
  54080. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54081. */
  54082. invertNormalMapY: boolean;
  54083. /**
  54084. * Normal map used in the model.
  54085. */
  54086. normalTexture: BaseTexture;
  54087. /**
  54088. * Emissivie color used to self-illuminate the model.
  54089. */
  54090. emissiveColor: Color3;
  54091. /**
  54092. * Emissivie texture used to self-illuminate the model.
  54093. */
  54094. emissiveTexture: BaseTexture;
  54095. /**
  54096. * Occlusion Channel Strenght.
  54097. */
  54098. occlusionStrength: number;
  54099. /**
  54100. * Occlusion Texture of the material (adding extra occlusion effects).
  54101. */
  54102. occlusionTexture: BaseTexture;
  54103. /**
  54104. * Defines the alpha limits in alpha test mode.
  54105. */
  54106. alphaCutOff: number;
  54107. /**
  54108. * Gets the current double sided mode.
  54109. */
  54110. /**
  54111. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54112. */
  54113. doubleSided: boolean;
  54114. /**
  54115. * Stores the pre-calculated light information of a mesh in a texture.
  54116. */
  54117. lightmapTexture: BaseTexture;
  54118. /**
  54119. * If true, the light map contains occlusion information instead of lighting info.
  54120. */
  54121. useLightmapAsShadowmap: boolean;
  54122. /**
  54123. * Instantiates a new PBRMaterial instance.
  54124. *
  54125. * @param name The material name
  54126. * @param scene The scene the material will be use in.
  54127. */
  54128. constructor(name: string, scene: Scene);
  54129. getClassName(): string;
  54130. }
  54131. }
  54132. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54133. import { Scene } from "babylonjs/scene";
  54134. import { Color3 } from "babylonjs/Maths/math.color";
  54135. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54136. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54137. /**
  54138. * The PBR material of BJS following the metal roughness convention.
  54139. *
  54140. * This fits to the PBR convention in the GLTF definition:
  54141. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54142. */
  54143. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54144. /**
  54145. * The base color has two different interpretations depending on the value of metalness.
  54146. * When the material is a metal, the base color is the specific measured reflectance value
  54147. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54148. * of the material.
  54149. */
  54150. baseColor: Color3;
  54151. /**
  54152. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54153. * well as opacity information in the alpha channel.
  54154. */
  54155. baseTexture: BaseTexture;
  54156. /**
  54157. * Specifies the metallic scalar value of the material.
  54158. * Can also be used to scale the metalness values of the metallic texture.
  54159. */
  54160. metallic: number;
  54161. /**
  54162. * Specifies the roughness scalar value of the material.
  54163. * Can also be used to scale the roughness values of the metallic texture.
  54164. */
  54165. roughness: number;
  54166. /**
  54167. * Texture containing both the metallic value in the B channel and the
  54168. * roughness value in the G channel to keep better precision.
  54169. */
  54170. metallicRoughnessTexture: BaseTexture;
  54171. /**
  54172. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54173. *
  54174. * @param name The material name
  54175. * @param scene The scene the material will be use in.
  54176. */
  54177. constructor(name: string, scene: Scene);
  54178. /**
  54179. * Return the currrent class name of the material.
  54180. */
  54181. getClassName(): string;
  54182. /**
  54183. * Makes a duplicate of the current material.
  54184. * @param name - name to use for the new material.
  54185. */
  54186. clone(name: string): PBRMetallicRoughnessMaterial;
  54187. /**
  54188. * Serialize the material to a parsable JSON object.
  54189. */
  54190. serialize(): any;
  54191. /**
  54192. * Parses a JSON object correponding to the serialize function.
  54193. */
  54194. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54195. }
  54196. }
  54197. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54198. import { Scene } from "babylonjs/scene";
  54199. import { Color3 } from "babylonjs/Maths/math.color";
  54200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54201. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54202. /**
  54203. * The PBR material of BJS following the specular glossiness convention.
  54204. *
  54205. * This fits to the PBR convention in the GLTF definition:
  54206. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54207. */
  54208. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54209. /**
  54210. * Specifies the diffuse color of the material.
  54211. */
  54212. diffuseColor: Color3;
  54213. /**
  54214. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54215. * channel.
  54216. */
  54217. diffuseTexture: BaseTexture;
  54218. /**
  54219. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54220. */
  54221. specularColor: Color3;
  54222. /**
  54223. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54224. */
  54225. glossiness: number;
  54226. /**
  54227. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54228. */
  54229. specularGlossinessTexture: BaseTexture;
  54230. /**
  54231. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54232. *
  54233. * @param name The material name
  54234. * @param scene The scene the material will be use in.
  54235. */
  54236. constructor(name: string, scene: Scene);
  54237. /**
  54238. * Return the currrent class name of the material.
  54239. */
  54240. getClassName(): string;
  54241. /**
  54242. * Makes a duplicate of the current material.
  54243. * @param name - name to use for the new material.
  54244. */
  54245. clone(name: string): PBRSpecularGlossinessMaterial;
  54246. /**
  54247. * Serialize the material to a parsable JSON object.
  54248. */
  54249. serialize(): any;
  54250. /**
  54251. * Parses a JSON object correponding to the serialize function.
  54252. */
  54253. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54254. }
  54255. }
  54256. declare module "babylonjs/Materials/PBR/index" {
  54257. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54258. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54259. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54260. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54261. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54262. }
  54263. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54264. import { Nullable } from "babylonjs/types";
  54265. import { Scene } from "babylonjs/scene";
  54266. import { Matrix } from "babylonjs/Maths/math.vector";
  54267. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54268. /**
  54269. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54270. * It can help converting any input color in a desired output one. This can then be used to create effects
  54271. * from sepia, black and white to sixties or futuristic rendering...
  54272. *
  54273. * The only supported format is currently 3dl.
  54274. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54275. */
  54276. export class ColorGradingTexture extends BaseTexture {
  54277. /**
  54278. * The current texture matrix. (will always be identity in color grading texture)
  54279. */
  54280. private _textureMatrix;
  54281. /**
  54282. * The texture URL.
  54283. */
  54284. url: string;
  54285. /**
  54286. * Empty line regex stored for GC.
  54287. */
  54288. private static _noneEmptyLineRegex;
  54289. private _engine;
  54290. /**
  54291. * Instantiates a ColorGradingTexture from the following parameters.
  54292. *
  54293. * @param url The location of the color gradind data (currently only supporting 3dl)
  54294. * @param scene The scene the texture will be used in
  54295. */
  54296. constructor(url: string, scene: Scene);
  54297. /**
  54298. * Returns the texture matrix used in most of the material.
  54299. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54300. */
  54301. getTextureMatrix(): Matrix;
  54302. /**
  54303. * Occurs when the file being loaded is a .3dl LUT file.
  54304. */
  54305. private load3dlTexture;
  54306. /**
  54307. * Starts the loading process of the texture.
  54308. */
  54309. private loadTexture;
  54310. /**
  54311. * Clones the color gradind texture.
  54312. */
  54313. clone(): ColorGradingTexture;
  54314. /**
  54315. * Called during delayed load for textures.
  54316. */
  54317. delayLoad(): void;
  54318. /**
  54319. * Parses a color grading texture serialized by Babylon.
  54320. * @param parsedTexture The texture information being parsedTexture
  54321. * @param scene The scene to load the texture in
  54322. * @param rootUrl The root url of the data assets to load
  54323. * @return A color gradind texture
  54324. */
  54325. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54326. /**
  54327. * Serializes the LUT texture to json format.
  54328. */
  54329. serialize(): any;
  54330. }
  54331. }
  54332. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54333. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54334. import { Scene } from "babylonjs/scene";
  54335. import { Nullable } from "babylonjs/types";
  54336. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54337. /**
  54338. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54339. */
  54340. export class EquiRectangularCubeTexture extends BaseTexture {
  54341. /** The six faces of the cube. */
  54342. private static _FacesMapping;
  54343. private _noMipmap;
  54344. private _onLoad;
  54345. private _onError;
  54346. /** The size of the cubemap. */
  54347. private _size;
  54348. /** The buffer of the image. */
  54349. private _buffer;
  54350. /** The width of the input image. */
  54351. private _width;
  54352. /** The height of the input image. */
  54353. private _height;
  54354. /** The URL to the image. */
  54355. url: string;
  54356. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54357. coordinatesMode: number;
  54358. /**
  54359. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54360. * @param url The location of the image
  54361. * @param scene The scene the texture will be used in
  54362. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54363. * @param noMipmap Forces to not generate the mipmap if true
  54364. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54365. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54366. * @param onLoad — defines a callback called when texture is loaded
  54367. * @param onError — defines a callback called if there is an error
  54368. */
  54369. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54370. /**
  54371. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54372. */
  54373. private loadImage;
  54374. /**
  54375. * Convert the image buffer into a cubemap and create a CubeTexture.
  54376. */
  54377. private loadTexture;
  54378. /**
  54379. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54380. * @param buffer The ArrayBuffer that should be converted.
  54381. * @returns The buffer as Float32Array.
  54382. */
  54383. private getFloat32ArrayFromArrayBuffer;
  54384. /**
  54385. * Get the current class name of the texture useful for serialization or dynamic coding.
  54386. * @returns "EquiRectangularCubeTexture"
  54387. */
  54388. getClassName(): string;
  54389. /**
  54390. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54391. * @returns A clone of the current EquiRectangularCubeTexture.
  54392. */
  54393. clone(): EquiRectangularCubeTexture;
  54394. }
  54395. }
  54396. declare module "babylonjs/Misc/tga" {
  54397. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54398. /**
  54399. * Based on jsTGALoader - Javascript loader for TGA file
  54400. * By Vincent Thibault
  54401. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54402. */
  54403. export class TGATools {
  54404. private static _TYPE_INDEXED;
  54405. private static _TYPE_RGB;
  54406. private static _TYPE_GREY;
  54407. private static _TYPE_RLE_INDEXED;
  54408. private static _TYPE_RLE_RGB;
  54409. private static _TYPE_RLE_GREY;
  54410. private static _ORIGIN_MASK;
  54411. private static _ORIGIN_SHIFT;
  54412. private static _ORIGIN_BL;
  54413. private static _ORIGIN_BR;
  54414. private static _ORIGIN_UL;
  54415. private static _ORIGIN_UR;
  54416. /**
  54417. * Gets the header of a TGA file
  54418. * @param data defines the TGA data
  54419. * @returns the header
  54420. */
  54421. static GetTGAHeader(data: Uint8Array): any;
  54422. /**
  54423. * Uploads TGA content to a Babylon Texture
  54424. * @hidden
  54425. */
  54426. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54427. /** @hidden */
  54428. 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;
  54429. /** @hidden */
  54430. 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;
  54431. /** @hidden */
  54432. 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;
  54433. /** @hidden */
  54434. 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;
  54435. /** @hidden */
  54436. 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;
  54437. /** @hidden */
  54438. 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;
  54439. }
  54440. }
  54441. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54442. import { Nullable } from "babylonjs/types";
  54443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54444. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54445. /**
  54446. * Implementation of the TGA Texture Loader.
  54447. * @hidden
  54448. */
  54449. export class _TGATextureLoader implements IInternalTextureLoader {
  54450. /**
  54451. * Defines wether the loader supports cascade loading the different faces.
  54452. */
  54453. readonly supportCascades: boolean;
  54454. /**
  54455. * This returns if the loader support the current file information.
  54456. * @param extension defines the file extension of the file being loaded
  54457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54458. * @param fallback defines the fallback internal texture if any
  54459. * @param isBase64 defines whether the texture is encoded as a base64
  54460. * @param isBuffer defines whether the texture data are stored as a buffer
  54461. * @returns true if the loader can load the specified file
  54462. */
  54463. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54464. /**
  54465. * Transform the url before loading if required.
  54466. * @param rootUrl the url of the texture
  54467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54468. * @returns the transformed texture
  54469. */
  54470. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54471. /**
  54472. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54473. * @param rootUrl the url of the texture
  54474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54475. * @returns the fallback texture
  54476. */
  54477. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54478. /**
  54479. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54480. * @param data contains the texture data
  54481. * @param texture defines the BabylonJS internal texture
  54482. * @param createPolynomials will be true if polynomials have been requested
  54483. * @param onLoad defines the callback to trigger once the texture is ready
  54484. * @param onError defines the callback to trigger in case of error
  54485. */
  54486. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54487. /**
  54488. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54489. * @param data contains the texture data
  54490. * @param texture defines the BabylonJS internal texture
  54491. * @param callback defines the method to call once ready to upload
  54492. */
  54493. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54494. }
  54495. }
  54496. declare module "babylonjs/Misc/basis" {
  54497. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54498. /**
  54499. * Info about the .basis files
  54500. */
  54501. class BasisFileInfo {
  54502. /**
  54503. * If the file has alpha
  54504. */
  54505. hasAlpha: boolean;
  54506. /**
  54507. * Info about each image of the basis file
  54508. */
  54509. images: Array<{
  54510. levels: Array<{
  54511. width: number;
  54512. height: number;
  54513. transcodedPixels: ArrayBufferView;
  54514. }>;
  54515. }>;
  54516. }
  54517. /**
  54518. * Result of transcoding a basis file
  54519. */
  54520. class TranscodeResult {
  54521. /**
  54522. * Info about the .basis file
  54523. */
  54524. fileInfo: BasisFileInfo;
  54525. /**
  54526. * Format to use when loading the file
  54527. */
  54528. format: number;
  54529. }
  54530. /**
  54531. * Configuration options for the Basis transcoder
  54532. */
  54533. export class BasisTranscodeConfiguration {
  54534. /**
  54535. * Supported compression formats used to determine the supported output format of the transcoder
  54536. */
  54537. supportedCompressionFormats?: {
  54538. /**
  54539. * etc1 compression format
  54540. */
  54541. etc1?: boolean;
  54542. /**
  54543. * s3tc compression format
  54544. */
  54545. s3tc?: boolean;
  54546. /**
  54547. * pvrtc compression format
  54548. */
  54549. pvrtc?: boolean;
  54550. /**
  54551. * etc2 compression format
  54552. */
  54553. etc2?: boolean;
  54554. };
  54555. /**
  54556. * If mipmap levels should be loaded for transcoded images (Default: true)
  54557. */
  54558. loadMipmapLevels?: boolean;
  54559. /**
  54560. * Index of a single image to load (Default: all images)
  54561. */
  54562. loadSingleImage?: number;
  54563. }
  54564. /**
  54565. * Used to load .Basis files
  54566. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54567. */
  54568. export class BasisTools {
  54569. private static _IgnoreSupportedFormats;
  54570. /**
  54571. * URL to use when loading the basis transcoder
  54572. */
  54573. static JSModuleURL: string;
  54574. /**
  54575. * URL to use when loading the wasm module for the transcoder
  54576. */
  54577. static WasmModuleURL: string;
  54578. /**
  54579. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54580. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54581. * @returns internal format corresponding to the Basis format
  54582. */
  54583. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54584. private static _WorkerPromise;
  54585. private static _Worker;
  54586. private static _actionId;
  54587. private static _CreateWorkerAsync;
  54588. /**
  54589. * Transcodes a loaded image file to compressed pixel data
  54590. * @param imageData image data to transcode
  54591. * @param config configuration options for the transcoding
  54592. * @returns a promise resulting in the transcoded image
  54593. */
  54594. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54595. /**
  54596. * Loads a texture from the transcode result
  54597. * @param texture texture load to
  54598. * @param transcodeResult the result of transcoding the basis file to load from
  54599. */
  54600. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54601. }
  54602. }
  54603. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54604. import { Nullable } from "babylonjs/types";
  54605. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54606. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54607. /**
  54608. * Loader for .basis file format
  54609. */
  54610. export class _BasisTextureLoader implements IInternalTextureLoader {
  54611. /**
  54612. * Defines whether the loader supports cascade loading the different faces.
  54613. */
  54614. readonly supportCascades: boolean;
  54615. /**
  54616. * This returns if the loader support the current file information.
  54617. * @param extension defines the file extension of the file being loaded
  54618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54619. * @param fallback defines the fallback internal texture if any
  54620. * @param isBase64 defines whether the texture is encoded as a base64
  54621. * @param isBuffer defines whether the texture data are stored as a buffer
  54622. * @returns true if the loader can load the specified file
  54623. */
  54624. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54625. /**
  54626. * Transform the url before loading if required.
  54627. * @param rootUrl the url of the texture
  54628. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54629. * @returns the transformed texture
  54630. */
  54631. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54632. /**
  54633. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54634. * @param rootUrl the url of the texture
  54635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54636. * @returns the fallback texture
  54637. */
  54638. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54639. /**
  54640. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54641. * @param data contains the texture data
  54642. * @param texture defines the BabylonJS internal texture
  54643. * @param createPolynomials will be true if polynomials have been requested
  54644. * @param onLoad defines the callback to trigger once the texture is ready
  54645. * @param onError defines the callback to trigger in case of error
  54646. */
  54647. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54648. /**
  54649. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54650. * @param data contains the texture data
  54651. * @param texture defines the BabylonJS internal texture
  54652. * @param callback defines the method to call once ready to upload
  54653. */
  54654. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54655. }
  54656. }
  54657. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54658. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54659. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54660. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54661. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54662. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54663. }
  54664. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54665. import { Scene } from "babylonjs/scene";
  54666. import { Texture } from "babylonjs/Materials/Textures/texture";
  54667. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54668. /**
  54669. * 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.
  54670. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54672. */
  54673. export class CustomProceduralTexture extends ProceduralTexture {
  54674. private _animate;
  54675. private _time;
  54676. private _config;
  54677. private _texturePath;
  54678. /**
  54679. * Instantiates a new Custom Procedural Texture.
  54680. * 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.
  54681. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54682. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54683. * @param name Define the name of the texture
  54684. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54685. * @param size Define the size of the texture to create
  54686. * @param scene Define the scene the texture belongs to
  54687. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54688. * @param generateMipMaps Define if the texture should creates mip maps or not
  54689. */
  54690. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54691. private _loadJson;
  54692. /**
  54693. * Is the texture ready to be used ? (rendered at least once)
  54694. * @returns true if ready, otherwise, false.
  54695. */
  54696. isReady(): boolean;
  54697. /**
  54698. * Render the texture to its associated render target.
  54699. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54700. */
  54701. render(useCameraPostProcess?: boolean): void;
  54702. /**
  54703. * Update the list of dependant textures samplers in the shader.
  54704. */
  54705. updateTextures(): void;
  54706. /**
  54707. * Update the uniform values of the procedural texture in the shader.
  54708. */
  54709. updateShaderUniforms(): void;
  54710. /**
  54711. * Define if the texture animates or not.
  54712. */
  54713. animate: boolean;
  54714. }
  54715. }
  54716. declare module "babylonjs/Shaders/noise.fragment" {
  54717. /** @hidden */
  54718. export var noisePixelShader: {
  54719. name: string;
  54720. shader: string;
  54721. };
  54722. }
  54723. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54724. import { Nullable } from "babylonjs/types";
  54725. import { Scene } from "babylonjs/scene";
  54726. import { Texture } from "babylonjs/Materials/Textures/texture";
  54727. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54728. import "babylonjs/Shaders/noise.fragment";
  54729. /**
  54730. * Class used to generate noise procedural textures
  54731. */
  54732. export class NoiseProceduralTexture extends ProceduralTexture {
  54733. private _time;
  54734. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54735. brightness: number;
  54736. /** Defines the number of octaves to process */
  54737. octaves: number;
  54738. /** Defines the level of persistence (0.8 by default) */
  54739. persistence: number;
  54740. /** Gets or sets animation speed factor (default is 1) */
  54741. animationSpeedFactor: number;
  54742. /**
  54743. * Creates a new NoiseProceduralTexture
  54744. * @param name defines the name fo the texture
  54745. * @param size defines the size of the texture (default is 256)
  54746. * @param scene defines the hosting scene
  54747. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54748. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54749. */
  54750. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54751. private _updateShaderUniforms;
  54752. protected _getDefines(): string;
  54753. /** Generate the current state of the procedural texture */
  54754. render(useCameraPostProcess?: boolean): void;
  54755. /**
  54756. * Serializes this noise procedural texture
  54757. * @returns a serialized noise procedural texture object
  54758. */
  54759. serialize(): any;
  54760. /**
  54761. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54762. * @param parsedTexture defines parsed texture data
  54763. * @param scene defines the current scene
  54764. * @param rootUrl defines the root URL containing noise procedural texture information
  54765. * @returns a parsed NoiseProceduralTexture
  54766. */
  54767. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54768. }
  54769. }
  54770. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54771. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54772. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54773. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54774. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54775. }
  54776. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54777. import { Nullable } from "babylonjs/types";
  54778. import { Scene } from "babylonjs/scene";
  54779. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54780. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54781. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54782. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54783. /**
  54784. * Raw cube texture where the raw buffers are passed in
  54785. */
  54786. export class RawCubeTexture extends CubeTexture {
  54787. /**
  54788. * Creates a cube texture where the raw buffers are passed in.
  54789. * @param scene defines the scene the texture is attached to
  54790. * @param data defines the array of data to use to create each face
  54791. * @param size defines the size of the textures
  54792. * @param format defines the format of the data
  54793. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54794. * @param generateMipMaps defines if the engine should generate the mip levels
  54795. * @param invertY defines if data must be stored with Y axis inverted
  54796. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54797. * @param compression defines the compression used (null by default)
  54798. */
  54799. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54800. /**
  54801. * Updates the raw cube texture.
  54802. * @param data defines the data to store
  54803. * @param format defines the data format
  54804. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54805. * @param invertY defines if data must be stored with Y axis inverted
  54806. * @param compression defines the compression used (null by default)
  54807. * @param level defines which level of the texture to update
  54808. */
  54809. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54810. /**
  54811. * Updates a raw cube texture with RGBD encoded data.
  54812. * @param data defines the array of data [mipmap][face] to use to create each face
  54813. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54814. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54815. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54816. * @returns a promsie that resolves when the operation is complete
  54817. */
  54818. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54819. /**
  54820. * Clones the raw cube texture.
  54821. * @return a new cube texture
  54822. */
  54823. clone(): CubeTexture;
  54824. /** @hidden */
  54825. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54826. }
  54827. }
  54828. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54829. import { Scene } from "babylonjs/scene";
  54830. import { Texture } from "babylonjs/Materials/Textures/texture";
  54831. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54832. /**
  54833. * Class used to store 3D textures containing user data
  54834. */
  54835. export class RawTexture3D extends Texture {
  54836. /** Gets or sets the texture format to use */
  54837. format: number;
  54838. private _engine;
  54839. /**
  54840. * Create a new RawTexture3D
  54841. * @param data defines the data of the texture
  54842. * @param width defines the width of the texture
  54843. * @param height defines the height of the texture
  54844. * @param depth defines the depth of the texture
  54845. * @param format defines the texture format to use
  54846. * @param scene defines the hosting scene
  54847. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54848. * @param invertY defines if texture must be stored with Y axis inverted
  54849. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54850. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54851. */
  54852. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54853. /** Gets or sets the texture format to use */
  54854. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54855. /**
  54856. * Update the texture with new data
  54857. * @param data defines the data to store in the texture
  54858. */
  54859. update(data: ArrayBufferView): void;
  54860. }
  54861. }
  54862. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54863. import { Scene } from "babylonjs/scene";
  54864. import { Plane } from "babylonjs/Maths/math.plane";
  54865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54866. /**
  54867. * Creates a refraction texture used by refraction channel of the standard material.
  54868. * It is like a mirror but to see through a material.
  54869. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54870. */
  54871. export class RefractionTexture extends RenderTargetTexture {
  54872. /**
  54873. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54874. * 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.
  54875. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54876. */
  54877. refractionPlane: Plane;
  54878. /**
  54879. * Define how deep under the surface we should see.
  54880. */
  54881. depth: number;
  54882. /**
  54883. * Creates a refraction texture used by refraction channel of the standard material.
  54884. * It is like a mirror but to see through a material.
  54885. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54886. * @param name Define the texture name
  54887. * @param size Define the size of the underlying texture
  54888. * @param scene Define the scene the refraction belongs to
  54889. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54890. */
  54891. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54892. /**
  54893. * Clone the refraction texture.
  54894. * @returns the cloned texture
  54895. */
  54896. clone(): RefractionTexture;
  54897. /**
  54898. * Serialize the texture to a JSON representation you could use in Parse later on
  54899. * @returns the serialized JSON representation
  54900. */
  54901. serialize(): any;
  54902. }
  54903. }
  54904. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54905. import { Nullable } from "babylonjs/types";
  54906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54907. import { Matrix } from "babylonjs/Maths/math.vector";
  54908. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54909. import "babylonjs/Engines/Extensions/engine.videoTexture";
  54910. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54911. import { Scene } from "babylonjs/scene";
  54912. /**
  54913. * Defines the options related to the creation of an HtmlElementTexture
  54914. */
  54915. export interface IHtmlElementTextureOptions {
  54916. /**
  54917. * Defines wether mip maps should be created or not.
  54918. */
  54919. generateMipMaps?: boolean;
  54920. /**
  54921. * Defines the sampling mode of the texture.
  54922. */
  54923. samplingMode?: number;
  54924. /**
  54925. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54926. */
  54927. engine: Nullable<ThinEngine>;
  54928. /**
  54929. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54930. */
  54931. scene: Nullable<Scene>;
  54932. }
  54933. /**
  54934. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54935. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54936. * is automatically managed.
  54937. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54938. * in your application.
  54939. *
  54940. * As the update is not automatic, you need to call them manually.
  54941. */
  54942. export class HtmlElementTexture extends BaseTexture {
  54943. /**
  54944. * The texture URL.
  54945. */
  54946. element: HTMLVideoElement | HTMLCanvasElement;
  54947. private static readonly DefaultOptions;
  54948. private _textureMatrix;
  54949. private _engine;
  54950. private _isVideo;
  54951. private _generateMipMaps;
  54952. private _samplingMode;
  54953. /**
  54954. * Instantiates a HtmlElementTexture from the following parameters.
  54955. *
  54956. * @param name Defines the name of the texture
  54957. * @param element Defines the video or canvas the texture is filled with
  54958. * @param options Defines the other none mandatory texture creation options
  54959. */
  54960. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54961. private _createInternalTexture;
  54962. /**
  54963. * Returns the texture matrix used in most of the material.
  54964. */
  54965. getTextureMatrix(): Matrix;
  54966. /**
  54967. * Updates the content of the texture.
  54968. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54969. */
  54970. update(invertY?: Nullable<boolean>): void;
  54971. }
  54972. }
  54973. declare module "babylonjs/Materials/Textures/index" {
  54974. export * from "babylonjs/Materials/Textures/baseTexture";
  54975. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  54976. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54977. export * from "babylonjs/Materials/Textures/cubeTexture";
  54978. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54979. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54980. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54981. export * from "babylonjs/Materials/Textures/internalTexture";
  54982. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54983. export * from "babylonjs/Materials/Textures/Loaders/index";
  54984. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54985. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54986. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54987. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54988. export * from "babylonjs/Materials/Textures/rawTexture";
  54989. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54990. export * from "babylonjs/Materials/Textures/refractionTexture";
  54991. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54992. export * from "babylonjs/Materials/Textures/texture";
  54993. export * from "babylonjs/Materials/Textures/videoTexture";
  54994. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54995. }
  54996. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54997. /**
  54998. * Enum used to define the target of a block
  54999. */
  55000. export enum NodeMaterialBlockTargets {
  55001. /** Vertex shader */
  55002. Vertex = 1,
  55003. /** Fragment shader */
  55004. Fragment = 2,
  55005. /** Neutral */
  55006. Neutral = 4,
  55007. /** Vertex and Fragment */
  55008. VertexAndFragment = 3
  55009. }
  55010. }
  55011. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55012. /**
  55013. * Defines the kind of connection point for node based material
  55014. */
  55015. export enum NodeMaterialBlockConnectionPointTypes {
  55016. /** Float */
  55017. Float = 1,
  55018. /** Int */
  55019. Int = 2,
  55020. /** Vector2 */
  55021. Vector2 = 4,
  55022. /** Vector3 */
  55023. Vector3 = 8,
  55024. /** Vector4 */
  55025. Vector4 = 16,
  55026. /** Color3 */
  55027. Color3 = 32,
  55028. /** Color4 */
  55029. Color4 = 64,
  55030. /** Matrix */
  55031. Matrix = 128,
  55032. /** Detect type based on connection */
  55033. AutoDetect = 1024,
  55034. /** Output type that will be defined by input type */
  55035. BasedOnInput = 2048
  55036. }
  55037. }
  55038. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55039. /**
  55040. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55041. */
  55042. export enum NodeMaterialBlockConnectionPointMode {
  55043. /** Value is an uniform */
  55044. Uniform = 0,
  55045. /** Value is a mesh attribute */
  55046. Attribute = 1,
  55047. /** Value is a varying between vertex and fragment shaders */
  55048. Varying = 2,
  55049. /** Mode is undefined */
  55050. Undefined = 3
  55051. }
  55052. }
  55053. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55054. /**
  55055. * Enum used to define system values e.g. values automatically provided by the system
  55056. */
  55057. export enum NodeMaterialSystemValues {
  55058. /** World */
  55059. World = 1,
  55060. /** View */
  55061. View = 2,
  55062. /** Projection */
  55063. Projection = 3,
  55064. /** ViewProjection */
  55065. ViewProjection = 4,
  55066. /** WorldView */
  55067. WorldView = 5,
  55068. /** WorldViewProjection */
  55069. WorldViewProjection = 6,
  55070. /** CameraPosition */
  55071. CameraPosition = 7,
  55072. /** Fog Color */
  55073. FogColor = 8,
  55074. /** Delta time */
  55075. DeltaTime = 9
  55076. }
  55077. }
  55078. declare module "babylonjs/Materials/Node/Enums/index" {
  55079. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55080. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55081. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55082. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55083. }
  55084. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55086. /**
  55087. * Root class for all node material optimizers
  55088. */
  55089. export class NodeMaterialOptimizer {
  55090. /**
  55091. * Function used to optimize a NodeMaterial graph
  55092. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55093. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55094. */
  55095. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55096. }
  55097. }
  55098. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55102. import { Scene } from "babylonjs/scene";
  55103. /**
  55104. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55105. */
  55106. export class TransformBlock extends NodeMaterialBlock {
  55107. /**
  55108. * Defines the value to use to complement W value to transform it to a Vector4
  55109. */
  55110. complementW: number;
  55111. /**
  55112. * Defines the value to use to complement z value to transform it to a Vector4
  55113. */
  55114. complementZ: number;
  55115. /**
  55116. * Creates a new TransformBlock
  55117. * @param name defines the block name
  55118. */
  55119. constructor(name: string);
  55120. /**
  55121. * Gets the current class name
  55122. * @returns the class name
  55123. */
  55124. getClassName(): string;
  55125. /**
  55126. * Gets the vector input
  55127. */
  55128. readonly vector: NodeMaterialConnectionPoint;
  55129. /**
  55130. * Gets the output component
  55131. */
  55132. readonly output: NodeMaterialConnectionPoint;
  55133. /**
  55134. * Gets the matrix transform input
  55135. */
  55136. readonly transform: NodeMaterialConnectionPoint;
  55137. protected _buildBlock(state: NodeMaterialBuildState): this;
  55138. serialize(): any;
  55139. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55140. protected _dumpPropertiesCode(): string;
  55141. }
  55142. }
  55143. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55145. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55146. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55147. /**
  55148. * Block used to output the vertex position
  55149. */
  55150. export class VertexOutputBlock extends NodeMaterialBlock {
  55151. /**
  55152. * Creates a new VertexOutputBlock
  55153. * @param name defines the block name
  55154. */
  55155. constructor(name: string);
  55156. /**
  55157. * Gets the current class name
  55158. * @returns the class name
  55159. */
  55160. getClassName(): string;
  55161. /**
  55162. * Gets the vector input component
  55163. */
  55164. readonly vector: NodeMaterialConnectionPoint;
  55165. protected _buildBlock(state: NodeMaterialBuildState): this;
  55166. }
  55167. }
  55168. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55169. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55170. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55171. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55172. /**
  55173. * Block used to output the final color
  55174. */
  55175. export class FragmentOutputBlock extends NodeMaterialBlock {
  55176. /**
  55177. * Create a new FragmentOutputBlock
  55178. * @param name defines the block name
  55179. */
  55180. constructor(name: string);
  55181. /**
  55182. * Gets the current class name
  55183. * @returns the class name
  55184. */
  55185. getClassName(): string;
  55186. /**
  55187. * Gets the rgba input component
  55188. */
  55189. readonly rgba: NodeMaterialConnectionPoint;
  55190. /**
  55191. * Gets the rgb input component
  55192. */
  55193. readonly rgb: NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the a input component
  55196. */
  55197. readonly a: NodeMaterialConnectionPoint;
  55198. protected _buildBlock(state: NodeMaterialBuildState): this;
  55199. }
  55200. }
  55201. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55202. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55203. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55204. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55205. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55207. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55208. import { Effect } from "babylonjs/Materials/effect";
  55209. import { Mesh } from "babylonjs/Meshes/mesh";
  55210. import { Nullable } from "babylonjs/types";
  55211. import { Scene } from "babylonjs/scene";
  55212. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55213. /**
  55214. * Block used to read a reflection texture from a sampler
  55215. */
  55216. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55217. private _define3DName;
  55218. private _defineCubicName;
  55219. private _defineExplicitName;
  55220. private _defineProjectionName;
  55221. private _defineLocalCubicName;
  55222. private _defineSphericalName;
  55223. private _definePlanarName;
  55224. private _defineEquirectangularName;
  55225. private _defineMirroredEquirectangularFixedName;
  55226. private _defineEquirectangularFixedName;
  55227. private _defineSkyboxName;
  55228. private _cubeSamplerName;
  55229. private _2DSamplerName;
  55230. private _positionUVWName;
  55231. private _directionWName;
  55232. private _reflectionCoordsName;
  55233. private _reflection2DCoordsName;
  55234. private _reflectionColorName;
  55235. private _reflectionMatrixName;
  55236. /**
  55237. * Gets or sets the texture associated with the node
  55238. */
  55239. texture: Nullable<BaseTexture>;
  55240. /**
  55241. * Create a new TextureBlock
  55242. * @param name defines the block name
  55243. */
  55244. constructor(name: string);
  55245. /**
  55246. * Gets the current class name
  55247. * @returns the class name
  55248. */
  55249. getClassName(): string;
  55250. /**
  55251. * Gets the world position input component
  55252. */
  55253. readonly position: NodeMaterialConnectionPoint;
  55254. /**
  55255. * Gets the world position input component
  55256. */
  55257. readonly worldPosition: NodeMaterialConnectionPoint;
  55258. /**
  55259. * Gets the world normal input component
  55260. */
  55261. readonly worldNormal: NodeMaterialConnectionPoint;
  55262. /**
  55263. * Gets the world input component
  55264. */
  55265. readonly world: NodeMaterialConnectionPoint;
  55266. /**
  55267. * Gets the camera (or eye) position component
  55268. */
  55269. readonly cameraPosition: NodeMaterialConnectionPoint;
  55270. /**
  55271. * Gets the view input component
  55272. */
  55273. readonly view: NodeMaterialConnectionPoint;
  55274. /**
  55275. * Gets the rgb output component
  55276. */
  55277. readonly rgb: NodeMaterialConnectionPoint;
  55278. /**
  55279. * Gets the r output component
  55280. */
  55281. readonly r: NodeMaterialConnectionPoint;
  55282. /**
  55283. * Gets the g output component
  55284. */
  55285. readonly g: NodeMaterialConnectionPoint;
  55286. /**
  55287. * Gets the b output component
  55288. */
  55289. readonly b: NodeMaterialConnectionPoint;
  55290. autoConfigure(material: NodeMaterial): void;
  55291. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55292. isReady(): boolean;
  55293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55294. private _injectVertexCode;
  55295. private _writeOutput;
  55296. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55297. serialize(): any;
  55298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55299. }
  55300. }
  55301. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55303. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55304. import { Scene } from "babylonjs/scene";
  55305. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55306. import { Matrix } from "babylonjs/Maths/math.vector";
  55307. import { Mesh } from "babylonjs/Meshes/mesh";
  55308. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55309. import { Observable } from "babylonjs/Misc/observable";
  55310. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55311. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55312. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55313. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55314. import { Nullable } from "babylonjs/types";
  55315. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55316. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55317. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55318. /**
  55319. * Interface used to configure the node material editor
  55320. */
  55321. export interface INodeMaterialEditorOptions {
  55322. /** Define the URl to load node editor script */
  55323. editorURL?: string;
  55324. }
  55325. /** @hidden */
  55326. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55327. /** BONES */
  55328. NUM_BONE_INFLUENCERS: number;
  55329. BonesPerMesh: number;
  55330. BONETEXTURE: boolean;
  55331. /** MORPH TARGETS */
  55332. MORPHTARGETS: boolean;
  55333. MORPHTARGETS_NORMAL: boolean;
  55334. MORPHTARGETS_TANGENT: boolean;
  55335. MORPHTARGETS_UV: boolean;
  55336. NUM_MORPH_INFLUENCERS: number;
  55337. /** IMAGE PROCESSING */
  55338. IMAGEPROCESSING: boolean;
  55339. VIGNETTE: boolean;
  55340. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55341. VIGNETTEBLENDMODEOPAQUE: boolean;
  55342. TONEMAPPING: boolean;
  55343. TONEMAPPING_ACES: boolean;
  55344. CONTRAST: boolean;
  55345. EXPOSURE: boolean;
  55346. COLORCURVES: boolean;
  55347. COLORGRADING: boolean;
  55348. COLORGRADING3D: boolean;
  55349. SAMPLER3DGREENDEPTH: boolean;
  55350. SAMPLER3DBGRMAP: boolean;
  55351. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55352. /** MISC. */
  55353. BUMPDIRECTUV: number;
  55354. constructor();
  55355. setValue(name: string, value: boolean): void;
  55356. }
  55357. /**
  55358. * Class used to configure NodeMaterial
  55359. */
  55360. export interface INodeMaterialOptions {
  55361. /**
  55362. * Defines if blocks should emit comments
  55363. */
  55364. emitComments: boolean;
  55365. }
  55366. /**
  55367. * Class used to create a node based material built by assembling shader blocks
  55368. */
  55369. export class NodeMaterial extends PushMaterial {
  55370. private static _BuildIdGenerator;
  55371. private _options;
  55372. private _vertexCompilationState;
  55373. private _fragmentCompilationState;
  55374. private _sharedData;
  55375. private _buildId;
  55376. private _buildWasSuccessful;
  55377. private _cachedWorldViewMatrix;
  55378. private _cachedWorldViewProjectionMatrix;
  55379. private _optimizers;
  55380. private _animationFrame;
  55381. /** Define the URl to load node editor script */
  55382. static EditorURL: string;
  55383. private BJSNODEMATERIALEDITOR;
  55384. /** Get the inspector from bundle or global */
  55385. private _getGlobalNodeMaterialEditor;
  55386. /**
  55387. * 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)
  55388. */
  55389. ignoreAlpha: boolean;
  55390. /**
  55391. * Defines the maximum number of lights that can be used in the material
  55392. */
  55393. maxSimultaneousLights: number;
  55394. /**
  55395. * Observable raised when the material is built
  55396. */
  55397. onBuildObservable: Observable<NodeMaterial>;
  55398. /**
  55399. * Gets or sets the root nodes of the material vertex shader
  55400. */
  55401. _vertexOutputNodes: NodeMaterialBlock[];
  55402. /**
  55403. * Gets or sets the root nodes of the material fragment (pixel) shader
  55404. */
  55405. _fragmentOutputNodes: NodeMaterialBlock[];
  55406. /** Gets or sets options to control the node material overall behavior */
  55407. options: INodeMaterialOptions;
  55408. /**
  55409. * Default configuration related to image processing available in the standard Material.
  55410. */
  55411. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55412. /**
  55413. * Gets the image processing configuration used either in this material.
  55414. */
  55415. /**
  55416. * Sets the Default image processing configuration used either in the this material.
  55417. *
  55418. * If sets to null, the scene one is in use.
  55419. */
  55420. imageProcessingConfiguration: ImageProcessingConfiguration;
  55421. /**
  55422. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55423. */
  55424. attachedBlocks: NodeMaterialBlock[];
  55425. /**
  55426. * Create a new node based material
  55427. * @param name defines the material name
  55428. * @param scene defines the hosting scene
  55429. * @param options defines creation option
  55430. */
  55431. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55432. /**
  55433. * Gets the current class name of the material e.g. "NodeMaterial"
  55434. * @returns the class name
  55435. */
  55436. getClassName(): string;
  55437. /**
  55438. * Keep track of the image processing observer to allow dispose and replace.
  55439. */
  55440. private _imageProcessingObserver;
  55441. /**
  55442. * Attaches a new image processing configuration to the Standard Material.
  55443. * @param configuration
  55444. */
  55445. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55446. /**
  55447. * Get a block by its name
  55448. * @param name defines the name of the block to retrieve
  55449. * @returns the required block or null if not found
  55450. */
  55451. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55452. /**
  55453. * Get a block by its name
  55454. * @param predicate defines the predicate used to find the good candidate
  55455. * @returns the required block or null if not found
  55456. */
  55457. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55458. /**
  55459. * Get an input block by its name
  55460. * @param predicate defines the predicate used to find the good candidate
  55461. * @returns the required input block or null if not found
  55462. */
  55463. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55464. /**
  55465. * Gets the list of input blocks attached to this material
  55466. * @returns an array of InputBlocks
  55467. */
  55468. getInputBlocks(): InputBlock[];
  55469. /**
  55470. * Adds a new optimizer to the list of optimizers
  55471. * @param optimizer defines the optimizers to add
  55472. * @returns the current material
  55473. */
  55474. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55475. /**
  55476. * Remove an optimizer from the list of optimizers
  55477. * @param optimizer defines the optimizers to remove
  55478. * @returns the current material
  55479. */
  55480. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55481. /**
  55482. * Add a new block to the list of output nodes
  55483. * @param node defines the node to add
  55484. * @returns the current material
  55485. */
  55486. addOutputNode(node: NodeMaterialBlock): this;
  55487. /**
  55488. * Remove a block from the list of root nodes
  55489. * @param node defines the node to remove
  55490. * @returns the current material
  55491. */
  55492. removeOutputNode(node: NodeMaterialBlock): this;
  55493. private _addVertexOutputNode;
  55494. private _removeVertexOutputNode;
  55495. private _addFragmentOutputNode;
  55496. private _removeFragmentOutputNode;
  55497. /**
  55498. * Specifies if the material will require alpha blending
  55499. * @returns a boolean specifying if alpha blending is needed
  55500. */
  55501. needAlphaBlending(): boolean;
  55502. /**
  55503. * Specifies if this material should be rendered in alpha test mode
  55504. * @returns a boolean specifying if an alpha test is needed.
  55505. */
  55506. needAlphaTesting(): boolean;
  55507. private _initializeBlock;
  55508. private _resetDualBlocks;
  55509. /**
  55510. * Build the material and generates the inner effect
  55511. * @param verbose defines if the build should log activity
  55512. */
  55513. build(verbose?: boolean): void;
  55514. /**
  55515. * Runs an otpimization phase to try to improve the shader code
  55516. */
  55517. optimize(): void;
  55518. private _prepareDefinesForAttributes;
  55519. /**
  55520. * Get if the submesh is ready to be used and all its information available.
  55521. * Child classes can use it to update shaders
  55522. * @param mesh defines the mesh to check
  55523. * @param subMesh defines which submesh to check
  55524. * @param useInstances specifies that instances should be used
  55525. * @returns a boolean indicating that the submesh is ready or not
  55526. */
  55527. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55528. /**
  55529. * Get a string representing the shaders built by the current node graph
  55530. */
  55531. readonly compiledShaders: string;
  55532. /**
  55533. * Binds the world matrix to the material
  55534. * @param world defines the world transformation matrix
  55535. */
  55536. bindOnlyWorldMatrix(world: Matrix): void;
  55537. /**
  55538. * Binds the submesh to this material by preparing the effect and shader to draw
  55539. * @param world defines the world transformation matrix
  55540. * @param mesh defines the mesh containing the submesh
  55541. * @param subMesh defines the submesh to bind the material to
  55542. */
  55543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55544. /**
  55545. * Gets the active textures from the material
  55546. * @returns an array of textures
  55547. */
  55548. getActiveTextures(): BaseTexture[];
  55549. /**
  55550. * Gets the list of texture blocks
  55551. * @returns an array of texture blocks
  55552. */
  55553. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55554. /**
  55555. * Specifies if the material uses a texture
  55556. * @param texture defines the texture to check against the material
  55557. * @returns a boolean specifying if the material uses the texture
  55558. */
  55559. hasTexture(texture: BaseTexture): boolean;
  55560. /**
  55561. * Disposes the material
  55562. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55563. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55564. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55565. */
  55566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55567. /** Creates the node editor window. */
  55568. private _createNodeEditor;
  55569. /**
  55570. * Launch the node material editor
  55571. * @param config Define the configuration of the editor
  55572. * @return a promise fulfilled when the node editor is visible
  55573. */
  55574. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55575. /**
  55576. * Clear the current material
  55577. */
  55578. clear(): void;
  55579. /**
  55580. * Clear the current material and set it to a default state
  55581. */
  55582. setToDefault(): void;
  55583. /**
  55584. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55585. * @param url defines the url to load from
  55586. * @returns a promise that will fullfil when the material is fully loaded
  55587. */
  55588. loadAsync(url: string): Promise<unknown>;
  55589. private _gatherBlocks;
  55590. /**
  55591. * Generate a string containing the code declaration required to create an equivalent of this material
  55592. * @returns a string
  55593. */
  55594. generateCode(): string;
  55595. /**
  55596. * Serializes this material in a JSON representation
  55597. * @returns the serialized material object
  55598. */
  55599. serialize(): any;
  55600. private _restoreConnections;
  55601. /**
  55602. * Clear the current graph and load a new one from a serialization object
  55603. * @param source defines the JSON representation of the material
  55604. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55605. */
  55606. loadFromSerialization(source: any, rootUrl?: string): void;
  55607. /**
  55608. * Creates a node material from parsed material data
  55609. * @param source defines the JSON representation of the material
  55610. * @param scene defines the hosting scene
  55611. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55612. * @returns a new node material
  55613. */
  55614. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55615. /**
  55616. * Creates a new node material set to default basic configuration
  55617. * @param name defines the name of the material
  55618. * @param scene defines the hosting scene
  55619. * @returns a new NodeMaterial
  55620. */
  55621. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55622. }
  55623. }
  55624. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55627. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55630. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55631. import { Effect } from "babylonjs/Materials/effect";
  55632. import { Mesh } from "babylonjs/Meshes/mesh";
  55633. import { Nullable } from "babylonjs/types";
  55634. import { Texture } from "babylonjs/Materials/Textures/texture";
  55635. import { Scene } from "babylonjs/scene";
  55636. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55637. /**
  55638. * Block used to read a texture from a sampler
  55639. */
  55640. export class TextureBlock extends NodeMaterialBlock {
  55641. private _defineName;
  55642. private _linearDefineName;
  55643. private _samplerName;
  55644. private _transformedUVName;
  55645. private _textureTransformName;
  55646. private _textureInfoName;
  55647. private _mainUVName;
  55648. private _mainUVDefineName;
  55649. /**
  55650. * Gets or sets the texture associated with the node
  55651. */
  55652. texture: Nullable<Texture>;
  55653. /**
  55654. * Create a new TextureBlock
  55655. * @param name defines the block name
  55656. */
  55657. constructor(name: string);
  55658. /**
  55659. * Gets the current class name
  55660. * @returns the class name
  55661. */
  55662. getClassName(): string;
  55663. /**
  55664. * Gets the uv input component
  55665. */
  55666. readonly uv: NodeMaterialConnectionPoint;
  55667. /**
  55668. * Gets the rgba output component
  55669. */
  55670. readonly rgba: NodeMaterialConnectionPoint;
  55671. /**
  55672. * Gets the rgb output component
  55673. */
  55674. readonly rgb: NodeMaterialConnectionPoint;
  55675. /**
  55676. * Gets the r output component
  55677. */
  55678. readonly r: NodeMaterialConnectionPoint;
  55679. /**
  55680. * Gets the g output component
  55681. */
  55682. readonly g: NodeMaterialConnectionPoint;
  55683. /**
  55684. * Gets the b output component
  55685. */
  55686. readonly b: NodeMaterialConnectionPoint;
  55687. /**
  55688. * Gets the a output component
  55689. */
  55690. readonly a: NodeMaterialConnectionPoint;
  55691. readonly target: NodeMaterialBlockTargets;
  55692. autoConfigure(material: NodeMaterial): void;
  55693. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55695. isReady(): boolean;
  55696. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55697. private readonly _isMixed;
  55698. private _injectVertexCode;
  55699. private _writeOutput;
  55700. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55701. protected _dumpPropertiesCode(): string;
  55702. serialize(): any;
  55703. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55704. }
  55705. }
  55706. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55708. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55709. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55710. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55711. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55712. import { Scene } from "babylonjs/scene";
  55713. /**
  55714. * Class used to store shared data between 2 NodeMaterialBuildState
  55715. */
  55716. export class NodeMaterialBuildStateSharedData {
  55717. /**
  55718. * Gets the list of emitted varyings
  55719. */
  55720. temps: string[];
  55721. /**
  55722. * Gets the list of emitted varyings
  55723. */
  55724. varyings: string[];
  55725. /**
  55726. * Gets the varying declaration string
  55727. */
  55728. varyingDeclaration: string;
  55729. /**
  55730. * Input blocks
  55731. */
  55732. inputBlocks: InputBlock[];
  55733. /**
  55734. * Input blocks
  55735. */
  55736. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55737. /**
  55738. * Bindable blocks (Blocks that need to set data to the effect)
  55739. */
  55740. bindableBlocks: NodeMaterialBlock[];
  55741. /**
  55742. * List of blocks that can provide a compilation fallback
  55743. */
  55744. blocksWithFallbacks: NodeMaterialBlock[];
  55745. /**
  55746. * List of blocks that can provide a define update
  55747. */
  55748. blocksWithDefines: NodeMaterialBlock[];
  55749. /**
  55750. * List of blocks that can provide a repeatable content
  55751. */
  55752. repeatableContentBlocks: NodeMaterialBlock[];
  55753. /**
  55754. * List of blocks that can provide a dynamic list of uniforms
  55755. */
  55756. dynamicUniformBlocks: NodeMaterialBlock[];
  55757. /**
  55758. * List of blocks that can block the isReady function for the material
  55759. */
  55760. blockingBlocks: NodeMaterialBlock[];
  55761. /**
  55762. * Gets the list of animated inputs
  55763. */
  55764. animatedInputs: InputBlock[];
  55765. /**
  55766. * Build Id used to avoid multiple recompilations
  55767. */
  55768. buildId: number;
  55769. /** List of emitted variables */
  55770. variableNames: {
  55771. [key: string]: number;
  55772. };
  55773. /** List of emitted defines */
  55774. defineNames: {
  55775. [key: string]: number;
  55776. };
  55777. /** Should emit comments? */
  55778. emitComments: boolean;
  55779. /** Emit build activity */
  55780. verbose: boolean;
  55781. /** Gets or sets the hosting scene */
  55782. scene: Scene;
  55783. /**
  55784. * Gets the compilation hints emitted at compilation time
  55785. */
  55786. hints: {
  55787. needWorldViewMatrix: boolean;
  55788. needWorldViewProjectionMatrix: boolean;
  55789. needAlphaBlending: boolean;
  55790. needAlphaTesting: boolean;
  55791. };
  55792. /**
  55793. * List of compilation checks
  55794. */
  55795. checks: {
  55796. emitVertex: boolean;
  55797. emitFragment: boolean;
  55798. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55799. };
  55800. /** Creates a new shared data */
  55801. constructor();
  55802. /**
  55803. * Emits console errors and exceptions if there is a failing check
  55804. */
  55805. emitErrors(): void;
  55806. }
  55807. }
  55808. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55809. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55810. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55811. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55812. /**
  55813. * Class used to store node based material build state
  55814. */
  55815. export class NodeMaterialBuildState {
  55816. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55817. supportUniformBuffers: boolean;
  55818. /**
  55819. * Gets the list of emitted attributes
  55820. */
  55821. attributes: string[];
  55822. /**
  55823. * Gets the list of emitted uniforms
  55824. */
  55825. uniforms: string[];
  55826. /**
  55827. * Gets the list of emitted constants
  55828. */
  55829. constants: string[];
  55830. /**
  55831. * Gets the list of emitted uniform buffers
  55832. */
  55833. uniformBuffers: string[];
  55834. /**
  55835. * Gets the list of emitted samplers
  55836. */
  55837. samplers: string[];
  55838. /**
  55839. * Gets the list of emitted functions
  55840. */
  55841. functions: {
  55842. [key: string]: string;
  55843. };
  55844. /**
  55845. * Gets the list of emitted extensions
  55846. */
  55847. extensions: {
  55848. [key: string]: string;
  55849. };
  55850. /**
  55851. * Gets the target of the compilation state
  55852. */
  55853. target: NodeMaterialBlockTargets;
  55854. /**
  55855. * Gets the list of emitted counters
  55856. */
  55857. counters: {
  55858. [key: string]: number;
  55859. };
  55860. /**
  55861. * Shared data between multiple NodeMaterialBuildState instances
  55862. */
  55863. sharedData: NodeMaterialBuildStateSharedData;
  55864. /** @hidden */
  55865. _vertexState: NodeMaterialBuildState;
  55866. /** @hidden */
  55867. _attributeDeclaration: string;
  55868. /** @hidden */
  55869. _uniformDeclaration: string;
  55870. /** @hidden */
  55871. _constantDeclaration: string;
  55872. /** @hidden */
  55873. _samplerDeclaration: string;
  55874. /** @hidden */
  55875. _varyingTransfer: string;
  55876. private _repeatableContentAnchorIndex;
  55877. /** @hidden */
  55878. _builtCompilationString: string;
  55879. /**
  55880. * Gets the emitted compilation strings
  55881. */
  55882. compilationString: string;
  55883. /**
  55884. * Finalize the compilation strings
  55885. * @param state defines the current compilation state
  55886. */
  55887. finalize(state: NodeMaterialBuildState): void;
  55888. /** @hidden */
  55889. readonly _repeatableContentAnchor: string;
  55890. /** @hidden */
  55891. _getFreeVariableName(prefix: string): string;
  55892. /** @hidden */
  55893. _getFreeDefineName(prefix: string): string;
  55894. /** @hidden */
  55895. _excludeVariableName(name: string): void;
  55896. /** @hidden */
  55897. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55898. /** @hidden */
  55899. _emitExtension(name: string, extension: string): void;
  55900. /** @hidden */
  55901. _emitFunction(name: string, code: string, comments: string): void;
  55902. /** @hidden */
  55903. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55904. replaceStrings?: {
  55905. search: RegExp;
  55906. replace: string;
  55907. }[];
  55908. repeatKey?: string;
  55909. }): string;
  55910. /** @hidden */
  55911. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55912. repeatKey?: string;
  55913. removeAttributes?: boolean;
  55914. removeUniforms?: boolean;
  55915. removeVaryings?: boolean;
  55916. removeIfDef?: boolean;
  55917. replaceStrings?: {
  55918. search: RegExp;
  55919. replace: string;
  55920. }[];
  55921. }, storeKey?: string): void;
  55922. /** @hidden */
  55923. _registerTempVariable(name: string): boolean;
  55924. /** @hidden */
  55925. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55926. /** @hidden */
  55927. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55928. /** @hidden */
  55929. _emitFloat(value: number): string;
  55930. }
  55931. }
  55932. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55933. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55935. import { Nullable } from "babylonjs/types";
  55936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55937. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55938. import { Effect } from "babylonjs/Materials/effect";
  55939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55940. import { Mesh } from "babylonjs/Meshes/mesh";
  55941. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55942. import { Scene } from "babylonjs/scene";
  55943. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55944. /**
  55945. * Defines a block that can be used inside a node based material
  55946. */
  55947. export class NodeMaterialBlock {
  55948. private _buildId;
  55949. private _buildTarget;
  55950. private _target;
  55951. private _isFinalMerger;
  55952. private _isInput;
  55953. /** @hidden */
  55954. _codeVariableName: string;
  55955. /** @hidden */
  55956. _inputs: NodeMaterialConnectionPoint[];
  55957. /** @hidden */
  55958. _outputs: NodeMaterialConnectionPoint[];
  55959. /** @hidden */
  55960. _preparationId: number;
  55961. /**
  55962. * Gets or sets the name of the block
  55963. */
  55964. name: string;
  55965. /**
  55966. * Gets or sets the unique id of the node
  55967. */
  55968. uniqueId: number;
  55969. /**
  55970. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55971. */
  55972. readonly isFinalMerger: boolean;
  55973. /**
  55974. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55975. */
  55976. readonly isInput: boolean;
  55977. /**
  55978. * Gets or sets the build Id
  55979. */
  55980. buildId: number;
  55981. /**
  55982. * Gets or sets the target of the block
  55983. */
  55984. target: NodeMaterialBlockTargets;
  55985. /**
  55986. * Gets the list of input points
  55987. */
  55988. readonly inputs: NodeMaterialConnectionPoint[];
  55989. /** Gets the list of output points */
  55990. readonly outputs: NodeMaterialConnectionPoint[];
  55991. /**
  55992. * Find an input by its name
  55993. * @param name defines the name of the input to look for
  55994. * @returns the input or null if not found
  55995. */
  55996. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55997. /**
  55998. * Find an output by its name
  55999. * @param name defines the name of the outputto look for
  56000. * @returns the output or null if not found
  56001. */
  56002. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56003. /**
  56004. * Creates a new NodeMaterialBlock
  56005. * @param name defines the block name
  56006. * @param target defines the target of that block (Vertex by default)
  56007. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56008. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56009. */
  56010. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56011. /**
  56012. * Initialize the block and prepare the context for build
  56013. * @param state defines the state that will be used for the build
  56014. */
  56015. initialize(state: NodeMaterialBuildState): void;
  56016. /**
  56017. * Bind data to effect. Will only be called for blocks with isBindable === true
  56018. * @param effect defines the effect to bind data to
  56019. * @param nodeMaterial defines the hosting NodeMaterial
  56020. * @param mesh defines the mesh that will be rendered
  56021. */
  56022. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56023. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56024. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56025. protected _writeFloat(value: number): string;
  56026. /**
  56027. * Gets the current class name e.g. "NodeMaterialBlock"
  56028. * @returns the class name
  56029. */
  56030. getClassName(): string;
  56031. /**
  56032. * Register a new input. Must be called inside a block constructor
  56033. * @param name defines the connection point name
  56034. * @param type defines the connection point type
  56035. * @param isOptional defines a boolean indicating that this input can be omitted
  56036. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56037. * @returns the current block
  56038. */
  56039. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56040. /**
  56041. * Register a new output. Must be called inside a block constructor
  56042. * @param name defines the connection point name
  56043. * @param type defines the connection point type
  56044. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56045. * @returns the current block
  56046. */
  56047. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56048. /**
  56049. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56050. * @param forOutput defines an optional connection point to check compatibility with
  56051. * @returns the first available input or null
  56052. */
  56053. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56054. /**
  56055. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56056. * @param forBlock defines an optional block to check compatibility with
  56057. * @returns the first available input or null
  56058. */
  56059. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56060. /**
  56061. * Gets the sibling of the given output
  56062. * @param current defines the current output
  56063. * @returns the next output in the list or null
  56064. */
  56065. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56066. /**
  56067. * Connect current block with another block
  56068. * @param other defines the block to connect with
  56069. * @param options define the various options to help pick the right connections
  56070. * @returns the current block
  56071. */
  56072. connectTo(other: NodeMaterialBlock, options?: {
  56073. input?: string;
  56074. output?: string;
  56075. outputSwizzle?: string;
  56076. }): this | undefined;
  56077. protected _buildBlock(state: NodeMaterialBuildState): void;
  56078. /**
  56079. * Add uniforms, samplers and uniform buffers at compilation time
  56080. * @param state defines the state to update
  56081. * @param nodeMaterial defines the node material requesting the update
  56082. * @param defines defines the material defines to update
  56083. */
  56084. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56085. /**
  56086. * Add potential fallbacks if shader compilation fails
  56087. * @param mesh defines the mesh to be rendered
  56088. * @param fallbacks defines the current prioritized list of fallbacks
  56089. */
  56090. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56091. /**
  56092. * Initialize defines for shader compilation
  56093. * @param mesh defines the mesh to be rendered
  56094. * @param nodeMaterial defines the node material requesting the update
  56095. * @param defines defines the material defines to update
  56096. * @param useInstances specifies that instances should be used
  56097. */
  56098. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56099. /**
  56100. * Update defines for shader compilation
  56101. * @param mesh defines the mesh to be rendered
  56102. * @param nodeMaterial defines the node material requesting the update
  56103. * @param defines defines the material defines to update
  56104. * @param useInstances specifies that instances should be used
  56105. */
  56106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56107. /**
  56108. * Lets the block try to connect some inputs automatically
  56109. * @param material defines the hosting NodeMaterial
  56110. */
  56111. autoConfigure(material: NodeMaterial): void;
  56112. /**
  56113. * Function called when a block is declared as repeatable content generator
  56114. * @param vertexShaderState defines the current compilation state for the vertex shader
  56115. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56116. * @param mesh defines the mesh to be rendered
  56117. * @param defines defines the material defines to update
  56118. */
  56119. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56120. /**
  56121. * Checks if the block is ready
  56122. * @param mesh defines the mesh to be rendered
  56123. * @param nodeMaterial defines the node material requesting the update
  56124. * @param defines defines the material defines to update
  56125. * @param useInstances specifies that instances should be used
  56126. * @returns true if the block is ready
  56127. */
  56128. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56129. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56130. private _processBuild;
  56131. /**
  56132. * Compile the current node and generate the shader code
  56133. * @param state defines the current compilation state (uniforms, samplers, current string)
  56134. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56135. * @returns true if already built
  56136. */
  56137. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56138. protected _inputRename(name: string): string;
  56139. protected _outputRename(name: string): string;
  56140. protected _dumpPropertiesCode(): string;
  56141. /** @hidden */
  56142. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56143. /**
  56144. * Clone the current block to a new identical block
  56145. * @param scene defines the hosting scene
  56146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56147. * @returns a copy of the current block
  56148. */
  56149. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56150. /**
  56151. * Serializes this block in a JSON representation
  56152. * @returns the serialized block object
  56153. */
  56154. serialize(): any;
  56155. /** @hidden */
  56156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56157. }
  56158. }
  56159. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56160. /**
  56161. * Enum defining the type of animations supported by InputBlock
  56162. */
  56163. export enum AnimatedInputBlockTypes {
  56164. /** No animation */
  56165. None = 0,
  56166. /** Time based animation. Will only work for floats */
  56167. Time = 1
  56168. }
  56169. }
  56170. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56172. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56173. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56174. import { Nullable } from "babylonjs/types";
  56175. import { Effect } from "babylonjs/Materials/effect";
  56176. import { Matrix } from "babylonjs/Maths/math.vector";
  56177. import { Scene } from "babylonjs/scene";
  56178. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56180. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56181. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56182. /**
  56183. * Block used to expose an input value
  56184. */
  56185. export class InputBlock extends NodeMaterialBlock {
  56186. private _mode;
  56187. private _associatedVariableName;
  56188. private _storedValue;
  56189. private _valueCallback;
  56190. private _type;
  56191. private _animationType;
  56192. /** Gets or set a value used to limit the range of float values */
  56193. min: number;
  56194. /** Gets or set a value used to limit the range of float values */
  56195. max: number;
  56196. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56197. matrixMode: number;
  56198. /** @hidden */
  56199. _systemValue: Nullable<NodeMaterialSystemValues>;
  56200. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56201. visibleInInspector: boolean;
  56202. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56203. isConstant: boolean;
  56204. /**
  56205. * Gets or sets the connection point type (default is float)
  56206. */
  56207. readonly type: NodeMaterialBlockConnectionPointTypes;
  56208. /**
  56209. * Creates a new InputBlock
  56210. * @param name defines the block name
  56211. * @param target defines the target of that block (Vertex by default)
  56212. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56213. */
  56214. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56215. /**
  56216. * Gets the output component
  56217. */
  56218. readonly output: NodeMaterialConnectionPoint;
  56219. /**
  56220. * Set the source of this connection point to a vertex attribute
  56221. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56222. * @returns the current connection point
  56223. */
  56224. setAsAttribute(attributeName?: string): InputBlock;
  56225. /**
  56226. * Set the source of this connection point to a system value
  56227. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56228. * @returns the current connection point
  56229. */
  56230. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56231. /**
  56232. * Gets or sets the value of that point.
  56233. * Please note that this value will be ignored if valueCallback is defined
  56234. */
  56235. value: any;
  56236. /**
  56237. * Gets or sets a callback used to get the value of that point.
  56238. * Please note that setting this value will force the connection point to ignore the value property
  56239. */
  56240. valueCallback: () => any;
  56241. /**
  56242. * Gets or sets the associated variable name in the shader
  56243. */
  56244. associatedVariableName: string;
  56245. /** Gets or sets the type of animation applied to the input */
  56246. animationType: AnimatedInputBlockTypes;
  56247. /**
  56248. * Gets a boolean indicating that this connection point not defined yet
  56249. */
  56250. readonly isUndefined: boolean;
  56251. /**
  56252. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56253. * In this case the connection point name must be the name of the uniform to use.
  56254. * Can only be set on inputs
  56255. */
  56256. isUniform: boolean;
  56257. /**
  56258. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56259. * In this case the connection point name must be the name of the attribute to use
  56260. * Can only be set on inputs
  56261. */
  56262. isAttribute: boolean;
  56263. /**
  56264. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56265. * Can only be set on exit points
  56266. */
  56267. isVarying: boolean;
  56268. /**
  56269. * Gets a boolean indicating that the current connection point is a system value
  56270. */
  56271. readonly isSystemValue: boolean;
  56272. /**
  56273. * Gets or sets the current well known value or null if not defined as a system value
  56274. */
  56275. systemValue: Nullable<NodeMaterialSystemValues>;
  56276. /**
  56277. * Gets the current class name
  56278. * @returns the class name
  56279. */
  56280. getClassName(): string;
  56281. /**
  56282. * Animate the input if animationType !== None
  56283. * @param scene defines the rendering scene
  56284. */
  56285. animate(scene: Scene): void;
  56286. private _emitDefine;
  56287. initialize(state: NodeMaterialBuildState): void;
  56288. /**
  56289. * Set the input block to its default value (based on its type)
  56290. */
  56291. setDefaultValue(): void;
  56292. private _emitConstant;
  56293. private _emit;
  56294. /** @hidden */
  56295. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56296. /** @hidden */
  56297. _transmit(effect: Effect, scene: Scene): void;
  56298. protected _buildBlock(state: NodeMaterialBuildState): void;
  56299. protected _dumpPropertiesCode(): string;
  56300. serialize(): any;
  56301. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56302. }
  56303. }
  56304. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56305. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56306. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56307. import { Nullable } from "babylonjs/types";
  56308. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56310. /**
  56311. * Defines a connection point for a block
  56312. */
  56313. export class NodeMaterialConnectionPoint {
  56314. /** @hidden */
  56315. _ownerBlock: NodeMaterialBlock;
  56316. /** @hidden */
  56317. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56318. private _endpoints;
  56319. private _associatedVariableName;
  56320. /** @hidden */
  56321. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56322. /** @hidden */
  56323. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56324. private _type;
  56325. /** @hidden */
  56326. _enforceAssociatedVariableName: boolean;
  56327. /**
  56328. * Gets or sets the additional types supported by this connection point
  56329. */
  56330. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56331. /**
  56332. * Gets or sets the additional types excluded by this connection point
  56333. */
  56334. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56335. /**
  56336. * Gets or sets the associated variable name in the shader
  56337. */
  56338. associatedVariableName: string;
  56339. /**
  56340. * Gets or sets the connection point type (default is float)
  56341. */
  56342. type: NodeMaterialBlockConnectionPointTypes;
  56343. /**
  56344. * Gets or sets the connection point name
  56345. */
  56346. name: string;
  56347. /**
  56348. * Gets or sets a boolean indicating that this connection point can be omitted
  56349. */
  56350. isOptional: boolean;
  56351. /**
  56352. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56353. */
  56354. define: string;
  56355. /** Gets or sets the target of that connection point */
  56356. target: NodeMaterialBlockTargets;
  56357. /**
  56358. * Gets a boolean indicating that the current point is connected
  56359. */
  56360. readonly isConnected: boolean;
  56361. /**
  56362. * Gets a boolean indicating that the current point is connected to an input block
  56363. */
  56364. readonly isConnectedToInputBlock: boolean;
  56365. /**
  56366. * Gets a the connected input block (if any)
  56367. */
  56368. readonly connectInputBlock: Nullable<InputBlock>;
  56369. /** Get the other side of the connection (if any) */
  56370. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56371. /** Get the block that owns this connection point */
  56372. readonly ownerBlock: NodeMaterialBlock;
  56373. /** Get the block connected on the other side of this connection (if any) */
  56374. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56375. /** Get the block connected on the endpoints of this connection (if any) */
  56376. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56377. /** Gets the list of connected endpoints */
  56378. readonly endpoints: NodeMaterialConnectionPoint[];
  56379. /** Gets a boolean indicating if that output point is connected to at least one input */
  56380. readonly hasEndpoints: boolean;
  56381. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56382. readonly isConnectedInVertexShader: boolean;
  56383. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56384. readonly isConnectedInFragmentShader: boolean;
  56385. /**
  56386. * Creates a new connection point
  56387. * @param name defines the connection point name
  56388. * @param ownerBlock defines the block hosting this connection point
  56389. */
  56390. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56391. /**
  56392. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56393. * @returns the class name
  56394. */
  56395. getClassName(): string;
  56396. /**
  56397. * Gets an boolean indicating if the current point can be connected to another point
  56398. * @param connectionPoint defines the other connection point
  56399. * @returns true if the connection is possible
  56400. */
  56401. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56402. /**
  56403. * Connect this point to another connection point
  56404. * @param connectionPoint defines the other connection point
  56405. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56406. * @returns the current connection point
  56407. */
  56408. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56409. /**
  56410. * Disconnect this point from one of his endpoint
  56411. * @param endpoint defines the other connection point
  56412. * @returns the current connection point
  56413. */
  56414. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56415. /**
  56416. * Serializes this point in a JSON representation
  56417. * @returns the serialized point object
  56418. */
  56419. serialize(): any;
  56420. }
  56421. }
  56422. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56423. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56424. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56426. import { Mesh } from "babylonjs/Meshes/mesh";
  56427. import { Effect } from "babylonjs/Materials/effect";
  56428. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56429. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56430. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56431. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56432. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56433. /**
  56434. * Block used to add support for vertex skinning (bones)
  56435. */
  56436. export class BonesBlock extends NodeMaterialBlock {
  56437. /**
  56438. * Creates a new BonesBlock
  56439. * @param name defines the block name
  56440. */
  56441. constructor(name: string);
  56442. /**
  56443. * Initialize the block and prepare the context for build
  56444. * @param state defines the state that will be used for the build
  56445. */
  56446. initialize(state: NodeMaterialBuildState): void;
  56447. /**
  56448. * Gets the current class name
  56449. * @returns the class name
  56450. */
  56451. getClassName(): string;
  56452. /**
  56453. * Gets the matrix indices input component
  56454. */
  56455. readonly matricesIndices: NodeMaterialConnectionPoint;
  56456. /**
  56457. * Gets the matrix weights input component
  56458. */
  56459. readonly matricesWeights: NodeMaterialConnectionPoint;
  56460. /**
  56461. * Gets the extra matrix indices input component
  56462. */
  56463. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56464. /**
  56465. * Gets the extra matrix weights input component
  56466. */
  56467. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56468. /**
  56469. * Gets the world input component
  56470. */
  56471. readonly world: NodeMaterialConnectionPoint;
  56472. /**
  56473. * Gets the output component
  56474. */
  56475. readonly output: NodeMaterialConnectionPoint;
  56476. autoConfigure(material: NodeMaterial): void;
  56477. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56478. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56479. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56480. protected _buildBlock(state: NodeMaterialBuildState): this;
  56481. }
  56482. }
  56483. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56488. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56489. /**
  56490. * Block used to add support for instances
  56491. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56492. */
  56493. export class InstancesBlock extends NodeMaterialBlock {
  56494. /**
  56495. * Creates a new InstancesBlock
  56496. * @param name defines the block name
  56497. */
  56498. constructor(name: string);
  56499. /**
  56500. * Gets the current class name
  56501. * @returns the class name
  56502. */
  56503. getClassName(): string;
  56504. /**
  56505. * Gets the first world row input component
  56506. */
  56507. readonly world0: NodeMaterialConnectionPoint;
  56508. /**
  56509. * Gets the second world row input component
  56510. */
  56511. readonly world1: NodeMaterialConnectionPoint;
  56512. /**
  56513. * Gets the third world row input component
  56514. */
  56515. readonly world2: NodeMaterialConnectionPoint;
  56516. /**
  56517. * Gets the forth world row input component
  56518. */
  56519. readonly world3: NodeMaterialConnectionPoint;
  56520. /**
  56521. * Gets the world input component
  56522. */
  56523. readonly world: NodeMaterialConnectionPoint;
  56524. /**
  56525. * Gets the output component
  56526. */
  56527. readonly output: NodeMaterialConnectionPoint;
  56528. autoConfigure(material: NodeMaterial): void;
  56529. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56530. protected _buildBlock(state: NodeMaterialBuildState): this;
  56531. }
  56532. }
  56533. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56534. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56535. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56536. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56538. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56539. import { Effect } from "babylonjs/Materials/effect";
  56540. import { Mesh } from "babylonjs/Meshes/mesh";
  56541. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56542. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56543. /**
  56544. * Block used to add morph targets support to vertex shader
  56545. */
  56546. export class MorphTargetsBlock extends NodeMaterialBlock {
  56547. private _repeatableContentAnchor;
  56548. private _repeatebleContentGenerated;
  56549. /**
  56550. * Create a new MorphTargetsBlock
  56551. * @param name defines the block name
  56552. */
  56553. constructor(name: string);
  56554. /**
  56555. * Gets the current class name
  56556. * @returns the class name
  56557. */
  56558. getClassName(): string;
  56559. /**
  56560. * Gets the position input component
  56561. */
  56562. readonly position: NodeMaterialConnectionPoint;
  56563. /**
  56564. * Gets the normal input component
  56565. */
  56566. readonly normal: NodeMaterialConnectionPoint;
  56567. /**
  56568. * Gets the tangent input component
  56569. */
  56570. readonly tangent: NodeMaterialConnectionPoint;
  56571. /**
  56572. * Gets the tangent input component
  56573. */
  56574. readonly uv: NodeMaterialConnectionPoint;
  56575. /**
  56576. * Gets the position output component
  56577. */
  56578. readonly positionOutput: NodeMaterialConnectionPoint;
  56579. /**
  56580. * Gets the normal output component
  56581. */
  56582. readonly normalOutput: NodeMaterialConnectionPoint;
  56583. /**
  56584. * Gets the tangent output component
  56585. */
  56586. readonly tangentOutput: NodeMaterialConnectionPoint;
  56587. /**
  56588. * Gets the tangent output component
  56589. */
  56590. readonly uvOutput: NodeMaterialConnectionPoint;
  56591. initialize(state: NodeMaterialBuildState): void;
  56592. autoConfigure(material: NodeMaterial): void;
  56593. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56594. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56595. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56596. protected _buildBlock(state: NodeMaterialBuildState): this;
  56597. }
  56598. }
  56599. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56600. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56601. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56602. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56603. import { Nullable } from "babylonjs/types";
  56604. import { Scene } from "babylonjs/scene";
  56605. import { Effect } from "babylonjs/Materials/effect";
  56606. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56607. import { Mesh } from "babylonjs/Meshes/mesh";
  56608. import { Light } from "babylonjs/Lights/light";
  56609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56610. /**
  56611. * Block used to get data information from a light
  56612. */
  56613. export class LightInformationBlock extends NodeMaterialBlock {
  56614. private _lightDataUniformName;
  56615. private _lightColorUniformName;
  56616. private _lightTypeDefineName;
  56617. /**
  56618. * Gets or sets the light associated with this block
  56619. */
  56620. light: Nullable<Light>;
  56621. /**
  56622. * Creates a new LightInformationBlock
  56623. * @param name defines the block name
  56624. */
  56625. constructor(name: string);
  56626. /**
  56627. * Gets the current class name
  56628. * @returns the class name
  56629. */
  56630. getClassName(): string;
  56631. /**
  56632. * Gets the world position input component
  56633. */
  56634. readonly worldPosition: NodeMaterialConnectionPoint;
  56635. /**
  56636. * Gets the direction output component
  56637. */
  56638. readonly direction: NodeMaterialConnectionPoint;
  56639. /**
  56640. * Gets the direction output component
  56641. */
  56642. readonly color: NodeMaterialConnectionPoint;
  56643. /**
  56644. * Gets the direction output component
  56645. */
  56646. readonly intensity: NodeMaterialConnectionPoint;
  56647. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56649. protected _buildBlock(state: NodeMaterialBuildState): this;
  56650. serialize(): any;
  56651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56652. }
  56653. }
  56654. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56655. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56656. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56657. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56658. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56659. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56660. }
  56661. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56662. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56663. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56664. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56666. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56667. import { Effect } from "babylonjs/Materials/effect";
  56668. import { Mesh } from "babylonjs/Meshes/mesh";
  56669. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56670. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56671. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56672. /**
  56673. * Block used to add image processing support to fragment shader
  56674. */
  56675. export class ImageProcessingBlock extends NodeMaterialBlock {
  56676. /**
  56677. * Create a new ImageProcessingBlock
  56678. * @param name defines the block name
  56679. */
  56680. constructor(name: string);
  56681. /**
  56682. * Gets the current class name
  56683. * @returns the class name
  56684. */
  56685. getClassName(): string;
  56686. /**
  56687. * Gets the color input component
  56688. */
  56689. readonly color: NodeMaterialConnectionPoint;
  56690. /**
  56691. * Gets the output component
  56692. */
  56693. readonly output: NodeMaterialConnectionPoint;
  56694. /**
  56695. * Initialize the block and prepare the context for build
  56696. * @param state defines the state that will be used for the build
  56697. */
  56698. initialize(state: NodeMaterialBuildState): void;
  56699. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56700. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56701. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56702. protected _buildBlock(state: NodeMaterialBuildState): this;
  56703. }
  56704. }
  56705. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56706. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56707. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56708. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56709. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56711. import { Effect } from "babylonjs/Materials/effect";
  56712. import { Mesh } from "babylonjs/Meshes/mesh";
  56713. import { Scene } from "babylonjs/scene";
  56714. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56715. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56716. /**
  56717. * Block used to pertub normals based on a normal map
  56718. */
  56719. export class PerturbNormalBlock extends NodeMaterialBlock {
  56720. private _tangentSpaceParameterName;
  56721. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56722. invertX: boolean;
  56723. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56724. invertY: boolean;
  56725. /**
  56726. * Create a new PerturbNormalBlock
  56727. * @param name defines the block name
  56728. */
  56729. constructor(name: string);
  56730. /**
  56731. * Gets the current class name
  56732. * @returns the class name
  56733. */
  56734. getClassName(): string;
  56735. /**
  56736. * Gets the world position input component
  56737. */
  56738. readonly worldPosition: NodeMaterialConnectionPoint;
  56739. /**
  56740. * Gets the world normal input component
  56741. */
  56742. readonly worldNormal: NodeMaterialConnectionPoint;
  56743. /**
  56744. * Gets the uv input component
  56745. */
  56746. readonly uv: NodeMaterialConnectionPoint;
  56747. /**
  56748. * Gets the normal map color input component
  56749. */
  56750. readonly normalMapColor: NodeMaterialConnectionPoint;
  56751. /**
  56752. * Gets the strength input component
  56753. */
  56754. readonly strength: NodeMaterialConnectionPoint;
  56755. /**
  56756. * Gets the output component
  56757. */
  56758. readonly output: NodeMaterialConnectionPoint;
  56759. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56760. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56761. autoConfigure(material: NodeMaterial): void;
  56762. protected _buildBlock(state: NodeMaterialBuildState): this;
  56763. protected _dumpPropertiesCode(): string;
  56764. serialize(): any;
  56765. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56766. }
  56767. }
  56768. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56772. /**
  56773. * Block used to discard a pixel if a value is smaller than a cutoff
  56774. */
  56775. export class DiscardBlock extends NodeMaterialBlock {
  56776. /**
  56777. * Create a new DiscardBlock
  56778. * @param name defines the block name
  56779. */
  56780. constructor(name: string);
  56781. /**
  56782. * Gets the current class name
  56783. * @returns the class name
  56784. */
  56785. getClassName(): string;
  56786. /**
  56787. * Gets the color input component
  56788. */
  56789. readonly value: NodeMaterialConnectionPoint;
  56790. /**
  56791. * Gets the cutoff input component
  56792. */
  56793. readonly cutoff: NodeMaterialConnectionPoint;
  56794. protected _buildBlock(state: NodeMaterialBuildState): this;
  56795. }
  56796. }
  56797. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56798. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56799. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56800. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56801. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56802. }
  56803. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56806. import { Mesh } from "babylonjs/Meshes/mesh";
  56807. import { Effect } from "babylonjs/Materials/effect";
  56808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56810. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56811. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56812. /**
  56813. * Block used to add support for scene fog
  56814. */
  56815. export class FogBlock extends NodeMaterialBlock {
  56816. private _fogDistanceName;
  56817. private _fogParameters;
  56818. /**
  56819. * Create a new FogBlock
  56820. * @param name defines the block name
  56821. */
  56822. constructor(name: string);
  56823. /**
  56824. * Gets the current class name
  56825. * @returns the class name
  56826. */
  56827. getClassName(): string;
  56828. /**
  56829. * Gets the world position input component
  56830. */
  56831. readonly worldPosition: NodeMaterialConnectionPoint;
  56832. /**
  56833. * Gets the view input component
  56834. */
  56835. readonly view: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the color input component
  56838. */
  56839. readonly input: NodeMaterialConnectionPoint;
  56840. /**
  56841. * Gets the fog color input component
  56842. */
  56843. readonly fogColor: NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the output component
  56846. */
  56847. readonly output: NodeMaterialConnectionPoint;
  56848. autoConfigure(material: NodeMaterial): void;
  56849. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56850. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56851. protected _buildBlock(state: NodeMaterialBuildState): this;
  56852. }
  56853. }
  56854. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56859. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56860. import { Effect } from "babylonjs/Materials/effect";
  56861. import { Mesh } from "babylonjs/Meshes/mesh";
  56862. import { Light } from "babylonjs/Lights/light";
  56863. import { Nullable } from "babylonjs/types";
  56864. import { Scene } from "babylonjs/scene";
  56865. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56866. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56867. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56868. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56869. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56870. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56871. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56872. /**
  56873. * Block used to add light in the fragment shader
  56874. */
  56875. export class LightBlock extends NodeMaterialBlock {
  56876. private _lightId;
  56877. /**
  56878. * Gets or sets the light associated with this block
  56879. */
  56880. light: Nullable<Light>;
  56881. /**
  56882. * Create a new LightBlock
  56883. * @param name defines the block name
  56884. */
  56885. constructor(name: string);
  56886. /**
  56887. * Gets the current class name
  56888. * @returns the class name
  56889. */
  56890. getClassName(): string;
  56891. /**
  56892. * Gets the world position input component
  56893. */
  56894. readonly worldPosition: NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the world normal input component
  56897. */
  56898. readonly worldNormal: NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the camera (or eye) position component
  56901. */
  56902. readonly cameraPosition: NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the glossiness component
  56905. */
  56906. readonly glossiness: NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the glossinness power component
  56909. */
  56910. readonly glossPower: NodeMaterialConnectionPoint;
  56911. /**
  56912. * Gets the diffuse color component
  56913. */
  56914. readonly diffuseColor: NodeMaterialConnectionPoint;
  56915. /**
  56916. * Gets the specular color component
  56917. */
  56918. readonly specularColor: NodeMaterialConnectionPoint;
  56919. /**
  56920. * Gets the diffuse output component
  56921. */
  56922. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56923. /**
  56924. * Gets the specular output component
  56925. */
  56926. readonly specularOutput: NodeMaterialConnectionPoint;
  56927. autoConfigure(material: NodeMaterial): void;
  56928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56929. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56930. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56931. private _injectVertexCode;
  56932. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56933. serialize(): any;
  56934. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56935. }
  56936. }
  56937. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56938. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56939. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56940. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56941. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56942. }
  56943. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56944. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56945. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56946. }
  56947. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56948. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56949. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56950. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56951. /**
  56952. * Block used to multiply 2 values
  56953. */
  56954. export class MultiplyBlock extends NodeMaterialBlock {
  56955. /**
  56956. * Creates a new MultiplyBlock
  56957. * @param name defines the block name
  56958. */
  56959. constructor(name: string);
  56960. /**
  56961. * Gets the current class name
  56962. * @returns the class name
  56963. */
  56964. getClassName(): string;
  56965. /**
  56966. * Gets the left operand input component
  56967. */
  56968. readonly left: NodeMaterialConnectionPoint;
  56969. /**
  56970. * Gets the right operand input component
  56971. */
  56972. readonly right: NodeMaterialConnectionPoint;
  56973. /**
  56974. * Gets the output component
  56975. */
  56976. readonly output: NodeMaterialConnectionPoint;
  56977. protected _buildBlock(state: NodeMaterialBuildState): this;
  56978. }
  56979. }
  56980. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56983. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56984. /**
  56985. * Block used to add 2 vectors
  56986. */
  56987. export class AddBlock extends NodeMaterialBlock {
  56988. /**
  56989. * Creates a new AddBlock
  56990. * @param name defines the block name
  56991. */
  56992. constructor(name: string);
  56993. /**
  56994. * Gets the current class name
  56995. * @returns the class name
  56996. */
  56997. getClassName(): string;
  56998. /**
  56999. * Gets the left operand input component
  57000. */
  57001. readonly left: NodeMaterialConnectionPoint;
  57002. /**
  57003. * Gets the right operand input component
  57004. */
  57005. readonly right: NodeMaterialConnectionPoint;
  57006. /**
  57007. * Gets the output component
  57008. */
  57009. readonly output: NodeMaterialConnectionPoint;
  57010. protected _buildBlock(state: NodeMaterialBuildState): this;
  57011. }
  57012. }
  57013. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57017. /**
  57018. * Block used to scale a vector by a float
  57019. */
  57020. export class ScaleBlock extends NodeMaterialBlock {
  57021. /**
  57022. * Creates a new ScaleBlock
  57023. * @param name defines the block name
  57024. */
  57025. constructor(name: string);
  57026. /**
  57027. * Gets the current class name
  57028. * @returns the class name
  57029. */
  57030. getClassName(): string;
  57031. /**
  57032. * Gets the input component
  57033. */
  57034. readonly input: NodeMaterialConnectionPoint;
  57035. /**
  57036. * Gets the factor input component
  57037. */
  57038. readonly factor: NodeMaterialConnectionPoint;
  57039. /**
  57040. * Gets the output component
  57041. */
  57042. readonly output: NodeMaterialConnectionPoint;
  57043. protected _buildBlock(state: NodeMaterialBuildState): this;
  57044. }
  57045. }
  57046. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57050. import { Scene } from "babylonjs/scene";
  57051. /**
  57052. * Block used to clamp a float
  57053. */
  57054. export class ClampBlock extends NodeMaterialBlock {
  57055. /** Gets or sets the minimum range */
  57056. minimum: number;
  57057. /** Gets or sets the maximum range */
  57058. maximum: number;
  57059. /**
  57060. * Creates a new ClampBlock
  57061. * @param name defines the block name
  57062. */
  57063. constructor(name: string);
  57064. /**
  57065. * Gets the current class name
  57066. * @returns the class name
  57067. */
  57068. getClassName(): string;
  57069. /**
  57070. * Gets the value input component
  57071. */
  57072. readonly value: NodeMaterialConnectionPoint;
  57073. /**
  57074. * Gets the output component
  57075. */
  57076. readonly output: NodeMaterialConnectionPoint;
  57077. protected _buildBlock(state: NodeMaterialBuildState): this;
  57078. protected _dumpPropertiesCode(): string;
  57079. serialize(): any;
  57080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57081. }
  57082. }
  57083. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57087. /**
  57088. * Block used to apply a cross product between 2 vectors
  57089. */
  57090. export class CrossBlock extends NodeMaterialBlock {
  57091. /**
  57092. * Creates a new CrossBlock
  57093. * @param name defines the block name
  57094. */
  57095. constructor(name: string);
  57096. /**
  57097. * Gets the current class name
  57098. * @returns the class name
  57099. */
  57100. getClassName(): string;
  57101. /**
  57102. * Gets the left operand input component
  57103. */
  57104. readonly left: NodeMaterialConnectionPoint;
  57105. /**
  57106. * Gets the right operand input component
  57107. */
  57108. readonly right: NodeMaterialConnectionPoint;
  57109. /**
  57110. * Gets the output component
  57111. */
  57112. readonly output: NodeMaterialConnectionPoint;
  57113. protected _buildBlock(state: NodeMaterialBuildState): this;
  57114. }
  57115. }
  57116. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57120. /**
  57121. * Block used to apply a dot product between 2 vectors
  57122. */
  57123. export class DotBlock extends NodeMaterialBlock {
  57124. /**
  57125. * Creates a new DotBlock
  57126. * @param name defines the block name
  57127. */
  57128. constructor(name: string);
  57129. /**
  57130. * Gets the current class name
  57131. * @returns the class name
  57132. */
  57133. getClassName(): string;
  57134. /**
  57135. * Gets the left operand input component
  57136. */
  57137. readonly left: NodeMaterialConnectionPoint;
  57138. /**
  57139. * Gets the right operand input component
  57140. */
  57141. readonly right: NodeMaterialConnectionPoint;
  57142. /**
  57143. * Gets the output component
  57144. */
  57145. readonly output: NodeMaterialConnectionPoint;
  57146. protected _buildBlock(state: NodeMaterialBuildState): this;
  57147. }
  57148. }
  57149. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57153. import { Vector2 } from "babylonjs/Maths/math.vector";
  57154. import { Scene } from "babylonjs/scene";
  57155. /**
  57156. * Block used to remap a float from a range to a new one
  57157. */
  57158. export class RemapBlock extends NodeMaterialBlock {
  57159. /**
  57160. * Gets or sets the source range
  57161. */
  57162. sourceRange: Vector2;
  57163. /**
  57164. * Gets or sets the target range
  57165. */
  57166. targetRange: Vector2;
  57167. /**
  57168. * Creates a new RemapBlock
  57169. * @param name defines the block name
  57170. */
  57171. constructor(name: string);
  57172. /**
  57173. * Gets the current class name
  57174. * @returns the class name
  57175. */
  57176. getClassName(): string;
  57177. /**
  57178. * Gets the input component
  57179. */
  57180. readonly input: NodeMaterialConnectionPoint;
  57181. /**
  57182. * Gets the source min input component
  57183. */
  57184. readonly sourceMin: NodeMaterialConnectionPoint;
  57185. /**
  57186. * Gets the source max input component
  57187. */
  57188. readonly sourceMax: NodeMaterialConnectionPoint;
  57189. /**
  57190. * Gets the target min input component
  57191. */
  57192. readonly targetMin: NodeMaterialConnectionPoint;
  57193. /**
  57194. * Gets the target max input component
  57195. */
  57196. readonly targetMax: NodeMaterialConnectionPoint;
  57197. /**
  57198. * Gets the output component
  57199. */
  57200. readonly output: NodeMaterialConnectionPoint;
  57201. protected _buildBlock(state: NodeMaterialBuildState): this;
  57202. protected _dumpPropertiesCode(): string;
  57203. serialize(): any;
  57204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57205. }
  57206. }
  57207. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57211. /**
  57212. * Block used to normalize a vector
  57213. */
  57214. export class NormalizeBlock extends NodeMaterialBlock {
  57215. /**
  57216. * Creates a new NormalizeBlock
  57217. * @param name defines the block name
  57218. */
  57219. constructor(name: string);
  57220. /**
  57221. * Gets the current class name
  57222. * @returns the class name
  57223. */
  57224. getClassName(): string;
  57225. /**
  57226. * Gets the input component
  57227. */
  57228. readonly input: NodeMaterialConnectionPoint;
  57229. /**
  57230. * Gets the output component
  57231. */
  57232. readonly output: NodeMaterialConnectionPoint;
  57233. protected _buildBlock(state: NodeMaterialBuildState): this;
  57234. }
  57235. }
  57236. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57237. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57238. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57239. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57240. import { Scene } from "babylonjs/scene";
  57241. /**
  57242. * Operations supported by the Trigonometry block
  57243. */
  57244. export enum TrigonometryBlockOperations {
  57245. /** Cos */
  57246. Cos = 0,
  57247. /** Sin */
  57248. Sin = 1,
  57249. /** Abs */
  57250. Abs = 2,
  57251. /** Exp */
  57252. Exp = 3,
  57253. /** Exp2 */
  57254. Exp2 = 4,
  57255. /** Round */
  57256. Round = 5,
  57257. /** Floor */
  57258. Floor = 6,
  57259. /** Ceiling */
  57260. Ceiling = 7,
  57261. /** Square root */
  57262. Sqrt = 8,
  57263. /** Log */
  57264. Log = 9,
  57265. /** Tangent */
  57266. Tan = 10,
  57267. /** Arc tangent */
  57268. ArcTan = 11,
  57269. /** Arc cosinus */
  57270. ArcCos = 12,
  57271. /** Arc sinus */
  57272. ArcSin = 13,
  57273. /** Fraction */
  57274. Fract = 14,
  57275. /** Sign */
  57276. Sign = 15,
  57277. /** To radians (from degrees) */
  57278. Radians = 16,
  57279. /** To degrees (from radians) */
  57280. Degrees = 17
  57281. }
  57282. /**
  57283. * Block used to apply trigonometry operation to floats
  57284. */
  57285. export class TrigonometryBlock extends NodeMaterialBlock {
  57286. /**
  57287. * Gets or sets the operation applied by the block
  57288. */
  57289. operation: TrigonometryBlockOperations;
  57290. /**
  57291. * Creates a new TrigonometryBlock
  57292. * @param name defines the block name
  57293. */
  57294. constructor(name: string);
  57295. /**
  57296. * Gets the current class name
  57297. * @returns the class name
  57298. */
  57299. getClassName(): string;
  57300. /**
  57301. * Gets the input component
  57302. */
  57303. readonly input: NodeMaterialConnectionPoint;
  57304. /**
  57305. * Gets the output component
  57306. */
  57307. readonly output: NodeMaterialConnectionPoint;
  57308. protected _buildBlock(state: NodeMaterialBuildState): this;
  57309. serialize(): any;
  57310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57311. }
  57312. }
  57313. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57317. /**
  57318. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57319. */
  57320. export class ColorMergerBlock extends NodeMaterialBlock {
  57321. /**
  57322. * Create a new ColorMergerBlock
  57323. * @param name defines the block name
  57324. */
  57325. constructor(name: string);
  57326. /**
  57327. * Gets the current class name
  57328. * @returns the class name
  57329. */
  57330. getClassName(): string;
  57331. /**
  57332. * Gets the r component (input)
  57333. */
  57334. readonly r: NodeMaterialConnectionPoint;
  57335. /**
  57336. * Gets the g component (input)
  57337. */
  57338. readonly g: NodeMaterialConnectionPoint;
  57339. /**
  57340. * Gets the b component (input)
  57341. */
  57342. readonly b: NodeMaterialConnectionPoint;
  57343. /**
  57344. * Gets the a component (input)
  57345. */
  57346. readonly a: NodeMaterialConnectionPoint;
  57347. /**
  57348. * Gets the rgba component (output)
  57349. */
  57350. readonly rgba: NodeMaterialConnectionPoint;
  57351. /**
  57352. * Gets the rgb component (output)
  57353. */
  57354. readonly rgb: NodeMaterialConnectionPoint;
  57355. protected _buildBlock(state: NodeMaterialBuildState): this;
  57356. }
  57357. }
  57358. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57359. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57360. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57361. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57362. /**
  57363. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57364. */
  57365. export class VectorMergerBlock extends NodeMaterialBlock {
  57366. /**
  57367. * Create a new VectorMergerBlock
  57368. * @param name defines the block name
  57369. */
  57370. constructor(name: string);
  57371. /**
  57372. * Gets the current class name
  57373. * @returns the class name
  57374. */
  57375. getClassName(): string;
  57376. /**
  57377. * Gets the x component (input)
  57378. */
  57379. readonly x: NodeMaterialConnectionPoint;
  57380. /**
  57381. * Gets the y component (input)
  57382. */
  57383. readonly y: NodeMaterialConnectionPoint;
  57384. /**
  57385. * Gets the z component (input)
  57386. */
  57387. readonly z: NodeMaterialConnectionPoint;
  57388. /**
  57389. * Gets the w component (input)
  57390. */
  57391. readonly w: NodeMaterialConnectionPoint;
  57392. /**
  57393. * Gets the xyzw component (output)
  57394. */
  57395. readonly xyzw: NodeMaterialConnectionPoint;
  57396. /**
  57397. * Gets the xyz component (output)
  57398. */
  57399. readonly xyz: NodeMaterialConnectionPoint;
  57400. /**
  57401. * Gets the xy component (output)
  57402. */
  57403. readonly xy: NodeMaterialConnectionPoint;
  57404. protected _buildBlock(state: NodeMaterialBuildState): this;
  57405. }
  57406. }
  57407. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57408. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57409. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57410. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57411. /**
  57412. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57413. */
  57414. export class ColorSplitterBlock extends NodeMaterialBlock {
  57415. /**
  57416. * Create a new ColorSplitterBlock
  57417. * @param name defines the block name
  57418. */
  57419. constructor(name: string);
  57420. /**
  57421. * Gets the current class name
  57422. * @returns the class name
  57423. */
  57424. getClassName(): string;
  57425. /**
  57426. * Gets the rgba component (input)
  57427. */
  57428. readonly rgba: NodeMaterialConnectionPoint;
  57429. /**
  57430. * Gets the rgb component (input)
  57431. */
  57432. readonly rgbIn: NodeMaterialConnectionPoint;
  57433. /**
  57434. * Gets the rgb component (output)
  57435. */
  57436. readonly rgbOut: NodeMaterialConnectionPoint;
  57437. /**
  57438. * Gets the r component (output)
  57439. */
  57440. readonly r: NodeMaterialConnectionPoint;
  57441. /**
  57442. * Gets the g component (output)
  57443. */
  57444. readonly g: NodeMaterialConnectionPoint;
  57445. /**
  57446. * Gets the b component (output)
  57447. */
  57448. readonly b: NodeMaterialConnectionPoint;
  57449. /**
  57450. * Gets the a component (output)
  57451. */
  57452. readonly a: NodeMaterialConnectionPoint;
  57453. protected _inputRename(name: string): string;
  57454. protected _outputRename(name: string): string;
  57455. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57456. }
  57457. }
  57458. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57462. /**
  57463. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57464. */
  57465. export class VectorSplitterBlock extends NodeMaterialBlock {
  57466. /**
  57467. * Create a new VectorSplitterBlock
  57468. * @param name defines the block name
  57469. */
  57470. constructor(name: string);
  57471. /**
  57472. * Gets the current class name
  57473. * @returns the class name
  57474. */
  57475. getClassName(): string;
  57476. /**
  57477. * Gets the xyzw component (input)
  57478. */
  57479. readonly xyzw: NodeMaterialConnectionPoint;
  57480. /**
  57481. * Gets the xyz component (input)
  57482. */
  57483. readonly xyzIn: NodeMaterialConnectionPoint;
  57484. /**
  57485. * Gets the xy component (input)
  57486. */
  57487. readonly xyIn: NodeMaterialConnectionPoint;
  57488. /**
  57489. * Gets the xyz component (output)
  57490. */
  57491. readonly xyzOut: NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the xy component (output)
  57494. */
  57495. readonly xyOut: NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the x component (output)
  57498. */
  57499. readonly x: NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the y component (output)
  57502. */
  57503. readonly y: NodeMaterialConnectionPoint;
  57504. /**
  57505. * Gets the z component (output)
  57506. */
  57507. readonly z: NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the w component (output)
  57510. */
  57511. readonly w: NodeMaterialConnectionPoint;
  57512. protected _inputRename(name: string): string;
  57513. protected _outputRename(name: string): string;
  57514. protected _buildBlock(state: NodeMaterialBuildState): this;
  57515. }
  57516. }
  57517. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57521. /**
  57522. * Block used to lerp between 2 values
  57523. */
  57524. export class LerpBlock extends NodeMaterialBlock {
  57525. /**
  57526. * Creates a new LerpBlock
  57527. * @param name defines the block name
  57528. */
  57529. constructor(name: string);
  57530. /**
  57531. * Gets the current class name
  57532. * @returns the class name
  57533. */
  57534. getClassName(): string;
  57535. /**
  57536. * Gets the left operand input component
  57537. */
  57538. readonly left: NodeMaterialConnectionPoint;
  57539. /**
  57540. * Gets the right operand input component
  57541. */
  57542. readonly right: NodeMaterialConnectionPoint;
  57543. /**
  57544. * Gets the gradient operand input component
  57545. */
  57546. readonly gradient: NodeMaterialConnectionPoint;
  57547. /**
  57548. * Gets the output component
  57549. */
  57550. readonly output: NodeMaterialConnectionPoint;
  57551. protected _buildBlock(state: NodeMaterialBuildState): this;
  57552. }
  57553. }
  57554. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57557. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57558. /**
  57559. * Block used to divide 2 vectors
  57560. */
  57561. export class DivideBlock extends NodeMaterialBlock {
  57562. /**
  57563. * Creates a new DivideBlock
  57564. * @param name defines the block name
  57565. */
  57566. constructor(name: string);
  57567. /**
  57568. * Gets the current class name
  57569. * @returns the class name
  57570. */
  57571. getClassName(): string;
  57572. /**
  57573. * Gets the left operand input component
  57574. */
  57575. readonly left: NodeMaterialConnectionPoint;
  57576. /**
  57577. * Gets the right operand input component
  57578. */
  57579. readonly right: NodeMaterialConnectionPoint;
  57580. /**
  57581. * Gets the output component
  57582. */
  57583. readonly output: NodeMaterialConnectionPoint;
  57584. protected _buildBlock(state: NodeMaterialBuildState): this;
  57585. }
  57586. }
  57587. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57591. /**
  57592. * Block used to subtract 2 vectors
  57593. */
  57594. export class SubtractBlock extends NodeMaterialBlock {
  57595. /**
  57596. * Creates a new SubtractBlock
  57597. * @param name defines the block name
  57598. */
  57599. constructor(name: string);
  57600. /**
  57601. * Gets the current class name
  57602. * @returns the class name
  57603. */
  57604. getClassName(): string;
  57605. /**
  57606. * Gets the left operand input component
  57607. */
  57608. readonly left: NodeMaterialConnectionPoint;
  57609. /**
  57610. * Gets the right operand input component
  57611. */
  57612. readonly right: NodeMaterialConnectionPoint;
  57613. /**
  57614. * Gets the output component
  57615. */
  57616. readonly output: NodeMaterialConnectionPoint;
  57617. protected _buildBlock(state: NodeMaterialBuildState): this;
  57618. }
  57619. }
  57620. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57624. /**
  57625. * Block used to step a value
  57626. */
  57627. export class StepBlock extends NodeMaterialBlock {
  57628. /**
  57629. * Creates a new StepBlock
  57630. * @param name defines the block name
  57631. */
  57632. constructor(name: string);
  57633. /**
  57634. * Gets the current class name
  57635. * @returns the class name
  57636. */
  57637. getClassName(): string;
  57638. /**
  57639. * Gets the value operand input component
  57640. */
  57641. readonly value: NodeMaterialConnectionPoint;
  57642. /**
  57643. * Gets the edge operand input component
  57644. */
  57645. readonly edge: NodeMaterialConnectionPoint;
  57646. /**
  57647. * Gets the output component
  57648. */
  57649. readonly output: NodeMaterialConnectionPoint;
  57650. protected _buildBlock(state: NodeMaterialBuildState): this;
  57651. }
  57652. }
  57653. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57654. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57655. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57657. /**
  57658. * Block used to get the opposite (1 - x) of a value
  57659. */
  57660. export class OneMinusBlock extends NodeMaterialBlock {
  57661. /**
  57662. * Creates a new OneMinusBlock
  57663. * @param name defines the block name
  57664. */
  57665. constructor(name: string);
  57666. /**
  57667. * Gets the current class name
  57668. * @returns the class name
  57669. */
  57670. getClassName(): string;
  57671. /**
  57672. * Gets the input component
  57673. */
  57674. readonly input: NodeMaterialConnectionPoint;
  57675. /**
  57676. * Gets the output component
  57677. */
  57678. readonly output: NodeMaterialConnectionPoint;
  57679. protected _buildBlock(state: NodeMaterialBuildState): this;
  57680. }
  57681. }
  57682. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57684. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57685. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57686. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57687. /**
  57688. * Block used to get the view direction
  57689. */
  57690. export class ViewDirectionBlock extends NodeMaterialBlock {
  57691. /**
  57692. * Creates a new ViewDirectionBlock
  57693. * @param name defines the block name
  57694. */
  57695. constructor(name: string);
  57696. /**
  57697. * Gets the current class name
  57698. * @returns the class name
  57699. */
  57700. getClassName(): string;
  57701. /**
  57702. * Gets the world position component
  57703. */
  57704. readonly worldPosition: NodeMaterialConnectionPoint;
  57705. /**
  57706. * Gets the camera position component
  57707. */
  57708. readonly cameraPosition: NodeMaterialConnectionPoint;
  57709. /**
  57710. * Gets the output component
  57711. */
  57712. readonly output: NodeMaterialConnectionPoint;
  57713. autoConfigure(material: NodeMaterial): void;
  57714. protected _buildBlock(state: NodeMaterialBuildState): this;
  57715. }
  57716. }
  57717. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57721. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57722. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57723. /**
  57724. * Block used to compute fresnel value
  57725. */
  57726. export class FresnelBlock extends NodeMaterialBlock {
  57727. /**
  57728. * Create a new FresnelBlock
  57729. * @param name defines the block name
  57730. */
  57731. constructor(name: string);
  57732. /**
  57733. * Gets the current class name
  57734. * @returns the class name
  57735. */
  57736. getClassName(): string;
  57737. /**
  57738. * Gets the world normal input component
  57739. */
  57740. readonly worldNormal: NodeMaterialConnectionPoint;
  57741. /**
  57742. * Gets the view direction input component
  57743. */
  57744. readonly viewDirection: NodeMaterialConnectionPoint;
  57745. /**
  57746. * Gets the bias input component
  57747. */
  57748. readonly bias: NodeMaterialConnectionPoint;
  57749. /**
  57750. * Gets the camera (or eye) position component
  57751. */
  57752. readonly power: NodeMaterialConnectionPoint;
  57753. /**
  57754. * Gets the fresnel output component
  57755. */
  57756. readonly fresnel: NodeMaterialConnectionPoint;
  57757. autoConfigure(material: NodeMaterial): void;
  57758. protected _buildBlock(state: NodeMaterialBuildState): this;
  57759. }
  57760. }
  57761. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57765. /**
  57766. * Block used to get the max of 2 values
  57767. */
  57768. export class MaxBlock extends NodeMaterialBlock {
  57769. /**
  57770. * Creates a new MaxBlock
  57771. * @param name defines the block name
  57772. */
  57773. constructor(name: string);
  57774. /**
  57775. * Gets the current class name
  57776. * @returns the class name
  57777. */
  57778. getClassName(): string;
  57779. /**
  57780. * Gets the left operand input component
  57781. */
  57782. readonly left: NodeMaterialConnectionPoint;
  57783. /**
  57784. * Gets the right operand input component
  57785. */
  57786. readonly right: NodeMaterialConnectionPoint;
  57787. /**
  57788. * Gets the output component
  57789. */
  57790. readonly output: NodeMaterialConnectionPoint;
  57791. protected _buildBlock(state: NodeMaterialBuildState): this;
  57792. }
  57793. }
  57794. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57795. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57796. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57797. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57798. /**
  57799. * Block used to get the min of 2 values
  57800. */
  57801. export class MinBlock extends NodeMaterialBlock {
  57802. /**
  57803. * Creates a new MinBlock
  57804. * @param name defines the block name
  57805. */
  57806. constructor(name: string);
  57807. /**
  57808. * Gets the current class name
  57809. * @returns the class name
  57810. */
  57811. getClassName(): string;
  57812. /**
  57813. * Gets the left operand input component
  57814. */
  57815. readonly left: NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the right operand input component
  57818. */
  57819. readonly right: NodeMaterialConnectionPoint;
  57820. /**
  57821. * Gets the output component
  57822. */
  57823. readonly output: NodeMaterialConnectionPoint;
  57824. protected _buildBlock(state: NodeMaterialBuildState): this;
  57825. }
  57826. }
  57827. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57831. /**
  57832. * Block used to get the distance between 2 values
  57833. */
  57834. export class DistanceBlock extends NodeMaterialBlock {
  57835. /**
  57836. * Creates a new DistanceBlock
  57837. * @param name defines the block name
  57838. */
  57839. constructor(name: string);
  57840. /**
  57841. * Gets the current class name
  57842. * @returns the class name
  57843. */
  57844. getClassName(): string;
  57845. /**
  57846. * Gets the left operand input component
  57847. */
  57848. readonly left: NodeMaterialConnectionPoint;
  57849. /**
  57850. * Gets the right operand input component
  57851. */
  57852. readonly right: NodeMaterialConnectionPoint;
  57853. /**
  57854. * Gets the output component
  57855. */
  57856. readonly output: NodeMaterialConnectionPoint;
  57857. protected _buildBlock(state: NodeMaterialBuildState): this;
  57858. }
  57859. }
  57860. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57864. /**
  57865. * Block used to get the length of a vector
  57866. */
  57867. export class LengthBlock extends NodeMaterialBlock {
  57868. /**
  57869. * Creates a new LengthBlock
  57870. * @param name defines the block name
  57871. */
  57872. constructor(name: string);
  57873. /**
  57874. * Gets the current class name
  57875. * @returns the class name
  57876. */
  57877. getClassName(): string;
  57878. /**
  57879. * Gets the value input component
  57880. */
  57881. readonly value: NodeMaterialConnectionPoint;
  57882. /**
  57883. * Gets the output component
  57884. */
  57885. readonly output: NodeMaterialConnectionPoint;
  57886. protected _buildBlock(state: NodeMaterialBuildState): this;
  57887. }
  57888. }
  57889. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57890. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57891. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57893. /**
  57894. * Block used to get negative version of a value (i.e. x * -1)
  57895. */
  57896. export class NegateBlock extends NodeMaterialBlock {
  57897. /**
  57898. * Creates a new NegateBlock
  57899. * @param name defines the block name
  57900. */
  57901. constructor(name: string);
  57902. /**
  57903. * Gets the current class name
  57904. * @returns the class name
  57905. */
  57906. getClassName(): string;
  57907. /**
  57908. * Gets the value input component
  57909. */
  57910. readonly value: NodeMaterialConnectionPoint;
  57911. /**
  57912. * Gets the output component
  57913. */
  57914. readonly output: NodeMaterialConnectionPoint;
  57915. protected _buildBlock(state: NodeMaterialBuildState): this;
  57916. }
  57917. }
  57918. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57922. /**
  57923. * Block used to get the value of the first parameter raised to the power of the second
  57924. */
  57925. export class PowBlock extends NodeMaterialBlock {
  57926. /**
  57927. * Creates a new PowBlock
  57928. * @param name defines the block name
  57929. */
  57930. constructor(name: string);
  57931. /**
  57932. * Gets the current class name
  57933. * @returns the class name
  57934. */
  57935. getClassName(): string;
  57936. /**
  57937. * Gets the value operand input component
  57938. */
  57939. readonly value: NodeMaterialConnectionPoint;
  57940. /**
  57941. * Gets the power operand input component
  57942. */
  57943. readonly power: NodeMaterialConnectionPoint;
  57944. /**
  57945. * Gets the output component
  57946. */
  57947. readonly output: NodeMaterialConnectionPoint;
  57948. protected _buildBlock(state: NodeMaterialBuildState): this;
  57949. }
  57950. }
  57951. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57952. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57953. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57954. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57955. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57956. /**
  57957. * Block used to get a random number
  57958. */
  57959. export class RandomNumberBlock extends NodeMaterialBlock {
  57960. /**
  57961. * Creates a new RandomNumberBlock
  57962. * @param name defines the block name
  57963. */
  57964. constructor(name: string);
  57965. /**
  57966. * Gets the current class name
  57967. * @returns the class name
  57968. */
  57969. getClassName(): string;
  57970. /**
  57971. * Gets the seed input component
  57972. */
  57973. readonly seed: NodeMaterialConnectionPoint;
  57974. /**
  57975. * Gets the output component
  57976. */
  57977. readonly output: NodeMaterialConnectionPoint;
  57978. protected _buildBlock(state: NodeMaterialBuildState): this;
  57979. }
  57980. }
  57981. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57982. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57983. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57984. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57985. /**
  57986. * Block used to compute arc tangent of 2 values
  57987. */
  57988. export class ArcTan2Block extends NodeMaterialBlock {
  57989. /**
  57990. * Creates a new ArcTan2Block
  57991. * @param name defines the block name
  57992. */
  57993. constructor(name: string);
  57994. /**
  57995. * Gets the current class name
  57996. * @returns the class name
  57997. */
  57998. getClassName(): string;
  57999. /**
  58000. * Gets the x operand input component
  58001. */
  58002. readonly x: NodeMaterialConnectionPoint;
  58003. /**
  58004. * Gets the y operand input component
  58005. */
  58006. readonly y: NodeMaterialConnectionPoint;
  58007. /**
  58008. * Gets the output component
  58009. */
  58010. readonly output: NodeMaterialConnectionPoint;
  58011. protected _buildBlock(state: NodeMaterialBuildState): this;
  58012. }
  58013. }
  58014. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58018. /**
  58019. * Block used to smooth step a value
  58020. */
  58021. export class SmoothStepBlock extends NodeMaterialBlock {
  58022. /**
  58023. * Creates a new SmoothStepBlock
  58024. * @param name defines the block name
  58025. */
  58026. constructor(name: string);
  58027. /**
  58028. * Gets the current class name
  58029. * @returns the class name
  58030. */
  58031. getClassName(): string;
  58032. /**
  58033. * Gets the value operand input component
  58034. */
  58035. readonly value: NodeMaterialConnectionPoint;
  58036. /**
  58037. * Gets the first edge operand input component
  58038. */
  58039. readonly edge0: NodeMaterialConnectionPoint;
  58040. /**
  58041. * Gets the second edge operand input component
  58042. */
  58043. readonly edge1: NodeMaterialConnectionPoint;
  58044. /**
  58045. * Gets the output component
  58046. */
  58047. readonly output: NodeMaterialConnectionPoint;
  58048. protected _buildBlock(state: NodeMaterialBuildState): this;
  58049. }
  58050. }
  58051. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58055. /**
  58056. * Block used to get the reciprocal (1 / x) of a value
  58057. */
  58058. export class ReciprocalBlock extends NodeMaterialBlock {
  58059. /**
  58060. * Creates a new ReciprocalBlock
  58061. * @param name defines the block name
  58062. */
  58063. constructor(name: string);
  58064. /**
  58065. * Gets the current class name
  58066. * @returns the class name
  58067. */
  58068. getClassName(): string;
  58069. /**
  58070. * Gets the input component
  58071. */
  58072. readonly input: NodeMaterialConnectionPoint;
  58073. /**
  58074. * Gets the output component
  58075. */
  58076. readonly output: NodeMaterialConnectionPoint;
  58077. protected _buildBlock(state: NodeMaterialBuildState): this;
  58078. }
  58079. }
  58080. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58084. /**
  58085. * Block used to replace a color by another one
  58086. */
  58087. export class ReplaceColorBlock extends NodeMaterialBlock {
  58088. /**
  58089. * Creates a new ReplaceColorBlock
  58090. * @param name defines the block name
  58091. */
  58092. constructor(name: string);
  58093. /**
  58094. * Gets the current class name
  58095. * @returns the class name
  58096. */
  58097. getClassName(): string;
  58098. /**
  58099. * Gets the value input component
  58100. */
  58101. readonly value: NodeMaterialConnectionPoint;
  58102. /**
  58103. * Gets the reference input component
  58104. */
  58105. readonly reference: NodeMaterialConnectionPoint;
  58106. /**
  58107. * Gets the distance input component
  58108. */
  58109. readonly distance: NodeMaterialConnectionPoint;
  58110. /**
  58111. * Gets the replacement input component
  58112. */
  58113. readonly replacement: NodeMaterialConnectionPoint;
  58114. /**
  58115. * Gets the output component
  58116. */
  58117. readonly output: NodeMaterialConnectionPoint;
  58118. protected _buildBlock(state: NodeMaterialBuildState): this;
  58119. }
  58120. }
  58121. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58125. /**
  58126. * Block used to posterize a value
  58127. * @see https://en.wikipedia.org/wiki/Posterization
  58128. */
  58129. export class PosterizeBlock extends NodeMaterialBlock {
  58130. /**
  58131. * Creates a new PosterizeBlock
  58132. * @param name defines the block name
  58133. */
  58134. constructor(name: string);
  58135. /**
  58136. * Gets the current class name
  58137. * @returns the class name
  58138. */
  58139. getClassName(): string;
  58140. /**
  58141. * Gets the value input component
  58142. */
  58143. readonly value: NodeMaterialConnectionPoint;
  58144. /**
  58145. * Gets the steps input component
  58146. */
  58147. readonly steps: NodeMaterialConnectionPoint;
  58148. /**
  58149. * Gets the output component
  58150. */
  58151. readonly output: NodeMaterialConnectionPoint;
  58152. protected _buildBlock(state: NodeMaterialBuildState): this;
  58153. }
  58154. }
  58155. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58159. import { Scene } from "babylonjs/scene";
  58160. /**
  58161. * Operations supported by the Wave block
  58162. */
  58163. export enum WaveBlockKind {
  58164. /** SawTooth */
  58165. SawTooth = 0,
  58166. /** Square */
  58167. Square = 1,
  58168. /** Triangle */
  58169. Triangle = 2
  58170. }
  58171. /**
  58172. * Block used to apply wave operation to floats
  58173. */
  58174. export class WaveBlock extends NodeMaterialBlock {
  58175. /**
  58176. * Gets or sets the kibnd of wave to be applied by the block
  58177. */
  58178. kind: WaveBlockKind;
  58179. /**
  58180. * Creates a new WaveBlock
  58181. * @param name defines the block name
  58182. */
  58183. constructor(name: string);
  58184. /**
  58185. * Gets the current class name
  58186. * @returns the class name
  58187. */
  58188. getClassName(): string;
  58189. /**
  58190. * Gets the input component
  58191. */
  58192. readonly input: NodeMaterialConnectionPoint;
  58193. /**
  58194. * Gets the output component
  58195. */
  58196. readonly output: NodeMaterialConnectionPoint;
  58197. protected _buildBlock(state: NodeMaterialBuildState): this;
  58198. serialize(): any;
  58199. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58200. }
  58201. }
  58202. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58206. import { Color3 } from "babylonjs/Maths/math.color";
  58207. import { Scene } from "babylonjs/scene";
  58208. /**
  58209. * Class used to store a color step for the GradientBlock
  58210. */
  58211. export class GradientBlockColorStep {
  58212. /**
  58213. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58214. */
  58215. step: number;
  58216. /**
  58217. * Gets or sets the color associated with this step
  58218. */
  58219. color: Color3;
  58220. /**
  58221. * Creates a new GradientBlockColorStep
  58222. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58223. * @param color defines the color associated with this step
  58224. */
  58225. constructor(
  58226. /**
  58227. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58228. */
  58229. step: number,
  58230. /**
  58231. * Gets or sets the color associated with this step
  58232. */
  58233. color: Color3);
  58234. }
  58235. /**
  58236. * Block used to return a color from a gradient based on an input value between 0 and 1
  58237. */
  58238. export class GradientBlock extends NodeMaterialBlock {
  58239. /**
  58240. * Gets or sets the list of color steps
  58241. */
  58242. colorSteps: GradientBlockColorStep[];
  58243. /**
  58244. * Creates a new GradientBlock
  58245. * @param name defines the block name
  58246. */
  58247. constructor(name: string);
  58248. /**
  58249. * Gets the current class name
  58250. * @returns the class name
  58251. */
  58252. getClassName(): string;
  58253. /**
  58254. * Gets the gradient input component
  58255. */
  58256. readonly gradient: NodeMaterialConnectionPoint;
  58257. /**
  58258. * Gets the output component
  58259. */
  58260. readonly output: NodeMaterialConnectionPoint;
  58261. private _writeColorConstant;
  58262. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58263. serialize(): any;
  58264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58265. protected _dumpPropertiesCode(): string;
  58266. }
  58267. }
  58268. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58269. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58270. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58271. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58272. /**
  58273. * Block used to normalize lerp between 2 values
  58274. */
  58275. export class NLerpBlock extends NodeMaterialBlock {
  58276. /**
  58277. * Creates a new NLerpBlock
  58278. * @param name defines the block name
  58279. */
  58280. constructor(name: string);
  58281. /**
  58282. * Gets the current class name
  58283. * @returns the class name
  58284. */
  58285. getClassName(): string;
  58286. /**
  58287. * Gets the left operand input component
  58288. */
  58289. readonly left: NodeMaterialConnectionPoint;
  58290. /**
  58291. * Gets the right operand input component
  58292. */
  58293. readonly right: NodeMaterialConnectionPoint;
  58294. /**
  58295. * Gets the gradient operand input component
  58296. */
  58297. readonly gradient: NodeMaterialConnectionPoint;
  58298. /**
  58299. * Gets the output component
  58300. */
  58301. readonly output: NodeMaterialConnectionPoint;
  58302. protected _buildBlock(state: NodeMaterialBuildState): this;
  58303. }
  58304. }
  58305. declare module "babylonjs/Materials/Node/Blocks/index" {
  58306. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58307. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58308. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58309. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58310. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58311. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58312. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58313. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58314. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58315. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58316. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58317. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58318. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58319. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58320. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58321. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58322. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58323. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58324. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58325. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58326. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58327. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58328. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58329. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58330. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58331. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58332. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58333. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58334. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58335. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58336. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58337. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58338. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58339. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58340. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58341. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58342. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58343. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58344. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58345. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58346. }
  58347. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58348. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58349. }
  58350. declare module "babylonjs/Materials/Node/index" {
  58351. export * from "babylonjs/Materials/Node/Enums/index";
  58352. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58353. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58354. export * from "babylonjs/Materials/Node/nodeMaterial";
  58355. export * from "babylonjs/Materials/Node/Blocks/index";
  58356. export * from "babylonjs/Materials/Node/Optimizers/index";
  58357. }
  58358. declare module "babylonjs/Materials/effectRenderer" {
  58359. import { Nullable } from "babylonjs/types";
  58360. import { Texture } from "babylonjs/Materials/Textures/texture";
  58361. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58362. import { Viewport } from "babylonjs/Maths/math.viewport";
  58363. import { Observable } from "babylonjs/Misc/observable";
  58364. import { Effect } from "babylonjs/Materials/effect";
  58365. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58366. import "babylonjs/Shaders/postprocess.vertex";
  58367. /**
  58368. * Effect Render Options
  58369. */
  58370. export interface IEffectRendererOptions {
  58371. /**
  58372. * Defines the vertices positions.
  58373. */
  58374. positions?: number[];
  58375. /**
  58376. * Defines the indices.
  58377. */
  58378. indices?: number[];
  58379. }
  58380. /**
  58381. * Helper class to render one or more effects
  58382. */
  58383. export class EffectRenderer {
  58384. private engine;
  58385. private static _DefaultOptions;
  58386. private _vertexBuffers;
  58387. private _indexBuffer;
  58388. private _ringBufferIndex;
  58389. private _ringScreenBuffer;
  58390. private _fullscreenViewport;
  58391. private _getNextFrameBuffer;
  58392. /**
  58393. * Creates an effect renderer
  58394. * @param engine the engine to use for rendering
  58395. * @param options defines the options of the effect renderer
  58396. */
  58397. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58398. /**
  58399. * Sets the current viewport in normalized coordinates 0-1
  58400. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58401. */
  58402. setViewport(viewport?: Viewport): void;
  58403. /**
  58404. * Binds the embedded attributes buffer to the effect.
  58405. * @param effect Defines the effect to bind the attributes for
  58406. */
  58407. bindBuffers(effect: Effect): void;
  58408. /**
  58409. * Sets the current effect wrapper to use during draw.
  58410. * The effect needs to be ready before calling this api.
  58411. * This also sets the default full screen position attribute.
  58412. * @param effectWrapper Defines the effect to draw with
  58413. */
  58414. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58415. /**
  58416. * Draws a full screen quad.
  58417. */
  58418. draw(): void;
  58419. /**
  58420. * renders one or more effects to a specified texture
  58421. * @param effectWrappers list of effects to renderer
  58422. * @param outputTexture texture to draw to, if null it will render to the screen
  58423. */
  58424. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58425. /**
  58426. * Disposes of the effect renderer
  58427. */
  58428. dispose(): void;
  58429. }
  58430. /**
  58431. * Options to create an EffectWrapper
  58432. */
  58433. interface EffectWrapperCreationOptions {
  58434. /**
  58435. * Engine to use to create the effect
  58436. */
  58437. engine: ThinEngine;
  58438. /**
  58439. * Fragment shader for the effect
  58440. */
  58441. fragmentShader: string;
  58442. /**
  58443. * Vertex shader for the effect
  58444. */
  58445. vertexShader?: string;
  58446. /**
  58447. * Attributes to use in the shader
  58448. */
  58449. attributeNames?: Array<string>;
  58450. /**
  58451. * Uniforms to use in the shader
  58452. */
  58453. uniformNames?: Array<string>;
  58454. /**
  58455. * Texture sampler names to use in the shader
  58456. */
  58457. samplerNames?: Array<string>;
  58458. /**
  58459. * The friendly name of the effect displayed in Spector.
  58460. */
  58461. name?: string;
  58462. }
  58463. /**
  58464. * Wraps an effect to be used for rendering
  58465. */
  58466. export class EffectWrapper {
  58467. /**
  58468. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58469. */
  58470. onApplyObservable: Observable<{}>;
  58471. /**
  58472. * The underlying effect
  58473. */
  58474. effect: Effect;
  58475. /**
  58476. * Creates an effect to be renderer
  58477. * @param creationOptions options to create the effect
  58478. */
  58479. constructor(creationOptions: EffectWrapperCreationOptions);
  58480. /**
  58481. * Disposes of the effect wrapper
  58482. */
  58483. dispose(): void;
  58484. }
  58485. }
  58486. declare module "babylonjs/Materials/index" {
  58487. export * from "babylonjs/Materials/Background/index";
  58488. export * from "babylonjs/Materials/colorCurves";
  58489. export * from "babylonjs/Materials/iEffectFallbacks";
  58490. export * from "babylonjs/Materials/effectFallbacks";
  58491. export * from "babylonjs/Materials/effect";
  58492. export * from "babylonjs/Materials/fresnelParameters";
  58493. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58494. export * from "babylonjs/Materials/material";
  58495. export * from "babylonjs/Materials/materialDefines";
  58496. export * from "babylonjs/Materials/materialHelper";
  58497. export * from "babylonjs/Materials/multiMaterial";
  58498. export * from "babylonjs/Materials/PBR/index";
  58499. export * from "babylonjs/Materials/pushMaterial";
  58500. export * from "babylonjs/Materials/shaderMaterial";
  58501. export * from "babylonjs/Materials/standardMaterial";
  58502. export * from "babylonjs/Materials/Textures/index";
  58503. export * from "babylonjs/Materials/uniformBuffer";
  58504. export * from "babylonjs/Materials/materialFlags";
  58505. export * from "babylonjs/Materials/Node/index";
  58506. export * from "babylonjs/Materials/effectRenderer";
  58507. }
  58508. declare module "babylonjs/Maths/index" {
  58509. export * from "babylonjs/Maths/math.scalar";
  58510. export * from "babylonjs/Maths/math";
  58511. export * from "babylonjs/Maths/sphericalPolynomial";
  58512. }
  58513. declare module "babylonjs/Misc/workerPool" {
  58514. import { IDisposable } from "babylonjs/scene";
  58515. /**
  58516. * Helper class to push actions to a pool of workers.
  58517. */
  58518. export class WorkerPool implements IDisposable {
  58519. private _workerInfos;
  58520. private _pendingActions;
  58521. /**
  58522. * Constructor
  58523. * @param workers Array of workers to use for actions
  58524. */
  58525. constructor(workers: Array<Worker>);
  58526. /**
  58527. * Terminates all workers and clears any pending actions.
  58528. */
  58529. dispose(): void;
  58530. /**
  58531. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58532. * pended until a worker has completed its action.
  58533. * @param action The action to perform. Call onComplete when the action is complete.
  58534. */
  58535. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58536. private _execute;
  58537. }
  58538. }
  58539. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58540. import { IDisposable } from "babylonjs/scene";
  58541. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58542. /**
  58543. * Configuration for Draco compression
  58544. */
  58545. export interface IDracoCompressionConfiguration {
  58546. /**
  58547. * Configuration for the decoder.
  58548. */
  58549. decoder: {
  58550. /**
  58551. * The url to the WebAssembly module.
  58552. */
  58553. wasmUrl?: string;
  58554. /**
  58555. * The url to the WebAssembly binary.
  58556. */
  58557. wasmBinaryUrl?: string;
  58558. /**
  58559. * The url to the fallback JavaScript module.
  58560. */
  58561. fallbackUrl?: string;
  58562. };
  58563. }
  58564. /**
  58565. * Draco compression (https://google.github.io/draco/)
  58566. *
  58567. * This class wraps the Draco module.
  58568. *
  58569. * **Encoder**
  58570. *
  58571. * The encoder is not currently implemented.
  58572. *
  58573. * **Decoder**
  58574. *
  58575. * 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.
  58576. *
  58577. * To update the configuration, use the following code:
  58578. * ```javascript
  58579. * DracoCompression.Configuration = {
  58580. * decoder: {
  58581. * wasmUrl: "<url to the WebAssembly library>",
  58582. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58583. * fallbackUrl: "<url to the fallback JavaScript library>",
  58584. * }
  58585. * };
  58586. * ```
  58587. *
  58588. * 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.
  58589. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58590. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58591. *
  58592. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58593. * ```javascript
  58594. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58595. * ```
  58596. *
  58597. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58598. */
  58599. export class DracoCompression implements IDisposable {
  58600. private _workerPoolPromise?;
  58601. private _decoderModulePromise?;
  58602. /**
  58603. * The configuration. Defaults to the following urls:
  58604. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58605. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58606. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58607. */
  58608. static Configuration: IDracoCompressionConfiguration;
  58609. /**
  58610. * Returns true if the decoder configuration is available.
  58611. */
  58612. static readonly DecoderAvailable: boolean;
  58613. /**
  58614. * Default number of workers to create when creating the draco compression object.
  58615. */
  58616. static DefaultNumWorkers: number;
  58617. private static GetDefaultNumWorkers;
  58618. private static _Default;
  58619. /**
  58620. * Default instance for the draco compression object.
  58621. */
  58622. static readonly Default: DracoCompression;
  58623. /**
  58624. * Constructor
  58625. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58626. */
  58627. constructor(numWorkers?: number);
  58628. /**
  58629. * Stop all async operations and release resources.
  58630. */
  58631. dispose(): void;
  58632. /**
  58633. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58634. * @returns a promise that resolves when ready
  58635. */
  58636. whenReadyAsync(): Promise<void>;
  58637. /**
  58638. * Decode Draco compressed mesh data to vertex data.
  58639. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58640. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58641. * @returns A promise that resolves with the decoded vertex data
  58642. */
  58643. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58644. [kind: string]: number;
  58645. }): Promise<VertexData>;
  58646. }
  58647. }
  58648. declare module "babylonjs/Meshes/Compression/index" {
  58649. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58650. }
  58651. declare module "babylonjs/Meshes/csg" {
  58652. import { Nullable } from "babylonjs/types";
  58653. import { Scene } from "babylonjs/scene";
  58654. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58655. import { Mesh } from "babylonjs/Meshes/mesh";
  58656. import { Material } from "babylonjs/Materials/material";
  58657. /**
  58658. * Class for building Constructive Solid Geometry
  58659. */
  58660. export class CSG {
  58661. private polygons;
  58662. /**
  58663. * The world matrix
  58664. */
  58665. matrix: Matrix;
  58666. /**
  58667. * Stores the position
  58668. */
  58669. position: Vector3;
  58670. /**
  58671. * Stores the rotation
  58672. */
  58673. rotation: Vector3;
  58674. /**
  58675. * Stores the rotation quaternion
  58676. */
  58677. rotationQuaternion: Nullable<Quaternion>;
  58678. /**
  58679. * Stores the scaling vector
  58680. */
  58681. scaling: Vector3;
  58682. /**
  58683. * Convert the Mesh to CSG
  58684. * @param mesh The Mesh to convert to CSG
  58685. * @returns A new CSG from the Mesh
  58686. */
  58687. static FromMesh(mesh: Mesh): CSG;
  58688. /**
  58689. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58690. * @param polygons Polygons used to construct a CSG solid
  58691. */
  58692. private static FromPolygons;
  58693. /**
  58694. * Clones, or makes a deep copy, of the CSG
  58695. * @returns A new CSG
  58696. */
  58697. clone(): CSG;
  58698. /**
  58699. * Unions this CSG with another CSG
  58700. * @param csg The CSG to union against this CSG
  58701. * @returns The unioned CSG
  58702. */
  58703. union(csg: CSG): CSG;
  58704. /**
  58705. * Unions this CSG with another CSG in place
  58706. * @param csg The CSG to union against this CSG
  58707. */
  58708. unionInPlace(csg: CSG): void;
  58709. /**
  58710. * Subtracts this CSG with another CSG
  58711. * @param csg The CSG to subtract against this CSG
  58712. * @returns A new CSG
  58713. */
  58714. subtract(csg: CSG): CSG;
  58715. /**
  58716. * Subtracts this CSG with another CSG in place
  58717. * @param csg The CSG to subtact against this CSG
  58718. */
  58719. subtractInPlace(csg: CSG): void;
  58720. /**
  58721. * Intersect this CSG with another CSG
  58722. * @param csg The CSG to intersect against this CSG
  58723. * @returns A new CSG
  58724. */
  58725. intersect(csg: CSG): CSG;
  58726. /**
  58727. * Intersects this CSG with another CSG in place
  58728. * @param csg The CSG to intersect against this CSG
  58729. */
  58730. intersectInPlace(csg: CSG): void;
  58731. /**
  58732. * Return a new CSG solid with solid and empty space switched. This solid is
  58733. * not modified.
  58734. * @returns A new CSG solid with solid and empty space switched
  58735. */
  58736. inverse(): CSG;
  58737. /**
  58738. * Inverses the CSG in place
  58739. */
  58740. inverseInPlace(): void;
  58741. /**
  58742. * This is used to keep meshes transformations so they can be restored
  58743. * when we build back a Babylon Mesh
  58744. * NB : All CSG operations are performed in world coordinates
  58745. * @param csg The CSG to copy the transform attributes from
  58746. * @returns This CSG
  58747. */
  58748. copyTransformAttributes(csg: CSG): CSG;
  58749. /**
  58750. * Build Raw mesh from CSG
  58751. * Coordinates here are in world space
  58752. * @param name The name of the mesh geometry
  58753. * @param scene The Scene
  58754. * @param keepSubMeshes Specifies if the submeshes should be kept
  58755. * @returns A new Mesh
  58756. */
  58757. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58758. /**
  58759. * Build Mesh from CSG taking material and transforms into account
  58760. * @param name The name of the Mesh
  58761. * @param material The material of the Mesh
  58762. * @param scene The Scene
  58763. * @param keepSubMeshes Specifies if submeshes should be kept
  58764. * @returns The new Mesh
  58765. */
  58766. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58767. }
  58768. }
  58769. declare module "babylonjs/Meshes/trailMesh" {
  58770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58771. import { Mesh } from "babylonjs/Meshes/mesh";
  58772. import { Scene } from "babylonjs/scene";
  58773. /**
  58774. * Class used to create a trail following a mesh
  58775. */
  58776. export class TrailMesh extends Mesh {
  58777. private _generator;
  58778. private _autoStart;
  58779. private _running;
  58780. private _diameter;
  58781. private _length;
  58782. private _sectionPolygonPointsCount;
  58783. private _sectionVectors;
  58784. private _sectionNormalVectors;
  58785. private _beforeRenderObserver;
  58786. /**
  58787. * @constructor
  58788. * @param name The value used by scene.getMeshByName() to do a lookup.
  58789. * @param generator The mesh to generate a trail.
  58790. * @param scene The scene to add this mesh to.
  58791. * @param diameter Diameter of trailing mesh. Default is 1.
  58792. * @param length Length of trailing mesh. Default is 60.
  58793. * @param autoStart Automatically start trailing mesh. Default true.
  58794. */
  58795. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58796. /**
  58797. * "TrailMesh"
  58798. * @returns "TrailMesh"
  58799. */
  58800. getClassName(): string;
  58801. private _createMesh;
  58802. /**
  58803. * Start trailing mesh.
  58804. */
  58805. start(): void;
  58806. /**
  58807. * Stop trailing mesh.
  58808. */
  58809. stop(): void;
  58810. /**
  58811. * Update trailing mesh geometry.
  58812. */
  58813. update(): void;
  58814. /**
  58815. * Returns a new TrailMesh object.
  58816. * @param name is a string, the name given to the new mesh
  58817. * @param newGenerator use new generator object for cloned trail mesh
  58818. * @returns a new mesh
  58819. */
  58820. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58821. /**
  58822. * Serializes this trail mesh
  58823. * @param serializationObject object to write serialization to
  58824. */
  58825. serialize(serializationObject: any): void;
  58826. /**
  58827. * Parses a serialized trail mesh
  58828. * @param parsedMesh the serialized mesh
  58829. * @param scene the scene to create the trail mesh in
  58830. * @returns the created trail mesh
  58831. */
  58832. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58833. }
  58834. }
  58835. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58836. import { Nullable } from "babylonjs/types";
  58837. import { Scene } from "babylonjs/scene";
  58838. import { Vector4 } from "babylonjs/Maths/math.vector";
  58839. import { Color4 } from "babylonjs/Maths/math.color";
  58840. import { Mesh } from "babylonjs/Meshes/mesh";
  58841. /**
  58842. * Class containing static functions to help procedurally build meshes
  58843. */
  58844. export class TiledBoxBuilder {
  58845. /**
  58846. * Creates a box mesh
  58847. * 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)
  58848. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58852. * @param name defines the name of the mesh
  58853. * @param options defines the options used to create the mesh
  58854. * @param scene defines the hosting scene
  58855. * @returns the box mesh
  58856. */
  58857. static CreateTiledBox(name: string, options: {
  58858. pattern?: number;
  58859. width?: number;
  58860. height?: number;
  58861. depth?: number;
  58862. tileSize?: number;
  58863. tileWidth?: number;
  58864. tileHeight?: number;
  58865. alignHorizontal?: number;
  58866. alignVertical?: number;
  58867. faceUV?: Vector4[];
  58868. faceColors?: Color4[];
  58869. sideOrientation?: number;
  58870. updatable?: boolean;
  58871. }, scene?: Nullable<Scene>): Mesh;
  58872. }
  58873. }
  58874. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58875. import { Vector4 } from "babylonjs/Maths/math.vector";
  58876. import { Mesh } from "babylonjs/Meshes/mesh";
  58877. /**
  58878. * Class containing static functions to help procedurally build meshes
  58879. */
  58880. export class TorusKnotBuilder {
  58881. /**
  58882. * Creates a torus knot mesh
  58883. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58884. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58885. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58886. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58890. * @param name defines the name of the mesh
  58891. * @param options defines the options used to create the mesh
  58892. * @param scene defines the hosting scene
  58893. * @returns the torus knot mesh
  58894. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58895. */
  58896. static CreateTorusKnot(name: string, options: {
  58897. radius?: number;
  58898. tube?: number;
  58899. radialSegments?: number;
  58900. tubularSegments?: number;
  58901. p?: number;
  58902. q?: number;
  58903. updatable?: boolean;
  58904. sideOrientation?: number;
  58905. frontUVs?: Vector4;
  58906. backUVs?: Vector4;
  58907. }, scene: any): Mesh;
  58908. }
  58909. }
  58910. declare module "babylonjs/Meshes/polygonMesh" {
  58911. import { Scene } from "babylonjs/scene";
  58912. import { Vector2 } from "babylonjs/Maths/math.vector";
  58913. import { Mesh } from "babylonjs/Meshes/mesh";
  58914. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58915. import { Path2 } from "babylonjs/Maths/math.path";
  58916. /**
  58917. * Polygon
  58918. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58919. */
  58920. export class Polygon {
  58921. /**
  58922. * Creates a rectangle
  58923. * @param xmin bottom X coord
  58924. * @param ymin bottom Y coord
  58925. * @param xmax top X coord
  58926. * @param ymax top Y coord
  58927. * @returns points that make the resulting rectation
  58928. */
  58929. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58930. /**
  58931. * Creates a circle
  58932. * @param radius radius of circle
  58933. * @param cx scale in x
  58934. * @param cy scale in y
  58935. * @param numberOfSides number of sides that make up the circle
  58936. * @returns points that make the resulting circle
  58937. */
  58938. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58939. /**
  58940. * Creates a polygon from input string
  58941. * @param input Input polygon data
  58942. * @returns the parsed points
  58943. */
  58944. static Parse(input: string): Vector2[];
  58945. /**
  58946. * Starts building a polygon from x and y coordinates
  58947. * @param x x coordinate
  58948. * @param y y coordinate
  58949. * @returns the started path2
  58950. */
  58951. static StartingAt(x: number, y: number): Path2;
  58952. }
  58953. /**
  58954. * Builds a polygon
  58955. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58956. */
  58957. export class PolygonMeshBuilder {
  58958. private _points;
  58959. private _outlinepoints;
  58960. private _holes;
  58961. private _name;
  58962. private _scene;
  58963. private _epoints;
  58964. private _eholes;
  58965. private _addToepoint;
  58966. /**
  58967. * Babylon reference to the earcut plugin.
  58968. */
  58969. bjsEarcut: any;
  58970. /**
  58971. * Creates a PolygonMeshBuilder
  58972. * @param name name of the builder
  58973. * @param contours Path of the polygon
  58974. * @param scene scene to add to when creating the mesh
  58975. * @param earcutInjection can be used to inject your own earcut reference
  58976. */
  58977. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58978. /**
  58979. * Adds a whole within the polygon
  58980. * @param hole Array of points defining the hole
  58981. * @returns this
  58982. */
  58983. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58984. /**
  58985. * Creates the polygon
  58986. * @param updatable If the mesh should be updatable
  58987. * @param depth The depth of the mesh created
  58988. * @returns the created mesh
  58989. */
  58990. build(updatable?: boolean, depth?: number): Mesh;
  58991. /**
  58992. * Creates the polygon
  58993. * @param depth The depth of the mesh created
  58994. * @returns the created VertexData
  58995. */
  58996. buildVertexData(depth?: number): VertexData;
  58997. /**
  58998. * Adds a side to the polygon
  58999. * @param positions points that make the polygon
  59000. * @param normals normals of the polygon
  59001. * @param uvs uvs of the polygon
  59002. * @param indices indices of the polygon
  59003. * @param bounds bounds of the polygon
  59004. * @param points points of the polygon
  59005. * @param depth depth of the polygon
  59006. * @param flip flip of the polygon
  59007. */
  59008. private addSide;
  59009. }
  59010. }
  59011. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59012. import { Scene } from "babylonjs/scene";
  59013. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59014. import { Color4 } from "babylonjs/Maths/math.color";
  59015. import { Mesh } from "babylonjs/Meshes/mesh";
  59016. import { Nullable } from "babylonjs/types";
  59017. /**
  59018. * Class containing static functions to help procedurally build meshes
  59019. */
  59020. export class PolygonBuilder {
  59021. /**
  59022. * Creates a polygon mesh
  59023. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59024. * * 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
  59025. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59028. * * Remember you can only change the shape positions, not their number when updating a polygon
  59029. * @param name defines the name of the mesh
  59030. * @param options defines the options used to create the mesh
  59031. * @param scene defines the hosting scene
  59032. * @param earcutInjection can be used to inject your own earcut reference
  59033. * @returns the polygon mesh
  59034. */
  59035. static CreatePolygon(name: string, options: {
  59036. shape: Vector3[];
  59037. holes?: Vector3[][];
  59038. depth?: number;
  59039. faceUV?: Vector4[];
  59040. faceColors?: Color4[];
  59041. updatable?: boolean;
  59042. sideOrientation?: number;
  59043. frontUVs?: Vector4;
  59044. backUVs?: Vector4;
  59045. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59046. /**
  59047. * Creates an extruded polygon mesh, with depth in the Y direction.
  59048. * * 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)
  59049. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59050. * @param name defines the name of the mesh
  59051. * @param options defines the options used to create the mesh
  59052. * @param scene defines the hosting scene
  59053. * @param earcutInjection can be used to inject your own earcut reference
  59054. * @returns the polygon mesh
  59055. */
  59056. static ExtrudePolygon(name: string, options: {
  59057. shape: Vector3[];
  59058. holes?: Vector3[][];
  59059. depth?: number;
  59060. faceUV?: Vector4[];
  59061. faceColors?: Color4[];
  59062. updatable?: boolean;
  59063. sideOrientation?: number;
  59064. frontUVs?: Vector4;
  59065. backUVs?: Vector4;
  59066. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59067. }
  59068. }
  59069. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59070. import { Scene } from "babylonjs/scene";
  59071. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59072. import { Mesh } from "babylonjs/Meshes/mesh";
  59073. import { Nullable } from "babylonjs/types";
  59074. /**
  59075. * Class containing static functions to help procedurally build meshes
  59076. */
  59077. export class LatheBuilder {
  59078. /**
  59079. * Creates lathe mesh.
  59080. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59081. * * 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
  59082. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59083. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59084. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59085. * * 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
  59086. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59087. * * 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
  59088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59092. * @param name defines the name of the mesh
  59093. * @param options defines the options used to create the mesh
  59094. * @param scene defines the hosting scene
  59095. * @returns the lathe mesh
  59096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59097. */
  59098. static CreateLathe(name: string, options: {
  59099. shape: Vector3[];
  59100. radius?: number;
  59101. tessellation?: number;
  59102. clip?: number;
  59103. arc?: number;
  59104. closed?: boolean;
  59105. updatable?: boolean;
  59106. sideOrientation?: number;
  59107. frontUVs?: Vector4;
  59108. backUVs?: Vector4;
  59109. cap?: number;
  59110. invertUV?: boolean;
  59111. }, scene?: Nullable<Scene>): Mesh;
  59112. }
  59113. }
  59114. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59115. import { Nullable } from "babylonjs/types";
  59116. import { Scene } from "babylonjs/scene";
  59117. import { Vector4 } from "babylonjs/Maths/math.vector";
  59118. import { Mesh } from "babylonjs/Meshes/mesh";
  59119. /**
  59120. * Class containing static functions to help procedurally build meshes
  59121. */
  59122. export class TiledPlaneBuilder {
  59123. /**
  59124. * Creates a tiled plane mesh
  59125. * * The parameter `pattern` will, depending on value, do nothing or
  59126. * * * flip (reflect about central vertical) alternate tiles across and up
  59127. * * * flip every tile on alternate rows
  59128. * * * rotate (180 degs) alternate tiles across and up
  59129. * * * rotate every tile on alternate rows
  59130. * * * flip and rotate alternate tiles across and up
  59131. * * * flip and rotate every tile on alternate rows
  59132. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59133. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59135. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59136. * * 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)
  59137. * * 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)
  59138. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59139. * @param name defines the name of the mesh
  59140. * @param options defines the options used to create the mesh
  59141. * @param scene defines the hosting scene
  59142. * @returns the box mesh
  59143. */
  59144. static CreateTiledPlane(name: string, options: {
  59145. pattern?: number;
  59146. tileSize?: number;
  59147. tileWidth?: number;
  59148. tileHeight?: number;
  59149. size?: number;
  59150. width?: number;
  59151. height?: number;
  59152. alignHorizontal?: number;
  59153. alignVertical?: number;
  59154. sideOrientation?: number;
  59155. frontUVs?: Vector4;
  59156. backUVs?: Vector4;
  59157. updatable?: boolean;
  59158. }, scene?: Nullable<Scene>): Mesh;
  59159. }
  59160. }
  59161. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59162. import { Nullable } from "babylonjs/types";
  59163. import { Scene } from "babylonjs/scene";
  59164. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59165. import { Mesh } from "babylonjs/Meshes/mesh";
  59166. /**
  59167. * Class containing static functions to help procedurally build meshes
  59168. */
  59169. export class TubeBuilder {
  59170. /**
  59171. * Creates a tube mesh.
  59172. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59173. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59174. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59175. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59176. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59177. * * 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)
  59178. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59179. * * 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
  59180. * * 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
  59181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59183. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59185. * @param name defines the name of the mesh
  59186. * @param options defines the options used to create the mesh
  59187. * @param scene defines the hosting scene
  59188. * @returns the tube mesh
  59189. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59190. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59191. */
  59192. static CreateTube(name: string, options: {
  59193. path: Vector3[];
  59194. radius?: number;
  59195. tessellation?: number;
  59196. radiusFunction?: {
  59197. (i: number, distance: number): number;
  59198. };
  59199. cap?: number;
  59200. arc?: number;
  59201. updatable?: boolean;
  59202. sideOrientation?: number;
  59203. frontUVs?: Vector4;
  59204. backUVs?: Vector4;
  59205. instance?: Mesh;
  59206. invertUV?: boolean;
  59207. }, scene?: Nullable<Scene>): Mesh;
  59208. }
  59209. }
  59210. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59211. import { Scene } from "babylonjs/scene";
  59212. import { Vector4 } from "babylonjs/Maths/math.vector";
  59213. import { Mesh } from "babylonjs/Meshes/mesh";
  59214. import { Nullable } from "babylonjs/types";
  59215. /**
  59216. * Class containing static functions to help procedurally build meshes
  59217. */
  59218. export class IcoSphereBuilder {
  59219. /**
  59220. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59221. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59222. * * 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`)
  59223. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59224. * * 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
  59225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59228. * @param name defines the name of the mesh
  59229. * @param options defines the options used to create the mesh
  59230. * @param scene defines the hosting scene
  59231. * @returns the icosahedron mesh
  59232. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59233. */
  59234. static CreateIcoSphere(name: string, options: {
  59235. radius?: number;
  59236. radiusX?: number;
  59237. radiusY?: number;
  59238. radiusZ?: number;
  59239. flat?: boolean;
  59240. subdivisions?: number;
  59241. sideOrientation?: number;
  59242. frontUVs?: Vector4;
  59243. backUVs?: Vector4;
  59244. updatable?: boolean;
  59245. }, scene?: Nullable<Scene>): Mesh;
  59246. }
  59247. }
  59248. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59249. import { Vector3 } from "babylonjs/Maths/math.vector";
  59250. import { Mesh } from "babylonjs/Meshes/mesh";
  59251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59252. /**
  59253. * Class containing static functions to help procedurally build meshes
  59254. */
  59255. export class DecalBuilder {
  59256. /**
  59257. * Creates a decal mesh.
  59258. * 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
  59259. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59260. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59261. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59262. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59263. * @param name defines the name of the mesh
  59264. * @param sourceMesh defines the mesh where the decal must be applied
  59265. * @param options defines the options used to create the mesh
  59266. * @param scene defines the hosting scene
  59267. * @returns the decal mesh
  59268. * @see https://doc.babylonjs.com/how_to/decals
  59269. */
  59270. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59271. position?: Vector3;
  59272. normal?: Vector3;
  59273. size?: Vector3;
  59274. angle?: number;
  59275. }): Mesh;
  59276. }
  59277. }
  59278. declare module "babylonjs/Meshes/meshBuilder" {
  59279. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59280. import { Nullable } from "babylonjs/types";
  59281. import { Scene } from "babylonjs/scene";
  59282. import { Mesh } from "babylonjs/Meshes/mesh";
  59283. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59284. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59286. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59287. import { Plane } from "babylonjs/Maths/math.plane";
  59288. /**
  59289. * Class containing static functions to help procedurally build meshes
  59290. */
  59291. export class MeshBuilder {
  59292. /**
  59293. * Creates a box mesh
  59294. * * The parameter `size` sets the size (float) of each box side (default 1)
  59295. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59296. * * 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)
  59297. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59301. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59302. * @param name defines the name of the mesh
  59303. * @param options defines the options used to create the mesh
  59304. * @param scene defines the hosting scene
  59305. * @returns the box mesh
  59306. */
  59307. static CreateBox(name: string, options: {
  59308. size?: number;
  59309. width?: number;
  59310. height?: number;
  59311. depth?: number;
  59312. faceUV?: Vector4[];
  59313. faceColors?: Color4[];
  59314. sideOrientation?: number;
  59315. frontUVs?: Vector4;
  59316. backUVs?: Vector4;
  59317. updatable?: boolean;
  59318. }, scene?: Nullable<Scene>): Mesh;
  59319. /**
  59320. * Creates a tiled box mesh
  59321. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59323. * @param name defines the name of the mesh
  59324. * @param options defines the options used to create the mesh
  59325. * @param scene defines the hosting scene
  59326. * @returns the tiled box mesh
  59327. */
  59328. static CreateTiledBox(name: string, options: {
  59329. pattern?: number;
  59330. size?: number;
  59331. width?: number;
  59332. height?: number;
  59333. depth: number;
  59334. tileSize?: number;
  59335. tileWidth?: number;
  59336. tileHeight?: number;
  59337. faceUV?: Vector4[];
  59338. faceColors?: Color4[];
  59339. alignHorizontal?: number;
  59340. alignVertical?: number;
  59341. sideOrientation?: number;
  59342. updatable?: boolean;
  59343. }, scene?: Nullable<Scene>): Mesh;
  59344. /**
  59345. * Creates a sphere mesh
  59346. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59347. * * 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`)
  59348. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59349. * * 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
  59350. * * 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)
  59351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59354. * @param name defines the name of the mesh
  59355. * @param options defines the options used to create the mesh
  59356. * @param scene defines the hosting scene
  59357. * @returns the sphere mesh
  59358. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59359. */
  59360. static CreateSphere(name: string, options: {
  59361. segments?: number;
  59362. diameter?: number;
  59363. diameterX?: number;
  59364. diameterY?: number;
  59365. diameterZ?: number;
  59366. arc?: number;
  59367. slice?: number;
  59368. sideOrientation?: number;
  59369. frontUVs?: Vector4;
  59370. backUVs?: Vector4;
  59371. updatable?: boolean;
  59372. }, scene?: Nullable<Scene>): Mesh;
  59373. /**
  59374. * Creates a plane polygonal mesh. By default, this is a disc
  59375. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59376. * * 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
  59377. * * 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
  59378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59379. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59381. * @param name defines the name of the mesh
  59382. * @param options defines the options used to create the mesh
  59383. * @param scene defines the hosting scene
  59384. * @returns the plane polygonal mesh
  59385. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59386. */
  59387. static CreateDisc(name: string, options: {
  59388. radius?: number;
  59389. tessellation?: number;
  59390. arc?: number;
  59391. updatable?: boolean;
  59392. sideOrientation?: number;
  59393. frontUVs?: Vector4;
  59394. backUVs?: Vector4;
  59395. }, scene?: Nullable<Scene>): Mesh;
  59396. /**
  59397. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59398. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59399. * * 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`)
  59400. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59401. * * 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
  59402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59405. * @param name defines the name of the mesh
  59406. * @param options defines the options used to create the mesh
  59407. * @param scene defines the hosting scene
  59408. * @returns the icosahedron mesh
  59409. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59410. */
  59411. static CreateIcoSphere(name: string, options: {
  59412. radius?: number;
  59413. radiusX?: number;
  59414. radiusY?: number;
  59415. radiusZ?: number;
  59416. flat?: boolean;
  59417. subdivisions?: number;
  59418. sideOrientation?: number;
  59419. frontUVs?: Vector4;
  59420. backUVs?: Vector4;
  59421. updatable?: boolean;
  59422. }, scene?: Nullable<Scene>): Mesh;
  59423. /**
  59424. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59425. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59426. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59427. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59428. * * 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
  59429. * * 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
  59430. * * 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
  59431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59433. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59434. * * 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
  59435. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59436. * * 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
  59437. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59439. * @param name defines the name of the mesh
  59440. * @param options defines the options used to create the mesh
  59441. * @param scene defines the hosting scene
  59442. * @returns the ribbon mesh
  59443. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59444. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59445. */
  59446. static CreateRibbon(name: string, options: {
  59447. pathArray: Vector3[][];
  59448. closeArray?: boolean;
  59449. closePath?: boolean;
  59450. offset?: number;
  59451. updatable?: boolean;
  59452. sideOrientation?: number;
  59453. frontUVs?: Vector4;
  59454. backUVs?: Vector4;
  59455. instance?: Mesh;
  59456. invertUV?: boolean;
  59457. uvs?: Vector2[];
  59458. colors?: Color4[];
  59459. }, scene?: Nullable<Scene>): Mesh;
  59460. /**
  59461. * Creates a cylinder or a cone mesh
  59462. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59463. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59464. * * 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.
  59465. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59466. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59467. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59468. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59469. * * 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).
  59470. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59471. * * 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).
  59472. * * 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
  59473. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59474. * * 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
  59475. * * 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.
  59476. * * If `enclose` is false, a ring surface is one element.
  59477. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59478. * * 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
  59479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59482. * @param name defines the name of the mesh
  59483. * @param options defines the options used to create the mesh
  59484. * @param scene defines the hosting scene
  59485. * @returns the cylinder mesh
  59486. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59487. */
  59488. static CreateCylinder(name: string, options: {
  59489. height?: number;
  59490. diameterTop?: number;
  59491. diameterBottom?: number;
  59492. diameter?: number;
  59493. tessellation?: number;
  59494. subdivisions?: number;
  59495. arc?: number;
  59496. faceColors?: Color4[];
  59497. faceUV?: Vector4[];
  59498. updatable?: boolean;
  59499. hasRings?: boolean;
  59500. enclose?: boolean;
  59501. cap?: number;
  59502. sideOrientation?: number;
  59503. frontUVs?: Vector4;
  59504. backUVs?: Vector4;
  59505. }, scene?: Nullable<Scene>): Mesh;
  59506. /**
  59507. * Creates a torus mesh
  59508. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59509. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59510. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59514. * @param name defines the name of the mesh
  59515. * @param options defines the options used to create the mesh
  59516. * @param scene defines the hosting scene
  59517. * @returns the torus mesh
  59518. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59519. */
  59520. static CreateTorus(name: string, options: {
  59521. diameter?: number;
  59522. thickness?: number;
  59523. tessellation?: number;
  59524. updatable?: boolean;
  59525. sideOrientation?: number;
  59526. frontUVs?: Vector4;
  59527. backUVs?: Vector4;
  59528. }, scene?: Nullable<Scene>): Mesh;
  59529. /**
  59530. * Creates a torus knot mesh
  59531. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59532. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59533. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59534. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59536. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59538. * @param name defines the name of the mesh
  59539. * @param options defines the options used to create the mesh
  59540. * @param scene defines the hosting scene
  59541. * @returns the torus knot mesh
  59542. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59543. */
  59544. static CreateTorusKnot(name: string, options: {
  59545. radius?: number;
  59546. tube?: number;
  59547. radialSegments?: number;
  59548. tubularSegments?: number;
  59549. p?: number;
  59550. q?: number;
  59551. updatable?: boolean;
  59552. sideOrientation?: number;
  59553. frontUVs?: Vector4;
  59554. backUVs?: Vector4;
  59555. }, scene?: Nullable<Scene>): Mesh;
  59556. /**
  59557. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59558. * * 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
  59559. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59560. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59561. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59562. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59563. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59564. * * 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
  59565. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59567. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59568. * @param name defines the name of the new line system
  59569. * @param options defines the options used to create the line system
  59570. * @param scene defines the hosting scene
  59571. * @returns a new line system mesh
  59572. */
  59573. static CreateLineSystem(name: string, options: {
  59574. lines: Vector3[][];
  59575. updatable?: boolean;
  59576. instance?: Nullable<LinesMesh>;
  59577. colors?: Nullable<Color4[][]>;
  59578. useVertexAlpha?: boolean;
  59579. }, scene: Nullable<Scene>): LinesMesh;
  59580. /**
  59581. * Creates a line mesh
  59582. * 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
  59583. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59584. * * The parameter `points` is an array successive Vector3
  59585. * * 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
  59586. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59587. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59588. * * When updating an instance, remember that only point positions can change, not the number of points
  59589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59591. * @param name defines the name of the new line system
  59592. * @param options defines the options used to create the line system
  59593. * @param scene defines the hosting scene
  59594. * @returns a new line mesh
  59595. */
  59596. static CreateLines(name: string, options: {
  59597. points: Vector3[];
  59598. updatable?: boolean;
  59599. instance?: Nullable<LinesMesh>;
  59600. colors?: Color4[];
  59601. useVertexAlpha?: boolean;
  59602. }, scene?: Nullable<Scene>): LinesMesh;
  59603. /**
  59604. * Creates a dashed line mesh
  59605. * * 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
  59606. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59607. * * The parameter `points` is an array successive Vector3
  59608. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59609. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59610. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59611. * * 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
  59612. * * When updating an instance, remember that only point positions can change, not the number of points
  59613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59614. * @param name defines the name of the mesh
  59615. * @param options defines the options used to create the mesh
  59616. * @param scene defines the hosting scene
  59617. * @returns the dashed line mesh
  59618. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59619. */
  59620. static CreateDashedLines(name: string, options: {
  59621. points: Vector3[];
  59622. dashSize?: number;
  59623. gapSize?: number;
  59624. dashNb?: number;
  59625. updatable?: boolean;
  59626. instance?: LinesMesh;
  59627. }, scene?: Nullable<Scene>): LinesMesh;
  59628. /**
  59629. * 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.
  59630. * * 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.
  59631. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59632. * * 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.
  59633. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59634. * * 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
  59635. * * 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
  59636. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59641. * @param name defines the name of the mesh
  59642. * @param options defines the options used to create the mesh
  59643. * @param scene defines the hosting scene
  59644. * @returns the extruded shape mesh
  59645. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59647. */
  59648. static ExtrudeShape(name: string, options: {
  59649. shape: Vector3[];
  59650. path: Vector3[];
  59651. scale?: number;
  59652. rotation?: number;
  59653. cap?: number;
  59654. updatable?: boolean;
  59655. sideOrientation?: number;
  59656. frontUVs?: Vector4;
  59657. backUVs?: Vector4;
  59658. instance?: Mesh;
  59659. invertUV?: boolean;
  59660. }, scene?: Nullable<Scene>): Mesh;
  59661. /**
  59662. * Creates an custom extruded shape mesh.
  59663. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59664. * * 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.
  59665. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59666. * * 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
  59667. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59668. * * 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
  59669. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59670. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59671. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59672. * * 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
  59673. * * 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
  59674. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59679. * @param name defines the name of the mesh
  59680. * @param options defines the options used to create the mesh
  59681. * @param scene defines the hosting scene
  59682. * @returns the custom extruded shape mesh
  59683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59684. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59686. */
  59687. static ExtrudeShapeCustom(name: string, options: {
  59688. shape: Vector3[];
  59689. path: Vector3[];
  59690. scaleFunction?: any;
  59691. rotationFunction?: any;
  59692. ribbonCloseArray?: boolean;
  59693. ribbonClosePath?: boolean;
  59694. cap?: number;
  59695. updatable?: boolean;
  59696. sideOrientation?: number;
  59697. frontUVs?: Vector4;
  59698. backUVs?: Vector4;
  59699. instance?: Mesh;
  59700. invertUV?: boolean;
  59701. }, scene?: Nullable<Scene>): Mesh;
  59702. /**
  59703. * Creates lathe mesh.
  59704. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59705. * * 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
  59706. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59707. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59708. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59709. * * 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
  59710. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59711. * * 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
  59712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59716. * @param name defines the name of the mesh
  59717. * @param options defines the options used to create the mesh
  59718. * @param scene defines the hosting scene
  59719. * @returns the lathe mesh
  59720. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59721. */
  59722. static CreateLathe(name: string, options: {
  59723. shape: Vector3[];
  59724. radius?: number;
  59725. tessellation?: number;
  59726. clip?: number;
  59727. arc?: number;
  59728. closed?: boolean;
  59729. updatable?: boolean;
  59730. sideOrientation?: number;
  59731. frontUVs?: Vector4;
  59732. backUVs?: Vector4;
  59733. cap?: number;
  59734. invertUV?: boolean;
  59735. }, scene?: Nullable<Scene>): Mesh;
  59736. /**
  59737. * Creates a tiled plane mesh
  59738. * * You can set a limited pattern arrangement with the tiles
  59739. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59742. * @param name defines the name of the mesh
  59743. * @param options defines the options used to create the mesh
  59744. * @param scene defines the hosting scene
  59745. * @returns the plane mesh
  59746. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59747. */
  59748. static CreateTiledPlane(name: string, options: {
  59749. pattern?: number;
  59750. tileSize?: number;
  59751. tileWidth?: number;
  59752. tileHeight?: number;
  59753. size?: number;
  59754. width?: number;
  59755. height?: number;
  59756. alignHorizontal?: number;
  59757. alignVertical?: number;
  59758. sideOrientation?: number;
  59759. frontUVs?: Vector4;
  59760. backUVs?: Vector4;
  59761. updatable?: boolean;
  59762. }, scene?: Nullable<Scene>): Mesh;
  59763. /**
  59764. * Creates a plane mesh
  59765. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59766. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59767. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59768. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59769. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59771. * @param name defines the name of the mesh
  59772. * @param options defines the options used to create the mesh
  59773. * @param scene defines the hosting scene
  59774. * @returns the plane mesh
  59775. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59776. */
  59777. static CreatePlane(name: string, options: {
  59778. size?: number;
  59779. width?: number;
  59780. height?: number;
  59781. sideOrientation?: number;
  59782. frontUVs?: Vector4;
  59783. backUVs?: Vector4;
  59784. updatable?: boolean;
  59785. sourcePlane?: Plane;
  59786. }, scene?: Nullable<Scene>): Mesh;
  59787. /**
  59788. * Creates a ground mesh
  59789. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59790. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59792. * @param name defines the name of the mesh
  59793. * @param options defines the options used to create the mesh
  59794. * @param scene defines the hosting scene
  59795. * @returns the ground mesh
  59796. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59797. */
  59798. static CreateGround(name: string, options: {
  59799. width?: number;
  59800. height?: number;
  59801. subdivisions?: number;
  59802. subdivisionsX?: number;
  59803. subdivisionsY?: number;
  59804. updatable?: boolean;
  59805. }, scene?: Nullable<Scene>): Mesh;
  59806. /**
  59807. * Creates a tiled ground mesh
  59808. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59809. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59810. * * 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
  59811. * * 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
  59812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59813. * @param name defines the name of the mesh
  59814. * @param options defines the options used to create the mesh
  59815. * @param scene defines the hosting scene
  59816. * @returns the tiled ground mesh
  59817. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59818. */
  59819. static CreateTiledGround(name: string, options: {
  59820. xmin: number;
  59821. zmin: number;
  59822. xmax: number;
  59823. zmax: number;
  59824. subdivisions?: {
  59825. w: number;
  59826. h: number;
  59827. };
  59828. precision?: {
  59829. w: number;
  59830. h: number;
  59831. };
  59832. updatable?: boolean;
  59833. }, scene?: Nullable<Scene>): Mesh;
  59834. /**
  59835. * Creates a ground mesh from a height map
  59836. * * The parameter `url` sets the URL of the height map image resource.
  59837. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59838. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59839. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59840. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59841. * * 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.
  59842. * * 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).
  59843. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59845. * @param name defines the name of the mesh
  59846. * @param url defines the url to the height map
  59847. * @param options defines the options used to create the mesh
  59848. * @param scene defines the hosting scene
  59849. * @returns the ground mesh
  59850. * @see https://doc.babylonjs.com/babylon101/height_map
  59851. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59852. */
  59853. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59854. width?: number;
  59855. height?: number;
  59856. subdivisions?: number;
  59857. minHeight?: number;
  59858. maxHeight?: number;
  59859. colorFilter?: Color3;
  59860. alphaFilter?: number;
  59861. updatable?: boolean;
  59862. onReady?: (mesh: GroundMesh) => void;
  59863. }, scene?: Nullable<Scene>): GroundMesh;
  59864. /**
  59865. * Creates a polygon mesh
  59866. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59867. * * 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
  59868. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59871. * * Remember you can only change the shape positions, not their number when updating a polygon
  59872. * @param name defines the name of the mesh
  59873. * @param options defines the options used to create the mesh
  59874. * @param scene defines the hosting scene
  59875. * @param earcutInjection can be used to inject your own earcut reference
  59876. * @returns the polygon mesh
  59877. */
  59878. static CreatePolygon(name: string, options: {
  59879. shape: Vector3[];
  59880. holes?: Vector3[][];
  59881. depth?: number;
  59882. faceUV?: Vector4[];
  59883. faceColors?: Color4[];
  59884. updatable?: boolean;
  59885. sideOrientation?: number;
  59886. frontUVs?: Vector4;
  59887. backUVs?: Vector4;
  59888. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59889. /**
  59890. * Creates an extruded polygon mesh, with depth in the Y direction.
  59891. * * 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)
  59892. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59893. * @param name defines the name of the mesh
  59894. * @param options defines the options used to create the mesh
  59895. * @param scene defines the hosting scene
  59896. * @param earcutInjection can be used to inject your own earcut reference
  59897. * @returns the polygon mesh
  59898. */
  59899. static ExtrudePolygon(name: string, options: {
  59900. shape: Vector3[];
  59901. holes?: Vector3[][];
  59902. depth?: number;
  59903. faceUV?: Vector4[];
  59904. faceColors?: Color4[];
  59905. updatable?: boolean;
  59906. sideOrientation?: number;
  59907. frontUVs?: Vector4;
  59908. backUVs?: Vector4;
  59909. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59910. /**
  59911. * Creates a tube mesh.
  59912. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59913. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59914. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59915. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59916. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59917. * * 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)
  59918. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59919. * * 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
  59920. * * 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
  59921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59923. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59925. * @param name defines the name of the mesh
  59926. * @param options defines the options used to create the mesh
  59927. * @param scene defines the hosting scene
  59928. * @returns the tube mesh
  59929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59930. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59931. */
  59932. static CreateTube(name: string, options: {
  59933. path: Vector3[];
  59934. radius?: number;
  59935. tessellation?: number;
  59936. radiusFunction?: {
  59937. (i: number, distance: number): number;
  59938. };
  59939. cap?: number;
  59940. arc?: number;
  59941. updatable?: boolean;
  59942. sideOrientation?: number;
  59943. frontUVs?: Vector4;
  59944. backUVs?: Vector4;
  59945. instance?: Mesh;
  59946. invertUV?: boolean;
  59947. }, scene?: Nullable<Scene>): Mesh;
  59948. /**
  59949. * Creates a polyhedron mesh
  59950. * * 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
  59951. * * The parameter `size` (positive float, default 1) sets the polygon size
  59952. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59953. * * 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`
  59954. * * 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
  59955. * * 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)`)
  59956. * * 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
  59957. * * 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
  59958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59961. * @param name defines the name of the mesh
  59962. * @param options defines the options used to create the mesh
  59963. * @param scene defines the hosting scene
  59964. * @returns the polyhedron mesh
  59965. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59966. */
  59967. static CreatePolyhedron(name: string, options: {
  59968. type?: number;
  59969. size?: number;
  59970. sizeX?: number;
  59971. sizeY?: number;
  59972. sizeZ?: number;
  59973. custom?: any;
  59974. faceUV?: Vector4[];
  59975. faceColors?: Color4[];
  59976. flat?: boolean;
  59977. updatable?: boolean;
  59978. sideOrientation?: number;
  59979. frontUVs?: Vector4;
  59980. backUVs?: Vector4;
  59981. }, scene?: Nullable<Scene>): Mesh;
  59982. /**
  59983. * Creates a decal mesh.
  59984. * 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
  59985. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59986. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59987. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59988. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59989. * @param name defines the name of the mesh
  59990. * @param sourceMesh defines the mesh where the decal must be applied
  59991. * @param options defines the options used to create the mesh
  59992. * @param scene defines the hosting scene
  59993. * @returns the decal mesh
  59994. * @see https://doc.babylonjs.com/how_to/decals
  59995. */
  59996. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59997. position?: Vector3;
  59998. normal?: Vector3;
  59999. size?: Vector3;
  60000. angle?: number;
  60001. }): Mesh;
  60002. }
  60003. }
  60004. declare module "babylonjs/Meshes/meshSimplification" {
  60005. import { Mesh } from "babylonjs/Meshes/mesh";
  60006. /**
  60007. * A simplifier interface for future simplification implementations
  60008. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60009. */
  60010. export interface ISimplifier {
  60011. /**
  60012. * Simplification of a given mesh according to the given settings.
  60013. * Since this requires computation, it is assumed that the function runs async.
  60014. * @param settings The settings of the simplification, including quality and distance
  60015. * @param successCallback A callback that will be called after the mesh was simplified.
  60016. * @param errorCallback in case of an error, this callback will be called. optional.
  60017. */
  60018. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60019. }
  60020. /**
  60021. * Expected simplification settings.
  60022. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60023. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60024. */
  60025. export interface ISimplificationSettings {
  60026. /**
  60027. * Gets or sets the expected quality
  60028. */
  60029. quality: number;
  60030. /**
  60031. * Gets or sets the distance when this optimized version should be used
  60032. */
  60033. distance: number;
  60034. /**
  60035. * Gets an already optimized mesh
  60036. */
  60037. optimizeMesh?: boolean;
  60038. }
  60039. /**
  60040. * Class used to specify simplification options
  60041. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60042. */
  60043. export class SimplificationSettings implements ISimplificationSettings {
  60044. /** expected quality */
  60045. quality: number;
  60046. /** distance when this optimized version should be used */
  60047. distance: number;
  60048. /** already optimized mesh */
  60049. optimizeMesh?: boolean | undefined;
  60050. /**
  60051. * Creates a SimplificationSettings
  60052. * @param quality expected quality
  60053. * @param distance distance when this optimized version should be used
  60054. * @param optimizeMesh already optimized mesh
  60055. */
  60056. constructor(
  60057. /** expected quality */
  60058. quality: number,
  60059. /** distance when this optimized version should be used */
  60060. distance: number,
  60061. /** already optimized mesh */
  60062. optimizeMesh?: boolean | undefined);
  60063. }
  60064. /**
  60065. * Interface used to define a simplification task
  60066. */
  60067. export interface ISimplificationTask {
  60068. /**
  60069. * Array of settings
  60070. */
  60071. settings: Array<ISimplificationSettings>;
  60072. /**
  60073. * Simplification type
  60074. */
  60075. simplificationType: SimplificationType;
  60076. /**
  60077. * Mesh to simplify
  60078. */
  60079. mesh: Mesh;
  60080. /**
  60081. * Callback called on success
  60082. */
  60083. successCallback?: () => void;
  60084. /**
  60085. * Defines if parallel processing can be used
  60086. */
  60087. parallelProcessing: boolean;
  60088. }
  60089. /**
  60090. * Queue used to order the simplification tasks
  60091. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60092. */
  60093. export class SimplificationQueue {
  60094. private _simplificationArray;
  60095. /**
  60096. * Gets a boolean indicating that the process is still running
  60097. */
  60098. running: boolean;
  60099. /**
  60100. * Creates a new queue
  60101. */
  60102. constructor();
  60103. /**
  60104. * Adds a new simplification task
  60105. * @param task defines a task to add
  60106. */
  60107. addTask(task: ISimplificationTask): void;
  60108. /**
  60109. * Execute next task
  60110. */
  60111. executeNext(): void;
  60112. /**
  60113. * Execute a simplification task
  60114. * @param task defines the task to run
  60115. */
  60116. runSimplification(task: ISimplificationTask): void;
  60117. private getSimplifier;
  60118. }
  60119. /**
  60120. * The implemented types of simplification
  60121. * At the moment only Quadratic Error Decimation is implemented
  60122. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60123. */
  60124. export enum SimplificationType {
  60125. /** Quadratic error decimation */
  60126. QUADRATIC = 0
  60127. }
  60128. }
  60129. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60130. import { Scene } from "babylonjs/scene";
  60131. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60132. import { ISceneComponent } from "babylonjs/sceneComponent";
  60133. module "babylonjs/scene" {
  60134. interface Scene {
  60135. /** @hidden (Backing field) */
  60136. _simplificationQueue: SimplificationQueue;
  60137. /**
  60138. * Gets or sets the simplification queue attached to the scene
  60139. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60140. */
  60141. simplificationQueue: SimplificationQueue;
  60142. }
  60143. }
  60144. module "babylonjs/Meshes/mesh" {
  60145. interface Mesh {
  60146. /**
  60147. * Simplify the mesh according to the given array of settings.
  60148. * Function will return immediately and will simplify async
  60149. * @param settings a collection of simplification settings
  60150. * @param parallelProcessing should all levels calculate parallel or one after the other
  60151. * @param simplificationType the type of simplification to run
  60152. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60153. * @returns the current mesh
  60154. */
  60155. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60156. }
  60157. }
  60158. /**
  60159. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60160. * created in a scene
  60161. */
  60162. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60163. /**
  60164. * The component name helpfull to identify the component in the list of scene components.
  60165. */
  60166. readonly name: string;
  60167. /**
  60168. * The scene the component belongs to.
  60169. */
  60170. scene: Scene;
  60171. /**
  60172. * Creates a new instance of the component for the given scene
  60173. * @param scene Defines the scene to register the component in
  60174. */
  60175. constructor(scene: Scene);
  60176. /**
  60177. * Registers the component in a given scene
  60178. */
  60179. register(): void;
  60180. /**
  60181. * Rebuilds the elements related to this component in case of
  60182. * context lost for instance.
  60183. */
  60184. rebuild(): void;
  60185. /**
  60186. * Disposes the component and the associated ressources
  60187. */
  60188. dispose(): void;
  60189. private _beforeCameraUpdate;
  60190. }
  60191. }
  60192. declare module "babylonjs/Meshes/Builders/index" {
  60193. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60194. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60195. export * from "babylonjs/Meshes/Builders/discBuilder";
  60196. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60197. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60198. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60199. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60200. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60201. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60202. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60203. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60204. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60205. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60206. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60207. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60208. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60209. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60210. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60211. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60212. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60213. }
  60214. declare module "babylonjs/Meshes/index" {
  60215. export * from "babylonjs/Meshes/abstractMesh";
  60216. export * from "babylonjs/Meshes/buffer";
  60217. export * from "babylonjs/Meshes/Compression/index";
  60218. export * from "babylonjs/Meshes/csg";
  60219. export * from "babylonjs/Meshes/geometry";
  60220. export * from "babylonjs/Meshes/groundMesh";
  60221. export * from "babylonjs/Meshes/trailMesh";
  60222. export * from "babylonjs/Meshes/instancedMesh";
  60223. export * from "babylonjs/Meshes/linesMesh";
  60224. export * from "babylonjs/Meshes/mesh";
  60225. export * from "babylonjs/Meshes/mesh.vertexData";
  60226. export * from "babylonjs/Meshes/meshBuilder";
  60227. export * from "babylonjs/Meshes/meshSimplification";
  60228. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60229. export * from "babylonjs/Meshes/polygonMesh";
  60230. export * from "babylonjs/Meshes/subMesh";
  60231. export * from "babylonjs/Meshes/meshLODLevel";
  60232. export * from "babylonjs/Meshes/transformNode";
  60233. export * from "babylonjs/Meshes/Builders/index";
  60234. export * from "babylonjs/Meshes/dataBuffer";
  60235. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60236. }
  60237. declare module "babylonjs/Morph/index" {
  60238. export * from "babylonjs/Morph/morphTarget";
  60239. export * from "babylonjs/Morph/morphTargetManager";
  60240. }
  60241. declare module "babylonjs/Navigation/INavigationEngine" {
  60242. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60243. import { Vector3 } from "babylonjs/Maths/math";
  60244. import { Mesh } from "babylonjs/Meshes/mesh";
  60245. import { Scene } from "babylonjs/scene";
  60246. /**
  60247. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60248. */
  60249. export interface INavigationEnginePlugin {
  60250. /**
  60251. * plugin name
  60252. */
  60253. name: string;
  60254. /**
  60255. * Creates a navigation mesh
  60256. * @param meshes array of all the geometry used to compute the navigatio mesh
  60257. * @param parameters bunch of parameters used to filter geometry
  60258. */
  60259. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60260. /**
  60261. * Create a navigation mesh debug mesh
  60262. * @param scene is where the mesh will be added
  60263. * @returns debug display mesh
  60264. */
  60265. createDebugNavMesh(scene: Scene): Mesh;
  60266. /**
  60267. * Get a navigation mesh constrained position, closest to the parameter position
  60268. * @param position world position
  60269. * @returns the closest point to position constrained by the navigation mesh
  60270. */
  60271. getClosestPoint(position: Vector3): Vector3;
  60272. /**
  60273. * Get a navigation mesh constrained position, within a particular radius
  60274. * @param position world position
  60275. * @param maxRadius the maximum distance to the constrained world position
  60276. * @returns the closest point to position constrained by the navigation mesh
  60277. */
  60278. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60279. /**
  60280. * Compute the final position from a segment made of destination-position
  60281. * @param position world position
  60282. * @param destination world position
  60283. * @returns the resulting point along the navmesh
  60284. */
  60285. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60286. /**
  60287. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60288. * @param start world position
  60289. * @param end world position
  60290. * @returns array containing world position composing the path
  60291. */
  60292. computePath(start: Vector3, end: Vector3): Vector3[];
  60293. /**
  60294. * If this plugin is supported
  60295. * @returns true if plugin is supported
  60296. */
  60297. isSupported(): boolean;
  60298. /**
  60299. * Create a new Crowd so you can add agents
  60300. * @param maxAgents the maximum agent count in the crowd
  60301. * @param maxAgentRadius the maximum radius an agent can have
  60302. * @param scene to attach the crowd to
  60303. * @returns the crowd you can add agents to
  60304. */
  60305. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60306. /**
  60307. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60308. * The queries will try to find a solution within those bounds
  60309. * default is (1,1,1)
  60310. * @param extent x,y,z value that define the extent around the queries point of reference
  60311. */
  60312. setDefaultQueryExtent(extent: Vector3): void;
  60313. /**
  60314. * Get the Bounding box extent specified by setDefaultQueryExtent
  60315. * @returns the box extent values
  60316. */
  60317. getDefaultQueryExtent(): Vector3;
  60318. /**
  60319. * Release all resources
  60320. */
  60321. dispose(): void;
  60322. }
  60323. /**
  60324. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60325. */
  60326. export interface ICrowd {
  60327. /**
  60328. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60329. * You can attach anything to that node. The node position is updated in the scene update tick.
  60330. * @param pos world position that will be constrained by the navigation mesh
  60331. * @param parameters agent parameters
  60332. * @param transform hooked to the agent that will be update by the scene
  60333. * @returns agent index
  60334. */
  60335. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60336. /**
  60337. * Returns the agent position in world space
  60338. * @param index agent index returned by addAgent
  60339. * @returns world space position
  60340. */
  60341. getAgentPosition(index: number): Vector3;
  60342. /**
  60343. * Gets the agent velocity in world space
  60344. * @param index agent index returned by addAgent
  60345. * @returns world space velocity
  60346. */
  60347. getAgentVelocity(index: number): Vector3;
  60348. /**
  60349. * remove a particular agent previously created
  60350. * @param index agent index returned by addAgent
  60351. */
  60352. removeAgent(index: number): void;
  60353. /**
  60354. * get the list of all agents attached to this crowd
  60355. * @returns list of agent indices
  60356. */
  60357. getAgents(): number[];
  60358. /**
  60359. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60360. * @param deltaTime in seconds
  60361. */
  60362. update(deltaTime: number): void;
  60363. /**
  60364. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60365. * @param index agent index returned by addAgent
  60366. * @param destination targeted world position
  60367. */
  60368. agentGoto(index: number, destination: Vector3): void;
  60369. /**
  60370. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60371. * The queries will try to find a solution within those bounds
  60372. * default is (1,1,1)
  60373. * @param extent x,y,z value that define the extent around the queries point of reference
  60374. */
  60375. setDefaultQueryExtent(extent: Vector3): void;
  60376. /**
  60377. * Get the Bounding box extent specified by setDefaultQueryExtent
  60378. * @returns the box extent values
  60379. */
  60380. getDefaultQueryExtent(): Vector3;
  60381. /**
  60382. * Release all resources
  60383. */
  60384. dispose(): void;
  60385. }
  60386. /**
  60387. * Configures an agent
  60388. */
  60389. export interface IAgentParameters {
  60390. /**
  60391. * Agent radius. [Limit: >= 0]
  60392. */
  60393. radius: number;
  60394. /**
  60395. * Agent height. [Limit: > 0]
  60396. */
  60397. height: number;
  60398. /**
  60399. * Maximum allowed acceleration. [Limit: >= 0]
  60400. */
  60401. maxAcceleration: number;
  60402. /**
  60403. * Maximum allowed speed. [Limit: >= 0]
  60404. */
  60405. maxSpeed: number;
  60406. /**
  60407. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60408. */
  60409. collisionQueryRange: number;
  60410. /**
  60411. * The path visibility optimization range. [Limit: > 0]
  60412. */
  60413. pathOptimizationRange: number;
  60414. /**
  60415. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60416. */
  60417. separationWeight: number;
  60418. }
  60419. /**
  60420. * Configures the navigation mesh creation
  60421. */
  60422. export interface INavMeshParameters {
  60423. /**
  60424. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60425. */
  60426. cs: number;
  60427. /**
  60428. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60429. */
  60430. ch: number;
  60431. /**
  60432. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60433. */
  60434. walkableSlopeAngle: number;
  60435. /**
  60436. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60437. * be considered walkable. [Limit: >= 3] [Units: vx]
  60438. */
  60439. walkableHeight: number;
  60440. /**
  60441. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60442. */
  60443. walkableClimb: number;
  60444. /**
  60445. * The distance to erode/shrink the walkable area of the heightfield away from
  60446. * obstructions. [Limit: >=0] [Units: vx]
  60447. */
  60448. walkableRadius: number;
  60449. /**
  60450. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60451. */
  60452. maxEdgeLen: number;
  60453. /**
  60454. * The maximum distance a simplfied contour's border edges should deviate
  60455. * the original raw contour. [Limit: >=0] [Units: vx]
  60456. */
  60457. maxSimplificationError: number;
  60458. /**
  60459. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60460. */
  60461. minRegionArea: number;
  60462. /**
  60463. * Any regions with a span count smaller than this value will, if possible,
  60464. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60465. */
  60466. mergeRegionArea: number;
  60467. /**
  60468. * The maximum number of vertices allowed for polygons generated during the
  60469. * contour to polygon conversion process. [Limit: >= 3]
  60470. */
  60471. maxVertsPerPoly: number;
  60472. /**
  60473. * Sets the sampling distance to use when generating the detail mesh.
  60474. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60475. */
  60476. detailSampleDist: number;
  60477. /**
  60478. * The maximum distance the detail mesh surface should deviate from heightfield
  60479. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60480. */
  60481. detailSampleMaxError: number;
  60482. }
  60483. }
  60484. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60485. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60486. import { Mesh } from "babylonjs/Meshes/mesh";
  60487. import { Scene } from "babylonjs/scene";
  60488. import { Vector3 } from "babylonjs/Maths/math";
  60489. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60490. /**
  60491. * RecastJS navigation plugin
  60492. */
  60493. export class RecastJSPlugin implements INavigationEnginePlugin {
  60494. /**
  60495. * Reference to the Recast library
  60496. */
  60497. bjsRECAST: any;
  60498. /**
  60499. * plugin name
  60500. */
  60501. name: string;
  60502. /**
  60503. * the first navmesh created. We might extend this to support multiple navmeshes
  60504. */
  60505. navMesh: any;
  60506. /**
  60507. * Initializes the recastJS plugin
  60508. * @param recastInjection can be used to inject your own recast reference
  60509. */
  60510. constructor(recastInjection?: any);
  60511. /**
  60512. * Creates a navigation mesh
  60513. * @param meshes array of all the geometry used to compute the navigatio mesh
  60514. * @param parameters bunch of parameters used to filter geometry
  60515. */
  60516. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60517. /**
  60518. * Create a navigation mesh debug mesh
  60519. * @param scene is where the mesh will be added
  60520. * @returns debug display mesh
  60521. */
  60522. createDebugNavMesh(scene: Scene): Mesh;
  60523. /**
  60524. * Get a navigation mesh constrained position, closest to the parameter position
  60525. * @param position world position
  60526. * @returns the closest point to position constrained by the navigation mesh
  60527. */
  60528. getClosestPoint(position: Vector3): Vector3;
  60529. /**
  60530. * Get a navigation mesh constrained position, within a particular radius
  60531. * @param position world position
  60532. * @param maxRadius the maximum distance to the constrained world position
  60533. * @returns the closest point to position constrained by the navigation mesh
  60534. */
  60535. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60536. /**
  60537. * Compute the final position from a segment made of destination-position
  60538. * @param position world position
  60539. * @param destination world position
  60540. * @returns the resulting point along the navmesh
  60541. */
  60542. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60543. /**
  60544. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60545. * @param start world position
  60546. * @param end world position
  60547. * @returns array containing world position composing the path
  60548. */
  60549. computePath(start: Vector3, end: Vector3): Vector3[];
  60550. /**
  60551. * Create a new Crowd so you can add agents
  60552. * @param maxAgents the maximum agent count in the crowd
  60553. * @param maxAgentRadius the maximum radius an agent can have
  60554. * @param scene to attach the crowd to
  60555. * @returns the crowd you can add agents to
  60556. */
  60557. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60558. /**
  60559. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60560. * The queries will try to find a solution within those bounds
  60561. * default is (1,1,1)
  60562. * @param extent x,y,z value that define the extent around the queries point of reference
  60563. */
  60564. setDefaultQueryExtent(extent: Vector3): void;
  60565. /**
  60566. * Get the Bounding box extent specified by setDefaultQueryExtent
  60567. * @returns the box extent values
  60568. */
  60569. getDefaultQueryExtent(): Vector3;
  60570. /**
  60571. * Disposes
  60572. */
  60573. dispose(): void;
  60574. /**
  60575. * If this plugin is supported
  60576. * @returns true if plugin is supported
  60577. */
  60578. isSupported(): boolean;
  60579. }
  60580. /**
  60581. * Recast detour crowd implementation
  60582. */
  60583. export class RecastJSCrowd implements ICrowd {
  60584. /**
  60585. * Recast/detour plugin
  60586. */
  60587. bjsRECASTPlugin: RecastJSPlugin;
  60588. /**
  60589. * Link to the detour crowd
  60590. */
  60591. recastCrowd: any;
  60592. /**
  60593. * One transform per agent
  60594. */
  60595. transforms: TransformNode[];
  60596. /**
  60597. * All agents created
  60598. */
  60599. agents: number[];
  60600. /**
  60601. * Link to the scene is kept to unregister the crowd from the scene
  60602. */
  60603. private _scene;
  60604. /**
  60605. * Observer for crowd updates
  60606. */
  60607. private _onBeforeAnimationsObserver;
  60608. /**
  60609. * Constructor
  60610. * @param plugin recastJS plugin
  60611. * @param maxAgents the maximum agent count in the crowd
  60612. * @param maxAgentRadius the maximum radius an agent can have
  60613. * @param scene to attach the crowd to
  60614. * @returns the crowd you can add agents to
  60615. */
  60616. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60617. /**
  60618. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60619. * You can attach anything to that node. The node position is updated in the scene update tick.
  60620. * @param pos world position that will be constrained by the navigation mesh
  60621. * @param parameters agent parameters
  60622. * @param transform hooked to the agent that will be update by the scene
  60623. * @returns agent index
  60624. */
  60625. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60626. /**
  60627. * Returns the agent position in world space
  60628. * @param index agent index returned by addAgent
  60629. * @returns world space position
  60630. */
  60631. getAgentPosition(index: number): Vector3;
  60632. /**
  60633. * Returns the agent velocity in world space
  60634. * @param index agent index returned by addAgent
  60635. * @returns world space velocity
  60636. */
  60637. getAgentVelocity(index: number): Vector3;
  60638. /**
  60639. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60640. * @param index agent index returned by addAgent
  60641. * @param destination targeted world position
  60642. */
  60643. agentGoto(index: number, destination: Vector3): void;
  60644. /**
  60645. * remove a particular agent previously created
  60646. * @param index agent index returned by addAgent
  60647. */
  60648. removeAgent(index: number): void;
  60649. /**
  60650. * get the list of all agents attached to this crowd
  60651. * @returns list of agent indices
  60652. */
  60653. getAgents(): number[];
  60654. /**
  60655. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60656. * @param deltaTime in seconds
  60657. */
  60658. update(deltaTime: number): void;
  60659. /**
  60660. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60661. * The queries will try to find a solution within those bounds
  60662. * default is (1,1,1)
  60663. * @param extent x,y,z value that define the extent around the queries point of reference
  60664. */
  60665. setDefaultQueryExtent(extent: Vector3): void;
  60666. /**
  60667. * Get the Bounding box extent specified by setDefaultQueryExtent
  60668. * @returns the box extent values
  60669. */
  60670. getDefaultQueryExtent(): Vector3;
  60671. /**
  60672. * Release all resources
  60673. */
  60674. dispose(): void;
  60675. }
  60676. }
  60677. declare module "babylonjs/Navigation/Plugins/index" {
  60678. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60679. }
  60680. declare module "babylonjs/Navigation/index" {
  60681. export * from "babylonjs/Navigation/INavigationEngine";
  60682. export * from "babylonjs/Navigation/Plugins/index";
  60683. }
  60684. declare module "babylonjs/Offline/database" {
  60685. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60686. /**
  60687. * Class used to enable access to IndexedDB
  60688. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60689. */
  60690. export class Database implements IOfflineProvider {
  60691. private _callbackManifestChecked;
  60692. private _currentSceneUrl;
  60693. private _db;
  60694. private _enableSceneOffline;
  60695. private _enableTexturesOffline;
  60696. private _manifestVersionFound;
  60697. private _mustUpdateRessources;
  60698. private _hasReachedQuota;
  60699. private _isSupported;
  60700. private _idbFactory;
  60701. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60702. private static IsUASupportingBlobStorage;
  60703. /**
  60704. * Gets a boolean indicating if Database storate is enabled (off by default)
  60705. */
  60706. static IDBStorageEnabled: boolean;
  60707. /**
  60708. * Gets a boolean indicating if scene must be saved in the database
  60709. */
  60710. readonly enableSceneOffline: boolean;
  60711. /**
  60712. * Gets a boolean indicating if textures must be saved in the database
  60713. */
  60714. readonly enableTexturesOffline: boolean;
  60715. /**
  60716. * Creates a new Database
  60717. * @param urlToScene defines the url to load the scene
  60718. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60719. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60720. */
  60721. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60722. private static _ParseURL;
  60723. private static _ReturnFullUrlLocation;
  60724. private _checkManifestFile;
  60725. /**
  60726. * Open the database and make it available
  60727. * @param successCallback defines the callback to call on success
  60728. * @param errorCallback defines the callback to call on error
  60729. */
  60730. open(successCallback: () => void, errorCallback: () => void): void;
  60731. /**
  60732. * Loads an image from the database
  60733. * @param url defines the url to load from
  60734. * @param image defines the target DOM image
  60735. */
  60736. loadImage(url: string, image: HTMLImageElement): void;
  60737. private _loadImageFromDBAsync;
  60738. private _saveImageIntoDBAsync;
  60739. private _checkVersionFromDB;
  60740. private _loadVersionFromDBAsync;
  60741. private _saveVersionIntoDBAsync;
  60742. /**
  60743. * Loads a file from database
  60744. * @param url defines the URL to load from
  60745. * @param sceneLoaded defines a callback to call on success
  60746. * @param progressCallBack defines a callback to call when progress changed
  60747. * @param errorCallback defines a callback to call on error
  60748. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60749. */
  60750. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60751. private _loadFileAsync;
  60752. private _saveFileAsync;
  60753. /**
  60754. * Validates if xhr data is correct
  60755. * @param xhr defines the request to validate
  60756. * @param dataType defines the expected data type
  60757. * @returns true if data is correct
  60758. */
  60759. private static _ValidateXHRData;
  60760. }
  60761. }
  60762. declare module "babylonjs/Offline/index" {
  60763. export * from "babylonjs/Offline/database";
  60764. export * from "babylonjs/Offline/IOfflineProvider";
  60765. }
  60766. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60767. /** @hidden */
  60768. export var gpuUpdateParticlesPixelShader: {
  60769. name: string;
  60770. shader: string;
  60771. };
  60772. }
  60773. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60774. /** @hidden */
  60775. export var gpuUpdateParticlesVertexShader: {
  60776. name: string;
  60777. shader: string;
  60778. };
  60779. }
  60780. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60781. /** @hidden */
  60782. export var clipPlaneFragmentDeclaration2: {
  60783. name: string;
  60784. shader: string;
  60785. };
  60786. }
  60787. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60788. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60789. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60790. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60791. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60792. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60793. /** @hidden */
  60794. export var gpuRenderParticlesPixelShader: {
  60795. name: string;
  60796. shader: string;
  60797. };
  60798. }
  60799. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60800. /** @hidden */
  60801. export var clipPlaneVertexDeclaration2: {
  60802. name: string;
  60803. shader: string;
  60804. };
  60805. }
  60806. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60807. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60808. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60809. /** @hidden */
  60810. export var gpuRenderParticlesVertexShader: {
  60811. name: string;
  60812. shader: string;
  60813. };
  60814. }
  60815. declare module "babylonjs/Particles/gpuParticleSystem" {
  60816. import { Nullable } from "babylonjs/types";
  60817. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60818. import { Observable } from "babylonjs/Misc/observable";
  60819. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60820. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60821. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60822. import { Scene, IDisposable } from "babylonjs/scene";
  60823. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60824. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60825. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60826. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60827. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60828. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60829. /**
  60830. * This represents a GPU particle system in Babylon
  60831. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60832. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60833. */
  60834. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60835. /**
  60836. * The layer mask we are rendering the particles through.
  60837. */
  60838. layerMask: number;
  60839. private _capacity;
  60840. private _activeCount;
  60841. private _currentActiveCount;
  60842. private _accumulatedCount;
  60843. private _renderEffect;
  60844. private _updateEffect;
  60845. private _buffer0;
  60846. private _buffer1;
  60847. private _spriteBuffer;
  60848. private _updateVAO;
  60849. private _renderVAO;
  60850. private _targetIndex;
  60851. private _sourceBuffer;
  60852. private _targetBuffer;
  60853. private _engine;
  60854. private _currentRenderId;
  60855. private _started;
  60856. private _stopped;
  60857. private _timeDelta;
  60858. private _randomTexture;
  60859. private _randomTexture2;
  60860. private _attributesStrideSize;
  60861. private _updateEffectOptions;
  60862. private _randomTextureSize;
  60863. private _actualFrame;
  60864. private readonly _rawTextureWidth;
  60865. /**
  60866. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60867. */
  60868. static readonly IsSupported: boolean;
  60869. /**
  60870. * An event triggered when the system is disposed.
  60871. */
  60872. onDisposeObservable: Observable<GPUParticleSystem>;
  60873. /**
  60874. * Gets the maximum number of particles active at the same time.
  60875. * @returns The max number of active particles.
  60876. */
  60877. getCapacity(): number;
  60878. /**
  60879. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60880. * to override the particles.
  60881. */
  60882. forceDepthWrite: boolean;
  60883. /**
  60884. * Gets or set the number of active particles
  60885. */
  60886. activeParticleCount: number;
  60887. private _preWarmDone;
  60888. /**
  60889. * Is this system ready to be used/rendered
  60890. * @return true if the system is ready
  60891. */
  60892. isReady(): boolean;
  60893. /**
  60894. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60895. * @returns True if it has been started, otherwise false.
  60896. */
  60897. isStarted(): boolean;
  60898. /**
  60899. * Starts the particle system and begins to emit
  60900. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60901. */
  60902. start(delay?: number): void;
  60903. /**
  60904. * Stops the particle system.
  60905. */
  60906. stop(): void;
  60907. /**
  60908. * Remove all active particles
  60909. */
  60910. reset(): void;
  60911. /**
  60912. * Returns the string "GPUParticleSystem"
  60913. * @returns a string containing the class name
  60914. */
  60915. getClassName(): string;
  60916. private _colorGradientsTexture;
  60917. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60918. /**
  60919. * Adds a new color gradient
  60920. * @param gradient defines the gradient to use (between 0 and 1)
  60921. * @param color1 defines the color to affect to the specified gradient
  60922. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60923. * @returns the current particle system
  60924. */
  60925. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60926. /**
  60927. * Remove a specific color gradient
  60928. * @param gradient defines the gradient to remove
  60929. * @returns the current particle system
  60930. */
  60931. removeColorGradient(gradient: number): GPUParticleSystem;
  60932. private _angularSpeedGradientsTexture;
  60933. private _sizeGradientsTexture;
  60934. private _velocityGradientsTexture;
  60935. private _limitVelocityGradientsTexture;
  60936. private _dragGradientsTexture;
  60937. private _addFactorGradient;
  60938. /**
  60939. * Adds a new size gradient
  60940. * @param gradient defines the gradient to use (between 0 and 1)
  60941. * @param factor defines the size factor to affect to the specified gradient
  60942. * @returns the current particle system
  60943. */
  60944. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60945. /**
  60946. * Remove a specific size gradient
  60947. * @param gradient defines the gradient to remove
  60948. * @returns the current particle system
  60949. */
  60950. removeSizeGradient(gradient: number): GPUParticleSystem;
  60951. /**
  60952. * Adds a new angular speed gradient
  60953. * @param gradient defines the gradient to use (between 0 and 1)
  60954. * @param factor defines the angular speed to affect to the specified gradient
  60955. * @returns the current particle system
  60956. */
  60957. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60958. /**
  60959. * Remove a specific angular speed gradient
  60960. * @param gradient defines the gradient to remove
  60961. * @returns the current particle system
  60962. */
  60963. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60964. /**
  60965. * Adds a new velocity gradient
  60966. * @param gradient defines the gradient to use (between 0 and 1)
  60967. * @param factor defines the velocity to affect to the specified gradient
  60968. * @returns the current particle system
  60969. */
  60970. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60971. /**
  60972. * Remove a specific velocity gradient
  60973. * @param gradient defines the gradient to remove
  60974. * @returns the current particle system
  60975. */
  60976. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60977. /**
  60978. * Adds a new limit velocity gradient
  60979. * @param gradient defines the gradient to use (between 0 and 1)
  60980. * @param factor defines the limit velocity value to affect to the specified gradient
  60981. * @returns the current particle system
  60982. */
  60983. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60984. /**
  60985. * Remove a specific limit velocity gradient
  60986. * @param gradient defines the gradient to remove
  60987. * @returns the current particle system
  60988. */
  60989. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60990. /**
  60991. * Adds a new drag gradient
  60992. * @param gradient defines the gradient to use (between 0 and 1)
  60993. * @param factor defines the drag value to affect to the specified gradient
  60994. * @returns the current particle system
  60995. */
  60996. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60997. /**
  60998. * Remove a specific drag gradient
  60999. * @param gradient defines the gradient to remove
  61000. * @returns the current particle system
  61001. */
  61002. removeDragGradient(gradient: number): GPUParticleSystem;
  61003. /**
  61004. * Not supported by GPUParticleSystem
  61005. * @param gradient defines the gradient to use (between 0 and 1)
  61006. * @param factor defines the emit rate value to affect to the specified gradient
  61007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61008. * @returns the current particle system
  61009. */
  61010. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61011. /**
  61012. * Not supported by GPUParticleSystem
  61013. * @param gradient defines the gradient to remove
  61014. * @returns the current particle system
  61015. */
  61016. removeEmitRateGradient(gradient: number): IParticleSystem;
  61017. /**
  61018. * Not supported by GPUParticleSystem
  61019. * @param gradient defines the gradient to use (between 0 and 1)
  61020. * @param factor defines the start size value to affect to the specified gradient
  61021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61022. * @returns the current particle system
  61023. */
  61024. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61025. /**
  61026. * Not supported by GPUParticleSystem
  61027. * @param gradient defines the gradient to remove
  61028. * @returns the current particle system
  61029. */
  61030. removeStartSizeGradient(gradient: number): IParticleSystem;
  61031. /**
  61032. * Not supported by GPUParticleSystem
  61033. * @param gradient defines the gradient to use (between 0 and 1)
  61034. * @param min defines the color remap minimal range
  61035. * @param max defines the color remap maximal range
  61036. * @returns the current particle system
  61037. */
  61038. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61039. /**
  61040. * Not supported by GPUParticleSystem
  61041. * @param gradient defines the gradient to remove
  61042. * @returns the current particle system
  61043. */
  61044. removeColorRemapGradient(): IParticleSystem;
  61045. /**
  61046. * Not supported by GPUParticleSystem
  61047. * @param gradient defines the gradient to use (between 0 and 1)
  61048. * @param min defines the alpha remap minimal range
  61049. * @param max defines the alpha remap maximal range
  61050. * @returns the current particle system
  61051. */
  61052. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61053. /**
  61054. * Not supported by GPUParticleSystem
  61055. * @param gradient defines the gradient to remove
  61056. * @returns the current particle system
  61057. */
  61058. removeAlphaRemapGradient(): IParticleSystem;
  61059. /**
  61060. * Not supported by GPUParticleSystem
  61061. * @param gradient defines the gradient to use (between 0 and 1)
  61062. * @param color defines the color to affect to the specified gradient
  61063. * @returns the current particle system
  61064. */
  61065. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61066. /**
  61067. * Not supported by GPUParticleSystem
  61068. * @param gradient defines the gradient to remove
  61069. * @returns the current particle system
  61070. */
  61071. removeRampGradient(): IParticleSystem;
  61072. /**
  61073. * Not supported by GPUParticleSystem
  61074. * @returns the list of ramp gradients
  61075. */
  61076. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61077. /**
  61078. * Not supported by GPUParticleSystem
  61079. * Gets or sets a boolean indicating that ramp gradients must be used
  61080. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61081. */
  61082. useRampGradients: boolean;
  61083. /**
  61084. * Not supported by GPUParticleSystem
  61085. * @param gradient defines the gradient to use (between 0 and 1)
  61086. * @param factor defines the life time factor to affect to the specified gradient
  61087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61088. * @returns the current particle system
  61089. */
  61090. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61091. /**
  61092. * Not supported by GPUParticleSystem
  61093. * @param gradient defines the gradient to remove
  61094. * @returns the current particle system
  61095. */
  61096. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61097. /**
  61098. * Instantiates a GPU particle system.
  61099. * 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.
  61100. * @param name The name of the particle system
  61101. * @param options The options used to create the system
  61102. * @param scene The scene the particle system belongs to
  61103. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61104. */
  61105. constructor(name: string, options: Partial<{
  61106. capacity: number;
  61107. randomTextureSize: number;
  61108. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61109. protected _reset(): void;
  61110. private _createUpdateVAO;
  61111. private _createRenderVAO;
  61112. private _initialize;
  61113. /** @hidden */
  61114. _recreateUpdateEffect(): void;
  61115. /** @hidden */
  61116. _recreateRenderEffect(): void;
  61117. /**
  61118. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61119. * @param preWarm defines if we are in the pre-warmimg phase
  61120. */
  61121. animate(preWarm?: boolean): void;
  61122. private _createFactorGradientTexture;
  61123. private _createSizeGradientTexture;
  61124. private _createAngularSpeedGradientTexture;
  61125. private _createVelocityGradientTexture;
  61126. private _createLimitVelocityGradientTexture;
  61127. private _createDragGradientTexture;
  61128. private _createColorGradientTexture;
  61129. /**
  61130. * Renders the particle system in its current state
  61131. * @param preWarm defines if the system should only update the particles but not render them
  61132. * @returns the current number of particles
  61133. */
  61134. render(preWarm?: boolean): number;
  61135. /**
  61136. * Rebuilds the particle system
  61137. */
  61138. rebuild(): void;
  61139. private _releaseBuffers;
  61140. private _releaseVAOs;
  61141. /**
  61142. * Disposes the particle system and free the associated resources
  61143. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61144. */
  61145. dispose(disposeTexture?: boolean): void;
  61146. /**
  61147. * Clones the particle system.
  61148. * @param name The name of the cloned object
  61149. * @param newEmitter The new emitter to use
  61150. * @returns the cloned particle system
  61151. */
  61152. clone(name: string, newEmitter: any): GPUParticleSystem;
  61153. /**
  61154. * Serializes the particle system to a JSON object.
  61155. * @returns the JSON object
  61156. */
  61157. serialize(): any;
  61158. /**
  61159. * Parses a JSON object to create a GPU particle system.
  61160. * @param parsedParticleSystem The JSON object to parse
  61161. * @param scene The scene to create the particle system in
  61162. * @param rootUrl The root url to use to load external dependencies like texture
  61163. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61164. * @returns the parsed GPU particle system
  61165. */
  61166. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61167. }
  61168. }
  61169. declare module "babylonjs/Particles/particleSystemSet" {
  61170. import { Nullable } from "babylonjs/types";
  61171. import { Color3 } from "babylonjs/Maths/math.color";
  61172. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61174. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61175. import { Scene, IDisposable } from "babylonjs/scene";
  61176. /**
  61177. * Represents a set of particle systems working together to create a specific effect
  61178. */
  61179. export class ParticleSystemSet implements IDisposable {
  61180. private _emitterCreationOptions;
  61181. private _emitterNode;
  61182. /**
  61183. * Gets the particle system list
  61184. */
  61185. systems: IParticleSystem[];
  61186. /**
  61187. * Gets the emitter node used with this set
  61188. */
  61189. readonly emitterNode: Nullable<TransformNode>;
  61190. /**
  61191. * Creates a new emitter mesh as a sphere
  61192. * @param options defines the options used to create the sphere
  61193. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61194. * @param scene defines the hosting scene
  61195. */
  61196. setEmitterAsSphere(options: {
  61197. diameter: number;
  61198. segments: number;
  61199. color: Color3;
  61200. }, renderingGroupId: number, scene: Scene): void;
  61201. /**
  61202. * Starts all particle systems of the set
  61203. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61204. */
  61205. start(emitter?: AbstractMesh): void;
  61206. /**
  61207. * Release all associated resources
  61208. */
  61209. dispose(): void;
  61210. /**
  61211. * Serialize the set into a JSON compatible object
  61212. * @returns a JSON compatible representation of the set
  61213. */
  61214. serialize(): any;
  61215. /**
  61216. * Parse a new ParticleSystemSet from a serialized source
  61217. * @param data defines a JSON compatible representation of the set
  61218. * @param scene defines the hosting scene
  61219. * @param gpu defines if we want GPU particles or CPU particles
  61220. * @returns a new ParticleSystemSet
  61221. */
  61222. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61223. }
  61224. }
  61225. declare module "babylonjs/Particles/particleHelper" {
  61226. import { Nullable } from "babylonjs/types";
  61227. import { Scene } from "babylonjs/scene";
  61228. import { Vector3 } from "babylonjs/Maths/math.vector";
  61229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61230. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61231. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61232. /**
  61233. * This class is made for on one-liner static method to help creating particle system set.
  61234. */
  61235. export class ParticleHelper {
  61236. /**
  61237. * Gets or sets base Assets URL
  61238. */
  61239. static BaseAssetsUrl: string;
  61240. /**
  61241. * Create a default particle system that you can tweak
  61242. * @param emitter defines the emitter to use
  61243. * @param capacity defines the system capacity (default is 500 particles)
  61244. * @param scene defines the hosting scene
  61245. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61246. * @returns the new Particle system
  61247. */
  61248. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61249. /**
  61250. * This is the main static method (one-liner) of this helper to create different particle systems
  61251. * @param type This string represents the type to the particle system to create
  61252. * @param scene The scene where the particle system should live
  61253. * @param gpu If the system will use gpu
  61254. * @returns the ParticleSystemSet created
  61255. */
  61256. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61257. /**
  61258. * Static function used to export a particle system to a ParticleSystemSet variable.
  61259. * Please note that the emitter shape is not exported
  61260. * @param systems defines the particle systems to export
  61261. * @returns the created particle system set
  61262. */
  61263. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61264. }
  61265. }
  61266. declare module "babylonjs/Particles/particleSystemComponent" {
  61267. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61268. import { Effect } from "babylonjs/Materials/effect";
  61269. import "babylonjs/Shaders/particles.vertex";
  61270. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61271. module "babylonjs/Engines/engine" {
  61272. interface Engine {
  61273. /**
  61274. * Create an effect to use with particle systems.
  61275. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61276. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61277. * @param uniformsNames defines a list of attribute names
  61278. * @param samplers defines an array of string used to represent textures
  61279. * @param defines defines the string containing the defines to use to compile the shaders
  61280. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61281. * @param onCompiled defines a function to call when the effect creation is successful
  61282. * @param onError defines a function to call when the effect creation has failed
  61283. * @returns the new Effect
  61284. */
  61285. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61286. }
  61287. }
  61288. module "babylonjs/Meshes/mesh" {
  61289. interface Mesh {
  61290. /**
  61291. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61292. * @returns an array of IParticleSystem
  61293. */
  61294. getEmittedParticleSystems(): IParticleSystem[];
  61295. /**
  61296. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61297. * @returns an array of IParticleSystem
  61298. */
  61299. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61300. }
  61301. }
  61302. /**
  61303. * @hidden
  61304. */
  61305. export var _IDoNeedToBeInTheBuild: number;
  61306. }
  61307. declare module "babylonjs/Particles/index" {
  61308. export * from "babylonjs/Particles/baseParticleSystem";
  61309. export * from "babylonjs/Particles/EmitterTypes/index";
  61310. export * from "babylonjs/Particles/gpuParticleSystem";
  61311. export * from "babylonjs/Particles/IParticleSystem";
  61312. export * from "babylonjs/Particles/particle";
  61313. export * from "babylonjs/Particles/particleHelper";
  61314. export * from "babylonjs/Particles/particleSystem";
  61315. export * from "babylonjs/Particles/particleSystemComponent";
  61316. export * from "babylonjs/Particles/particleSystemSet";
  61317. export * from "babylonjs/Particles/solidParticle";
  61318. export * from "babylonjs/Particles/solidParticleSystem";
  61319. export * from "babylonjs/Particles/subEmitter";
  61320. }
  61321. declare module "babylonjs/Physics/physicsEngineComponent" {
  61322. import { Nullable } from "babylonjs/types";
  61323. import { Observable, Observer } from "babylonjs/Misc/observable";
  61324. import { Vector3 } from "babylonjs/Maths/math.vector";
  61325. import { Mesh } from "babylonjs/Meshes/mesh";
  61326. import { ISceneComponent } from "babylonjs/sceneComponent";
  61327. import { Scene } from "babylonjs/scene";
  61328. import { Node } from "babylonjs/node";
  61329. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61330. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61331. module "babylonjs/scene" {
  61332. interface Scene {
  61333. /** @hidden (Backing field) */
  61334. _physicsEngine: Nullable<IPhysicsEngine>;
  61335. /**
  61336. * Gets the current physics engine
  61337. * @returns a IPhysicsEngine or null if none attached
  61338. */
  61339. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61340. /**
  61341. * Enables physics to the current scene
  61342. * @param gravity defines the scene's gravity for the physics engine
  61343. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61344. * @return a boolean indicating if the physics engine was initialized
  61345. */
  61346. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61347. /**
  61348. * Disables and disposes the physics engine associated with the scene
  61349. */
  61350. disablePhysicsEngine(): void;
  61351. /**
  61352. * Gets a boolean indicating if there is an active physics engine
  61353. * @returns a boolean indicating if there is an active physics engine
  61354. */
  61355. isPhysicsEnabled(): boolean;
  61356. /**
  61357. * Deletes a physics compound impostor
  61358. * @param compound defines the compound to delete
  61359. */
  61360. deleteCompoundImpostor(compound: any): void;
  61361. /**
  61362. * An event triggered when physic simulation is about to be run
  61363. */
  61364. onBeforePhysicsObservable: Observable<Scene>;
  61365. /**
  61366. * An event triggered when physic simulation has been done
  61367. */
  61368. onAfterPhysicsObservable: Observable<Scene>;
  61369. }
  61370. }
  61371. module "babylonjs/Meshes/abstractMesh" {
  61372. interface AbstractMesh {
  61373. /** @hidden */
  61374. _physicsImpostor: Nullable<PhysicsImpostor>;
  61375. /**
  61376. * Gets or sets impostor used for physic simulation
  61377. * @see http://doc.babylonjs.com/features/physics_engine
  61378. */
  61379. physicsImpostor: Nullable<PhysicsImpostor>;
  61380. /**
  61381. * Gets the current physics impostor
  61382. * @see http://doc.babylonjs.com/features/physics_engine
  61383. * @returns a physics impostor or null
  61384. */
  61385. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61386. /** Apply a physic impulse to the mesh
  61387. * @param force defines the force to apply
  61388. * @param contactPoint defines where to apply the force
  61389. * @returns the current mesh
  61390. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61391. */
  61392. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61393. /**
  61394. * Creates a physic joint between two meshes
  61395. * @param otherMesh defines the other mesh to use
  61396. * @param pivot1 defines the pivot to use on this mesh
  61397. * @param pivot2 defines the pivot to use on the other mesh
  61398. * @param options defines additional options (can be plugin dependent)
  61399. * @returns the current mesh
  61400. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61401. */
  61402. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61403. /** @hidden */
  61404. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61405. }
  61406. }
  61407. /**
  61408. * Defines the physics engine scene component responsible to manage a physics engine
  61409. */
  61410. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61411. /**
  61412. * The component name helpful to identify the component in the list of scene components.
  61413. */
  61414. readonly name: string;
  61415. /**
  61416. * The scene the component belongs to.
  61417. */
  61418. scene: Scene;
  61419. /**
  61420. * Creates a new instance of the component for the given scene
  61421. * @param scene Defines the scene to register the component in
  61422. */
  61423. constructor(scene: Scene);
  61424. /**
  61425. * Registers the component in a given scene
  61426. */
  61427. register(): void;
  61428. /**
  61429. * Rebuilds the elements related to this component in case of
  61430. * context lost for instance.
  61431. */
  61432. rebuild(): void;
  61433. /**
  61434. * Disposes the component and the associated ressources
  61435. */
  61436. dispose(): void;
  61437. }
  61438. }
  61439. declare module "babylonjs/Physics/physicsHelper" {
  61440. import { Nullable } from "babylonjs/types";
  61441. import { Vector3 } from "babylonjs/Maths/math.vector";
  61442. import { Mesh } from "babylonjs/Meshes/mesh";
  61443. import { Scene } from "babylonjs/scene";
  61444. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61445. /**
  61446. * A helper for physics simulations
  61447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61448. */
  61449. export class PhysicsHelper {
  61450. private _scene;
  61451. private _physicsEngine;
  61452. /**
  61453. * Initializes the Physics helper
  61454. * @param scene Babylon.js scene
  61455. */
  61456. constructor(scene: Scene);
  61457. /**
  61458. * Applies a radial explosion impulse
  61459. * @param origin the origin of the explosion
  61460. * @param radiusOrEventOptions the radius or the options of radial explosion
  61461. * @param strength the explosion strength
  61462. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61463. * @returns A physics radial explosion event, or null
  61464. */
  61465. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61466. /**
  61467. * Applies a radial explosion force
  61468. * @param origin the origin of the explosion
  61469. * @param radiusOrEventOptions the radius or the options of radial explosion
  61470. * @param strength the explosion strength
  61471. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61472. * @returns A physics radial explosion event, or null
  61473. */
  61474. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61475. /**
  61476. * Creates a gravitational field
  61477. * @param origin the origin of the explosion
  61478. * @param radiusOrEventOptions the radius or the options of radial explosion
  61479. * @param strength the explosion strength
  61480. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61481. * @returns A physics gravitational field event, or null
  61482. */
  61483. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61484. /**
  61485. * Creates a physics updraft event
  61486. * @param origin the origin of the updraft
  61487. * @param radiusOrEventOptions the radius or the options of the updraft
  61488. * @param strength the strength of the updraft
  61489. * @param height the height of the updraft
  61490. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61491. * @returns A physics updraft event, or null
  61492. */
  61493. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61494. /**
  61495. * Creates a physics vortex event
  61496. * @param origin the of the vortex
  61497. * @param radiusOrEventOptions the radius or the options of the vortex
  61498. * @param strength the strength of the vortex
  61499. * @param height the height of the vortex
  61500. * @returns a Physics vortex event, or null
  61501. * A physics vortex event or null
  61502. */
  61503. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61504. }
  61505. /**
  61506. * Represents a physics radial explosion event
  61507. */
  61508. class PhysicsRadialExplosionEvent {
  61509. private _scene;
  61510. private _options;
  61511. private _sphere;
  61512. private _dataFetched;
  61513. /**
  61514. * Initializes a radial explosioin event
  61515. * @param _scene BabylonJS scene
  61516. * @param _options The options for the vortex event
  61517. */
  61518. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61519. /**
  61520. * Returns the data related to the radial explosion event (sphere).
  61521. * @returns The radial explosion event data
  61522. */
  61523. getData(): PhysicsRadialExplosionEventData;
  61524. /**
  61525. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61526. * @param impostor A physics imposter
  61527. * @param origin the origin of the explosion
  61528. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61529. */
  61530. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61531. /**
  61532. * Triggers affecterd impostors callbacks
  61533. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61534. */
  61535. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61536. /**
  61537. * Disposes the sphere.
  61538. * @param force Specifies if the sphere should be disposed by force
  61539. */
  61540. dispose(force?: boolean): void;
  61541. /*** Helpers ***/
  61542. private _prepareSphere;
  61543. private _intersectsWithSphere;
  61544. }
  61545. /**
  61546. * Represents a gravitational field event
  61547. */
  61548. class PhysicsGravitationalFieldEvent {
  61549. private _physicsHelper;
  61550. private _scene;
  61551. private _origin;
  61552. private _options;
  61553. private _tickCallback;
  61554. private _sphere;
  61555. private _dataFetched;
  61556. /**
  61557. * Initializes the physics gravitational field event
  61558. * @param _physicsHelper A physics helper
  61559. * @param _scene BabylonJS scene
  61560. * @param _origin The origin position of the gravitational field event
  61561. * @param _options The options for the vortex event
  61562. */
  61563. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61564. /**
  61565. * Returns the data related to the gravitational field event (sphere).
  61566. * @returns A gravitational field event
  61567. */
  61568. getData(): PhysicsGravitationalFieldEventData;
  61569. /**
  61570. * Enables the gravitational field.
  61571. */
  61572. enable(): void;
  61573. /**
  61574. * Disables the gravitational field.
  61575. */
  61576. disable(): void;
  61577. /**
  61578. * Disposes the sphere.
  61579. * @param force The force to dispose from the gravitational field event
  61580. */
  61581. dispose(force?: boolean): void;
  61582. private _tick;
  61583. }
  61584. /**
  61585. * Represents a physics updraft event
  61586. */
  61587. class PhysicsUpdraftEvent {
  61588. private _scene;
  61589. private _origin;
  61590. private _options;
  61591. private _physicsEngine;
  61592. private _originTop;
  61593. private _originDirection;
  61594. private _tickCallback;
  61595. private _cylinder;
  61596. private _cylinderPosition;
  61597. private _dataFetched;
  61598. /**
  61599. * Initializes the physics updraft event
  61600. * @param _scene BabylonJS scene
  61601. * @param _origin The origin position of the updraft
  61602. * @param _options The options for the updraft event
  61603. */
  61604. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61605. /**
  61606. * Returns the data related to the updraft event (cylinder).
  61607. * @returns A physics updraft event
  61608. */
  61609. getData(): PhysicsUpdraftEventData;
  61610. /**
  61611. * Enables the updraft.
  61612. */
  61613. enable(): void;
  61614. /**
  61615. * Disables the updraft.
  61616. */
  61617. disable(): void;
  61618. /**
  61619. * Disposes the cylinder.
  61620. * @param force Specifies if the updraft should be disposed by force
  61621. */
  61622. dispose(force?: boolean): void;
  61623. private getImpostorHitData;
  61624. private _tick;
  61625. /*** Helpers ***/
  61626. private _prepareCylinder;
  61627. private _intersectsWithCylinder;
  61628. }
  61629. /**
  61630. * Represents a physics vortex event
  61631. */
  61632. class PhysicsVortexEvent {
  61633. private _scene;
  61634. private _origin;
  61635. private _options;
  61636. private _physicsEngine;
  61637. private _originTop;
  61638. private _tickCallback;
  61639. private _cylinder;
  61640. private _cylinderPosition;
  61641. private _dataFetched;
  61642. /**
  61643. * Initializes the physics vortex event
  61644. * @param _scene The BabylonJS scene
  61645. * @param _origin The origin position of the vortex
  61646. * @param _options The options for the vortex event
  61647. */
  61648. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61649. /**
  61650. * Returns the data related to the vortex event (cylinder).
  61651. * @returns The physics vortex event data
  61652. */
  61653. getData(): PhysicsVortexEventData;
  61654. /**
  61655. * Enables the vortex.
  61656. */
  61657. enable(): void;
  61658. /**
  61659. * Disables the cortex.
  61660. */
  61661. disable(): void;
  61662. /**
  61663. * Disposes the sphere.
  61664. * @param force
  61665. */
  61666. dispose(force?: boolean): void;
  61667. private getImpostorHitData;
  61668. private _tick;
  61669. /*** Helpers ***/
  61670. private _prepareCylinder;
  61671. private _intersectsWithCylinder;
  61672. }
  61673. /**
  61674. * Options fot the radial explosion event
  61675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61676. */
  61677. export class PhysicsRadialExplosionEventOptions {
  61678. /**
  61679. * The radius of the sphere for the radial explosion.
  61680. */
  61681. radius: number;
  61682. /**
  61683. * The strenth of the explosion.
  61684. */
  61685. strength: number;
  61686. /**
  61687. * The strenght of the force in correspondence to the distance of the affected object
  61688. */
  61689. falloff: PhysicsRadialImpulseFalloff;
  61690. /**
  61691. * Sphere options for the radial explosion.
  61692. */
  61693. sphere: {
  61694. segments: number;
  61695. diameter: number;
  61696. };
  61697. /**
  61698. * Sphere options for the radial explosion.
  61699. */
  61700. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61701. }
  61702. /**
  61703. * Options fot the updraft event
  61704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61705. */
  61706. export class PhysicsUpdraftEventOptions {
  61707. /**
  61708. * The radius of the cylinder for the vortex
  61709. */
  61710. radius: number;
  61711. /**
  61712. * The strenth of the updraft.
  61713. */
  61714. strength: number;
  61715. /**
  61716. * The height of the cylinder for the updraft.
  61717. */
  61718. height: number;
  61719. /**
  61720. * The mode for the the updraft.
  61721. */
  61722. updraftMode: PhysicsUpdraftMode;
  61723. }
  61724. /**
  61725. * Options fot the vortex event
  61726. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61727. */
  61728. export class PhysicsVortexEventOptions {
  61729. /**
  61730. * The radius of the cylinder for the vortex
  61731. */
  61732. radius: number;
  61733. /**
  61734. * The strenth of the vortex.
  61735. */
  61736. strength: number;
  61737. /**
  61738. * The height of the cylinder for the vortex.
  61739. */
  61740. height: number;
  61741. /**
  61742. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61743. */
  61744. centripetalForceThreshold: number;
  61745. /**
  61746. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61747. */
  61748. centripetalForceMultiplier: number;
  61749. /**
  61750. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61751. */
  61752. centrifugalForceMultiplier: number;
  61753. /**
  61754. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61755. */
  61756. updraftForceMultiplier: number;
  61757. }
  61758. /**
  61759. * The strenght of the force in correspondence to the distance of the affected object
  61760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61761. */
  61762. export enum PhysicsRadialImpulseFalloff {
  61763. /** Defines that impulse is constant in strength across it's whole radius */
  61764. Constant = 0,
  61765. /** Defines that impulse gets weaker if it's further from the origin */
  61766. Linear = 1
  61767. }
  61768. /**
  61769. * The strength of the force in correspondence to the distance of the affected object
  61770. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61771. */
  61772. export enum PhysicsUpdraftMode {
  61773. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61774. Center = 0,
  61775. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61776. Perpendicular = 1
  61777. }
  61778. /**
  61779. * Interface for a physics hit data
  61780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61781. */
  61782. export interface PhysicsHitData {
  61783. /**
  61784. * The force applied at the contact point
  61785. */
  61786. force: Vector3;
  61787. /**
  61788. * The contact point
  61789. */
  61790. contactPoint: Vector3;
  61791. /**
  61792. * The distance from the origin to the contact point
  61793. */
  61794. distanceFromOrigin: number;
  61795. }
  61796. /**
  61797. * Interface for radial explosion event data
  61798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61799. */
  61800. export interface PhysicsRadialExplosionEventData {
  61801. /**
  61802. * A sphere used for the radial explosion event
  61803. */
  61804. sphere: Mesh;
  61805. }
  61806. /**
  61807. * Interface for gravitational field event data
  61808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61809. */
  61810. export interface PhysicsGravitationalFieldEventData {
  61811. /**
  61812. * A sphere mesh used for the gravitational field event
  61813. */
  61814. sphere: Mesh;
  61815. }
  61816. /**
  61817. * Interface for updraft event data
  61818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61819. */
  61820. export interface PhysicsUpdraftEventData {
  61821. /**
  61822. * A cylinder used for the updraft event
  61823. */
  61824. cylinder: Mesh;
  61825. }
  61826. /**
  61827. * Interface for vortex event data
  61828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61829. */
  61830. export interface PhysicsVortexEventData {
  61831. /**
  61832. * A cylinder used for the vortex event
  61833. */
  61834. cylinder: Mesh;
  61835. }
  61836. /**
  61837. * Interface for an affected physics impostor
  61838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61839. */
  61840. export interface PhysicsAffectedImpostorWithData {
  61841. /**
  61842. * The impostor affected by the effect
  61843. */
  61844. impostor: PhysicsImpostor;
  61845. /**
  61846. * The data about the hit/horce from the explosion
  61847. */
  61848. hitData: PhysicsHitData;
  61849. }
  61850. }
  61851. declare module "babylonjs/Physics/Plugins/index" {
  61852. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61853. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61854. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61855. }
  61856. declare module "babylonjs/Physics/index" {
  61857. export * from "babylonjs/Physics/IPhysicsEngine";
  61858. export * from "babylonjs/Physics/physicsEngine";
  61859. export * from "babylonjs/Physics/physicsEngineComponent";
  61860. export * from "babylonjs/Physics/physicsHelper";
  61861. export * from "babylonjs/Physics/physicsImpostor";
  61862. export * from "babylonjs/Physics/physicsJoint";
  61863. export * from "babylonjs/Physics/Plugins/index";
  61864. }
  61865. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61866. /** @hidden */
  61867. export var blackAndWhitePixelShader: {
  61868. name: string;
  61869. shader: string;
  61870. };
  61871. }
  61872. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61873. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61874. import { Camera } from "babylonjs/Cameras/camera";
  61875. import { Engine } from "babylonjs/Engines/engine";
  61876. import "babylonjs/Shaders/blackAndWhite.fragment";
  61877. /**
  61878. * Post process used to render in black and white
  61879. */
  61880. export class BlackAndWhitePostProcess extends PostProcess {
  61881. /**
  61882. * Linear about to convert he result to black and white (default: 1)
  61883. */
  61884. degree: number;
  61885. /**
  61886. * Creates a black and white post process
  61887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61888. * @param name The name of the effect.
  61889. * @param options The required width/height ratio to downsize to before computing the render pass.
  61890. * @param camera The camera to apply the render pass to.
  61891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61892. * @param engine The engine which the post process will be applied. (default: current engine)
  61893. * @param reusable If the post process can be reused on the same frame. (default: false)
  61894. */
  61895. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61896. }
  61897. }
  61898. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61899. import { Nullable } from "babylonjs/types";
  61900. import { Camera } from "babylonjs/Cameras/camera";
  61901. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61902. import { Engine } from "babylonjs/Engines/engine";
  61903. /**
  61904. * This represents a set of one or more post processes in Babylon.
  61905. * A post process can be used to apply a shader to a texture after it is rendered.
  61906. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61907. */
  61908. export class PostProcessRenderEffect {
  61909. private _postProcesses;
  61910. private _getPostProcesses;
  61911. private _singleInstance;
  61912. private _cameras;
  61913. private _indicesForCamera;
  61914. /**
  61915. * Name of the effect
  61916. * @hidden
  61917. */
  61918. _name: string;
  61919. /**
  61920. * Instantiates a post process render effect.
  61921. * A post process can be used to apply a shader to a texture after it is rendered.
  61922. * @param engine The engine the effect is tied to
  61923. * @param name The name of the effect
  61924. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61925. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61926. */
  61927. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61928. /**
  61929. * Checks if all the post processes in the effect are supported.
  61930. */
  61931. readonly isSupported: boolean;
  61932. /**
  61933. * Updates the current state of the effect
  61934. * @hidden
  61935. */
  61936. _update(): void;
  61937. /**
  61938. * Attaches the effect on cameras
  61939. * @param cameras The camera to attach to.
  61940. * @hidden
  61941. */
  61942. _attachCameras(cameras: Camera): void;
  61943. /**
  61944. * Attaches the effect on cameras
  61945. * @param cameras The camera to attach to.
  61946. * @hidden
  61947. */
  61948. _attachCameras(cameras: Camera[]): void;
  61949. /**
  61950. * Detaches the effect on cameras
  61951. * @param cameras The camera to detatch from.
  61952. * @hidden
  61953. */
  61954. _detachCameras(cameras: Camera): void;
  61955. /**
  61956. * Detatches the effect on cameras
  61957. * @param cameras The camera to detatch from.
  61958. * @hidden
  61959. */
  61960. _detachCameras(cameras: Camera[]): void;
  61961. /**
  61962. * Enables the effect on given cameras
  61963. * @param cameras The camera to enable.
  61964. * @hidden
  61965. */
  61966. _enable(cameras: Camera): void;
  61967. /**
  61968. * Enables the effect on given cameras
  61969. * @param cameras The camera to enable.
  61970. * @hidden
  61971. */
  61972. _enable(cameras: Nullable<Camera[]>): void;
  61973. /**
  61974. * Disables the effect on the given cameras
  61975. * @param cameras The camera to disable.
  61976. * @hidden
  61977. */
  61978. _disable(cameras: Camera): void;
  61979. /**
  61980. * Disables the effect on the given cameras
  61981. * @param cameras The camera to disable.
  61982. * @hidden
  61983. */
  61984. _disable(cameras: Nullable<Camera[]>): void;
  61985. /**
  61986. * Gets a list of the post processes contained in the effect.
  61987. * @param camera The camera to get the post processes on.
  61988. * @returns The list of the post processes in the effect.
  61989. */
  61990. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61991. }
  61992. }
  61993. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61994. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61995. /** @hidden */
  61996. export var extractHighlightsPixelShader: {
  61997. name: string;
  61998. shader: string;
  61999. };
  62000. }
  62001. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62002. import { Nullable } from "babylonjs/types";
  62003. import { Camera } from "babylonjs/Cameras/camera";
  62004. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62005. import { Engine } from "babylonjs/Engines/engine";
  62006. import "babylonjs/Shaders/extractHighlights.fragment";
  62007. /**
  62008. * 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.
  62009. */
  62010. export class ExtractHighlightsPostProcess extends PostProcess {
  62011. /**
  62012. * The luminance threshold, pixels below this value will be set to black.
  62013. */
  62014. threshold: number;
  62015. /** @hidden */
  62016. _exposure: number;
  62017. /**
  62018. * Post process which has the input texture to be used when performing highlight extraction
  62019. * @hidden
  62020. */
  62021. _inputPostProcess: Nullable<PostProcess>;
  62022. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62023. }
  62024. }
  62025. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62026. /** @hidden */
  62027. export var bloomMergePixelShader: {
  62028. name: string;
  62029. shader: string;
  62030. };
  62031. }
  62032. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62033. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62034. import { Nullable } from "babylonjs/types";
  62035. import { Engine } from "babylonjs/Engines/engine";
  62036. import { Camera } from "babylonjs/Cameras/camera";
  62037. import "babylonjs/Shaders/bloomMerge.fragment";
  62038. /**
  62039. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62040. */
  62041. export class BloomMergePostProcess extends PostProcess {
  62042. /** Weight of the bloom to be added to the original input. */
  62043. weight: number;
  62044. /**
  62045. * Creates a new instance of @see BloomMergePostProcess
  62046. * @param name The name of the effect.
  62047. * @param originalFromInput Post process which's input will be used for the merge.
  62048. * @param blurred Blurred highlights post process which's output will be used.
  62049. * @param weight Weight of the bloom to be added to the original input.
  62050. * @param options The required width/height ratio to downsize to before computing the render pass.
  62051. * @param camera The camera to apply the render pass to.
  62052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62053. * @param engine The engine which the post process will be applied. (default: current engine)
  62054. * @param reusable If the post process can be reused on the same frame. (default: false)
  62055. * @param textureType Type of textures used when performing the post process. (default: 0)
  62056. * @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)
  62057. */
  62058. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62059. /** Weight of the bloom to be added to the original input. */
  62060. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62061. }
  62062. }
  62063. declare module "babylonjs/PostProcesses/bloomEffect" {
  62064. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62065. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62066. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62067. import { Camera } from "babylonjs/Cameras/camera";
  62068. import { Scene } from "babylonjs/scene";
  62069. /**
  62070. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62071. */
  62072. export class BloomEffect extends PostProcessRenderEffect {
  62073. private bloomScale;
  62074. /**
  62075. * @hidden Internal
  62076. */
  62077. _effects: Array<PostProcess>;
  62078. /**
  62079. * @hidden Internal
  62080. */
  62081. _downscale: ExtractHighlightsPostProcess;
  62082. private _blurX;
  62083. private _blurY;
  62084. private _merge;
  62085. /**
  62086. * The luminance threshold to find bright areas of the image to bloom.
  62087. */
  62088. threshold: number;
  62089. /**
  62090. * The strength of the bloom.
  62091. */
  62092. weight: number;
  62093. /**
  62094. * Specifies the size of the bloom blur kernel, relative to the final output size
  62095. */
  62096. kernel: number;
  62097. /**
  62098. * Creates a new instance of @see BloomEffect
  62099. * @param scene The scene the effect belongs to.
  62100. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62101. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62102. * @param bloomWeight The the strength of bloom.
  62103. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62104. * @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)
  62105. */
  62106. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62107. /**
  62108. * Disposes each of the internal effects for a given camera.
  62109. * @param camera The camera to dispose the effect on.
  62110. */
  62111. disposeEffects(camera: Camera): void;
  62112. /**
  62113. * @hidden Internal
  62114. */
  62115. _updateEffects(): void;
  62116. /**
  62117. * Internal
  62118. * @returns if all the contained post processes are ready.
  62119. * @hidden
  62120. */
  62121. _isReady(): boolean;
  62122. }
  62123. }
  62124. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62125. /** @hidden */
  62126. export var chromaticAberrationPixelShader: {
  62127. name: string;
  62128. shader: string;
  62129. };
  62130. }
  62131. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62132. import { Vector2 } from "babylonjs/Maths/math.vector";
  62133. import { Nullable } from "babylonjs/types";
  62134. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62135. import { Camera } from "babylonjs/Cameras/camera";
  62136. import { Engine } from "babylonjs/Engines/engine";
  62137. import "babylonjs/Shaders/chromaticAberration.fragment";
  62138. /**
  62139. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62140. */
  62141. export class ChromaticAberrationPostProcess extends PostProcess {
  62142. /**
  62143. * The amount of seperation of rgb channels (default: 30)
  62144. */
  62145. aberrationAmount: number;
  62146. /**
  62147. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62148. */
  62149. radialIntensity: number;
  62150. /**
  62151. * 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))
  62152. */
  62153. direction: Vector2;
  62154. /**
  62155. * 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))
  62156. */
  62157. centerPosition: Vector2;
  62158. /**
  62159. * Creates a new instance ChromaticAberrationPostProcess
  62160. * @param name The name of the effect.
  62161. * @param screenWidth The width of the screen to apply the effect on.
  62162. * @param screenHeight The height of the screen to apply the effect on.
  62163. * @param options The required width/height ratio to downsize to before computing the render pass.
  62164. * @param camera The camera to apply the render pass to.
  62165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62166. * @param engine The engine which the post process will be applied. (default: current engine)
  62167. * @param reusable If the post process can be reused on the same frame. (default: false)
  62168. * @param textureType Type of textures used when performing the post process. (default: 0)
  62169. * @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)
  62170. */
  62171. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62172. }
  62173. }
  62174. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62175. /** @hidden */
  62176. export var circleOfConfusionPixelShader: {
  62177. name: string;
  62178. shader: string;
  62179. };
  62180. }
  62181. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62182. import { Nullable } from "babylonjs/types";
  62183. import { Engine } from "babylonjs/Engines/engine";
  62184. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62185. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62186. import { Camera } from "babylonjs/Cameras/camera";
  62187. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62188. /**
  62189. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62190. */
  62191. export class CircleOfConfusionPostProcess extends PostProcess {
  62192. /**
  62193. * 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.
  62194. */
  62195. lensSize: number;
  62196. /**
  62197. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62198. */
  62199. fStop: number;
  62200. /**
  62201. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62202. */
  62203. focusDistance: number;
  62204. /**
  62205. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62206. */
  62207. focalLength: number;
  62208. private _depthTexture;
  62209. /**
  62210. * Creates a new instance CircleOfConfusionPostProcess
  62211. * @param name The name of the effect.
  62212. * @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.
  62213. * @param options The required width/height ratio to downsize to before computing the render pass.
  62214. * @param camera The camera to apply the render pass to.
  62215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62216. * @param engine The engine which the post process will be applied. (default: current engine)
  62217. * @param reusable If the post process can be reused on the same frame. (default: false)
  62218. * @param textureType Type of textures used when performing the post process. (default: 0)
  62219. * @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)
  62220. */
  62221. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62222. /**
  62223. * 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.
  62224. */
  62225. depthTexture: RenderTargetTexture;
  62226. }
  62227. }
  62228. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62229. /** @hidden */
  62230. export var colorCorrectionPixelShader: {
  62231. name: string;
  62232. shader: string;
  62233. };
  62234. }
  62235. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62236. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62237. import { Engine } from "babylonjs/Engines/engine";
  62238. import { Camera } from "babylonjs/Cameras/camera";
  62239. import "babylonjs/Shaders/colorCorrection.fragment";
  62240. /**
  62241. *
  62242. * This post-process allows the modification of rendered colors by using
  62243. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62244. *
  62245. * The object needs to be provided an url to a texture containing the color
  62246. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62247. * Use an image editing software to tweak the LUT to match your needs.
  62248. *
  62249. * For an example of a color LUT, see here:
  62250. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62251. * For explanations on color grading, see here:
  62252. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62253. *
  62254. */
  62255. export class ColorCorrectionPostProcess extends PostProcess {
  62256. private _colorTableTexture;
  62257. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62258. }
  62259. }
  62260. declare module "babylonjs/Shaders/convolution.fragment" {
  62261. /** @hidden */
  62262. export var convolutionPixelShader: {
  62263. name: string;
  62264. shader: string;
  62265. };
  62266. }
  62267. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62268. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62269. import { Nullable } from "babylonjs/types";
  62270. import { Camera } from "babylonjs/Cameras/camera";
  62271. import { Engine } from "babylonjs/Engines/engine";
  62272. import "babylonjs/Shaders/convolution.fragment";
  62273. /**
  62274. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62275. * input texture to perform effects such as edge detection or sharpening
  62276. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62277. */
  62278. export class ConvolutionPostProcess extends PostProcess {
  62279. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62280. kernel: number[];
  62281. /**
  62282. * Creates a new instance ConvolutionPostProcess
  62283. * @param name The name of the effect.
  62284. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62285. * @param options The required width/height ratio to downsize to before computing the render pass.
  62286. * @param camera The camera to apply the render pass to.
  62287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62288. * @param engine The engine which the post process will be applied. (default: current engine)
  62289. * @param reusable If the post process can be reused on the same frame. (default: false)
  62290. * @param textureType Type of textures used when performing the post process. (default: 0)
  62291. */
  62292. constructor(name: string,
  62293. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62294. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62295. /**
  62296. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62297. */
  62298. static EdgeDetect0Kernel: number[];
  62299. /**
  62300. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62301. */
  62302. static EdgeDetect1Kernel: number[];
  62303. /**
  62304. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62305. */
  62306. static EdgeDetect2Kernel: number[];
  62307. /**
  62308. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62309. */
  62310. static SharpenKernel: number[];
  62311. /**
  62312. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62313. */
  62314. static EmbossKernel: number[];
  62315. /**
  62316. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62317. */
  62318. static GaussianKernel: number[];
  62319. }
  62320. }
  62321. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62322. import { Nullable } from "babylonjs/types";
  62323. import { Vector2 } from "babylonjs/Maths/math.vector";
  62324. import { Camera } from "babylonjs/Cameras/camera";
  62325. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62326. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62327. import { Engine } from "babylonjs/Engines/engine";
  62328. import { Scene } from "babylonjs/scene";
  62329. /**
  62330. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62331. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62332. * based on samples that have a large difference in distance than the center pixel.
  62333. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62334. */
  62335. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62336. direction: Vector2;
  62337. /**
  62338. * Creates a new instance CircleOfConfusionPostProcess
  62339. * @param name The name of the effect.
  62340. * @param scene The scene the effect belongs to.
  62341. * @param direction The direction the blur should be applied.
  62342. * @param kernel The size of the kernel used to blur.
  62343. * @param options The required width/height ratio to downsize to before computing the render pass.
  62344. * @param camera The camera to apply the render pass to.
  62345. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62346. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62348. * @param engine The engine which the post process will be applied. (default: current engine)
  62349. * @param reusable If the post process can be reused on the same frame. (default: false)
  62350. * @param textureType Type of textures used when performing the post process. (default: 0)
  62351. * @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)
  62352. */
  62353. 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);
  62354. }
  62355. }
  62356. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62357. /** @hidden */
  62358. export var depthOfFieldMergePixelShader: {
  62359. name: string;
  62360. shader: string;
  62361. };
  62362. }
  62363. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62364. import { Nullable } from "babylonjs/types";
  62365. import { Camera } from "babylonjs/Cameras/camera";
  62366. import { Effect } from "babylonjs/Materials/effect";
  62367. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62368. import { Engine } from "babylonjs/Engines/engine";
  62369. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62370. /**
  62371. * Options to be set when merging outputs from the default pipeline.
  62372. */
  62373. export class DepthOfFieldMergePostProcessOptions {
  62374. /**
  62375. * The original image to merge on top of
  62376. */
  62377. originalFromInput: PostProcess;
  62378. /**
  62379. * Parameters to perform the merge of the depth of field effect
  62380. */
  62381. depthOfField?: {
  62382. circleOfConfusion: PostProcess;
  62383. blurSteps: Array<PostProcess>;
  62384. };
  62385. /**
  62386. * Parameters to perform the merge of bloom effect
  62387. */
  62388. bloom?: {
  62389. blurred: PostProcess;
  62390. weight: number;
  62391. };
  62392. }
  62393. /**
  62394. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62395. */
  62396. export class DepthOfFieldMergePostProcess extends PostProcess {
  62397. private blurSteps;
  62398. /**
  62399. * Creates a new instance of DepthOfFieldMergePostProcess
  62400. * @param name The name of the effect.
  62401. * @param originalFromInput Post process which's input will be used for the merge.
  62402. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62403. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62404. * @param options The required width/height ratio to downsize to before computing the render pass.
  62405. * @param camera The camera to apply the render pass to.
  62406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62407. * @param engine The engine which the post process will be applied. (default: current engine)
  62408. * @param reusable If the post process can be reused on the same frame. (default: false)
  62409. * @param textureType Type of textures used when performing the post process. (default: 0)
  62410. * @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)
  62411. */
  62412. 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);
  62413. /**
  62414. * Updates the effect with the current post process compile time values and recompiles the shader.
  62415. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62416. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62417. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62418. * @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
  62419. * @param onCompiled Called when the shader has been compiled.
  62420. * @param onError Called if there is an error when compiling a shader.
  62421. */
  62422. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62423. }
  62424. }
  62425. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62426. import { Nullable } from "babylonjs/types";
  62427. import { Camera } from "babylonjs/Cameras/camera";
  62428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62429. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62430. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62431. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62432. import { Scene } from "babylonjs/scene";
  62433. /**
  62434. * Specifies the level of max blur that should be applied when using the depth of field effect
  62435. */
  62436. export enum DepthOfFieldEffectBlurLevel {
  62437. /**
  62438. * Subtle blur
  62439. */
  62440. Low = 0,
  62441. /**
  62442. * Medium blur
  62443. */
  62444. Medium = 1,
  62445. /**
  62446. * Large blur
  62447. */
  62448. High = 2
  62449. }
  62450. /**
  62451. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62452. */
  62453. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62454. private _circleOfConfusion;
  62455. /**
  62456. * @hidden Internal, blurs from high to low
  62457. */
  62458. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62459. private _depthOfFieldBlurY;
  62460. private _dofMerge;
  62461. /**
  62462. * @hidden Internal post processes in depth of field effect
  62463. */
  62464. _effects: Array<PostProcess>;
  62465. /**
  62466. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62467. */
  62468. focalLength: number;
  62469. /**
  62470. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62471. */
  62472. fStop: number;
  62473. /**
  62474. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62475. */
  62476. focusDistance: number;
  62477. /**
  62478. * 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.
  62479. */
  62480. lensSize: number;
  62481. /**
  62482. * Creates a new instance DepthOfFieldEffect
  62483. * @param scene The scene the effect belongs to.
  62484. * @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.
  62485. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62486. * @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)
  62487. */
  62488. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62489. /**
  62490. * Get the current class name of the current effet
  62491. * @returns "DepthOfFieldEffect"
  62492. */
  62493. getClassName(): string;
  62494. /**
  62495. * 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.
  62496. */
  62497. depthTexture: RenderTargetTexture;
  62498. /**
  62499. * Disposes each of the internal effects for a given camera.
  62500. * @param camera The camera to dispose the effect on.
  62501. */
  62502. disposeEffects(camera: Camera): void;
  62503. /**
  62504. * @hidden Internal
  62505. */
  62506. _updateEffects(): void;
  62507. /**
  62508. * Internal
  62509. * @returns if all the contained post processes are ready.
  62510. * @hidden
  62511. */
  62512. _isReady(): boolean;
  62513. }
  62514. }
  62515. declare module "babylonjs/Shaders/displayPass.fragment" {
  62516. /** @hidden */
  62517. export var displayPassPixelShader: {
  62518. name: string;
  62519. shader: string;
  62520. };
  62521. }
  62522. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62523. import { Nullable } from "babylonjs/types";
  62524. import { Camera } from "babylonjs/Cameras/camera";
  62525. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62526. import { Engine } from "babylonjs/Engines/engine";
  62527. import "babylonjs/Shaders/displayPass.fragment";
  62528. /**
  62529. * DisplayPassPostProcess which produces an output the same as it's input
  62530. */
  62531. export class DisplayPassPostProcess extends PostProcess {
  62532. /**
  62533. * Creates the DisplayPassPostProcess
  62534. * @param name The name of the effect.
  62535. * @param options The required width/height ratio to downsize to before computing the render pass.
  62536. * @param camera The camera to apply the render pass to.
  62537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62538. * @param engine The engine which the post process will be applied. (default: current engine)
  62539. * @param reusable If the post process can be reused on the same frame. (default: false)
  62540. */
  62541. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62542. }
  62543. }
  62544. declare module "babylonjs/Shaders/filter.fragment" {
  62545. /** @hidden */
  62546. export var filterPixelShader: {
  62547. name: string;
  62548. shader: string;
  62549. };
  62550. }
  62551. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62552. import { Nullable } from "babylonjs/types";
  62553. import { Matrix } from "babylonjs/Maths/math.vector";
  62554. import { Camera } from "babylonjs/Cameras/camera";
  62555. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62556. import { Engine } from "babylonjs/Engines/engine";
  62557. import "babylonjs/Shaders/filter.fragment";
  62558. /**
  62559. * Applies a kernel filter to the image
  62560. */
  62561. export class FilterPostProcess extends PostProcess {
  62562. /** The matrix to be applied to the image */
  62563. kernelMatrix: Matrix;
  62564. /**
  62565. *
  62566. * @param name The name of the effect.
  62567. * @param kernelMatrix The matrix to be applied to the image
  62568. * @param options The required width/height ratio to downsize to before computing the render pass.
  62569. * @param camera The camera to apply the render pass to.
  62570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62571. * @param engine The engine which the post process will be applied. (default: current engine)
  62572. * @param reusable If the post process can be reused on the same frame. (default: false)
  62573. */
  62574. constructor(name: string,
  62575. /** The matrix to be applied to the image */
  62576. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62577. }
  62578. }
  62579. declare module "babylonjs/Shaders/fxaa.fragment" {
  62580. /** @hidden */
  62581. export var fxaaPixelShader: {
  62582. name: string;
  62583. shader: string;
  62584. };
  62585. }
  62586. declare module "babylonjs/Shaders/fxaa.vertex" {
  62587. /** @hidden */
  62588. export var fxaaVertexShader: {
  62589. name: string;
  62590. shader: string;
  62591. };
  62592. }
  62593. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62594. import { Nullable } from "babylonjs/types";
  62595. import { Camera } from "babylonjs/Cameras/camera";
  62596. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62597. import { Engine } from "babylonjs/Engines/engine";
  62598. import "babylonjs/Shaders/fxaa.fragment";
  62599. import "babylonjs/Shaders/fxaa.vertex";
  62600. /**
  62601. * Fxaa post process
  62602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62603. */
  62604. export class FxaaPostProcess extends PostProcess {
  62605. /** @hidden */
  62606. texelWidth: number;
  62607. /** @hidden */
  62608. texelHeight: number;
  62609. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62610. private _getDefines;
  62611. }
  62612. }
  62613. declare module "babylonjs/Shaders/grain.fragment" {
  62614. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62615. /** @hidden */
  62616. export var grainPixelShader: {
  62617. name: string;
  62618. shader: string;
  62619. };
  62620. }
  62621. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62622. import { Nullable } from "babylonjs/types";
  62623. import { Camera } from "babylonjs/Cameras/camera";
  62624. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62625. import { Engine } from "babylonjs/Engines/engine";
  62626. import "babylonjs/Shaders/grain.fragment";
  62627. /**
  62628. * The GrainPostProcess adds noise to the image at mid luminance levels
  62629. */
  62630. export class GrainPostProcess extends PostProcess {
  62631. /**
  62632. * The intensity of the grain added (default: 30)
  62633. */
  62634. intensity: number;
  62635. /**
  62636. * If the grain should be randomized on every frame
  62637. */
  62638. animated: boolean;
  62639. /**
  62640. * Creates a new instance of @see GrainPostProcess
  62641. * @param name The name of the effect.
  62642. * @param options The required width/height ratio to downsize to before computing the render pass.
  62643. * @param camera The camera to apply the render pass to.
  62644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62645. * @param engine The engine which the post process will be applied. (default: current engine)
  62646. * @param reusable If the post process can be reused on the same frame. (default: false)
  62647. * @param textureType Type of textures used when performing the post process. (default: 0)
  62648. * @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)
  62649. */
  62650. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62651. }
  62652. }
  62653. declare module "babylonjs/Shaders/highlights.fragment" {
  62654. /** @hidden */
  62655. export var highlightsPixelShader: {
  62656. name: string;
  62657. shader: string;
  62658. };
  62659. }
  62660. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62661. import { Nullable } from "babylonjs/types";
  62662. import { Camera } from "babylonjs/Cameras/camera";
  62663. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62664. import { Engine } from "babylonjs/Engines/engine";
  62665. import "babylonjs/Shaders/highlights.fragment";
  62666. /**
  62667. * Extracts highlights from the image
  62668. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62669. */
  62670. export class HighlightsPostProcess extends PostProcess {
  62671. /**
  62672. * Extracts highlights from the image
  62673. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62674. * @param name The name of the effect.
  62675. * @param options The required width/height ratio to downsize to before computing the render pass.
  62676. * @param camera The camera to apply the render pass to.
  62677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62678. * @param engine The engine which the post process will be applied. (default: current engine)
  62679. * @param reusable If the post process can be reused on the same frame. (default: false)
  62680. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62681. */
  62682. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62683. }
  62684. }
  62685. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62686. /** @hidden */
  62687. export var mrtFragmentDeclaration: {
  62688. name: string;
  62689. shader: string;
  62690. };
  62691. }
  62692. declare module "babylonjs/Shaders/geometry.fragment" {
  62693. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62694. /** @hidden */
  62695. export var geometryPixelShader: {
  62696. name: string;
  62697. shader: string;
  62698. };
  62699. }
  62700. declare module "babylonjs/Shaders/geometry.vertex" {
  62701. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62702. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62703. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62704. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62705. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62706. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62707. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62708. /** @hidden */
  62709. export var geometryVertexShader: {
  62710. name: string;
  62711. shader: string;
  62712. };
  62713. }
  62714. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62715. import { Matrix } from "babylonjs/Maths/math.vector";
  62716. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62717. import { Mesh } from "babylonjs/Meshes/mesh";
  62718. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62719. import { Effect } from "babylonjs/Materials/effect";
  62720. import { Scene } from "babylonjs/scene";
  62721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62722. import "babylonjs/Shaders/geometry.fragment";
  62723. import "babylonjs/Shaders/geometry.vertex";
  62724. /** @hidden */
  62725. interface ISavedTransformationMatrix {
  62726. world: Matrix;
  62727. viewProjection: Matrix;
  62728. }
  62729. /**
  62730. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62731. */
  62732. export class GeometryBufferRenderer {
  62733. /**
  62734. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62735. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62736. */
  62737. static readonly POSITION_TEXTURE_TYPE: number;
  62738. /**
  62739. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62740. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62741. */
  62742. static readonly VELOCITY_TEXTURE_TYPE: number;
  62743. /**
  62744. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62745. * in order to compute objects velocities when enableVelocity is set to "true"
  62746. * @hidden
  62747. */
  62748. _previousTransformationMatrices: {
  62749. [index: number]: ISavedTransformationMatrix;
  62750. };
  62751. /**
  62752. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62753. * in order to compute objects velocities when enableVelocity is set to "true"
  62754. * @hidden
  62755. */
  62756. _previousBonesTransformationMatrices: {
  62757. [index: number]: Float32Array;
  62758. };
  62759. /**
  62760. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62761. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62762. */
  62763. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62764. private _scene;
  62765. private _multiRenderTarget;
  62766. private _ratio;
  62767. private _enablePosition;
  62768. private _enableVelocity;
  62769. private _positionIndex;
  62770. private _velocityIndex;
  62771. protected _effect: Effect;
  62772. protected _cachedDefines: string;
  62773. /**
  62774. * Set the render list (meshes to be rendered) used in the G buffer.
  62775. */
  62776. renderList: Mesh[];
  62777. /**
  62778. * Gets wether or not G buffer are supported by the running hardware.
  62779. * This requires draw buffer supports
  62780. */
  62781. readonly isSupported: boolean;
  62782. /**
  62783. * Returns the index of the given texture type in the G-Buffer textures array
  62784. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62785. * @returns the index of the given texture type in the G-Buffer textures array
  62786. */
  62787. getTextureIndex(textureType: number): number;
  62788. /**
  62789. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62790. */
  62791. /**
  62792. * Sets whether or not objects positions are enabled for the G buffer.
  62793. */
  62794. enablePosition: boolean;
  62795. /**
  62796. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62797. */
  62798. /**
  62799. * Sets wether or not objects velocities are enabled for the G buffer.
  62800. */
  62801. enableVelocity: boolean;
  62802. /**
  62803. * Gets the scene associated with the buffer.
  62804. */
  62805. readonly scene: Scene;
  62806. /**
  62807. * Gets the ratio used by the buffer during its creation.
  62808. * How big is the buffer related to the main canvas.
  62809. */
  62810. readonly ratio: number;
  62811. /** @hidden */
  62812. static _SceneComponentInitialization: (scene: Scene) => void;
  62813. /**
  62814. * Creates a new G Buffer for the scene
  62815. * @param scene The scene the buffer belongs to
  62816. * @param ratio How big is the buffer related to the main canvas.
  62817. */
  62818. constructor(scene: Scene, ratio?: number);
  62819. /**
  62820. * Checks wether everything is ready to render a submesh to the G buffer.
  62821. * @param subMesh the submesh to check readiness for
  62822. * @param useInstances is the mesh drawn using instance or not
  62823. * @returns true if ready otherwise false
  62824. */
  62825. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62826. /**
  62827. * Gets the current underlying G Buffer.
  62828. * @returns the buffer
  62829. */
  62830. getGBuffer(): MultiRenderTarget;
  62831. /**
  62832. * Gets the number of samples used to render the buffer (anti aliasing).
  62833. */
  62834. /**
  62835. * Sets the number of samples used to render the buffer (anti aliasing).
  62836. */
  62837. samples: number;
  62838. /**
  62839. * Disposes the renderer and frees up associated resources.
  62840. */
  62841. dispose(): void;
  62842. protected _createRenderTargets(): void;
  62843. private _copyBonesTransformationMatrices;
  62844. }
  62845. }
  62846. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62847. import { Nullable } from "babylonjs/types";
  62848. import { Scene } from "babylonjs/scene";
  62849. import { ISceneComponent } from "babylonjs/sceneComponent";
  62850. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62851. module "babylonjs/scene" {
  62852. interface Scene {
  62853. /** @hidden (Backing field) */
  62854. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62855. /**
  62856. * Gets or Sets the current geometry buffer associated to the scene.
  62857. */
  62858. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62859. /**
  62860. * Enables a GeometryBufferRender and associates it with the scene
  62861. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62862. * @returns the GeometryBufferRenderer
  62863. */
  62864. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62865. /**
  62866. * Disables the GeometryBufferRender associated with the scene
  62867. */
  62868. disableGeometryBufferRenderer(): void;
  62869. }
  62870. }
  62871. /**
  62872. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62873. * in several rendering techniques.
  62874. */
  62875. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62876. /**
  62877. * The component name helpful to identify the component in the list of scene components.
  62878. */
  62879. readonly name: string;
  62880. /**
  62881. * The scene the component belongs to.
  62882. */
  62883. scene: Scene;
  62884. /**
  62885. * Creates a new instance of the component for the given scene
  62886. * @param scene Defines the scene to register the component in
  62887. */
  62888. constructor(scene: Scene);
  62889. /**
  62890. * Registers the component in a given scene
  62891. */
  62892. register(): void;
  62893. /**
  62894. * Rebuilds the elements related to this component in case of
  62895. * context lost for instance.
  62896. */
  62897. rebuild(): void;
  62898. /**
  62899. * Disposes the component and the associated ressources
  62900. */
  62901. dispose(): void;
  62902. private _gatherRenderTargets;
  62903. }
  62904. }
  62905. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62906. /** @hidden */
  62907. export var motionBlurPixelShader: {
  62908. name: string;
  62909. shader: string;
  62910. };
  62911. }
  62912. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62913. import { Nullable } from "babylonjs/types";
  62914. import { Camera } from "babylonjs/Cameras/camera";
  62915. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62916. import { Scene } from "babylonjs/scene";
  62917. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62918. import "babylonjs/Animations/animatable";
  62919. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62920. import "babylonjs/Shaders/motionBlur.fragment";
  62921. import { Engine } from "babylonjs/Engines/engine";
  62922. /**
  62923. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62924. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62925. * As an example, all you have to do is to create the post-process:
  62926. * var mb = new BABYLON.MotionBlurPostProcess(
  62927. * 'mb', // The name of the effect.
  62928. * scene, // The scene containing the objects to blur according to their velocity.
  62929. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62930. * camera // The camera to apply the render pass to.
  62931. * );
  62932. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62933. */
  62934. export class MotionBlurPostProcess extends PostProcess {
  62935. /**
  62936. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62937. */
  62938. motionStrength: number;
  62939. /**
  62940. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62941. */
  62942. /**
  62943. * Sets the number of iterations to be used for motion blur quality
  62944. */
  62945. motionBlurSamples: number;
  62946. private _motionBlurSamples;
  62947. private _geometryBufferRenderer;
  62948. /**
  62949. * Creates a new instance MotionBlurPostProcess
  62950. * @param name The name of the effect.
  62951. * @param scene The scene containing the objects to blur according to their velocity.
  62952. * @param options The required width/height ratio to downsize to before computing the render pass.
  62953. * @param camera The camera to apply the render pass to.
  62954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62955. * @param engine The engine which the post process will be applied. (default: current engine)
  62956. * @param reusable If the post process can be reused on the same frame. (default: false)
  62957. * @param textureType Type of textures used when performing the post process. (default: 0)
  62958. * @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)
  62959. */
  62960. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62961. /**
  62962. * Excludes the given skinned mesh from computing bones velocities.
  62963. * 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.
  62964. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62965. */
  62966. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62967. /**
  62968. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62969. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62970. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62971. */
  62972. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62973. /**
  62974. * Disposes the post process.
  62975. * @param camera The camera to dispose the post process on.
  62976. */
  62977. dispose(camera?: Camera): void;
  62978. }
  62979. }
  62980. declare module "babylonjs/Shaders/refraction.fragment" {
  62981. /** @hidden */
  62982. export var refractionPixelShader: {
  62983. name: string;
  62984. shader: string;
  62985. };
  62986. }
  62987. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62988. import { Color3 } from "babylonjs/Maths/math.color";
  62989. import { Camera } from "babylonjs/Cameras/camera";
  62990. import { Texture } from "babylonjs/Materials/Textures/texture";
  62991. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62992. import { Engine } from "babylonjs/Engines/engine";
  62993. import "babylonjs/Shaders/refraction.fragment";
  62994. /**
  62995. * Post process which applies a refractin texture
  62996. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62997. */
  62998. export class RefractionPostProcess extends PostProcess {
  62999. /** the base color of the refraction (used to taint the rendering) */
  63000. color: Color3;
  63001. /** simulated refraction depth */
  63002. depth: number;
  63003. /** the coefficient of the base color (0 to remove base color tainting) */
  63004. colorLevel: number;
  63005. private _refTexture;
  63006. private _ownRefractionTexture;
  63007. /**
  63008. * Gets or sets the refraction texture
  63009. * Please note that you are responsible for disposing the texture if you set it manually
  63010. */
  63011. refractionTexture: Texture;
  63012. /**
  63013. * Initializes the RefractionPostProcess
  63014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63015. * @param name The name of the effect.
  63016. * @param refractionTextureUrl Url of the refraction texture to use
  63017. * @param color the base color of the refraction (used to taint the rendering)
  63018. * @param depth simulated refraction depth
  63019. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63020. * @param camera The camera to apply the render pass to.
  63021. * @param options The required width/height ratio to downsize to before computing the render pass.
  63022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63023. * @param engine The engine which the post process will be applied. (default: current engine)
  63024. * @param reusable If the post process can be reused on the same frame. (default: false)
  63025. */
  63026. constructor(name: string, refractionTextureUrl: string,
  63027. /** the base color of the refraction (used to taint the rendering) */
  63028. color: Color3,
  63029. /** simulated refraction depth */
  63030. depth: number,
  63031. /** the coefficient of the base color (0 to remove base color tainting) */
  63032. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63033. /**
  63034. * Disposes of the post process
  63035. * @param camera Camera to dispose post process on
  63036. */
  63037. dispose(camera: Camera): void;
  63038. }
  63039. }
  63040. declare module "babylonjs/Shaders/sharpen.fragment" {
  63041. /** @hidden */
  63042. export var sharpenPixelShader: {
  63043. name: string;
  63044. shader: string;
  63045. };
  63046. }
  63047. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63048. import { Nullable } from "babylonjs/types";
  63049. import { Camera } from "babylonjs/Cameras/camera";
  63050. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63051. import "babylonjs/Shaders/sharpen.fragment";
  63052. import { Engine } from "babylonjs/Engines/engine";
  63053. /**
  63054. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63055. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63056. */
  63057. export class SharpenPostProcess extends PostProcess {
  63058. /**
  63059. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63060. */
  63061. colorAmount: number;
  63062. /**
  63063. * How much sharpness should be applied (default: 0.3)
  63064. */
  63065. edgeAmount: number;
  63066. /**
  63067. * Creates a new instance ConvolutionPostProcess
  63068. * @param name The name of the effect.
  63069. * @param options The required width/height ratio to downsize to before computing the render pass.
  63070. * @param camera The camera to apply the render pass to.
  63071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63072. * @param engine The engine which the post process will be applied. (default: current engine)
  63073. * @param reusable If the post process can be reused on the same frame. (default: false)
  63074. * @param textureType Type of textures used when performing the post process. (default: 0)
  63075. * @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)
  63076. */
  63077. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63078. }
  63079. }
  63080. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63081. import { Nullable } from "babylonjs/types";
  63082. import { Camera } from "babylonjs/Cameras/camera";
  63083. import { Engine } from "babylonjs/Engines/engine";
  63084. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63085. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63086. /**
  63087. * PostProcessRenderPipeline
  63088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63089. */
  63090. export class PostProcessRenderPipeline {
  63091. private engine;
  63092. private _renderEffects;
  63093. private _renderEffectsForIsolatedPass;
  63094. /**
  63095. * List of inspectable custom properties (used by the Inspector)
  63096. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63097. */
  63098. inspectableCustomProperties: IInspectable[];
  63099. /**
  63100. * @hidden
  63101. */
  63102. protected _cameras: Camera[];
  63103. /** @hidden */
  63104. _name: string;
  63105. /**
  63106. * Gets pipeline name
  63107. */
  63108. readonly name: string;
  63109. /**
  63110. * Initializes a PostProcessRenderPipeline
  63111. * @param engine engine to add the pipeline to
  63112. * @param name name of the pipeline
  63113. */
  63114. constructor(engine: Engine, name: string);
  63115. /**
  63116. * Gets the class name
  63117. * @returns "PostProcessRenderPipeline"
  63118. */
  63119. getClassName(): string;
  63120. /**
  63121. * If all the render effects in the pipeline are supported
  63122. */
  63123. readonly isSupported: boolean;
  63124. /**
  63125. * Adds an effect to the pipeline
  63126. * @param renderEffect the effect to add
  63127. */
  63128. addEffect(renderEffect: PostProcessRenderEffect): void;
  63129. /** @hidden */
  63130. _rebuild(): void;
  63131. /** @hidden */
  63132. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63133. /** @hidden */
  63134. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63135. /** @hidden */
  63136. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63137. /** @hidden */
  63138. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63139. /** @hidden */
  63140. _attachCameras(cameras: Camera, unique: boolean): void;
  63141. /** @hidden */
  63142. _attachCameras(cameras: Camera[], unique: boolean): void;
  63143. /** @hidden */
  63144. _detachCameras(cameras: Camera): void;
  63145. /** @hidden */
  63146. _detachCameras(cameras: Nullable<Camera[]>): void;
  63147. /** @hidden */
  63148. _update(): void;
  63149. /** @hidden */
  63150. _reset(): void;
  63151. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63152. /**
  63153. * Disposes of the pipeline
  63154. */
  63155. dispose(): void;
  63156. }
  63157. }
  63158. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63159. import { Camera } from "babylonjs/Cameras/camera";
  63160. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63161. /**
  63162. * PostProcessRenderPipelineManager class
  63163. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63164. */
  63165. export class PostProcessRenderPipelineManager {
  63166. private _renderPipelines;
  63167. /**
  63168. * Initializes a PostProcessRenderPipelineManager
  63169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63170. */
  63171. constructor();
  63172. /**
  63173. * Gets the list of supported render pipelines
  63174. */
  63175. readonly supportedPipelines: PostProcessRenderPipeline[];
  63176. /**
  63177. * Adds a pipeline to the manager
  63178. * @param renderPipeline The pipeline to add
  63179. */
  63180. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63181. /**
  63182. * Attaches a camera to the pipeline
  63183. * @param renderPipelineName The name of the pipeline to attach to
  63184. * @param cameras the camera to attach
  63185. * @param unique if the camera can be attached multiple times to the pipeline
  63186. */
  63187. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63188. /**
  63189. * Detaches a camera from the pipeline
  63190. * @param renderPipelineName The name of the pipeline to detach from
  63191. * @param cameras the camera to detach
  63192. */
  63193. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63194. /**
  63195. * Enables an effect by name on a pipeline
  63196. * @param renderPipelineName the name of the pipeline to enable the effect in
  63197. * @param renderEffectName the name of the effect to enable
  63198. * @param cameras the cameras that the effect should be enabled on
  63199. */
  63200. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63201. /**
  63202. * Disables an effect by name on a pipeline
  63203. * @param renderPipelineName the name of the pipeline to disable the effect in
  63204. * @param renderEffectName the name of the effect to disable
  63205. * @param cameras the cameras that the effect should be disabled on
  63206. */
  63207. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63208. /**
  63209. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63210. */
  63211. update(): void;
  63212. /** @hidden */
  63213. _rebuild(): void;
  63214. /**
  63215. * Disposes of the manager and pipelines
  63216. */
  63217. dispose(): void;
  63218. }
  63219. }
  63220. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63221. import { ISceneComponent } from "babylonjs/sceneComponent";
  63222. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63223. import { Scene } from "babylonjs/scene";
  63224. module "babylonjs/scene" {
  63225. interface Scene {
  63226. /** @hidden (Backing field) */
  63227. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63228. /**
  63229. * Gets the postprocess render pipeline manager
  63230. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63231. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63232. */
  63233. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63234. }
  63235. }
  63236. /**
  63237. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63238. */
  63239. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63240. /**
  63241. * The component name helpfull to identify the component in the list of scene components.
  63242. */
  63243. readonly name: string;
  63244. /**
  63245. * The scene the component belongs to.
  63246. */
  63247. scene: Scene;
  63248. /**
  63249. * Creates a new instance of the component for the given scene
  63250. * @param scene Defines the scene to register the component in
  63251. */
  63252. constructor(scene: Scene);
  63253. /**
  63254. * Registers the component in a given scene
  63255. */
  63256. register(): void;
  63257. /**
  63258. * Rebuilds the elements related to this component in case of
  63259. * context lost for instance.
  63260. */
  63261. rebuild(): void;
  63262. /**
  63263. * Disposes the component and the associated ressources
  63264. */
  63265. dispose(): void;
  63266. private _gatherRenderTargets;
  63267. }
  63268. }
  63269. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63270. import { Nullable } from "babylonjs/types";
  63271. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63272. import { Camera } from "babylonjs/Cameras/camera";
  63273. import { IDisposable } from "babylonjs/scene";
  63274. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63275. import { Scene } from "babylonjs/scene";
  63276. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63277. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63278. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63279. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63280. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63281. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63282. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63283. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63284. import { Animation } from "babylonjs/Animations/animation";
  63285. /**
  63286. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63287. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63288. */
  63289. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63290. private _scene;
  63291. private _camerasToBeAttached;
  63292. /**
  63293. * ID of the sharpen post process,
  63294. */
  63295. private readonly SharpenPostProcessId;
  63296. /**
  63297. * @ignore
  63298. * ID of the image processing post process;
  63299. */
  63300. readonly ImageProcessingPostProcessId: string;
  63301. /**
  63302. * @ignore
  63303. * ID of the Fast Approximate Anti-Aliasing post process;
  63304. */
  63305. readonly FxaaPostProcessId: string;
  63306. /**
  63307. * ID of the chromatic aberration post process,
  63308. */
  63309. private readonly ChromaticAberrationPostProcessId;
  63310. /**
  63311. * ID of the grain post process
  63312. */
  63313. private readonly GrainPostProcessId;
  63314. /**
  63315. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63316. */
  63317. sharpen: SharpenPostProcess;
  63318. private _sharpenEffect;
  63319. private bloom;
  63320. /**
  63321. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63322. */
  63323. depthOfField: DepthOfFieldEffect;
  63324. /**
  63325. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63326. */
  63327. fxaa: FxaaPostProcess;
  63328. /**
  63329. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63330. */
  63331. imageProcessing: ImageProcessingPostProcess;
  63332. /**
  63333. * Chromatic aberration post process which will shift rgb colors in the image
  63334. */
  63335. chromaticAberration: ChromaticAberrationPostProcess;
  63336. private _chromaticAberrationEffect;
  63337. /**
  63338. * Grain post process which add noise to the image
  63339. */
  63340. grain: GrainPostProcess;
  63341. private _grainEffect;
  63342. /**
  63343. * Glow post process which adds a glow to emissive areas of the image
  63344. */
  63345. private _glowLayer;
  63346. /**
  63347. * Animations which can be used to tweak settings over a period of time
  63348. */
  63349. animations: Animation[];
  63350. private _imageProcessingConfigurationObserver;
  63351. private _sharpenEnabled;
  63352. private _bloomEnabled;
  63353. private _depthOfFieldEnabled;
  63354. private _depthOfFieldBlurLevel;
  63355. private _fxaaEnabled;
  63356. private _imageProcessingEnabled;
  63357. private _defaultPipelineTextureType;
  63358. private _bloomScale;
  63359. private _chromaticAberrationEnabled;
  63360. private _grainEnabled;
  63361. private _buildAllowed;
  63362. /**
  63363. * Gets active scene
  63364. */
  63365. readonly scene: Scene;
  63366. /**
  63367. * Enable or disable the sharpen process from the pipeline
  63368. */
  63369. sharpenEnabled: boolean;
  63370. private _resizeObserver;
  63371. private _hardwareScaleLevel;
  63372. private _bloomKernel;
  63373. /**
  63374. * Specifies the size of the bloom blur kernel, relative to the final output size
  63375. */
  63376. bloomKernel: number;
  63377. /**
  63378. * Specifies the weight of the bloom in the final rendering
  63379. */
  63380. private _bloomWeight;
  63381. /**
  63382. * Specifies the luma threshold for the area that will be blurred by the bloom
  63383. */
  63384. private _bloomThreshold;
  63385. private _hdr;
  63386. /**
  63387. * The strength of the bloom.
  63388. */
  63389. bloomWeight: number;
  63390. /**
  63391. * The strength of the bloom.
  63392. */
  63393. bloomThreshold: number;
  63394. /**
  63395. * The scale of the bloom, lower value will provide better performance.
  63396. */
  63397. bloomScale: number;
  63398. /**
  63399. * Enable or disable the bloom from the pipeline
  63400. */
  63401. bloomEnabled: boolean;
  63402. private _rebuildBloom;
  63403. /**
  63404. * If the depth of field is enabled.
  63405. */
  63406. depthOfFieldEnabled: boolean;
  63407. /**
  63408. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63409. */
  63410. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63411. /**
  63412. * If the anti aliasing is enabled.
  63413. */
  63414. fxaaEnabled: boolean;
  63415. private _samples;
  63416. /**
  63417. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63418. */
  63419. samples: number;
  63420. /**
  63421. * If image processing is enabled.
  63422. */
  63423. imageProcessingEnabled: boolean;
  63424. /**
  63425. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63426. */
  63427. glowLayerEnabled: boolean;
  63428. /**
  63429. * Gets the glow layer (or null if not defined)
  63430. */
  63431. readonly glowLayer: Nullable<GlowLayer>;
  63432. /**
  63433. * Enable or disable the chromaticAberration process from the pipeline
  63434. */
  63435. chromaticAberrationEnabled: boolean;
  63436. /**
  63437. * Enable or disable the grain process from the pipeline
  63438. */
  63439. grainEnabled: boolean;
  63440. /**
  63441. * @constructor
  63442. * @param name - The rendering pipeline name (default: "")
  63443. * @param hdr - If high dynamic range textures should be used (default: true)
  63444. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63445. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63446. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63447. */
  63448. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63449. /**
  63450. * Get the class name
  63451. * @returns "DefaultRenderingPipeline"
  63452. */
  63453. getClassName(): string;
  63454. /**
  63455. * Force the compilation of the entire pipeline.
  63456. */
  63457. prepare(): void;
  63458. private _hasCleared;
  63459. private _prevPostProcess;
  63460. private _prevPrevPostProcess;
  63461. private _setAutoClearAndTextureSharing;
  63462. private _depthOfFieldSceneObserver;
  63463. private _buildPipeline;
  63464. private _disposePostProcesses;
  63465. /**
  63466. * Adds a camera to the pipeline
  63467. * @param camera the camera to be added
  63468. */
  63469. addCamera(camera: Camera): void;
  63470. /**
  63471. * Removes a camera from the pipeline
  63472. * @param camera the camera to remove
  63473. */
  63474. removeCamera(camera: Camera): void;
  63475. /**
  63476. * Dispose of the pipeline and stop all post processes
  63477. */
  63478. dispose(): void;
  63479. /**
  63480. * Serialize the rendering pipeline (Used when exporting)
  63481. * @returns the serialized object
  63482. */
  63483. serialize(): any;
  63484. /**
  63485. * Parse the serialized pipeline
  63486. * @param source Source pipeline.
  63487. * @param scene The scene to load the pipeline to.
  63488. * @param rootUrl The URL of the serialized pipeline.
  63489. * @returns An instantiated pipeline from the serialized object.
  63490. */
  63491. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63492. }
  63493. }
  63494. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63495. /** @hidden */
  63496. export var lensHighlightsPixelShader: {
  63497. name: string;
  63498. shader: string;
  63499. };
  63500. }
  63501. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63502. /** @hidden */
  63503. export var depthOfFieldPixelShader: {
  63504. name: string;
  63505. shader: string;
  63506. };
  63507. }
  63508. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63509. import { Camera } from "babylonjs/Cameras/camera";
  63510. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63511. import { Scene } from "babylonjs/scene";
  63512. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63513. import "babylonjs/Shaders/chromaticAberration.fragment";
  63514. import "babylonjs/Shaders/lensHighlights.fragment";
  63515. import "babylonjs/Shaders/depthOfField.fragment";
  63516. /**
  63517. * BABYLON.JS Chromatic Aberration GLSL Shader
  63518. * Author: Olivier Guyot
  63519. * Separates very slightly R, G and B colors on the edges of the screen
  63520. * Inspired by Francois Tarlier & Martins Upitis
  63521. */
  63522. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63523. /**
  63524. * @ignore
  63525. * The chromatic aberration PostProcess id in the pipeline
  63526. */
  63527. LensChromaticAberrationEffect: string;
  63528. /**
  63529. * @ignore
  63530. * The highlights enhancing PostProcess id in the pipeline
  63531. */
  63532. HighlightsEnhancingEffect: string;
  63533. /**
  63534. * @ignore
  63535. * The depth-of-field PostProcess id in the pipeline
  63536. */
  63537. LensDepthOfFieldEffect: string;
  63538. private _scene;
  63539. private _depthTexture;
  63540. private _grainTexture;
  63541. private _chromaticAberrationPostProcess;
  63542. private _highlightsPostProcess;
  63543. private _depthOfFieldPostProcess;
  63544. private _edgeBlur;
  63545. private _grainAmount;
  63546. private _chromaticAberration;
  63547. private _distortion;
  63548. private _highlightsGain;
  63549. private _highlightsThreshold;
  63550. private _dofDistance;
  63551. private _dofAperture;
  63552. private _dofDarken;
  63553. private _dofPentagon;
  63554. private _blurNoise;
  63555. /**
  63556. * @constructor
  63557. *
  63558. * Effect parameters are as follow:
  63559. * {
  63560. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63561. * edge_blur: number; // from 0 to x (1 for realism)
  63562. * distortion: number; // from 0 to x (1 for realism)
  63563. * grain_amount: number; // from 0 to 1
  63564. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63565. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63566. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63567. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63568. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63569. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63570. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63571. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63572. * }
  63573. * Note: if an effect parameter is unset, effect is disabled
  63574. *
  63575. * @param name The rendering pipeline name
  63576. * @param parameters - An object containing all parameters (see above)
  63577. * @param scene The scene linked to this pipeline
  63578. * @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)
  63579. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63580. */
  63581. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63582. /**
  63583. * Get the class name
  63584. * @returns "LensRenderingPipeline"
  63585. */
  63586. getClassName(): string;
  63587. /**
  63588. * Gets associated scene
  63589. */
  63590. readonly scene: Scene;
  63591. /**
  63592. * Gets or sets the edge blur
  63593. */
  63594. edgeBlur: number;
  63595. /**
  63596. * Gets or sets the grain amount
  63597. */
  63598. grainAmount: number;
  63599. /**
  63600. * Gets or sets the chromatic aberration amount
  63601. */
  63602. chromaticAberration: number;
  63603. /**
  63604. * Gets or sets the depth of field aperture
  63605. */
  63606. dofAperture: number;
  63607. /**
  63608. * Gets or sets the edge distortion
  63609. */
  63610. edgeDistortion: number;
  63611. /**
  63612. * Gets or sets the depth of field distortion
  63613. */
  63614. dofDistortion: number;
  63615. /**
  63616. * Gets or sets the darken out of focus amount
  63617. */
  63618. darkenOutOfFocus: number;
  63619. /**
  63620. * Gets or sets a boolean indicating if blur noise is enabled
  63621. */
  63622. blurNoise: boolean;
  63623. /**
  63624. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63625. */
  63626. pentagonBokeh: boolean;
  63627. /**
  63628. * Gets or sets the highlight grain amount
  63629. */
  63630. highlightsGain: number;
  63631. /**
  63632. * Gets or sets the highlight threshold
  63633. */
  63634. highlightsThreshold: number;
  63635. /**
  63636. * Sets the amount of blur at the edges
  63637. * @param amount blur amount
  63638. */
  63639. setEdgeBlur(amount: number): void;
  63640. /**
  63641. * Sets edge blur to 0
  63642. */
  63643. disableEdgeBlur(): void;
  63644. /**
  63645. * Sets the amout of grain
  63646. * @param amount Amount of grain
  63647. */
  63648. setGrainAmount(amount: number): void;
  63649. /**
  63650. * Set grain amount to 0
  63651. */
  63652. disableGrain(): void;
  63653. /**
  63654. * Sets the chromatic aberration amount
  63655. * @param amount amount of chromatic aberration
  63656. */
  63657. setChromaticAberration(amount: number): void;
  63658. /**
  63659. * Sets chromatic aberration amount to 0
  63660. */
  63661. disableChromaticAberration(): void;
  63662. /**
  63663. * Sets the EdgeDistortion amount
  63664. * @param amount amount of EdgeDistortion
  63665. */
  63666. setEdgeDistortion(amount: number): void;
  63667. /**
  63668. * Sets edge distortion to 0
  63669. */
  63670. disableEdgeDistortion(): void;
  63671. /**
  63672. * Sets the FocusDistance amount
  63673. * @param amount amount of FocusDistance
  63674. */
  63675. setFocusDistance(amount: number): void;
  63676. /**
  63677. * Disables depth of field
  63678. */
  63679. disableDepthOfField(): void;
  63680. /**
  63681. * Sets the Aperture amount
  63682. * @param amount amount of Aperture
  63683. */
  63684. setAperture(amount: number): void;
  63685. /**
  63686. * Sets the DarkenOutOfFocus amount
  63687. * @param amount amount of DarkenOutOfFocus
  63688. */
  63689. setDarkenOutOfFocus(amount: number): void;
  63690. private _pentagonBokehIsEnabled;
  63691. /**
  63692. * Creates a pentagon bokeh effect
  63693. */
  63694. enablePentagonBokeh(): void;
  63695. /**
  63696. * Disables the pentagon bokeh effect
  63697. */
  63698. disablePentagonBokeh(): void;
  63699. /**
  63700. * Enables noise blur
  63701. */
  63702. enableNoiseBlur(): void;
  63703. /**
  63704. * Disables noise blur
  63705. */
  63706. disableNoiseBlur(): void;
  63707. /**
  63708. * Sets the HighlightsGain amount
  63709. * @param amount amount of HighlightsGain
  63710. */
  63711. setHighlightsGain(amount: number): void;
  63712. /**
  63713. * Sets the HighlightsThreshold amount
  63714. * @param amount amount of HighlightsThreshold
  63715. */
  63716. setHighlightsThreshold(amount: number): void;
  63717. /**
  63718. * Disables highlights
  63719. */
  63720. disableHighlights(): void;
  63721. /**
  63722. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63723. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63724. */
  63725. dispose(disableDepthRender?: boolean): void;
  63726. private _createChromaticAberrationPostProcess;
  63727. private _createHighlightsPostProcess;
  63728. private _createDepthOfFieldPostProcess;
  63729. private _createGrainTexture;
  63730. }
  63731. }
  63732. declare module "babylonjs/Shaders/ssao2.fragment" {
  63733. /** @hidden */
  63734. export var ssao2PixelShader: {
  63735. name: string;
  63736. shader: string;
  63737. };
  63738. }
  63739. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63740. /** @hidden */
  63741. export var ssaoCombinePixelShader: {
  63742. name: string;
  63743. shader: string;
  63744. };
  63745. }
  63746. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63747. import { Camera } from "babylonjs/Cameras/camera";
  63748. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63749. import { Scene } from "babylonjs/scene";
  63750. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63751. import "babylonjs/Shaders/ssao2.fragment";
  63752. import "babylonjs/Shaders/ssaoCombine.fragment";
  63753. /**
  63754. * Render pipeline to produce ssao effect
  63755. */
  63756. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63757. /**
  63758. * @ignore
  63759. * The PassPostProcess id in the pipeline that contains the original scene color
  63760. */
  63761. SSAOOriginalSceneColorEffect: string;
  63762. /**
  63763. * @ignore
  63764. * The SSAO PostProcess id in the pipeline
  63765. */
  63766. SSAORenderEffect: string;
  63767. /**
  63768. * @ignore
  63769. * The horizontal blur PostProcess id in the pipeline
  63770. */
  63771. SSAOBlurHRenderEffect: string;
  63772. /**
  63773. * @ignore
  63774. * The vertical blur PostProcess id in the pipeline
  63775. */
  63776. SSAOBlurVRenderEffect: string;
  63777. /**
  63778. * @ignore
  63779. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63780. */
  63781. SSAOCombineRenderEffect: string;
  63782. /**
  63783. * The output strength of the SSAO post-process. Default value is 1.0.
  63784. */
  63785. totalStrength: number;
  63786. /**
  63787. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63788. */
  63789. maxZ: number;
  63790. /**
  63791. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63792. */
  63793. minZAspect: number;
  63794. private _samples;
  63795. /**
  63796. * Number of samples used for the SSAO calculations. Default value is 8
  63797. */
  63798. samples: number;
  63799. private _textureSamples;
  63800. /**
  63801. * Number of samples to use for antialiasing
  63802. */
  63803. textureSamples: number;
  63804. /**
  63805. * Ratio object used for SSAO ratio and blur ratio
  63806. */
  63807. private _ratio;
  63808. /**
  63809. * Dynamically generated sphere sampler.
  63810. */
  63811. private _sampleSphere;
  63812. /**
  63813. * Blur filter offsets
  63814. */
  63815. private _samplerOffsets;
  63816. private _expensiveBlur;
  63817. /**
  63818. * If bilateral blur should be used
  63819. */
  63820. expensiveBlur: boolean;
  63821. /**
  63822. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63823. */
  63824. radius: number;
  63825. /**
  63826. * The base color of the SSAO post-process
  63827. * The final result is "base + ssao" between [0, 1]
  63828. */
  63829. base: number;
  63830. /**
  63831. * Support test.
  63832. */
  63833. static readonly IsSupported: boolean;
  63834. private _scene;
  63835. private _depthTexture;
  63836. private _normalTexture;
  63837. private _randomTexture;
  63838. private _originalColorPostProcess;
  63839. private _ssaoPostProcess;
  63840. private _blurHPostProcess;
  63841. private _blurVPostProcess;
  63842. private _ssaoCombinePostProcess;
  63843. private _firstUpdate;
  63844. /**
  63845. * Gets active scene
  63846. */
  63847. readonly scene: Scene;
  63848. /**
  63849. * @constructor
  63850. * @param name The rendering pipeline name
  63851. * @param scene The scene linked to this pipeline
  63852. * @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 }
  63853. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63854. */
  63855. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63856. /**
  63857. * Get the class name
  63858. * @returns "SSAO2RenderingPipeline"
  63859. */
  63860. getClassName(): string;
  63861. /**
  63862. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63863. */
  63864. dispose(disableGeometryBufferRenderer?: boolean): void;
  63865. private _createBlurPostProcess;
  63866. /** @hidden */
  63867. _rebuild(): void;
  63868. private _bits;
  63869. private _radicalInverse_VdC;
  63870. private _hammersley;
  63871. private _hemisphereSample_uniform;
  63872. private _generateHemisphere;
  63873. private _createSSAOPostProcess;
  63874. private _createSSAOCombinePostProcess;
  63875. private _createRandomTexture;
  63876. /**
  63877. * Serialize the rendering pipeline (Used when exporting)
  63878. * @returns the serialized object
  63879. */
  63880. serialize(): any;
  63881. /**
  63882. * Parse the serialized pipeline
  63883. * @param source Source pipeline.
  63884. * @param scene The scene to load the pipeline to.
  63885. * @param rootUrl The URL of the serialized pipeline.
  63886. * @returns An instantiated pipeline from the serialized object.
  63887. */
  63888. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63889. }
  63890. }
  63891. declare module "babylonjs/Shaders/ssao.fragment" {
  63892. /** @hidden */
  63893. export var ssaoPixelShader: {
  63894. name: string;
  63895. shader: string;
  63896. };
  63897. }
  63898. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63899. import { Camera } from "babylonjs/Cameras/camera";
  63900. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63901. import { Scene } from "babylonjs/scene";
  63902. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63903. import "babylonjs/Shaders/ssao.fragment";
  63904. import "babylonjs/Shaders/ssaoCombine.fragment";
  63905. /**
  63906. * Render pipeline to produce ssao effect
  63907. */
  63908. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63909. /**
  63910. * @ignore
  63911. * The PassPostProcess id in the pipeline that contains the original scene color
  63912. */
  63913. SSAOOriginalSceneColorEffect: string;
  63914. /**
  63915. * @ignore
  63916. * The SSAO PostProcess id in the pipeline
  63917. */
  63918. SSAORenderEffect: string;
  63919. /**
  63920. * @ignore
  63921. * The horizontal blur PostProcess id in the pipeline
  63922. */
  63923. SSAOBlurHRenderEffect: string;
  63924. /**
  63925. * @ignore
  63926. * The vertical blur PostProcess id in the pipeline
  63927. */
  63928. SSAOBlurVRenderEffect: string;
  63929. /**
  63930. * @ignore
  63931. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63932. */
  63933. SSAOCombineRenderEffect: string;
  63934. /**
  63935. * The output strength of the SSAO post-process. Default value is 1.0.
  63936. */
  63937. totalStrength: number;
  63938. /**
  63939. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63940. */
  63941. radius: number;
  63942. /**
  63943. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63944. * Must not be equal to fallOff and superior to fallOff.
  63945. * Default value is 0.0075
  63946. */
  63947. area: number;
  63948. /**
  63949. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63950. * Must not be equal to area and inferior to area.
  63951. * Default value is 0.000001
  63952. */
  63953. fallOff: number;
  63954. /**
  63955. * The base color of the SSAO post-process
  63956. * The final result is "base + ssao" between [0, 1]
  63957. */
  63958. base: number;
  63959. private _scene;
  63960. private _depthTexture;
  63961. private _randomTexture;
  63962. private _originalColorPostProcess;
  63963. private _ssaoPostProcess;
  63964. private _blurHPostProcess;
  63965. private _blurVPostProcess;
  63966. private _ssaoCombinePostProcess;
  63967. private _firstUpdate;
  63968. /**
  63969. * Gets active scene
  63970. */
  63971. readonly scene: Scene;
  63972. /**
  63973. * @constructor
  63974. * @param name - The rendering pipeline name
  63975. * @param scene - The scene linked to this pipeline
  63976. * @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 }
  63977. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63978. */
  63979. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63980. /**
  63981. * Get the class name
  63982. * @returns "SSAORenderingPipeline"
  63983. */
  63984. getClassName(): string;
  63985. /**
  63986. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63987. */
  63988. dispose(disableDepthRender?: boolean): void;
  63989. private _createBlurPostProcess;
  63990. /** @hidden */
  63991. _rebuild(): void;
  63992. private _createSSAOPostProcess;
  63993. private _createSSAOCombinePostProcess;
  63994. private _createRandomTexture;
  63995. }
  63996. }
  63997. declare module "babylonjs/Shaders/standard.fragment" {
  63998. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63999. /** @hidden */
  64000. export var standardPixelShader: {
  64001. name: string;
  64002. shader: string;
  64003. };
  64004. }
  64005. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64006. import { Nullable } from "babylonjs/types";
  64007. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64008. import { Camera } from "babylonjs/Cameras/camera";
  64009. import { Texture } from "babylonjs/Materials/Textures/texture";
  64010. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64011. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64012. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64013. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64014. import { IDisposable } from "babylonjs/scene";
  64015. import { SpotLight } from "babylonjs/Lights/spotLight";
  64016. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64017. import { Scene } from "babylonjs/scene";
  64018. import { Animation } from "babylonjs/Animations/animation";
  64019. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64020. import "babylonjs/Shaders/standard.fragment";
  64021. /**
  64022. * Standard rendering pipeline
  64023. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64024. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64025. */
  64026. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64027. /**
  64028. * Public members
  64029. */
  64030. /**
  64031. * Post-process which contains the original scene color before the pipeline applies all the effects
  64032. */
  64033. originalPostProcess: Nullable<PostProcess>;
  64034. /**
  64035. * Post-process used to down scale an image x4
  64036. */
  64037. downSampleX4PostProcess: Nullable<PostProcess>;
  64038. /**
  64039. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64040. */
  64041. brightPassPostProcess: Nullable<PostProcess>;
  64042. /**
  64043. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64044. */
  64045. blurHPostProcesses: PostProcess[];
  64046. /**
  64047. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64048. */
  64049. blurVPostProcesses: PostProcess[];
  64050. /**
  64051. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64052. */
  64053. textureAdderPostProcess: Nullable<PostProcess>;
  64054. /**
  64055. * Post-process used to create volumetric lighting effect
  64056. */
  64057. volumetricLightPostProcess: Nullable<PostProcess>;
  64058. /**
  64059. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64060. */
  64061. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64062. /**
  64063. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64064. */
  64065. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64066. /**
  64067. * Post-process used to merge the volumetric light effect and the real scene color
  64068. */
  64069. volumetricLightMergePostProces: Nullable<PostProcess>;
  64070. /**
  64071. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64072. */
  64073. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64074. /**
  64075. * Base post-process used to calculate the average luminance of the final image for HDR
  64076. */
  64077. luminancePostProcess: Nullable<PostProcess>;
  64078. /**
  64079. * Post-processes used to create down sample post-processes in order to get
  64080. * the average luminance of the final image for HDR
  64081. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64082. */
  64083. luminanceDownSamplePostProcesses: PostProcess[];
  64084. /**
  64085. * Post-process used to create a HDR effect (light adaptation)
  64086. */
  64087. hdrPostProcess: Nullable<PostProcess>;
  64088. /**
  64089. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64090. */
  64091. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64092. /**
  64093. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64094. */
  64095. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64096. /**
  64097. * Post-process used to merge the final HDR post-process and the real scene color
  64098. */
  64099. hdrFinalPostProcess: Nullable<PostProcess>;
  64100. /**
  64101. * Post-process used to create a lens flare effect
  64102. */
  64103. lensFlarePostProcess: Nullable<PostProcess>;
  64104. /**
  64105. * Post-process that merges the result of the lens flare post-process and the real scene color
  64106. */
  64107. lensFlareComposePostProcess: Nullable<PostProcess>;
  64108. /**
  64109. * Post-process used to create a motion blur effect
  64110. */
  64111. motionBlurPostProcess: Nullable<PostProcess>;
  64112. /**
  64113. * Post-process used to create a depth of field effect
  64114. */
  64115. depthOfFieldPostProcess: Nullable<PostProcess>;
  64116. /**
  64117. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64118. */
  64119. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64120. /**
  64121. * Represents the brightness threshold in order to configure the illuminated surfaces
  64122. */
  64123. brightThreshold: number;
  64124. /**
  64125. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64126. */
  64127. blurWidth: number;
  64128. /**
  64129. * Sets if the blur for highlighted surfaces must be only horizontal
  64130. */
  64131. horizontalBlur: boolean;
  64132. /**
  64133. * Gets the overall exposure used by the pipeline
  64134. */
  64135. /**
  64136. * Sets the overall exposure used by the pipeline
  64137. */
  64138. exposure: number;
  64139. /**
  64140. * Texture used typically to simulate "dirty" on camera lens
  64141. */
  64142. lensTexture: Nullable<Texture>;
  64143. /**
  64144. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64145. */
  64146. volumetricLightCoefficient: number;
  64147. /**
  64148. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64149. */
  64150. volumetricLightPower: number;
  64151. /**
  64152. * Used the set the blur intensity to smooth the volumetric lights
  64153. */
  64154. volumetricLightBlurScale: number;
  64155. /**
  64156. * Light (spot or directional) used to generate the volumetric lights rays
  64157. * The source light must have a shadow generate so the pipeline can get its
  64158. * depth map
  64159. */
  64160. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64161. /**
  64162. * For eye adaptation, represents the minimum luminance the eye can see
  64163. */
  64164. hdrMinimumLuminance: number;
  64165. /**
  64166. * For eye adaptation, represents the decrease luminance speed
  64167. */
  64168. hdrDecreaseRate: number;
  64169. /**
  64170. * For eye adaptation, represents the increase luminance speed
  64171. */
  64172. hdrIncreaseRate: number;
  64173. /**
  64174. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64175. */
  64176. /**
  64177. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64178. */
  64179. hdrAutoExposure: boolean;
  64180. /**
  64181. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64182. */
  64183. lensColorTexture: Nullable<Texture>;
  64184. /**
  64185. * The overall strengh for the lens flare effect
  64186. */
  64187. lensFlareStrength: number;
  64188. /**
  64189. * Dispersion coefficient for lens flare ghosts
  64190. */
  64191. lensFlareGhostDispersal: number;
  64192. /**
  64193. * Main lens flare halo width
  64194. */
  64195. lensFlareHaloWidth: number;
  64196. /**
  64197. * Based on the lens distortion effect, defines how much the lens flare result
  64198. * is distorted
  64199. */
  64200. lensFlareDistortionStrength: number;
  64201. /**
  64202. * Configures the blur intensity used for for lens flare (halo)
  64203. */
  64204. lensFlareBlurWidth: number;
  64205. /**
  64206. * Lens star texture must be used to simulate rays on the flares and is available
  64207. * in the documentation
  64208. */
  64209. lensStarTexture: Nullable<Texture>;
  64210. /**
  64211. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64212. * flare effect by taking account of the dirt texture
  64213. */
  64214. lensFlareDirtTexture: Nullable<Texture>;
  64215. /**
  64216. * Represents the focal length for the depth of field effect
  64217. */
  64218. depthOfFieldDistance: number;
  64219. /**
  64220. * Represents the blur intensity for the blurred part of the depth of field effect
  64221. */
  64222. depthOfFieldBlurWidth: number;
  64223. /**
  64224. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64225. */
  64226. /**
  64227. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64228. */
  64229. motionStrength: number;
  64230. /**
  64231. * Gets wether or not the motion blur post-process is object based or screen based.
  64232. */
  64233. /**
  64234. * Sets wether or not the motion blur post-process should be object based or screen based
  64235. */
  64236. objectBasedMotionBlur: boolean;
  64237. /**
  64238. * List of animations for the pipeline (IAnimatable implementation)
  64239. */
  64240. animations: Animation[];
  64241. /**
  64242. * Private members
  64243. */
  64244. private _scene;
  64245. private _currentDepthOfFieldSource;
  64246. private _basePostProcess;
  64247. private _fixedExposure;
  64248. private _currentExposure;
  64249. private _hdrAutoExposure;
  64250. private _hdrCurrentLuminance;
  64251. private _motionStrength;
  64252. private _isObjectBasedMotionBlur;
  64253. private _floatTextureType;
  64254. private _camerasToBeAttached;
  64255. private _ratio;
  64256. private _bloomEnabled;
  64257. private _depthOfFieldEnabled;
  64258. private _vlsEnabled;
  64259. private _lensFlareEnabled;
  64260. private _hdrEnabled;
  64261. private _motionBlurEnabled;
  64262. private _fxaaEnabled;
  64263. private _motionBlurSamples;
  64264. private _volumetricLightStepsCount;
  64265. private _samples;
  64266. /**
  64267. * @ignore
  64268. * Specifies if the bloom pipeline is enabled
  64269. */
  64270. BloomEnabled: boolean;
  64271. /**
  64272. * @ignore
  64273. * Specifies if the depth of field pipeline is enabed
  64274. */
  64275. DepthOfFieldEnabled: boolean;
  64276. /**
  64277. * @ignore
  64278. * Specifies if the lens flare pipeline is enabed
  64279. */
  64280. LensFlareEnabled: boolean;
  64281. /**
  64282. * @ignore
  64283. * Specifies if the HDR pipeline is enabled
  64284. */
  64285. HDREnabled: boolean;
  64286. /**
  64287. * @ignore
  64288. * Specifies if the volumetric lights scattering effect is enabled
  64289. */
  64290. VLSEnabled: boolean;
  64291. /**
  64292. * @ignore
  64293. * Specifies if the motion blur effect is enabled
  64294. */
  64295. MotionBlurEnabled: boolean;
  64296. /**
  64297. * Specifies if anti-aliasing is enabled
  64298. */
  64299. fxaaEnabled: boolean;
  64300. /**
  64301. * Specifies the number of steps used to calculate the volumetric lights
  64302. * Typically in interval [50, 200]
  64303. */
  64304. volumetricLightStepsCount: number;
  64305. /**
  64306. * Specifies the number of samples used for the motion blur effect
  64307. * Typically in interval [16, 64]
  64308. */
  64309. motionBlurSamples: number;
  64310. /**
  64311. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64312. */
  64313. samples: number;
  64314. /**
  64315. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64316. * @constructor
  64317. * @param name The rendering pipeline name
  64318. * @param scene The scene linked to this pipeline
  64319. * @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)
  64320. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64321. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64322. */
  64323. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64324. private _buildPipeline;
  64325. private _createDownSampleX4PostProcess;
  64326. private _createBrightPassPostProcess;
  64327. private _createBlurPostProcesses;
  64328. private _createTextureAdderPostProcess;
  64329. private _createVolumetricLightPostProcess;
  64330. private _createLuminancePostProcesses;
  64331. private _createHdrPostProcess;
  64332. private _createLensFlarePostProcess;
  64333. private _createDepthOfFieldPostProcess;
  64334. private _createMotionBlurPostProcess;
  64335. private _getDepthTexture;
  64336. private _disposePostProcesses;
  64337. /**
  64338. * Dispose of the pipeline and stop all post processes
  64339. */
  64340. dispose(): void;
  64341. /**
  64342. * Serialize the rendering pipeline (Used when exporting)
  64343. * @returns the serialized object
  64344. */
  64345. serialize(): any;
  64346. /**
  64347. * Parse the serialized pipeline
  64348. * @param source Source pipeline.
  64349. * @param scene The scene to load the pipeline to.
  64350. * @param rootUrl The URL of the serialized pipeline.
  64351. * @returns An instantiated pipeline from the serialized object.
  64352. */
  64353. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64354. /**
  64355. * Luminance steps
  64356. */
  64357. static LuminanceSteps: number;
  64358. }
  64359. }
  64360. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64361. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64362. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64363. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64364. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64365. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64366. }
  64367. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64368. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64369. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64370. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64371. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64372. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64373. }
  64374. declare module "babylonjs/Shaders/tonemap.fragment" {
  64375. /** @hidden */
  64376. export var tonemapPixelShader: {
  64377. name: string;
  64378. shader: string;
  64379. };
  64380. }
  64381. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64382. import { Camera } from "babylonjs/Cameras/camera";
  64383. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64384. import "babylonjs/Shaders/tonemap.fragment";
  64385. import { Engine } from "babylonjs/Engines/engine";
  64386. /** Defines operator used for tonemapping */
  64387. export enum TonemappingOperator {
  64388. /** Hable */
  64389. Hable = 0,
  64390. /** Reinhard */
  64391. Reinhard = 1,
  64392. /** HejiDawson */
  64393. HejiDawson = 2,
  64394. /** Photographic */
  64395. Photographic = 3
  64396. }
  64397. /**
  64398. * Defines a post process to apply tone mapping
  64399. */
  64400. export class TonemapPostProcess extends PostProcess {
  64401. private _operator;
  64402. /** Defines the required exposure adjustement */
  64403. exposureAdjustment: number;
  64404. /**
  64405. * Creates a new TonemapPostProcess
  64406. * @param name defines the name of the postprocess
  64407. * @param _operator defines the operator to use
  64408. * @param exposureAdjustment defines the required exposure adjustement
  64409. * @param camera defines the camera to use (can be null)
  64410. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64411. * @param engine defines the hosting engine (can be ignore if camera is set)
  64412. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64413. */
  64414. constructor(name: string, _operator: TonemappingOperator,
  64415. /** Defines the required exposure adjustement */
  64416. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64417. }
  64418. }
  64419. declare module "babylonjs/Shaders/depth.vertex" {
  64420. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64422. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64423. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64424. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64425. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64426. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64427. /** @hidden */
  64428. export var depthVertexShader: {
  64429. name: string;
  64430. shader: string;
  64431. };
  64432. }
  64433. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64434. /** @hidden */
  64435. export var volumetricLightScatteringPixelShader: {
  64436. name: string;
  64437. shader: string;
  64438. };
  64439. }
  64440. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64441. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64442. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64443. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64444. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64445. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64446. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64447. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64448. /** @hidden */
  64449. export var volumetricLightScatteringPassVertexShader: {
  64450. name: string;
  64451. shader: string;
  64452. };
  64453. }
  64454. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64455. /** @hidden */
  64456. export var volumetricLightScatteringPassPixelShader: {
  64457. name: string;
  64458. shader: string;
  64459. };
  64460. }
  64461. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64462. import { Vector3 } from "babylonjs/Maths/math.vector";
  64463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64464. import { Mesh } from "babylonjs/Meshes/mesh";
  64465. import { Camera } from "babylonjs/Cameras/camera";
  64466. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64467. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64468. import { Scene } from "babylonjs/scene";
  64469. import "babylonjs/Meshes/Builders/planeBuilder";
  64470. import "babylonjs/Shaders/depth.vertex";
  64471. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64472. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64473. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64474. import { Engine } from "babylonjs/Engines/engine";
  64475. /**
  64476. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64477. */
  64478. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64479. private _volumetricLightScatteringPass;
  64480. private _volumetricLightScatteringRTT;
  64481. private _viewPort;
  64482. private _screenCoordinates;
  64483. private _cachedDefines;
  64484. /**
  64485. * If not undefined, the mesh position is computed from the attached node position
  64486. */
  64487. attachedNode: {
  64488. position: Vector3;
  64489. };
  64490. /**
  64491. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64492. */
  64493. customMeshPosition: Vector3;
  64494. /**
  64495. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64496. */
  64497. useCustomMeshPosition: boolean;
  64498. /**
  64499. * If the post-process should inverse the light scattering direction
  64500. */
  64501. invert: boolean;
  64502. /**
  64503. * The internal mesh used by the post-process
  64504. */
  64505. mesh: Mesh;
  64506. /**
  64507. * @hidden
  64508. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64509. */
  64510. useDiffuseColor: boolean;
  64511. /**
  64512. * Array containing the excluded meshes not rendered in the internal pass
  64513. */
  64514. excludedMeshes: AbstractMesh[];
  64515. /**
  64516. * Controls the overall intensity of the post-process
  64517. */
  64518. exposure: number;
  64519. /**
  64520. * Dissipates each sample's contribution in range [0, 1]
  64521. */
  64522. decay: number;
  64523. /**
  64524. * Controls the overall intensity of each sample
  64525. */
  64526. weight: number;
  64527. /**
  64528. * Controls the density of each sample
  64529. */
  64530. density: number;
  64531. /**
  64532. * @constructor
  64533. * @param name The post-process name
  64534. * @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)
  64535. * @param camera The camera that the post-process will be attached to
  64536. * @param mesh The mesh used to create the light scattering
  64537. * @param samples The post-process quality, default 100
  64538. * @param samplingModeThe post-process filtering mode
  64539. * @param engine The babylon engine
  64540. * @param reusable If the post-process is reusable
  64541. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64542. */
  64543. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64544. /**
  64545. * Returns the string "VolumetricLightScatteringPostProcess"
  64546. * @returns "VolumetricLightScatteringPostProcess"
  64547. */
  64548. getClassName(): string;
  64549. private _isReady;
  64550. /**
  64551. * Sets the new light position for light scattering effect
  64552. * @param position The new custom light position
  64553. */
  64554. setCustomMeshPosition(position: Vector3): void;
  64555. /**
  64556. * Returns the light position for light scattering effect
  64557. * @return Vector3 The custom light position
  64558. */
  64559. getCustomMeshPosition(): Vector3;
  64560. /**
  64561. * Disposes the internal assets and detaches the post-process from the camera
  64562. */
  64563. dispose(camera: Camera): void;
  64564. /**
  64565. * Returns the render target texture used by the post-process
  64566. * @return the render target texture used by the post-process
  64567. */
  64568. getPass(): RenderTargetTexture;
  64569. private _meshExcluded;
  64570. private _createPass;
  64571. private _updateMeshScreenCoordinates;
  64572. /**
  64573. * Creates a default mesh for the Volumeric Light Scattering post-process
  64574. * @param name The mesh name
  64575. * @param scene The scene where to create the mesh
  64576. * @return the default mesh
  64577. */
  64578. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64579. }
  64580. }
  64581. declare module "babylonjs/PostProcesses/index" {
  64582. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64583. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64584. export * from "babylonjs/PostProcesses/bloomEffect";
  64585. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64586. export * from "babylonjs/PostProcesses/blurPostProcess";
  64587. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64588. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64589. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64590. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64591. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64592. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64593. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64594. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64595. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64596. export * from "babylonjs/PostProcesses/filterPostProcess";
  64597. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64598. export * from "babylonjs/PostProcesses/grainPostProcess";
  64599. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64600. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64601. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64602. export * from "babylonjs/PostProcesses/passPostProcess";
  64603. export * from "babylonjs/PostProcesses/postProcess";
  64604. export * from "babylonjs/PostProcesses/postProcessManager";
  64605. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64606. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64607. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64608. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64609. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64610. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64611. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64612. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64613. }
  64614. declare module "babylonjs/Probes/index" {
  64615. export * from "babylonjs/Probes/reflectionProbe";
  64616. }
  64617. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64618. import { Scene } from "babylonjs/scene";
  64619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64620. import { SmartArray } from "babylonjs/Misc/smartArray";
  64621. import { ISceneComponent } from "babylonjs/sceneComponent";
  64622. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64623. import "babylonjs/Meshes/Builders/boxBuilder";
  64624. import "babylonjs/Shaders/color.fragment";
  64625. import "babylonjs/Shaders/color.vertex";
  64626. import { Color3 } from "babylonjs/Maths/math.color";
  64627. module "babylonjs/scene" {
  64628. interface Scene {
  64629. /** @hidden (Backing field) */
  64630. _boundingBoxRenderer: BoundingBoxRenderer;
  64631. /** @hidden (Backing field) */
  64632. _forceShowBoundingBoxes: boolean;
  64633. /**
  64634. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64635. */
  64636. forceShowBoundingBoxes: boolean;
  64637. /**
  64638. * Gets the bounding box renderer associated with the scene
  64639. * @returns a BoundingBoxRenderer
  64640. */
  64641. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64642. }
  64643. }
  64644. module "babylonjs/Meshes/abstractMesh" {
  64645. interface AbstractMesh {
  64646. /** @hidden (Backing field) */
  64647. _showBoundingBox: boolean;
  64648. /**
  64649. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64650. */
  64651. showBoundingBox: boolean;
  64652. }
  64653. }
  64654. /**
  64655. * Component responsible of rendering the bounding box of the meshes in a scene.
  64656. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64657. */
  64658. export class BoundingBoxRenderer implements ISceneComponent {
  64659. /**
  64660. * The component name helpfull to identify the component in the list of scene components.
  64661. */
  64662. readonly name: string;
  64663. /**
  64664. * The scene the component belongs to.
  64665. */
  64666. scene: Scene;
  64667. /**
  64668. * Color of the bounding box lines placed in front of an object
  64669. */
  64670. frontColor: Color3;
  64671. /**
  64672. * Color of the bounding box lines placed behind an object
  64673. */
  64674. backColor: Color3;
  64675. /**
  64676. * Defines if the renderer should show the back lines or not
  64677. */
  64678. showBackLines: boolean;
  64679. /**
  64680. * @hidden
  64681. */
  64682. renderList: SmartArray<BoundingBox>;
  64683. private _colorShader;
  64684. private _vertexBuffers;
  64685. private _indexBuffer;
  64686. private _fillIndexBuffer;
  64687. private _fillIndexData;
  64688. /**
  64689. * Instantiates a new bounding box renderer in a scene.
  64690. * @param scene the scene the renderer renders in
  64691. */
  64692. constructor(scene: Scene);
  64693. /**
  64694. * Registers the component in a given scene
  64695. */
  64696. register(): void;
  64697. private _evaluateSubMesh;
  64698. private _activeMesh;
  64699. private _prepareRessources;
  64700. private _createIndexBuffer;
  64701. /**
  64702. * Rebuilds the elements related to this component in case of
  64703. * context lost for instance.
  64704. */
  64705. rebuild(): void;
  64706. /**
  64707. * @hidden
  64708. */
  64709. reset(): void;
  64710. /**
  64711. * Render the bounding boxes of a specific rendering group
  64712. * @param renderingGroupId defines the rendering group to render
  64713. */
  64714. render(renderingGroupId: number): void;
  64715. /**
  64716. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64717. * @param mesh Define the mesh to render the occlusion bounding box for
  64718. */
  64719. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64720. /**
  64721. * Dispose and release the resources attached to this renderer.
  64722. */
  64723. dispose(): void;
  64724. }
  64725. }
  64726. declare module "babylonjs/Shaders/depth.fragment" {
  64727. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64728. /** @hidden */
  64729. export var depthPixelShader: {
  64730. name: string;
  64731. shader: string;
  64732. };
  64733. }
  64734. declare module "babylonjs/Rendering/depthRenderer" {
  64735. import { Nullable } from "babylonjs/types";
  64736. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64737. import { Scene } from "babylonjs/scene";
  64738. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64739. import { Camera } from "babylonjs/Cameras/camera";
  64740. import "babylonjs/Shaders/depth.fragment";
  64741. import "babylonjs/Shaders/depth.vertex";
  64742. /**
  64743. * This represents a depth renderer in Babylon.
  64744. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64745. */
  64746. export class DepthRenderer {
  64747. private _scene;
  64748. private _depthMap;
  64749. private _effect;
  64750. private readonly _storeNonLinearDepth;
  64751. private readonly _clearColor;
  64752. /** Get if the depth renderer is using packed depth or not */
  64753. readonly isPacked: boolean;
  64754. private _cachedDefines;
  64755. private _camera;
  64756. /**
  64757. * Specifiess that the depth renderer will only be used within
  64758. * the camera it is created for.
  64759. * This can help forcing its rendering during the camera processing.
  64760. */
  64761. useOnlyInActiveCamera: boolean;
  64762. /** @hidden */
  64763. static _SceneComponentInitialization: (scene: Scene) => void;
  64764. /**
  64765. * Instantiates a depth renderer
  64766. * @param scene The scene the renderer belongs to
  64767. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64768. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64769. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64770. */
  64771. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64772. /**
  64773. * Creates the depth rendering effect and checks if the effect is ready.
  64774. * @param subMesh The submesh to be used to render the depth map of
  64775. * @param useInstances If multiple world instances should be used
  64776. * @returns if the depth renderer is ready to render the depth map
  64777. */
  64778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64779. /**
  64780. * Gets the texture which the depth map will be written to.
  64781. * @returns The depth map texture
  64782. */
  64783. getDepthMap(): RenderTargetTexture;
  64784. /**
  64785. * Disposes of the depth renderer.
  64786. */
  64787. dispose(): void;
  64788. }
  64789. }
  64790. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64791. import { Nullable } from "babylonjs/types";
  64792. import { Scene } from "babylonjs/scene";
  64793. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64794. import { Camera } from "babylonjs/Cameras/camera";
  64795. import { ISceneComponent } from "babylonjs/sceneComponent";
  64796. module "babylonjs/scene" {
  64797. interface Scene {
  64798. /** @hidden (Backing field) */
  64799. _depthRenderer: {
  64800. [id: string]: DepthRenderer;
  64801. };
  64802. /**
  64803. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64804. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64805. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64806. * @returns the created depth renderer
  64807. */
  64808. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64809. /**
  64810. * Disables a depth renderer for a given camera
  64811. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64812. */
  64813. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64814. }
  64815. }
  64816. /**
  64817. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64818. * in several rendering techniques.
  64819. */
  64820. export class DepthRendererSceneComponent implements ISceneComponent {
  64821. /**
  64822. * The component name helpfull to identify the component in the list of scene components.
  64823. */
  64824. readonly name: string;
  64825. /**
  64826. * The scene the component belongs to.
  64827. */
  64828. scene: Scene;
  64829. /**
  64830. * Creates a new instance of the component for the given scene
  64831. * @param scene Defines the scene to register the component in
  64832. */
  64833. constructor(scene: Scene);
  64834. /**
  64835. * Registers the component in a given scene
  64836. */
  64837. register(): void;
  64838. /**
  64839. * Rebuilds the elements related to this component in case of
  64840. * context lost for instance.
  64841. */
  64842. rebuild(): void;
  64843. /**
  64844. * Disposes the component and the associated ressources
  64845. */
  64846. dispose(): void;
  64847. private _gatherRenderTargets;
  64848. private _gatherActiveCameraRenderTargets;
  64849. }
  64850. }
  64851. declare module "babylonjs/Shaders/outline.fragment" {
  64852. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64853. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64854. /** @hidden */
  64855. export var outlinePixelShader: {
  64856. name: string;
  64857. shader: string;
  64858. };
  64859. }
  64860. declare module "babylonjs/Shaders/outline.vertex" {
  64861. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64862. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64864. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64865. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64866. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64867. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64868. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64869. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64870. /** @hidden */
  64871. export var outlineVertexShader: {
  64872. name: string;
  64873. shader: string;
  64874. };
  64875. }
  64876. declare module "babylonjs/Rendering/outlineRenderer" {
  64877. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64878. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64879. import { Scene } from "babylonjs/scene";
  64880. import { ISceneComponent } from "babylonjs/sceneComponent";
  64881. import "babylonjs/Shaders/outline.fragment";
  64882. import "babylonjs/Shaders/outline.vertex";
  64883. module "babylonjs/scene" {
  64884. interface Scene {
  64885. /** @hidden */
  64886. _outlineRenderer: OutlineRenderer;
  64887. /**
  64888. * Gets the outline renderer associated with the scene
  64889. * @returns a OutlineRenderer
  64890. */
  64891. getOutlineRenderer(): OutlineRenderer;
  64892. }
  64893. }
  64894. module "babylonjs/Meshes/abstractMesh" {
  64895. interface AbstractMesh {
  64896. /** @hidden (Backing field) */
  64897. _renderOutline: boolean;
  64898. /**
  64899. * Gets or sets a boolean indicating if the outline must be rendered as well
  64900. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64901. */
  64902. renderOutline: boolean;
  64903. /** @hidden (Backing field) */
  64904. _renderOverlay: boolean;
  64905. /**
  64906. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64907. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64908. */
  64909. renderOverlay: boolean;
  64910. }
  64911. }
  64912. /**
  64913. * This class is responsible to draw bothe outline/overlay of meshes.
  64914. * It should not be used directly but through the available method on mesh.
  64915. */
  64916. export class OutlineRenderer implements ISceneComponent {
  64917. /**
  64918. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64919. */
  64920. private static _StencilReference;
  64921. /**
  64922. * The name of the component. Each component must have a unique name.
  64923. */
  64924. name: string;
  64925. /**
  64926. * The scene the component belongs to.
  64927. */
  64928. scene: Scene;
  64929. /**
  64930. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64931. */
  64932. zOffset: number;
  64933. private _engine;
  64934. private _effect;
  64935. private _cachedDefines;
  64936. private _savedDepthWrite;
  64937. /**
  64938. * Instantiates a new outline renderer. (There could be only one per scene).
  64939. * @param scene Defines the scene it belongs to
  64940. */
  64941. constructor(scene: Scene);
  64942. /**
  64943. * Register the component to one instance of a scene.
  64944. */
  64945. register(): void;
  64946. /**
  64947. * Rebuilds the elements related to this component in case of
  64948. * context lost for instance.
  64949. */
  64950. rebuild(): void;
  64951. /**
  64952. * Disposes the component and the associated ressources.
  64953. */
  64954. dispose(): void;
  64955. /**
  64956. * Renders the outline in the canvas.
  64957. * @param subMesh Defines the sumesh to render
  64958. * @param batch Defines the batch of meshes in case of instances
  64959. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64960. */
  64961. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64962. /**
  64963. * Returns whether or not the outline renderer is ready for a given submesh.
  64964. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64965. * @param subMesh Defines the submesh to check readyness for
  64966. * @param useInstances Defines wheter wee are trying to render instances or not
  64967. * @returns true if ready otherwise false
  64968. */
  64969. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64970. private _beforeRenderingMesh;
  64971. private _afterRenderingMesh;
  64972. }
  64973. }
  64974. declare module "babylonjs/Rendering/index" {
  64975. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64976. export * from "babylonjs/Rendering/depthRenderer";
  64977. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64978. export * from "babylonjs/Rendering/edgesRenderer";
  64979. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64980. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64981. export * from "babylonjs/Rendering/outlineRenderer";
  64982. export * from "babylonjs/Rendering/renderingGroup";
  64983. export * from "babylonjs/Rendering/renderingManager";
  64984. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64985. }
  64986. declare module "babylonjs/Sprites/spritePackedManager" {
  64987. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64988. import { Scene } from "babylonjs/scene";
  64989. /**
  64990. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64991. * @see http://doc.babylonjs.com/babylon101/sprites
  64992. */
  64993. export class SpritePackedManager extends SpriteManager {
  64994. /** defines the packed manager's name */
  64995. name: string;
  64996. /**
  64997. * Creates a new sprite manager from a packed sprite sheet
  64998. * @param name defines the manager's name
  64999. * @param imgUrl defines the sprite sheet url
  65000. * @param capacity defines the maximum allowed number of sprites
  65001. * @param scene defines the hosting scene
  65002. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65003. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65004. * @param samplingMode defines the smapling mode to use with spritesheet
  65005. * @param fromPacked set to true; do not alter
  65006. */
  65007. constructor(
  65008. /** defines the packed manager's name */
  65009. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65010. }
  65011. }
  65012. declare module "babylonjs/Sprites/index" {
  65013. export * from "babylonjs/Sprites/sprite";
  65014. export * from "babylonjs/Sprites/spriteManager";
  65015. export * from "babylonjs/Sprites/spritePackedManager";
  65016. export * from "babylonjs/Sprites/spriteSceneComponent";
  65017. }
  65018. declare module "babylonjs/States/index" {
  65019. export * from "babylonjs/States/alphaCullingState";
  65020. export * from "babylonjs/States/depthCullingState";
  65021. export * from "babylonjs/States/stencilState";
  65022. }
  65023. declare module "babylonjs/Misc/assetsManager" {
  65024. import { Scene } from "babylonjs/scene";
  65025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65026. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65027. import { Skeleton } from "babylonjs/Bones/skeleton";
  65028. import { Observable } from "babylonjs/Misc/observable";
  65029. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65030. import { Texture } from "babylonjs/Materials/Textures/texture";
  65031. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65032. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65033. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65034. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65035. /**
  65036. * Defines the list of states available for a task inside a AssetsManager
  65037. */
  65038. export enum AssetTaskState {
  65039. /**
  65040. * Initialization
  65041. */
  65042. INIT = 0,
  65043. /**
  65044. * Running
  65045. */
  65046. RUNNING = 1,
  65047. /**
  65048. * Done
  65049. */
  65050. DONE = 2,
  65051. /**
  65052. * Error
  65053. */
  65054. ERROR = 3
  65055. }
  65056. /**
  65057. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65058. */
  65059. export abstract class AbstractAssetTask {
  65060. /**
  65061. * Task name
  65062. */ name: string;
  65063. /**
  65064. * Callback called when the task is successful
  65065. */
  65066. onSuccess: (task: any) => void;
  65067. /**
  65068. * Callback called when the task is not successful
  65069. */
  65070. onError: (task: any, message?: string, exception?: any) => void;
  65071. /**
  65072. * Creates a new AssetsManager
  65073. * @param name defines the name of the task
  65074. */
  65075. constructor(
  65076. /**
  65077. * Task name
  65078. */ name: string);
  65079. private _isCompleted;
  65080. private _taskState;
  65081. private _errorObject;
  65082. /**
  65083. * Get if the task is completed
  65084. */
  65085. readonly isCompleted: boolean;
  65086. /**
  65087. * Gets the current state of the task
  65088. */
  65089. readonly taskState: AssetTaskState;
  65090. /**
  65091. * Gets the current error object (if task is in error)
  65092. */
  65093. readonly errorObject: {
  65094. message?: string;
  65095. exception?: any;
  65096. };
  65097. /**
  65098. * Internal only
  65099. * @hidden
  65100. */
  65101. _setErrorObject(message?: string, exception?: any): void;
  65102. /**
  65103. * Execute the current task
  65104. * @param scene defines the scene where you want your assets to be loaded
  65105. * @param onSuccess is a callback called when the task is successfully executed
  65106. * @param onError is a callback called if an error occurs
  65107. */
  65108. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65109. /**
  65110. * Execute the current task
  65111. * @param scene defines the scene where you want your assets to be loaded
  65112. * @param onSuccess is a callback called when the task is successfully executed
  65113. * @param onError is a callback called if an error occurs
  65114. */
  65115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65116. /**
  65117. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65118. * This can be used with failed tasks that have the reason for failure fixed.
  65119. */
  65120. reset(): void;
  65121. private onErrorCallback;
  65122. private onDoneCallback;
  65123. }
  65124. /**
  65125. * Define the interface used by progress events raised during assets loading
  65126. */
  65127. export interface IAssetsProgressEvent {
  65128. /**
  65129. * Defines the number of remaining tasks to process
  65130. */
  65131. remainingCount: number;
  65132. /**
  65133. * Defines the total number of tasks
  65134. */
  65135. totalCount: number;
  65136. /**
  65137. * Defines the task that was just processed
  65138. */
  65139. task: AbstractAssetTask;
  65140. }
  65141. /**
  65142. * Class used to share progress information about assets loading
  65143. */
  65144. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65145. /**
  65146. * Defines the number of remaining tasks to process
  65147. */
  65148. remainingCount: number;
  65149. /**
  65150. * Defines the total number of tasks
  65151. */
  65152. totalCount: number;
  65153. /**
  65154. * Defines the task that was just processed
  65155. */
  65156. task: AbstractAssetTask;
  65157. /**
  65158. * Creates a AssetsProgressEvent
  65159. * @param remainingCount defines the number of remaining tasks to process
  65160. * @param totalCount defines the total number of tasks
  65161. * @param task defines the task that was just processed
  65162. */
  65163. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65164. }
  65165. /**
  65166. * Define a task used by AssetsManager to load meshes
  65167. */
  65168. export class MeshAssetTask extends AbstractAssetTask {
  65169. /**
  65170. * Defines the name of the task
  65171. */
  65172. name: string;
  65173. /**
  65174. * Defines the list of mesh's names you want to load
  65175. */
  65176. meshesNames: any;
  65177. /**
  65178. * Defines the root url to use as a base to load your meshes and associated resources
  65179. */
  65180. rootUrl: string;
  65181. /**
  65182. * Defines the filename of the scene to load from
  65183. */
  65184. sceneFilename: string;
  65185. /**
  65186. * Gets the list of loaded meshes
  65187. */
  65188. loadedMeshes: Array<AbstractMesh>;
  65189. /**
  65190. * Gets the list of loaded particle systems
  65191. */
  65192. loadedParticleSystems: Array<IParticleSystem>;
  65193. /**
  65194. * Gets the list of loaded skeletons
  65195. */
  65196. loadedSkeletons: Array<Skeleton>;
  65197. /**
  65198. * Gets the list of loaded animation groups
  65199. */
  65200. loadedAnimationGroups: Array<AnimationGroup>;
  65201. /**
  65202. * Callback called when the task is successful
  65203. */
  65204. onSuccess: (task: MeshAssetTask) => void;
  65205. /**
  65206. * Callback called when the task is successful
  65207. */
  65208. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65209. /**
  65210. * Creates a new MeshAssetTask
  65211. * @param name defines the name of the task
  65212. * @param meshesNames defines the list of mesh's names you want to load
  65213. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65214. * @param sceneFilename defines the filename of the scene to load from
  65215. */
  65216. constructor(
  65217. /**
  65218. * Defines the name of the task
  65219. */
  65220. name: string,
  65221. /**
  65222. * Defines the list of mesh's names you want to load
  65223. */
  65224. meshesNames: any,
  65225. /**
  65226. * Defines the root url to use as a base to load your meshes and associated resources
  65227. */
  65228. rootUrl: string,
  65229. /**
  65230. * Defines the filename of the scene to load from
  65231. */
  65232. sceneFilename: string);
  65233. /**
  65234. * Execute the current task
  65235. * @param scene defines the scene where you want your assets to be loaded
  65236. * @param onSuccess is a callback called when the task is successfully executed
  65237. * @param onError is a callback called if an error occurs
  65238. */
  65239. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65240. }
  65241. /**
  65242. * Define a task used by AssetsManager to load text content
  65243. */
  65244. export class TextFileAssetTask extends AbstractAssetTask {
  65245. /**
  65246. * Defines the name of the task
  65247. */
  65248. name: string;
  65249. /**
  65250. * Defines the location of the file to load
  65251. */
  65252. url: string;
  65253. /**
  65254. * Gets the loaded text string
  65255. */
  65256. text: string;
  65257. /**
  65258. * Callback called when the task is successful
  65259. */
  65260. onSuccess: (task: TextFileAssetTask) => void;
  65261. /**
  65262. * Callback called when the task is successful
  65263. */
  65264. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65265. /**
  65266. * Creates a new TextFileAssetTask object
  65267. * @param name defines the name of the task
  65268. * @param url defines the location of the file to load
  65269. */
  65270. constructor(
  65271. /**
  65272. * Defines the name of the task
  65273. */
  65274. name: string,
  65275. /**
  65276. * Defines the location of the file to load
  65277. */
  65278. url: string);
  65279. /**
  65280. * Execute the current task
  65281. * @param scene defines the scene where you want your assets to be loaded
  65282. * @param onSuccess is a callback called when the task is successfully executed
  65283. * @param onError is a callback called if an error occurs
  65284. */
  65285. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65286. }
  65287. /**
  65288. * Define a task used by AssetsManager to load binary data
  65289. */
  65290. export class BinaryFileAssetTask extends AbstractAssetTask {
  65291. /**
  65292. * Defines the name of the task
  65293. */
  65294. name: string;
  65295. /**
  65296. * Defines the location of the file to load
  65297. */
  65298. url: string;
  65299. /**
  65300. * Gets the lodaded data (as an array buffer)
  65301. */
  65302. data: ArrayBuffer;
  65303. /**
  65304. * Callback called when the task is successful
  65305. */
  65306. onSuccess: (task: BinaryFileAssetTask) => void;
  65307. /**
  65308. * Callback called when the task is successful
  65309. */
  65310. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65311. /**
  65312. * Creates a new BinaryFileAssetTask object
  65313. * @param name defines the name of the new task
  65314. * @param url defines the location of the file to load
  65315. */
  65316. constructor(
  65317. /**
  65318. * Defines the name of the task
  65319. */
  65320. name: string,
  65321. /**
  65322. * Defines the location of the file to load
  65323. */
  65324. url: string);
  65325. /**
  65326. * Execute the current task
  65327. * @param scene defines the scene where you want your assets to be loaded
  65328. * @param onSuccess is a callback called when the task is successfully executed
  65329. * @param onError is a callback called if an error occurs
  65330. */
  65331. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65332. }
  65333. /**
  65334. * Define a task used by AssetsManager to load images
  65335. */
  65336. export class ImageAssetTask extends AbstractAssetTask {
  65337. /**
  65338. * Defines the name of the task
  65339. */
  65340. name: string;
  65341. /**
  65342. * Defines the location of the image to load
  65343. */
  65344. url: string;
  65345. /**
  65346. * Gets the loaded images
  65347. */
  65348. image: HTMLImageElement;
  65349. /**
  65350. * Callback called when the task is successful
  65351. */
  65352. onSuccess: (task: ImageAssetTask) => void;
  65353. /**
  65354. * Callback called when the task is successful
  65355. */
  65356. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65357. /**
  65358. * Creates a new ImageAssetTask
  65359. * @param name defines the name of the task
  65360. * @param url defines the location of the image to load
  65361. */
  65362. constructor(
  65363. /**
  65364. * Defines the name of the task
  65365. */
  65366. name: string,
  65367. /**
  65368. * Defines the location of the image to load
  65369. */
  65370. url: string);
  65371. /**
  65372. * Execute the current task
  65373. * @param scene defines the scene where you want your assets to be loaded
  65374. * @param onSuccess is a callback called when the task is successfully executed
  65375. * @param onError is a callback called if an error occurs
  65376. */
  65377. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65378. }
  65379. /**
  65380. * Defines the interface used by texture loading tasks
  65381. */
  65382. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65383. /**
  65384. * Gets the loaded texture
  65385. */
  65386. texture: TEX;
  65387. }
  65388. /**
  65389. * Define a task used by AssetsManager to load 2D textures
  65390. */
  65391. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65392. /**
  65393. * Defines the name of the task
  65394. */
  65395. name: string;
  65396. /**
  65397. * Defines the location of the file to load
  65398. */
  65399. url: string;
  65400. /**
  65401. * Defines if mipmap should not be generated (default is false)
  65402. */
  65403. noMipmap?: boolean | undefined;
  65404. /**
  65405. * Defines if texture must be inverted on Y axis (default is false)
  65406. */
  65407. invertY?: boolean | undefined;
  65408. /**
  65409. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65410. */
  65411. samplingMode: number;
  65412. /**
  65413. * Gets the loaded texture
  65414. */
  65415. texture: Texture;
  65416. /**
  65417. * Callback called when the task is successful
  65418. */
  65419. onSuccess: (task: TextureAssetTask) => void;
  65420. /**
  65421. * Callback called when the task is successful
  65422. */
  65423. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65424. /**
  65425. * Creates a new TextureAssetTask object
  65426. * @param name defines the name of the task
  65427. * @param url defines the location of the file to load
  65428. * @param noMipmap defines if mipmap should not be generated (default is false)
  65429. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65430. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65431. */
  65432. constructor(
  65433. /**
  65434. * Defines the name of the task
  65435. */
  65436. name: string,
  65437. /**
  65438. * Defines the location of the file to load
  65439. */
  65440. url: string,
  65441. /**
  65442. * Defines if mipmap should not be generated (default is false)
  65443. */
  65444. noMipmap?: boolean | undefined,
  65445. /**
  65446. * Defines if texture must be inverted on Y axis (default is false)
  65447. */
  65448. invertY?: boolean | undefined,
  65449. /**
  65450. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65451. */
  65452. samplingMode?: number);
  65453. /**
  65454. * Execute the current task
  65455. * @param scene defines the scene where you want your assets to be loaded
  65456. * @param onSuccess is a callback called when the task is successfully executed
  65457. * @param onError is a callback called if an error occurs
  65458. */
  65459. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65460. }
  65461. /**
  65462. * Define a task used by AssetsManager to load cube textures
  65463. */
  65464. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65465. /**
  65466. * Defines the name of the task
  65467. */
  65468. name: string;
  65469. /**
  65470. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65471. */
  65472. url: string;
  65473. /**
  65474. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65475. */
  65476. extensions?: string[] | undefined;
  65477. /**
  65478. * Defines if mipmaps should not be generated (default is false)
  65479. */
  65480. noMipmap?: boolean | undefined;
  65481. /**
  65482. * Defines the explicit list of files (undefined by default)
  65483. */
  65484. files?: string[] | undefined;
  65485. /**
  65486. * Gets the loaded texture
  65487. */
  65488. texture: CubeTexture;
  65489. /**
  65490. * Callback called when the task is successful
  65491. */
  65492. onSuccess: (task: CubeTextureAssetTask) => void;
  65493. /**
  65494. * Callback called when the task is successful
  65495. */
  65496. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65497. /**
  65498. * Creates a new CubeTextureAssetTask
  65499. * @param name defines the name of the task
  65500. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65501. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65502. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65503. * @param files defines the explicit list of files (undefined by default)
  65504. */
  65505. constructor(
  65506. /**
  65507. * Defines the name of the task
  65508. */
  65509. name: string,
  65510. /**
  65511. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65512. */
  65513. url: string,
  65514. /**
  65515. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65516. */
  65517. extensions?: string[] | undefined,
  65518. /**
  65519. * Defines if mipmaps should not be generated (default is false)
  65520. */
  65521. noMipmap?: boolean | undefined,
  65522. /**
  65523. * Defines the explicit list of files (undefined by default)
  65524. */
  65525. files?: string[] | undefined);
  65526. /**
  65527. * Execute the current task
  65528. * @param scene defines the scene where you want your assets to be loaded
  65529. * @param onSuccess is a callback called when the task is successfully executed
  65530. * @param onError is a callback called if an error occurs
  65531. */
  65532. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65533. }
  65534. /**
  65535. * Define a task used by AssetsManager to load HDR cube textures
  65536. */
  65537. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65538. /**
  65539. * Defines the name of the task
  65540. */
  65541. name: string;
  65542. /**
  65543. * Defines the location of the file to load
  65544. */
  65545. url: string;
  65546. /**
  65547. * Defines the desired size (the more it increases the longer the generation will be)
  65548. */
  65549. size: number;
  65550. /**
  65551. * Defines if mipmaps should not be generated (default is false)
  65552. */
  65553. noMipmap: boolean;
  65554. /**
  65555. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65556. */
  65557. generateHarmonics: boolean;
  65558. /**
  65559. * 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)
  65560. */
  65561. gammaSpace: boolean;
  65562. /**
  65563. * Internal Use Only
  65564. */
  65565. reserved: boolean;
  65566. /**
  65567. * Gets the loaded texture
  65568. */
  65569. texture: HDRCubeTexture;
  65570. /**
  65571. * Callback called when the task is successful
  65572. */
  65573. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65574. /**
  65575. * Callback called when the task is successful
  65576. */
  65577. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65578. /**
  65579. * Creates a new HDRCubeTextureAssetTask object
  65580. * @param name defines the name of the task
  65581. * @param url defines the location of the file to load
  65582. * @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.
  65583. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65584. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65585. * @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)
  65586. * @param reserved Internal use only
  65587. */
  65588. constructor(
  65589. /**
  65590. * Defines the name of the task
  65591. */
  65592. name: string,
  65593. /**
  65594. * Defines the location of the file to load
  65595. */
  65596. url: string,
  65597. /**
  65598. * Defines the desired size (the more it increases the longer the generation will be)
  65599. */
  65600. size: number,
  65601. /**
  65602. * Defines if mipmaps should not be generated (default is false)
  65603. */
  65604. noMipmap?: boolean,
  65605. /**
  65606. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65607. */
  65608. generateHarmonics?: boolean,
  65609. /**
  65610. * 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)
  65611. */
  65612. gammaSpace?: boolean,
  65613. /**
  65614. * Internal Use Only
  65615. */
  65616. reserved?: boolean);
  65617. /**
  65618. * Execute the current task
  65619. * @param scene defines the scene where you want your assets to be loaded
  65620. * @param onSuccess is a callback called when the task is successfully executed
  65621. * @param onError is a callback called if an error occurs
  65622. */
  65623. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65624. }
  65625. /**
  65626. * Define a task used by AssetsManager to load Equirectangular cube textures
  65627. */
  65628. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65629. /**
  65630. * Defines the name of the task
  65631. */
  65632. name: string;
  65633. /**
  65634. * Defines the location of the file to load
  65635. */
  65636. url: string;
  65637. /**
  65638. * Defines the desired size (the more it increases the longer the generation will be)
  65639. */
  65640. size: number;
  65641. /**
  65642. * Defines if mipmaps should not be generated (default is false)
  65643. */
  65644. noMipmap: boolean;
  65645. /**
  65646. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65647. * but the standard material would require them in Gamma space) (default is true)
  65648. */
  65649. gammaSpace: boolean;
  65650. /**
  65651. * Gets the loaded texture
  65652. */
  65653. texture: EquiRectangularCubeTexture;
  65654. /**
  65655. * Callback called when the task is successful
  65656. */
  65657. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65658. /**
  65659. * Callback called when the task is successful
  65660. */
  65661. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65662. /**
  65663. * Creates a new EquiRectangularCubeTextureAssetTask object
  65664. * @param name defines the name of the task
  65665. * @param url defines the location of the file to load
  65666. * @param size defines the desired size (the more it increases the longer the generation will be)
  65667. * If the size is omitted this implies you are using a preprocessed cubemap.
  65668. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65669. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65670. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65671. * (default is true)
  65672. */
  65673. constructor(
  65674. /**
  65675. * Defines the name of the task
  65676. */
  65677. name: string,
  65678. /**
  65679. * Defines the location of the file to load
  65680. */
  65681. url: string,
  65682. /**
  65683. * Defines the desired size (the more it increases the longer the generation will be)
  65684. */
  65685. size: number,
  65686. /**
  65687. * Defines if mipmaps should not be generated (default is false)
  65688. */
  65689. noMipmap?: boolean,
  65690. /**
  65691. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65692. * but the standard material would require them in Gamma space) (default is true)
  65693. */
  65694. gammaSpace?: boolean);
  65695. /**
  65696. * Execute the current task
  65697. * @param scene defines the scene where you want your assets to be loaded
  65698. * @param onSuccess is a callback called when the task is successfully executed
  65699. * @param onError is a callback called if an error occurs
  65700. */
  65701. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65702. }
  65703. /**
  65704. * This class can be used to easily import assets into a scene
  65705. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65706. */
  65707. export class AssetsManager {
  65708. private _scene;
  65709. private _isLoading;
  65710. protected _tasks: AbstractAssetTask[];
  65711. protected _waitingTasksCount: number;
  65712. protected _totalTasksCount: number;
  65713. /**
  65714. * Callback called when all tasks are processed
  65715. */
  65716. onFinish: (tasks: AbstractAssetTask[]) => void;
  65717. /**
  65718. * Callback called when a task is successful
  65719. */
  65720. onTaskSuccess: (task: AbstractAssetTask) => void;
  65721. /**
  65722. * Callback called when a task had an error
  65723. */
  65724. onTaskError: (task: AbstractAssetTask) => void;
  65725. /**
  65726. * Callback called when a task is done (whatever the result is)
  65727. */
  65728. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65729. /**
  65730. * Observable called when all tasks are processed
  65731. */
  65732. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65733. /**
  65734. * Observable called when a task had an error
  65735. */
  65736. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65737. /**
  65738. * Observable called when all tasks were executed
  65739. */
  65740. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65741. /**
  65742. * Observable called when a task is done (whatever the result is)
  65743. */
  65744. onProgressObservable: Observable<IAssetsProgressEvent>;
  65745. /**
  65746. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65747. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65748. */
  65749. useDefaultLoadingScreen: boolean;
  65750. /**
  65751. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65752. * when all assets have been downloaded.
  65753. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65754. */
  65755. autoHideLoadingUI: boolean;
  65756. /**
  65757. * Creates a new AssetsManager
  65758. * @param scene defines the scene to work on
  65759. */
  65760. constructor(scene: Scene);
  65761. /**
  65762. * Add a MeshAssetTask to the list of active tasks
  65763. * @param taskName defines the name of the new task
  65764. * @param meshesNames defines the name of meshes to load
  65765. * @param rootUrl defines the root url to use to locate files
  65766. * @param sceneFilename defines the filename of the scene file
  65767. * @returns a new MeshAssetTask object
  65768. */
  65769. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65770. /**
  65771. * Add a TextFileAssetTask to the list of active tasks
  65772. * @param taskName defines the name of the new task
  65773. * @param url defines the url of the file to load
  65774. * @returns a new TextFileAssetTask object
  65775. */
  65776. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65777. /**
  65778. * Add a BinaryFileAssetTask to the list of active tasks
  65779. * @param taskName defines the name of the new task
  65780. * @param url defines the url of the file to load
  65781. * @returns a new BinaryFileAssetTask object
  65782. */
  65783. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65784. /**
  65785. * Add a ImageAssetTask to the list of active tasks
  65786. * @param taskName defines the name of the new task
  65787. * @param url defines the url of the file to load
  65788. * @returns a new ImageAssetTask object
  65789. */
  65790. addImageTask(taskName: string, url: string): ImageAssetTask;
  65791. /**
  65792. * Add a TextureAssetTask to the list of active tasks
  65793. * @param taskName defines the name of the new task
  65794. * @param url defines the url of the file to load
  65795. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65796. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65797. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65798. * @returns a new TextureAssetTask object
  65799. */
  65800. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65801. /**
  65802. * Add a CubeTextureAssetTask to the list of active tasks
  65803. * @param taskName defines the name of the new task
  65804. * @param url defines the url of the file to load
  65805. * @param extensions defines the extension to use to load the cube map (can be null)
  65806. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65807. * @param files defines the list of files to load (can be null)
  65808. * @returns a new CubeTextureAssetTask object
  65809. */
  65810. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65811. /**
  65812. *
  65813. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65814. * @param taskName defines the name of the new task
  65815. * @param url defines the url of the file to load
  65816. * @param size defines the size you want for the cubemap (can be null)
  65817. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65818. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65819. * @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)
  65820. * @param reserved Internal use only
  65821. * @returns a new HDRCubeTextureAssetTask object
  65822. */
  65823. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65824. /**
  65825. *
  65826. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65827. * @param taskName defines the name of the new task
  65828. * @param url defines the url of the file to load
  65829. * @param size defines the size you want for the cubemap (can be null)
  65830. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65831. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65832. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65833. * @returns a new EquiRectangularCubeTextureAssetTask object
  65834. */
  65835. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65836. /**
  65837. * Remove a task from the assets manager.
  65838. * @param task the task to remove
  65839. */
  65840. removeTask(task: AbstractAssetTask): void;
  65841. private _decreaseWaitingTasksCount;
  65842. private _runTask;
  65843. /**
  65844. * Reset the AssetsManager and remove all tasks
  65845. * @return the current instance of the AssetsManager
  65846. */
  65847. reset(): AssetsManager;
  65848. /**
  65849. * Start the loading process
  65850. * @return the current instance of the AssetsManager
  65851. */
  65852. load(): AssetsManager;
  65853. /**
  65854. * Start the loading process as an async operation
  65855. * @return a promise returning the list of failed tasks
  65856. */
  65857. loadAsync(): Promise<void>;
  65858. }
  65859. }
  65860. declare module "babylonjs/Misc/deferred" {
  65861. /**
  65862. * Wrapper class for promise with external resolve and reject.
  65863. */
  65864. export class Deferred<T> {
  65865. /**
  65866. * The promise associated with this deferred object.
  65867. */
  65868. readonly promise: Promise<T>;
  65869. private _resolve;
  65870. private _reject;
  65871. /**
  65872. * The resolve method of the promise associated with this deferred object.
  65873. */
  65874. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65875. /**
  65876. * The reject method of the promise associated with this deferred object.
  65877. */
  65878. readonly reject: (reason?: any) => void;
  65879. /**
  65880. * Constructor for this deferred object.
  65881. */
  65882. constructor();
  65883. }
  65884. }
  65885. declare module "babylonjs/Misc/meshExploder" {
  65886. import { Mesh } from "babylonjs/Meshes/mesh";
  65887. /**
  65888. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65889. */
  65890. export class MeshExploder {
  65891. private _centerMesh;
  65892. private _meshes;
  65893. private _meshesOrigins;
  65894. private _toCenterVectors;
  65895. private _scaledDirection;
  65896. private _newPosition;
  65897. private _centerPosition;
  65898. /**
  65899. * Explodes meshes from a center mesh.
  65900. * @param meshes The meshes to explode.
  65901. * @param centerMesh The mesh to be center of explosion.
  65902. */
  65903. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65904. private _setCenterMesh;
  65905. /**
  65906. * Get class name
  65907. * @returns "MeshExploder"
  65908. */
  65909. getClassName(): string;
  65910. /**
  65911. * "Exploded meshes"
  65912. * @returns Array of meshes with the centerMesh at index 0.
  65913. */
  65914. getMeshes(): Array<Mesh>;
  65915. /**
  65916. * Explodes meshes giving a specific direction
  65917. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65918. */
  65919. explode(direction?: number): void;
  65920. }
  65921. }
  65922. declare module "babylonjs/Misc/filesInput" {
  65923. import { Engine } from "babylonjs/Engines/engine";
  65924. import { Scene } from "babylonjs/scene";
  65925. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65926. /**
  65927. * Class used to help managing file picking and drag'n'drop
  65928. */
  65929. export class FilesInput {
  65930. /**
  65931. * List of files ready to be loaded
  65932. */
  65933. static readonly FilesToLoad: {
  65934. [key: string]: File;
  65935. };
  65936. /**
  65937. * Callback called when a file is processed
  65938. */
  65939. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65940. private _engine;
  65941. private _currentScene;
  65942. private _sceneLoadedCallback;
  65943. private _progressCallback;
  65944. private _additionalRenderLoopLogicCallback;
  65945. private _textureLoadingCallback;
  65946. private _startingProcessingFilesCallback;
  65947. private _onReloadCallback;
  65948. private _errorCallback;
  65949. private _elementToMonitor;
  65950. private _sceneFileToLoad;
  65951. private _filesToLoad;
  65952. /**
  65953. * Creates a new FilesInput
  65954. * @param engine defines the rendering engine
  65955. * @param scene defines the hosting scene
  65956. * @param sceneLoadedCallback callback called when scene is loaded
  65957. * @param progressCallback callback called to track progress
  65958. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65959. * @param textureLoadingCallback callback called when a texture is loading
  65960. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65961. * @param onReloadCallback callback called when a reload is requested
  65962. * @param errorCallback callback call if an error occurs
  65963. */
  65964. 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);
  65965. private _dragEnterHandler;
  65966. private _dragOverHandler;
  65967. private _dropHandler;
  65968. /**
  65969. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65970. * @param elementToMonitor defines the DOM element to track
  65971. */
  65972. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65973. /**
  65974. * Release all associated resources
  65975. */
  65976. dispose(): void;
  65977. private renderFunction;
  65978. private drag;
  65979. private drop;
  65980. private _traverseFolder;
  65981. private _processFiles;
  65982. /**
  65983. * Load files from a drop event
  65984. * @param event defines the drop event to use as source
  65985. */
  65986. loadFiles(event: any): void;
  65987. private _processReload;
  65988. /**
  65989. * Reload the current scene from the loaded files
  65990. */
  65991. reload(): void;
  65992. }
  65993. }
  65994. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65995. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65996. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65997. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65998. }
  65999. declare module "babylonjs/Misc/sceneOptimizer" {
  66000. import { Scene, IDisposable } from "babylonjs/scene";
  66001. import { Observable } from "babylonjs/Misc/observable";
  66002. /**
  66003. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66004. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66005. */
  66006. export class SceneOptimization {
  66007. /**
  66008. * Defines the priority of this optimization (0 by default which means first in the list)
  66009. */
  66010. priority: number;
  66011. /**
  66012. * Gets a string describing the action executed by the current optimization
  66013. * @returns description string
  66014. */
  66015. getDescription(): string;
  66016. /**
  66017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66018. * @param scene defines the current scene where to apply this optimization
  66019. * @param optimizer defines the current optimizer
  66020. * @returns true if everything that can be done was applied
  66021. */
  66022. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66023. /**
  66024. * Creates the SceneOptimization object
  66025. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66026. * @param desc defines the description associated with the optimization
  66027. */
  66028. constructor(
  66029. /**
  66030. * Defines the priority of this optimization (0 by default which means first in the list)
  66031. */
  66032. priority?: number);
  66033. }
  66034. /**
  66035. * Defines an optimization used to reduce the size of render target textures
  66036. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66037. */
  66038. export class TextureOptimization extends SceneOptimization {
  66039. /**
  66040. * Defines the priority of this optimization (0 by default which means first in the list)
  66041. */
  66042. priority: number;
  66043. /**
  66044. * 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
  66045. */
  66046. maximumSize: number;
  66047. /**
  66048. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66049. */
  66050. step: number;
  66051. /**
  66052. * Gets a string describing the action executed by the current optimization
  66053. * @returns description string
  66054. */
  66055. getDescription(): string;
  66056. /**
  66057. * Creates the TextureOptimization object
  66058. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66059. * @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
  66060. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66061. */
  66062. constructor(
  66063. /**
  66064. * Defines the priority of this optimization (0 by default which means first in the list)
  66065. */
  66066. priority?: number,
  66067. /**
  66068. * 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
  66069. */
  66070. maximumSize?: number,
  66071. /**
  66072. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66073. */
  66074. step?: number);
  66075. /**
  66076. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66077. * @param scene defines the current scene where to apply this optimization
  66078. * @param optimizer defines the current optimizer
  66079. * @returns true if everything that can be done was applied
  66080. */
  66081. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66082. }
  66083. /**
  66084. * Defines an optimization used to increase or decrease the rendering resolution
  66085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66086. */
  66087. export class HardwareScalingOptimization extends SceneOptimization {
  66088. /**
  66089. * Defines the priority of this optimization (0 by default which means first in the list)
  66090. */
  66091. priority: number;
  66092. /**
  66093. * Defines the maximum scale to use (2 by default)
  66094. */
  66095. maximumScale: number;
  66096. /**
  66097. * Defines the step to use between two passes (0.5 by default)
  66098. */
  66099. step: number;
  66100. private _currentScale;
  66101. private _directionOffset;
  66102. /**
  66103. * Gets a string describing the action executed by the current optimization
  66104. * @return description string
  66105. */
  66106. getDescription(): string;
  66107. /**
  66108. * Creates the HardwareScalingOptimization object
  66109. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66110. * @param maximumScale defines the maximum scale to use (2 by default)
  66111. * @param step defines the step to use between two passes (0.5 by default)
  66112. */
  66113. constructor(
  66114. /**
  66115. * Defines the priority of this optimization (0 by default which means first in the list)
  66116. */
  66117. priority?: number,
  66118. /**
  66119. * Defines the maximum scale to use (2 by default)
  66120. */
  66121. maximumScale?: number,
  66122. /**
  66123. * Defines the step to use between two passes (0.5 by default)
  66124. */
  66125. step?: number);
  66126. /**
  66127. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66128. * @param scene defines the current scene where to apply this optimization
  66129. * @param optimizer defines the current optimizer
  66130. * @returns true if everything that can be done was applied
  66131. */
  66132. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66133. }
  66134. /**
  66135. * Defines an optimization used to remove shadows
  66136. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66137. */
  66138. export class ShadowsOptimization extends SceneOptimization {
  66139. /**
  66140. * Gets a string describing the action executed by the current optimization
  66141. * @return description string
  66142. */
  66143. getDescription(): string;
  66144. /**
  66145. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66146. * @param scene defines the current scene where to apply this optimization
  66147. * @param optimizer defines the current optimizer
  66148. * @returns true if everything that can be done was applied
  66149. */
  66150. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66151. }
  66152. /**
  66153. * Defines an optimization used to turn post-processes off
  66154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66155. */
  66156. export class PostProcessesOptimization extends SceneOptimization {
  66157. /**
  66158. * Gets a string describing the action executed by the current optimization
  66159. * @return description string
  66160. */
  66161. getDescription(): string;
  66162. /**
  66163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66164. * @param scene defines the current scene where to apply this optimization
  66165. * @param optimizer defines the current optimizer
  66166. * @returns true if everything that can be done was applied
  66167. */
  66168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66169. }
  66170. /**
  66171. * Defines an optimization used to turn lens flares off
  66172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66173. */
  66174. export class LensFlaresOptimization extends SceneOptimization {
  66175. /**
  66176. * Gets a string describing the action executed by the current optimization
  66177. * @return description string
  66178. */
  66179. getDescription(): string;
  66180. /**
  66181. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66182. * @param scene defines the current scene where to apply this optimization
  66183. * @param optimizer defines the current optimizer
  66184. * @returns true if everything that can be done was applied
  66185. */
  66186. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66187. }
  66188. /**
  66189. * Defines an optimization based on user defined callback.
  66190. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66191. */
  66192. export class CustomOptimization extends SceneOptimization {
  66193. /**
  66194. * Callback called to apply the custom optimization.
  66195. */
  66196. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66197. /**
  66198. * Callback called to get custom description
  66199. */
  66200. onGetDescription: () => string;
  66201. /**
  66202. * Gets a string describing the action executed by the current optimization
  66203. * @returns description string
  66204. */
  66205. getDescription(): string;
  66206. /**
  66207. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66208. * @param scene defines the current scene where to apply this optimization
  66209. * @param optimizer defines the current optimizer
  66210. * @returns true if everything that can be done was applied
  66211. */
  66212. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66213. }
  66214. /**
  66215. * Defines an optimization used to turn particles off
  66216. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66217. */
  66218. export class ParticlesOptimization extends SceneOptimization {
  66219. /**
  66220. * Gets a string describing the action executed by the current optimization
  66221. * @return description string
  66222. */
  66223. getDescription(): string;
  66224. /**
  66225. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66226. * @param scene defines the current scene where to apply this optimization
  66227. * @param optimizer defines the current optimizer
  66228. * @returns true if everything that can be done was applied
  66229. */
  66230. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66231. }
  66232. /**
  66233. * Defines an optimization used to turn render targets off
  66234. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66235. */
  66236. export class RenderTargetsOptimization extends SceneOptimization {
  66237. /**
  66238. * Gets a string describing the action executed by the current optimization
  66239. * @return description string
  66240. */
  66241. getDescription(): string;
  66242. /**
  66243. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66244. * @param scene defines the current scene where to apply this optimization
  66245. * @param optimizer defines the current optimizer
  66246. * @returns true if everything that can be done was applied
  66247. */
  66248. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66249. }
  66250. /**
  66251. * Defines an optimization used to merge meshes with compatible materials
  66252. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66253. */
  66254. export class MergeMeshesOptimization extends SceneOptimization {
  66255. private static _UpdateSelectionTree;
  66256. /**
  66257. * Gets or sets a boolean which defines if optimization octree has to be updated
  66258. */
  66259. /**
  66260. * Gets or sets a boolean which defines if optimization octree has to be updated
  66261. */
  66262. static UpdateSelectionTree: boolean;
  66263. /**
  66264. * Gets a string describing the action executed by the current optimization
  66265. * @return description string
  66266. */
  66267. getDescription(): string;
  66268. private _canBeMerged;
  66269. /**
  66270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66271. * @param scene defines the current scene where to apply this optimization
  66272. * @param optimizer defines the current optimizer
  66273. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66274. * @returns true if everything that can be done was applied
  66275. */
  66276. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66277. }
  66278. /**
  66279. * Defines a list of options used by SceneOptimizer
  66280. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66281. */
  66282. export class SceneOptimizerOptions {
  66283. /**
  66284. * Defines the target frame rate to reach (60 by default)
  66285. */
  66286. targetFrameRate: number;
  66287. /**
  66288. * Defines the interval between two checkes (2000ms by default)
  66289. */
  66290. trackerDuration: number;
  66291. /**
  66292. * Gets the list of optimizations to apply
  66293. */
  66294. optimizations: SceneOptimization[];
  66295. /**
  66296. * Creates a new list of options used by SceneOptimizer
  66297. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66298. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66299. */
  66300. constructor(
  66301. /**
  66302. * Defines the target frame rate to reach (60 by default)
  66303. */
  66304. targetFrameRate?: number,
  66305. /**
  66306. * Defines the interval between two checkes (2000ms by default)
  66307. */
  66308. trackerDuration?: number);
  66309. /**
  66310. * Add a new optimization
  66311. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66312. * @returns the current SceneOptimizerOptions
  66313. */
  66314. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66315. /**
  66316. * Add a new custom optimization
  66317. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66318. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66319. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66320. * @returns the current SceneOptimizerOptions
  66321. */
  66322. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66323. /**
  66324. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66325. * @param targetFrameRate defines the target frame rate (60 by default)
  66326. * @returns a SceneOptimizerOptions object
  66327. */
  66328. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66329. /**
  66330. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66331. * @param targetFrameRate defines the target frame rate (60 by default)
  66332. * @returns a SceneOptimizerOptions object
  66333. */
  66334. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66335. /**
  66336. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66337. * @param targetFrameRate defines the target frame rate (60 by default)
  66338. * @returns a SceneOptimizerOptions object
  66339. */
  66340. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66341. }
  66342. /**
  66343. * Class used to run optimizations in order to reach a target frame rate
  66344. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66345. */
  66346. export class SceneOptimizer implements IDisposable {
  66347. private _isRunning;
  66348. private _options;
  66349. private _scene;
  66350. private _currentPriorityLevel;
  66351. private _targetFrameRate;
  66352. private _trackerDuration;
  66353. private _currentFrameRate;
  66354. private _sceneDisposeObserver;
  66355. private _improvementMode;
  66356. /**
  66357. * Defines an observable called when the optimizer reaches the target frame rate
  66358. */
  66359. onSuccessObservable: Observable<SceneOptimizer>;
  66360. /**
  66361. * Defines an observable called when the optimizer enables an optimization
  66362. */
  66363. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66364. /**
  66365. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66366. */
  66367. onFailureObservable: Observable<SceneOptimizer>;
  66368. /**
  66369. * Gets a boolean indicating if the optimizer is in improvement mode
  66370. */
  66371. readonly isInImprovementMode: boolean;
  66372. /**
  66373. * Gets the current priority level (0 at start)
  66374. */
  66375. readonly currentPriorityLevel: number;
  66376. /**
  66377. * Gets the current frame rate checked by the SceneOptimizer
  66378. */
  66379. readonly currentFrameRate: number;
  66380. /**
  66381. * Gets or sets the current target frame rate (60 by default)
  66382. */
  66383. /**
  66384. * Gets or sets the current target frame rate (60 by default)
  66385. */
  66386. targetFrameRate: number;
  66387. /**
  66388. * Gets or sets the current interval between two checks (every 2000ms by default)
  66389. */
  66390. /**
  66391. * Gets or sets the current interval between two checks (every 2000ms by default)
  66392. */
  66393. trackerDuration: number;
  66394. /**
  66395. * Gets the list of active optimizations
  66396. */
  66397. readonly optimizations: SceneOptimization[];
  66398. /**
  66399. * Creates a new SceneOptimizer
  66400. * @param scene defines the scene to work on
  66401. * @param options defines the options to use with the SceneOptimizer
  66402. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66403. * @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)
  66404. */
  66405. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66406. /**
  66407. * Stops the current optimizer
  66408. */
  66409. stop(): void;
  66410. /**
  66411. * Reset the optimizer to initial step (current priority level = 0)
  66412. */
  66413. reset(): void;
  66414. /**
  66415. * Start the optimizer. By default it will try to reach a specific framerate
  66416. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66417. */
  66418. start(): void;
  66419. private _checkCurrentState;
  66420. /**
  66421. * Release all resources
  66422. */
  66423. dispose(): void;
  66424. /**
  66425. * Helper function to create a SceneOptimizer with one single line of code
  66426. * @param scene defines the scene to work on
  66427. * @param options defines the options to use with the SceneOptimizer
  66428. * @param onSuccess defines a callback to call on success
  66429. * @param onFailure defines a callback to call on failure
  66430. * @returns the new SceneOptimizer object
  66431. */
  66432. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66433. }
  66434. }
  66435. declare module "babylonjs/Misc/sceneSerializer" {
  66436. import { Scene } from "babylonjs/scene";
  66437. /**
  66438. * Class used to serialize a scene into a string
  66439. */
  66440. export class SceneSerializer {
  66441. /**
  66442. * Clear cache used by a previous serialization
  66443. */
  66444. static ClearCache(): void;
  66445. /**
  66446. * Serialize a scene into a JSON compatible object
  66447. * @param scene defines the scene to serialize
  66448. * @returns a JSON compatible object
  66449. */
  66450. static Serialize(scene: Scene): any;
  66451. /**
  66452. * Serialize a mesh into a JSON compatible object
  66453. * @param toSerialize defines the mesh to serialize
  66454. * @param withParents defines if parents must be serialized as well
  66455. * @param withChildren defines if children must be serialized as well
  66456. * @returns a JSON compatible object
  66457. */
  66458. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66459. }
  66460. }
  66461. declare module "babylonjs/Misc/textureTools" {
  66462. import { Texture } from "babylonjs/Materials/Textures/texture";
  66463. /**
  66464. * Class used to host texture specific utilities
  66465. */
  66466. export class TextureTools {
  66467. /**
  66468. * Uses the GPU to create a copy texture rescaled at a given size
  66469. * @param texture Texture to copy from
  66470. * @param width defines the desired width
  66471. * @param height defines the desired height
  66472. * @param useBilinearMode defines if bilinear mode has to be used
  66473. * @return the generated texture
  66474. */
  66475. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66476. }
  66477. }
  66478. declare module "babylonjs/Misc/videoRecorder" {
  66479. import { Nullable } from "babylonjs/types";
  66480. import { Engine } from "babylonjs/Engines/engine";
  66481. /**
  66482. * This represents the different options available for the video capture.
  66483. */
  66484. export interface VideoRecorderOptions {
  66485. /** Defines the mime type of the video. */
  66486. mimeType: string;
  66487. /** Defines the FPS the video should be recorded at. */
  66488. fps: number;
  66489. /** Defines the chunk size for the recording data. */
  66490. recordChunckSize: number;
  66491. /** The audio tracks to attach to the recording. */
  66492. audioTracks?: MediaStreamTrack[];
  66493. }
  66494. /**
  66495. * This can help with recording videos from BabylonJS.
  66496. * This is based on the available WebRTC functionalities of the browser.
  66497. *
  66498. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66499. */
  66500. export class VideoRecorder {
  66501. private static readonly _defaultOptions;
  66502. /**
  66503. * Returns whether or not the VideoRecorder is available in your browser.
  66504. * @param engine Defines the Babylon Engine.
  66505. * @returns true if supported otherwise false.
  66506. */
  66507. static IsSupported(engine: Engine): boolean;
  66508. private readonly _options;
  66509. private _canvas;
  66510. private _mediaRecorder;
  66511. private _recordedChunks;
  66512. private _fileName;
  66513. private _resolve;
  66514. private _reject;
  66515. /**
  66516. * True when a recording is already in progress.
  66517. */
  66518. readonly isRecording: boolean;
  66519. /**
  66520. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66521. * @param engine Defines the BabylonJS Engine you wish to record.
  66522. * @param options Defines options that can be used to customize the capture.
  66523. */
  66524. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66525. /**
  66526. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66527. */
  66528. stopRecording(): void;
  66529. /**
  66530. * Starts recording the canvas for a max duration specified in parameters.
  66531. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66532. * If null no automatic download will start and you can rely on the promise to get the data back.
  66533. * @param maxDuration Defines the maximum recording time in seconds.
  66534. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66535. * @return A promise callback at the end of the recording with the video data in Blob.
  66536. */
  66537. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66538. /**
  66539. * Releases internal resources used during the recording.
  66540. */
  66541. dispose(): void;
  66542. private _handleDataAvailable;
  66543. private _handleError;
  66544. private _handleStop;
  66545. }
  66546. }
  66547. declare module "babylonjs/Misc/screenshotTools" {
  66548. import { Camera } from "babylonjs/Cameras/camera";
  66549. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66550. import { Engine } from "babylonjs/Engines/engine";
  66551. /**
  66552. * Class containing a set of static utilities functions for screenshots
  66553. */
  66554. export class ScreenshotTools {
  66555. /**
  66556. * Captures a screenshot of the current rendering
  66557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66558. * @param engine defines the rendering engine
  66559. * @param camera defines the source camera
  66560. * @param size This parameter can be set to a single number or to an object with the
  66561. * following (optional) properties: precision, width, height. If a single number is passed,
  66562. * it will be used for both width and height. If an object is passed, the screenshot size
  66563. * will be derived from the parameters. The precision property is a multiplier allowing
  66564. * rendering at a higher or lower resolution
  66565. * @param successCallback defines the callback receives a single parameter which contains the
  66566. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66567. * src parameter of an <img> to display it
  66568. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66569. * Check your browser for supported MIME types
  66570. */
  66571. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66572. /**
  66573. * Captures a screenshot of the current rendering
  66574. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66575. * @param engine defines the rendering engine
  66576. * @param camera defines the source camera
  66577. * @param size This parameter can be set to a single number or to an object with the
  66578. * following (optional) properties: precision, width, height. If a single number is passed,
  66579. * it will be used for both width and height. If an object is passed, the screenshot size
  66580. * will be derived from the parameters. The precision property is a multiplier allowing
  66581. * rendering at a higher or lower resolution
  66582. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66583. * Check your browser for supported MIME types
  66584. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66585. * to the src parameter of an <img> to display it
  66586. */
  66587. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66588. /**
  66589. * Generates an image screenshot from the specified camera.
  66590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66591. * @param engine The engine to use for rendering
  66592. * @param camera The camera to use for rendering
  66593. * @param size This parameter can be set to a single number or to an object with the
  66594. * following (optional) properties: precision, width, height. If a single number is passed,
  66595. * it will be used for both width and height. If an object is passed, the screenshot size
  66596. * will be derived from the parameters. The precision property is a multiplier allowing
  66597. * rendering at a higher or lower resolution
  66598. * @param successCallback The callback receives a single parameter which contains the
  66599. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66600. * src parameter of an <img> to display it
  66601. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66602. * Check your browser for supported MIME types
  66603. * @param samples Texture samples (default: 1)
  66604. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66605. * @param fileName A name for for the downloaded file.
  66606. */
  66607. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66608. /**
  66609. * Generates an image screenshot from the specified camera.
  66610. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66611. * @param engine The engine to use for rendering
  66612. * @param camera The camera to use for rendering
  66613. * @param size This parameter can be set to a single number or to an object with the
  66614. * following (optional) properties: precision, width, height. If a single number is passed,
  66615. * it will be used for both width and height. If an object is passed, the screenshot size
  66616. * will be derived from the parameters. The precision property is a multiplier allowing
  66617. * rendering at a higher or lower resolution
  66618. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66619. * Check your browser for supported MIME types
  66620. * @param samples Texture samples (default: 1)
  66621. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66622. * @param fileName A name for for the downloaded file.
  66623. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66624. * to the src parameter of an <img> to display it
  66625. */
  66626. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66627. /**
  66628. * Gets height and width for screenshot size
  66629. * @private
  66630. */
  66631. private static _getScreenshotSize;
  66632. }
  66633. }
  66634. declare module "babylonjs/Misc/index" {
  66635. export * from "babylonjs/Misc/andOrNotEvaluator";
  66636. export * from "babylonjs/Misc/assetsManager";
  66637. export * from "babylonjs/Misc/dds";
  66638. export * from "babylonjs/Misc/decorators";
  66639. export * from "babylonjs/Misc/deferred";
  66640. export * from "babylonjs/Misc/environmentTextureTools";
  66641. export * from "babylonjs/Misc/meshExploder";
  66642. export * from "babylonjs/Misc/filesInput";
  66643. export * from "babylonjs/Misc/HighDynamicRange/index";
  66644. export * from "babylonjs/Misc/khronosTextureContainer";
  66645. export * from "babylonjs/Misc/observable";
  66646. export * from "babylonjs/Misc/performanceMonitor";
  66647. export * from "babylonjs/Misc/promise";
  66648. export * from "babylonjs/Misc/sceneOptimizer";
  66649. export * from "babylonjs/Misc/sceneSerializer";
  66650. export * from "babylonjs/Misc/smartArray";
  66651. export * from "babylonjs/Misc/stringDictionary";
  66652. export * from "babylonjs/Misc/tags";
  66653. export * from "babylonjs/Misc/textureTools";
  66654. export * from "babylonjs/Misc/tga";
  66655. export * from "babylonjs/Misc/tools";
  66656. export * from "babylonjs/Misc/videoRecorder";
  66657. export * from "babylonjs/Misc/virtualJoystick";
  66658. export * from "babylonjs/Misc/workerPool";
  66659. export * from "babylonjs/Misc/logger";
  66660. export * from "babylonjs/Misc/typeStore";
  66661. export * from "babylonjs/Misc/filesInputStore";
  66662. export * from "babylonjs/Misc/deepCopier";
  66663. export * from "babylonjs/Misc/pivotTools";
  66664. export * from "babylonjs/Misc/precisionDate";
  66665. export * from "babylonjs/Misc/screenshotTools";
  66666. export * from "babylonjs/Misc/typeStore";
  66667. export * from "babylonjs/Misc/webRequest";
  66668. export * from "babylonjs/Misc/iInspectable";
  66669. export * from "babylonjs/Misc/brdfTextureTools";
  66670. export * from "babylonjs/Misc/rgbdTextureTools";
  66671. export * from "babylonjs/Misc/gradients";
  66672. export * from "babylonjs/Misc/perfCounter";
  66673. export * from "babylonjs/Misc/fileRequest";
  66674. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66675. export * from "babylonjs/Misc/retryStrategy";
  66676. export * from "babylonjs/Misc/loadFileError";
  66677. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66678. }
  66679. declare module "babylonjs/index" {
  66680. export * from "babylonjs/abstractScene";
  66681. export * from "babylonjs/Actions/index";
  66682. export * from "babylonjs/Animations/index";
  66683. export * from "babylonjs/assetContainer";
  66684. export * from "babylonjs/Audio/index";
  66685. export * from "babylonjs/Behaviors/index";
  66686. export * from "babylonjs/Bones/index";
  66687. export * from "babylonjs/Cameras/index";
  66688. export * from "babylonjs/Collisions/index";
  66689. export * from "babylonjs/Culling/index";
  66690. export * from "babylonjs/Debug/index";
  66691. export * from "babylonjs/Engines/index";
  66692. export * from "babylonjs/Events/index";
  66693. export * from "babylonjs/Gamepads/index";
  66694. export * from "babylonjs/Gizmos/index";
  66695. export * from "babylonjs/Helpers/index";
  66696. export * from "babylonjs/Instrumentation/index";
  66697. export * from "babylonjs/Layers/index";
  66698. export * from "babylonjs/LensFlares/index";
  66699. export * from "babylonjs/Lights/index";
  66700. export * from "babylonjs/Loading/index";
  66701. export * from "babylonjs/Materials/index";
  66702. export * from "babylonjs/Maths/index";
  66703. export * from "babylonjs/Meshes/index";
  66704. export * from "babylonjs/Morph/index";
  66705. export * from "babylonjs/Navigation/index";
  66706. export * from "babylonjs/node";
  66707. export * from "babylonjs/Offline/index";
  66708. export * from "babylonjs/Particles/index";
  66709. export * from "babylonjs/Physics/index";
  66710. export * from "babylonjs/PostProcesses/index";
  66711. export * from "babylonjs/Probes/index";
  66712. export * from "babylonjs/Rendering/index";
  66713. export * from "babylonjs/scene";
  66714. export * from "babylonjs/sceneComponent";
  66715. export * from "babylonjs/Sprites/index";
  66716. export * from "babylonjs/States/index";
  66717. export * from "babylonjs/Misc/index";
  66718. export * from "babylonjs/types";
  66719. }
  66720. declare module "babylonjs/Animations/pathCursor" {
  66721. import { Vector3 } from "babylonjs/Maths/math.vector";
  66722. import { Path2 } from "babylonjs/Maths/math.path";
  66723. /**
  66724. * A cursor which tracks a point on a path
  66725. */
  66726. export class PathCursor {
  66727. private path;
  66728. /**
  66729. * Stores path cursor callbacks for when an onchange event is triggered
  66730. */
  66731. private _onchange;
  66732. /**
  66733. * The value of the path cursor
  66734. */
  66735. value: number;
  66736. /**
  66737. * The animation array of the path cursor
  66738. */
  66739. animations: Animation[];
  66740. /**
  66741. * Initializes the path cursor
  66742. * @param path The path to track
  66743. */
  66744. constructor(path: Path2);
  66745. /**
  66746. * Gets the cursor point on the path
  66747. * @returns A point on the path cursor at the cursor location
  66748. */
  66749. getPoint(): Vector3;
  66750. /**
  66751. * Moves the cursor ahead by the step amount
  66752. * @param step The amount to move the cursor forward
  66753. * @returns This path cursor
  66754. */
  66755. moveAhead(step?: number): PathCursor;
  66756. /**
  66757. * Moves the cursor behind by the step amount
  66758. * @param step The amount to move the cursor back
  66759. * @returns This path cursor
  66760. */
  66761. moveBack(step?: number): PathCursor;
  66762. /**
  66763. * Moves the cursor by the step amount
  66764. * If the step amount is greater than one, an exception is thrown
  66765. * @param step The amount to move the cursor
  66766. * @returns This path cursor
  66767. */
  66768. move(step: number): PathCursor;
  66769. /**
  66770. * Ensures that the value is limited between zero and one
  66771. * @returns This path cursor
  66772. */
  66773. private ensureLimits;
  66774. /**
  66775. * Runs onchange callbacks on change (used by the animation engine)
  66776. * @returns This path cursor
  66777. */
  66778. private raiseOnChange;
  66779. /**
  66780. * Executes a function on change
  66781. * @param f A path cursor onchange callback
  66782. * @returns This path cursor
  66783. */
  66784. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66785. }
  66786. }
  66787. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66788. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66789. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66790. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66791. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66792. }
  66793. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66794. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66795. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66796. }
  66797. declare module "babylonjs/Engines/Processors/index" {
  66798. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66799. export * from "babylonjs/Engines/Processors/Expressions/index";
  66800. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66801. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66802. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66803. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66804. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66805. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66806. }
  66807. declare module "babylonjs/Legacy/legacy" {
  66808. import * as Babylon from "babylonjs/index";
  66809. export * from "babylonjs/index";
  66810. }
  66811. declare module "babylonjs/Shaders/blur.fragment" {
  66812. /** @hidden */
  66813. export var blurPixelShader: {
  66814. name: string;
  66815. shader: string;
  66816. };
  66817. }
  66818. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66819. /** @hidden */
  66820. export var pointCloudVertexDeclaration: {
  66821. name: string;
  66822. shader: string;
  66823. };
  66824. }
  66825. declare module "babylonjs" {
  66826. export * from "babylonjs/Legacy/legacy";
  66827. }
  66828. declare module BABYLON {
  66829. /** Alias type for value that can be null */
  66830. export type Nullable<T> = T | null;
  66831. /**
  66832. * Alias type for number that are floats
  66833. * @ignorenaming
  66834. */
  66835. export type float = number;
  66836. /**
  66837. * Alias type for number that are doubles.
  66838. * @ignorenaming
  66839. */
  66840. export type double = number;
  66841. /**
  66842. * Alias type for number that are integer
  66843. * @ignorenaming
  66844. */
  66845. export type int = number;
  66846. /** Alias type for number array or Float32Array */
  66847. export type FloatArray = number[] | Float32Array;
  66848. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66849. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66850. /**
  66851. * Alias for types that can be used by a Buffer or VertexBuffer.
  66852. */
  66853. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66854. /**
  66855. * Alias type for primitive types
  66856. * @ignorenaming
  66857. */
  66858. type Primitive = undefined | null | boolean | string | number | Function;
  66859. /**
  66860. * Type modifier to make all the properties of an object Readonly
  66861. */
  66862. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66863. /**
  66864. * Type modifier to make all the properties of an object Readonly recursively
  66865. */
  66866. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66867. /**
  66868. * Type modifier to make object properties readonly.
  66869. */
  66870. export type DeepImmutableObject<T> = {
  66871. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66872. };
  66873. /** @hidden */
  66874. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66875. }
  66876. }
  66877. declare module BABYLON {
  66878. /**
  66879. * A class serves as a medium between the observable and its observers
  66880. */
  66881. export class EventState {
  66882. /**
  66883. * Create a new EventState
  66884. * @param mask defines the mask associated with this state
  66885. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66886. * @param target defines the original target of the state
  66887. * @param currentTarget defines the current target of the state
  66888. */
  66889. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66890. /**
  66891. * Initialize the current event state
  66892. * @param mask defines the mask associated with this state
  66893. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66894. * @param target defines the original target of the state
  66895. * @param currentTarget defines the current target of the state
  66896. * @returns the current event state
  66897. */
  66898. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66899. /**
  66900. * An Observer can set this property to true to prevent subsequent observers of being notified
  66901. */
  66902. skipNextObservers: boolean;
  66903. /**
  66904. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66905. */
  66906. mask: number;
  66907. /**
  66908. * The object that originally notified the event
  66909. */
  66910. target?: any;
  66911. /**
  66912. * The current object in the bubbling phase
  66913. */
  66914. currentTarget?: any;
  66915. /**
  66916. * This will be populated with the return value of the last function that was executed.
  66917. * If it is the first function in the callback chain it will be the event data.
  66918. */
  66919. lastReturnValue?: any;
  66920. }
  66921. /**
  66922. * Represent an Observer registered to a given Observable object.
  66923. */
  66924. export class Observer<T> {
  66925. /**
  66926. * Defines the callback to call when the observer is notified
  66927. */
  66928. callback: (eventData: T, eventState: EventState) => void;
  66929. /**
  66930. * Defines the mask of the observer (used to filter notifications)
  66931. */
  66932. mask: number;
  66933. /**
  66934. * Defines the current scope used to restore the JS context
  66935. */
  66936. scope: any;
  66937. /** @hidden */
  66938. _willBeUnregistered: boolean;
  66939. /**
  66940. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66941. */
  66942. unregisterOnNextCall: boolean;
  66943. /**
  66944. * Creates a new observer
  66945. * @param callback defines the callback to call when the observer is notified
  66946. * @param mask defines the mask of the observer (used to filter notifications)
  66947. * @param scope defines the current scope used to restore the JS context
  66948. */
  66949. constructor(
  66950. /**
  66951. * Defines the callback to call when the observer is notified
  66952. */
  66953. callback: (eventData: T, eventState: EventState) => void,
  66954. /**
  66955. * Defines the mask of the observer (used to filter notifications)
  66956. */
  66957. mask: number,
  66958. /**
  66959. * Defines the current scope used to restore the JS context
  66960. */
  66961. scope?: any);
  66962. }
  66963. /**
  66964. * Represent a list of observers registered to multiple Observables object.
  66965. */
  66966. export class MultiObserver<T> {
  66967. private _observers;
  66968. private _observables;
  66969. /**
  66970. * Release associated resources
  66971. */
  66972. dispose(): void;
  66973. /**
  66974. * Raise a callback when one of the observable will notify
  66975. * @param observables defines a list of observables to watch
  66976. * @param callback defines the callback to call on notification
  66977. * @param mask defines the mask used to filter notifications
  66978. * @param scope defines the current scope used to restore the JS context
  66979. * @returns the new MultiObserver
  66980. */
  66981. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66982. }
  66983. /**
  66984. * The Observable class is a simple implementation of the Observable pattern.
  66985. *
  66986. * 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.
  66987. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66988. * 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).
  66989. * 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.
  66990. */
  66991. export class Observable<T> {
  66992. private _observers;
  66993. private _eventState;
  66994. private _onObserverAdded;
  66995. /**
  66996. * Gets the list of observers
  66997. */
  66998. readonly observers: Array<Observer<T>>;
  66999. /**
  67000. * Creates a new observable
  67001. * @param onObserverAdded defines a callback to call when a new observer is added
  67002. */
  67003. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67004. /**
  67005. * Create a new Observer with the specified callback
  67006. * @param callback the callback that will be executed for that Observer
  67007. * @param mask the mask used to filter observers
  67008. * @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.
  67009. * @param scope optional scope for the callback to be called from
  67010. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67011. * @returns the new observer created for the callback
  67012. */
  67013. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67014. /**
  67015. * Create a new Observer with the specified callback and unregisters after the next notification
  67016. * @param callback the callback that will be executed for that Observer
  67017. * @returns the new observer created for the callback
  67018. */
  67019. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67020. /**
  67021. * Remove an Observer from the Observable object
  67022. * @param observer the instance of the Observer to remove
  67023. * @returns false if it doesn't belong to this Observable
  67024. */
  67025. remove(observer: Nullable<Observer<T>>): boolean;
  67026. /**
  67027. * Remove a callback from the Observable object
  67028. * @param callback the callback to remove
  67029. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67030. * @returns false if it doesn't belong to this Observable
  67031. */
  67032. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67033. private _deferUnregister;
  67034. private _remove;
  67035. /**
  67036. * Moves the observable to the top of the observer list making it get called first when notified
  67037. * @param observer the observer to move
  67038. */
  67039. makeObserverTopPriority(observer: Observer<T>): void;
  67040. /**
  67041. * Moves the observable to the bottom of the observer list making it get called last when notified
  67042. * @param observer the observer to move
  67043. */
  67044. makeObserverBottomPriority(observer: Observer<T>): void;
  67045. /**
  67046. * Notify all Observers by calling their respective callback with the given data
  67047. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67048. * @param eventData defines the data to send to all observers
  67049. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67050. * @param target defines the original target of the state
  67051. * @param currentTarget defines the current target of the state
  67052. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67053. */
  67054. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67055. /**
  67056. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67057. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67058. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67059. * and it is crucial that all callbacks will be executed.
  67060. * The order of the callbacks is kept, callbacks are not executed parallel.
  67061. *
  67062. * @param eventData The data to be sent to each callback
  67063. * @param mask is used to filter observers defaults to -1
  67064. * @param target defines the callback target (see EventState)
  67065. * @param currentTarget defines he current object in the bubbling phase
  67066. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67067. */
  67068. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67069. /**
  67070. * Notify a specific observer
  67071. * @param observer defines the observer to notify
  67072. * @param eventData defines the data to be sent to each callback
  67073. * @param mask is used to filter observers defaults to -1
  67074. */
  67075. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67076. /**
  67077. * Gets a boolean indicating if the observable has at least one observer
  67078. * @returns true is the Observable has at least one Observer registered
  67079. */
  67080. hasObservers(): boolean;
  67081. /**
  67082. * Clear the list of observers
  67083. */
  67084. clear(): void;
  67085. /**
  67086. * Clone the current observable
  67087. * @returns a new observable
  67088. */
  67089. clone(): Observable<T>;
  67090. /**
  67091. * Does this observable handles observer registered with a given mask
  67092. * @param mask defines the mask to be tested
  67093. * @return whether or not one observer registered with the given mask is handeled
  67094. **/
  67095. hasSpecificMask(mask?: number): boolean;
  67096. }
  67097. }
  67098. declare module BABYLON {
  67099. /**
  67100. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67101. * Babylon.js
  67102. */
  67103. export class DomManagement {
  67104. /**
  67105. * Checks if the window object exists
  67106. * @returns true if the window object exists
  67107. */
  67108. static IsWindowObjectExist(): boolean;
  67109. /**
  67110. * Checks if the navigator object exists
  67111. * @returns true if the navigator object exists
  67112. */
  67113. static IsNavigatorAvailable(): boolean;
  67114. /**
  67115. * Extracts text content from a DOM element hierarchy
  67116. * @param element defines the root element
  67117. * @returns a string
  67118. */
  67119. static GetDOMTextContent(element: HTMLElement): string;
  67120. }
  67121. }
  67122. declare module BABYLON {
  67123. /**
  67124. * Logger used througouht the application to allow configuration of
  67125. * the log level required for the messages.
  67126. */
  67127. export class Logger {
  67128. /**
  67129. * No log
  67130. */
  67131. static readonly NoneLogLevel: number;
  67132. /**
  67133. * Only message logs
  67134. */
  67135. static readonly MessageLogLevel: number;
  67136. /**
  67137. * Only warning logs
  67138. */
  67139. static readonly WarningLogLevel: number;
  67140. /**
  67141. * Only error logs
  67142. */
  67143. static readonly ErrorLogLevel: number;
  67144. /**
  67145. * All logs
  67146. */
  67147. static readonly AllLogLevel: number;
  67148. private static _LogCache;
  67149. /**
  67150. * Gets a value indicating the number of loading errors
  67151. * @ignorenaming
  67152. */
  67153. static errorsCount: number;
  67154. /**
  67155. * Callback called when a new log is added
  67156. */
  67157. static OnNewCacheEntry: (entry: string) => void;
  67158. private static _AddLogEntry;
  67159. private static _FormatMessage;
  67160. private static _LogDisabled;
  67161. private static _LogEnabled;
  67162. private static _WarnDisabled;
  67163. private static _WarnEnabled;
  67164. private static _ErrorDisabled;
  67165. private static _ErrorEnabled;
  67166. /**
  67167. * Log a message to the console
  67168. */
  67169. static Log: (message: string) => void;
  67170. /**
  67171. * Write a warning message to the console
  67172. */
  67173. static Warn: (message: string) => void;
  67174. /**
  67175. * Write an error message to the console
  67176. */
  67177. static Error: (message: string) => void;
  67178. /**
  67179. * Gets current log cache (list of logs)
  67180. */
  67181. static readonly LogCache: string;
  67182. /**
  67183. * Clears the log cache
  67184. */
  67185. static ClearLogCache(): void;
  67186. /**
  67187. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67188. */
  67189. static LogLevels: number;
  67190. }
  67191. }
  67192. declare module BABYLON {
  67193. /** @hidden */
  67194. export class _TypeStore {
  67195. /** @hidden */
  67196. static RegisteredTypes: {
  67197. [key: string]: Object;
  67198. };
  67199. /** @hidden */
  67200. static GetClass(fqdn: string): any;
  67201. }
  67202. }
  67203. declare module BABYLON {
  67204. /**
  67205. * Class containing a set of static utilities functions for deep copy.
  67206. */
  67207. export class DeepCopier {
  67208. /**
  67209. * Tries to copy an object by duplicating every property
  67210. * @param source defines the source object
  67211. * @param destination defines the target object
  67212. * @param doNotCopyList defines a list of properties to avoid
  67213. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67214. */
  67215. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67216. }
  67217. }
  67218. declare module BABYLON {
  67219. /**
  67220. * Class containing a set of static utilities functions for precision date
  67221. */
  67222. export class PrecisionDate {
  67223. /**
  67224. * Gets either window.performance.now() if supported or Date.now() else
  67225. */
  67226. static readonly Now: number;
  67227. }
  67228. }
  67229. declare module BABYLON {
  67230. /** @hidden */
  67231. export class _DevTools {
  67232. static WarnImport(name: string): string;
  67233. }
  67234. }
  67235. declare module BABYLON {
  67236. /**
  67237. * Interface used to define the mechanism to get data from the network
  67238. */
  67239. export interface IWebRequest {
  67240. /**
  67241. * Returns client's response url
  67242. */
  67243. responseURL: string;
  67244. /**
  67245. * Returns client's status
  67246. */
  67247. status: number;
  67248. /**
  67249. * Returns client's status as a text
  67250. */
  67251. statusText: string;
  67252. }
  67253. }
  67254. declare module BABYLON {
  67255. /**
  67256. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67257. */
  67258. export class WebRequest implements IWebRequest {
  67259. private _xhr;
  67260. /**
  67261. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67262. * i.e. when loading files, where the server/service expects an Authorization header
  67263. */
  67264. static CustomRequestHeaders: {
  67265. [key: string]: string;
  67266. };
  67267. /**
  67268. * Add callback functions in this array to update all the requests before they get sent to the network
  67269. */
  67270. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67271. private _injectCustomRequestHeaders;
  67272. /**
  67273. * Gets or sets a function to be called when loading progress changes
  67274. */
  67275. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67276. /**
  67277. * Returns client's state
  67278. */
  67279. readonly readyState: number;
  67280. /**
  67281. * Returns client's status
  67282. */
  67283. readonly status: number;
  67284. /**
  67285. * Returns client's status as a text
  67286. */
  67287. readonly statusText: string;
  67288. /**
  67289. * Returns client's response
  67290. */
  67291. readonly response: any;
  67292. /**
  67293. * Returns client's response url
  67294. */
  67295. readonly responseURL: string;
  67296. /**
  67297. * Returns client's response as text
  67298. */
  67299. readonly responseText: string;
  67300. /**
  67301. * Gets or sets the expected response type
  67302. */
  67303. responseType: XMLHttpRequestResponseType;
  67304. /** @hidden */
  67305. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67306. /** @hidden */
  67307. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67308. /**
  67309. * Cancels any network activity
  67310. */
  67311. abort(): void;
  67312. /**
  67313. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67314. * @param body defines an optional request body
  67315. */
  67316. send(body?: Document | BodyInit | null): void;
  67317. /**
  67318. * Sets the request method, request URL
  67319. * @param method defines the method to use (GET, POST, etc..)
  67320. * @param url defines the url to connect with
  67321. */
  67322. open(method: string, url: string): void;
  67323. }
  67324. }
  67325. declare module BABYLON {
  67326. /**
  67327. * File request interface
  67328. */
  67329. export interface IFileRequest {
  67330. /**
  67331. * Raised when the request is complete (success or error).
  67332. */
  67333. onCompleteObservable: Observable<IFileRequest>;
  67334. /**
  67335. * Aborts the request for a file.
  67336. */
  67337. abort: () => void;
  67338. }
  67339. }
  67340. declare module BABYLON {
  67341. /**
  67342. * Define options used to create a render target texture
  67343. */
  67344. export class RenderTargetCreationOptions {
  67345. /**
  67346. * Specifies is mipmaps must be generated
  67347. */
  67348. generateMipMaps?: boolean;
  67349. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67350. generateDepthBuffer?: boolean;
  67351. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67352. generateStencilBuffer?: boolean;
  67353. /** Defines texture type (int by default) */
  67354. type?: number;
  67355. /** Defines sampling mode (trilinear by default) */
  67356. samplingMode?: number;
  67357. /** Defines format (RGBA by default) */
  67358. format?: number;
  67359. }
  67360. }
  67361. declare module BABYLON {
  67362. /**
  67363. * @hidden
  67364. **/
  67365. export class _TimeToken {
  67366. _startTimeQuery: Nullable<WebGLQuery>;
  67367. _endTimeQuery: Nullable<WebGLQuery>;
  67368. _timeElapsedQuery: Nullable<WebGLQuery>;
  67369. _timeElapsedQueryEnded: boolean;
  67370. }
  67371. }
  67372. declare module BABYLON {
  67373. /** Defines the cross module used constants to avoid circular dependncies */
  67374. export class Constants {
  67375. /** Defines that alpha blending is disabled */
  67376. static readonly ALPHA_DISABLE: number;
  67377. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67378. static readonly ALPHA_ADD: number;
  67379. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67380. static readonly ALPHA_COMBINE: number;
  67381. /** Defines that alpha blending to DEST - SRC * DEST */
  67382. static readonly ALPHA_SUBTRACT: number;
  67383. /** Defines that alpha blending to SRC * DEST */
  67384. static readonly ALPHA_MULTIPLY: number;
  67385. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67386. static readonly ALPHA_MAXIMIZED: number;
  67387. /** Defines that alpha blending to SRC + DEST */
  67388. static readonly ALPHA_ONEONE: number;
  67389. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67390. static readonly ALPHA_PREMULTIPLIED: number;
  67391. /**
  67392. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67393. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67394. */
  67395. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67396. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67397. static readonly ALPHA_INTERPOLATE: number;
  67398. /**
  67399. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67400. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67401. */
  67402. static readonly ALPHA_SCREENMODE: number;
  67403. /**
  67404. * Defines that alpha blending to SRC + DST
  67405. * Alpha will be set to SRC ALPHA + DST ALPHA
  67406. */
  67407. static readonly ALPHA_ONEONE_ONEONE: number;
  67408. /**
  67409. * Defines that alpha blending to SRC * DST ALPHA + DST
  67410. * Alpha will be set to 0
  67411. */
  67412. static readonly ALPHA_ALPHATOCOLOR: number;
  67413. /**
  67414. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  67415. */
  67416. static readonly ALPHA_REVERSEONEMINUS: number;
  67417. /**
  67418. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  67419. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  67420. */
  67421. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  67422. /**
  67423. * Defines that alpha blending to SRC + DST
  67424. * Alpha will be set to SRC ALPHA
  67425. */
  67426. static readonly ALPHA_ONEONE_ONEZERO: number;
  67427. /** Defines that alpha blending equation a SUM */
  67428. static readonly ALPHA_EQUATION_ADD: number;
  67429. /** Defines that alpha blending equation a SUBSTRACTION */
  67430. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  67431. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  67432. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  67433. /** Defines that alpha blending equation a MAX operation */
  67434. static readonly ALPHA_EQUATION_MAX: number;
  67435. /** Defines that alpha blending equation a MIN operation */
  67436. static readonly ALPHA_EQUATION_MIN: number;
  67437. /**
  67438. * Defines that alpha blending equation a DARKEN operation:
  67439. * It takes the min of the src and sums the alpha channels.
  67440. */
  67441. static readonly ALPHA_EQUATION_DARKEN: number;
  67442. /** Defines that the ressource is not delayed*/
  67443. static readonly DELAYLOADSTATE_NONE: number;
  67444. /** Defines that the ressource was successfully delay loaded */
  67445. static readonly DELAYLOADSTATE_LOADED: number;
  67446. /** Defines that the ressource is currently delay loading */
  67447. static readonly DELAYLOADSTATE_LOADING: number;
  67448. /** Defines that the ressource is delayed and has not started loading */
  67449. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67450. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67451. static readonly NEVER: number;
  67452. /** 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 */
  67453. static readonly ALWAYS: number;
  67454. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67455. static readonly LESS: number;
  67456. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67457. static readonly EQUAL: number;
  67458. /** 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 */
  67459. static readonly LEQUAL: number;
  67460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67461. static readonly GREATER: number;
  67462. /** 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 */
  67463. static readonly GEQUAL: number;
  67464. /** 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 */
  67465. static readonly NOTEQUAL: number;
  67466. /** Passed to stencilOperation to specify that stencil value must be kept */
  67467. static readonly KEEP: number;
  67468. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67469. static readonly REPLACE: number;
  67470. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67471. static readonly INCR: number;
  67472. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67473. static readonly DECR: number;
  67474. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67475. static readonly INVERT: number;
  67476. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67477. static readonly INCR_WRAP: number;
  67478. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67479. static readonly DECR_WRAP: number;
  67480. /** Texture is not repeating outside of 0..1 UVs */
  67481. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67482. /** Texture is repeating outside of 0..1 UVs */
  67483. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67484. /** Texture is repeating and mirrored */
  67485. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67486. /** ALPHA */
  67487. static readonly TEXTUREFORMAT_ALPHA: number;
  67488. /** LUMINANCE */
  67489. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67490. /** LUMINANCE_ALPHA */
  67491. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67492. /** RGB */
  67493. static readonly TEXTUREFORMAT_RGB: number;
  67494. /** RGBA */
  67495. static readonly TEXTUREFORMAT_RGBA: number;
  67496. /** RED */
  67497. static readonly TEXTUREFORMAT_RED: number;
  67498. /** RED (2nd reference) */
  67499. static readonly TEXTUREFORMAT_R: number;
  67500. /** RG */
  67501. static readonly TEXTUREFORMAT_RG: number;
  67502. /** RED_INTEGER */
  67503. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67504. /** RED_INTEGER (2nd reference) */
  67505. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67506. /** RG_INTEGER */
  67507. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67508. /** RGB_INTEGER */
  67509. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67510. /** RGBA_INTEGER */
  67511. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67512. /** UNSIGNED_BYTE */
  67513. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67514. /** UNSIGNED_BYTE (2nd reference) */
  67515. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67516. /** FLOAT */
  67517. static readonly TEXTURETYPE_FLOAT: number;
  67518. /** HALF_FLOAT */
  67519. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67520. /** BYTE */
  67521. static readonly TEXTURETYPE_BYTE: number;
  67522. /** SHORT */
  67523. static readonly TEXTURETYPE_SHORT: number;
  67524. /** UNSIGNED_SHORT */
  67525. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67526. /** INT */
  67527. static readonly TEXTURETYPE_INT: number;
  67528. /** UNSIGNED_INT */
  67529. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67530. /** UNSIGNED_SHORT_4_4_4_4 */
  67531. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67532. /** UNSIGNED_SHORT_5_5_5_1 */
  67533. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67534. /** UNSIGNED_SHORT_5_6_5 */
  67535. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67536. /** UNSIGNED_INT_2_10_10_10_REV */
  67537. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67538. /** UNSIGNED_INT_24_8 */
  67539. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67540. /** UNSIGNED_INT_10F_11F_11F_REV */
  67541. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67542. /** UNSIGNED_INT_5_9_9_9_REV */
  67543. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67544. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67545. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67546. /** nearest is mag = nearest and min = nearest and mip = linear */
  67547. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67548. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67549. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67550. /** Trilinear is mag = linear and min = linear and mip = linear */
  67551. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67552. /** nearest is mag = nearest and min = nearest and mip = linear */
  67553. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67554. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67555. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67556. /** Trilinear is mag = linear and min = linear and mip = linear */
  67557. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67558. /** mag = nearest and min = nearest and mip = nearest */
  67559. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67560. /** mag = nearest and min = linear and mip = nearest */
  67561. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67562. /** mag = nearest and min = linear and mip = linear */
  67563. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67564. /** mag = nearest and min = linear and mip = none */
  67565. static readonly TEXTURE_NEAREST_LINEAR: number;
  67566. /** mag = nearest and min = nearest and mip = none */
  67567. static readonly TEXTURE_NEAREST_NEAREST: number;
  67568. /** mag = linear and min = nearest and mip = nearest */
  67569. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67570. /** mag = linear and min = nearest and mip = linear */
  67571. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67572. /** mag = linear and min = linear and mip = none */
  67573. static readonly TEXTURE_LINEAR_LINEAR: number;
  67574. /** mag = linear and min = nearest and mip = none */
  67575. static readonly TEXTURE_LINEAR_NEAREST: number;
  67576. /** Explicit coordinates mode */
  67577. static readonly TEXTURE_EXPLICIT_MODE: number;
  67578. /** Spherical coordinates mode */
  67579. static readonly TEXTURE_SPHERICAL_MODE: number;
  67580. /** Planar coordinates mode */
  67581. static readonly TEXTURE_PLANAR_MODE: number;
  67582. /** Cubic coordinates mode */
  67583. static readonly TEXTURE_CUBIC_MODE: number;
  67584. /** Projection coordinates mode */
  67585. static readonly TEXTURE_PROJECTION_MODE: number;
  67586. /** Skybox coordinates mode */
  67587. static readonly TEXTURE_SKYBOX_MODE: number;
  67588. /** Inverse Cubic coordinates mode */
  67589. static readonly TEXTURE_INVCUBIC_MODE: number;
  67590. /** Equirectangular coordinates mode */
  67591. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67592. /** Equirectangular Fixed coordinates mode */
  67593. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67594. /** Equirectangular Fixed Mirrored coordinates mode */
  67595. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67596. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67597. static readonly SCALEMODE_FLOOR: number;
  67598. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67599. static readonly SCALEMODE_NEAREST: number;
  67600. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67601. static readonly SCALEMODE_CEILING: number;
  67602. /**
  67603. * The dirty texture flag value
  67604. */
  67605. static readonly MATERIAL_TextureDirtyFlag: number;
  67606. /**
  67607. * The dirty light flag value
  67608. */
  67609. static readonly MATERIAL_LightDirtyFlag: number;
  67610. /**
  67611. * The dirty fresnel flag value
  67612. */
  67613. static readonly MATERIAL_FresnelDirtyFlag: number;
  67614. /**
  67615. * The dirty attribute flag value
  67616. */
  67617. static readonly MATERIAL_AttributesDirtyFlag: number;
  67618. /**
  67619. * The dirty misc flag value
  67620. */
  67621. static readonly MATERIAL_MiscDirtyFlag: number;
  67622. /**
  67623. * The all dirty flag value
  67624. */
  67625. static readonly MATERIAL_AllDirtyFlag: number;
  67626. /**
  67627. * Returns the triangle fill mode
  67628. */
  67629. static readonly MATERIAL_TriangleFillMode: number;
  67630. /**
  67631. * Returns the wireframe mode
  67632. */
  67633. static readonly MATERIAL_WireFrameFillMode: number;
  67634. /**
  67635. * Returns the point fill mode
  67636. */
  67637. static readonly MATERIAL_PointFillMode: number;
  67638. /**
  67639. * Returns the point list draw mode
  67640. */
  67641. static readonly MATERIAL_PointListDrawMode: number;
  67642. /**
  67643. * Returns the line list draw mode
  67644. */
  67645. static readonly MATERIAL_LineListDrawMode: number;
  67646. /**
  67647. * Returns the line loop draw mode
  67648. */
  67649. static readonly MATERIAL_LineLoopDrawMode: number;
  67650. /**
  67651. * Returns the line strip draw mode
  67652. */
  67653. static readonly MATERIAL_LineStripDrawMode: number;
  67654. /**
  67655. * Returns the triangle strip draw mode
  67656. */
  67657. static readonly MATERIAL_TriangleStripDrawMode: number;
  67658. /**
  67659. * Returns the triangle fan draw mode
  67660. */
  67661. static readonly MATERIAL_TriangleFanDrawMode: number;
  67662. /**
  67663. * Stores the clock-wise side orientation
  67664. */
  67665. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67666. /**
  67667. * Stores the counter clock-wise side orientation
  67668. */
  67669. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67670. /**
  67671. * Nothing
  67672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67673. */
  67674. static readonly ACTION_NothingTrigger: number;
  67675. /**
  67676. * On pick
  67677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67678. */
  67679. static readonly ACTION_OnPickTrigger: number;
  67680. /**
  67681. * On left pick
  67682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67683. */
  67684. static readonly ACTION_OnLeftPickTrigger: number;
  67685. /**
  67686. * On right pick
  67687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67688. */
  67689. static readonly ACTION_OnRightPickTrigger: number;
  67690. /**
  67691. * On center pick
  67692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67693. */
  67694. static readonly ACTION_OnCenterPickTrigger: number;
  67695. /**
  67696. * On pick down
  67697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67698. */
  67699. static readonly ACTION_OnPickDownTrigger: number;
  67700. /**
  67701. * On double pick
  67702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67703. */
  67704. static readonly ACTION_OnDoublePickTrigger: number;
  67705. /**
  67706. * On pick up
  67707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67708. */
  67709. static readonly ACTION_OnPickUpTrigger: number;
  67710. /**
  67711. * On pick out.
  67712. * This trigger will only be raised if you also declared a OnPickDown
  67713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67714. */
  67715. static readonly ACTION_OnPickOutTrigger: number;
  67716. /**
  67717. * On long press
  67718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67719. */
  67720. static readonly ACTION_OnLongPressTrigger: number;
  67721. /**
  67722. * On pointer over
  67723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67724. */
  67725. static readonly ACTION_OnPointerOverTrigger: number;
  67726. /**
  67727. * On pointer out
  67728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67729. */
  67730. static readonly ACTION_OnPointerOutTrigger: number;
  67731. /**
  67732. * On every frame
  67733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67734. */
  67735. static readonly ACTION_OnEveryFrameTrigger: number;
  67736. /**
  67737. * On intersection enter
  67738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67739. */
  67740. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67741. /**
  67742. * On intersection exit
  67743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67744. */
  67745. static readonly ACTION_OnIntersectionExitTrigger: number;
  67746. /**
  67747. * On key down
  67748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67749. */
  67750. static readonly ACTION_OnKeyDownTrigger: number;
  67751. /**
  67752. * On key up
  67753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67754. */
  67755. static readonly ACTION_OnKeyUpTrigger: number;
  67756. /**
  67757. * Billboard mode will only apply to Y axis
  67758. */
  67759. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67760. /**
  67761. * Billboard mode will apply to all axes
  67762. */
  67763. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67764. /**
  67765. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67766. */
  67767. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67768. /**
  67769. * Gets or sets base Assets URL
  67770. */
  67771. static PARTICLES_BaseAssetsUrl: string;
  67772. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67773. * Test order :
  67774. * Is the bounding sphere outside the frustum ?
  67775. * If not, are the bounding box vertices outside the frustum ?
  67776. * It not, then the cullable object is in the frustum.
  67777. */
  67778. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67779. /** Culling strategy : Bounding Sphere Only.
  67780. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67781. * It's also less accurate than the standard because some not visible objects can still be selected.
  67782. * Test : is the bounding sphere outside the frustum ?
  67783. * If not, then the cullable object is in the frustum.
  67784. */
  67785. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67786. /** Culling strategy : Optimistic Inclusion.
  67787. * This in an inclusion test first, then the standard exclusion test.
  67788. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67789. * 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.
  67790. * Anyway, it's as accurate as the standard strategy.
  67791. * Test :
  67792. * Is the cullable object bounding sphere center in the frustum ?
  67793. * If not, apply the default culling strategy.
  67794. */
  67795. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67796. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67797. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67798. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67799. * 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.
  67800. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67801. * Test :
  67802. * Is the cullable object bounding sphere center in the frustum ?
  67803. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67804. */
  67805. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67806. /**
  67807. * No logging while loading
  67808. */
  67809. static readonly SCENELOADER_NO_LOGGING: number;
  67810. /**
  67811. * Minimal logging while loading
  67812. */
  67813. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67814. /**
  67815. * Summary logging while loading
  67816. */
  67817. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67818. /**
  67819. * Detailled logging while loading
  67820. */
  67821. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67822. }
  67823. }
  67824. declare module BABYLON {
  67825. /**
  67826. * This represents the required contract to create a new type of texture loader.
  67827. */
  67828. export interface IInternalTextureLoader {
  67829. /**
  67830. * Defines wether the loader supports cascade loading the different faces.
  67831. */
  67832. supportCascades: boolean;
  67833. /**
  67834. * This returns if the loader support the current file information.
  67835. * @param extension defines the file extension of the file being loaded
  67836. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67837. * @param fallback defines the fallback internal texture if any
  67838. * @param isBase64 defines whether the texture is encoded as a base64
  67839. * @param isBuffer defines whether the texture data are stored as a buffer
  67840. * @returns true if the loader can load the specified file
  67841. */
  67842. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  67843. /**
  67844. * Transform the url before loading if required.
  67845. * @param rootUrl the url of the texture
  67846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67847. * @returns the transformed texture
  67848. */
  67849. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  67850. /**
  67851. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  67852. * @param rootUrl the url of the texture
  67853. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67854. * @returns the fallback texture
  67855. */
  67856. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  67857. /**
  67858. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  67859. * @param data contains the texture data
  67860. * @param texture defines the BabylonJS internal texture
  67861. * @param createPolynomials will be true if polynomials have been requested
  67862. * @param onLoad defines the callback to trigger once the texture is ready
  67863. * @param onError defines the callback to trigger in case of error
  67864. */
  67865. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67866. /**
  67867. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  67868. * @param data contains the texture data
  67869. * @param texture defines the BabylonJS internal texture
  67870. * @param callback defines the method to call once ready to upload
  67871. */
  67872. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  67873. }
  67874. }
  67875. declare module BABYLON {
  67876. /**
  67877. * Class used to store and describe the pipeline context associated with an effect
  67878. */
  67879. export interface IPipelineContext {
  67880. /**
  67881. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67882. */
  67883. isAsync: boolean;
  67884. /**
  67885. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67886. */
  67887. isReady: boolean;
  67888. /** @hidden */
  67889. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67890. }
  67891. }
  67892. declare module BABYLON {
  67893. /**
  67894. * Class used to store gfx data (like WebGLBuffer)
  67895. */
  67896. export class DataBuffer {
  67897. /**
  67898. * Gets or sets the number of objects referencing this buffer
  67899. */
  67900. references: number;
  67901. /** Gets or sets the size of the underlying buffer */
  67902. capacity: number;
  67903. /**
  67904. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67905. */
  67906. is32Bits: boolean;
  67907. /**
  67908. * Gets the underlying buffer
  67909. */
  67910. readonly underlyingResource: any;
  67911. }
  67912. }
  67913. declare module BABYLON {
  67914. /** @hidden */
  67915. export interface IShaderProcessor {
  67916. attributeProcessor?: (attribute: string) => string;
  67917. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67918. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67919. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67920. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67921. lineProcessor?: (line: string, isFragment: boolean) => string;
  67922. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67923. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67924. }
  67925. }
  67926. declare module BABYLON {
  67927. /** @hidden */
  67928. export interface ProcessingOptions {
  67929. defines: string[];
  67930. indexParameters: any;
  67931. isFragment: boolean;
  67932. shouldUseHighPrecisionShader: boolean;
  67933. supportsUniformBuffers: boolean;
  67934. shadersRepository: string;
  67935. includesShadersStore: {
  67936. [key: string]: string;
  67937. };
  67938. processor?: IShaderProcessor;
  67939. version: string;
  67940. platformName: string;
  67941. lookForClosingBracketForUniformBuffer?: boolean;
  67942. }
  67943. }
  67944. declare module BABYLON {
  67945. /**
  67946. * Helper to manipulate strings
  67947. */
  67948. export class StringTools {
  67949. /**
  67950. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  67951. * @param str Source string
  67952. * @param suffix Suffix to search for in the source string
  67953. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67954. */
  67955. static EndsWith(str: string, suffix: string): boolean;
  67956. /**
  67957. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  67958. * @param str Source string
  67959. * @param suffix Suffix to search for in the source string
  67960. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67961. */
  67962. static StartsWith(str: string, suffix: string): boolean;
  67963. }
  67964. }
  67965. declare module BABYLON {
  67966. /** @hidden */
  67967. export class ShaderCodeNode {
  67968. line: string;
  67969. children: ShaderCodeNode[];
  67970. additionalDefineKey?: string;
  67971. additionalDefineValue?: string;
  67972. isValid(preprocessors: {
  67973. [key: string]: string;
  67974. }): boolean;
  67975. process(preprocessors: {
  67976. [key: string]: string;
  67977. }, options: ProcessingOptions): string;
  67978. }
  67979. }
  67980. declare module BABYLON {
  67981. /** @hidden */
  67982. export class ShaderCodeCursor {
  67983. private _lines;
  67984. lineIndex: number;
  67985. readonly currentLine: string;
  67986. readonly canRead: boolean;
  67987. lines: string[];
  67988. }
  67989. }
  67990. declare module BABYLON {
  67991. /** @hidden */
  67992. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67993. process(preprocessors: {
  67994. [key: string]: string;
  67995. }, options: ProcessingOptions): string;
  67996. }
  67997. }
  67998. declare module BABYLON {
  67999. /** @hidden */
  68000. export class ShaderDefineExpression {
  68001. isTrue(preprocessors: {
  68002. [key: string]: string;
  68003. }): boolean;
  68004. }
  68005. }
  68006. declare module BABYLON {
  68007. /** @hidden */
  68008. export class ShaderCodeTestNode extends ShaderCodeNode {
  68009. testExpression: ShaderDefineExpression;
  68010. isValid(preprocessors: {
  68011. [key: string]: string;
  68012. }): boolean;
  68013. }
  68014. }
  68015. declare module BABYLON {
  68016. /** @hidden */
  68017. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68018. define: string;
  68019. not: boolean;
  68020. constructor(define: string, not?: boolean);
  68021. isTrue(preprocessors: {
  68022. [key: string]: string;
  68023. }): boolean;
  68024. }
  68025. }
  68026. declare module BABYLON {
  68027. /** @hidden */
  68028. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68029. leftOperand: ShaderDefineExpression;
  68030. rightOperand: ShaderDefineExpression;
  68031. isTrue(preprocessors: {
  68032. [key: string]: string;
  68033. }): boolean;
  68034. }
  68035. }
  68036. declare module BABYLON {
  68037. /** @hidden */
  68038. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68039. leftOperand: ShaderDefineExpression;
  68040. rightOperand: ShaderDefineExpression;
  68041. isTrue(preprocessors: {
  68042. [key: string]: string;
  68043. }): boolean;
  68044. }
  68045. }
  68046. declare module BABYLON {
  68047. /** @hidden */
  68048. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68049. define: string;
  68050. operand: string;
  68051. testValue: string;
  68052. constructor(define: string, operand: string, testValue: string);
  68053. isTrue(preprocessors: {
  68054. [key: string]: string;
  68055. }): boolean;
  68056. }
  68057. }
  68058. declare module BABYLON {
  68059. /**
  68060. * @ignore
  68061. * Application error to support additional information when loading a file
  68062. */
  68063. export class LoadFileError extends Error {
  68064. /** defines the optional web request */
  68065. request?: WebRequest | undefined;
  68066. private static _setPrototypeOf;
  68067. /**
  68068. * Creates a new LoadFileError
  68069. * @param message defines the message of the error
  68070. * @param request defines the optional web request
  68071. */
  68072. constructor(message: string,
  68073. /** defines the optional web request */
  68074. request?: WebRequest | undefined);
  68075. }
  68076. }
  68077. declare module BABYLON {
  68078. /**
  68079. * Class used to enable access to offline support
  68080. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68081. */
  68082. export interface IOfflineProvider {
  68083. /**
  68084. * Gets a boolean indicating if scene must be saved in the database
  68085. */
  68086. enableSceneOffline: boolean;
  68087. /**
  68088. * Gets a boolean indicating if textures must be saved in the database
  68089. */
  68090. enableTexturesOffline: boolean;
  68091. /**
  68092. * Open the offline support and make it available
  68093. * @param successCallback defines the callback to call on success
  68094. * @param errorCallback defines the callback to call on error
  68095. */
  68096. open(successCallback: () => void, errorCallback: () => void): void;
  68097. /**
  68098. * Loads an image from the offline support
  68099. * @param url defines the url to load from
  68100. * @param image defines the target DOM image
  68101. */
  68102. loadImage(url: string, image: HTMLImageElement): void;
  68103. /**
  68104. * Loads a file from offline support
  68105. * @param url defines the URL to load from
  68106. * @param sceneLoaded defines a callback to call on success
  68107. * @param progressCallBack defines a callback to call when progress changed
  68108. * @param errorCallback defines a callback to call on error
  68109. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68110. */
  68111. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68112. }
  68113. }
  68114. declare module BABYLON {
  68115. /**
  68116. * Class used to help managing file picking and drag'n'drop
  68117. * File Storage
  68118. */
  68119. export class FilesInputStore {
  68120. /**
  68121. * List of files ready to be loaded
  68122. */
  68123. static FilesToLoad: {
  68124. [key: string]: File;
  68125. };
  68126. }
  68127. }
  68128. declare module BABYLON {
  68129. /**
  68130. * Class used to define a retry strategy when error happens while loading assets
  68131. */
  68132. export class RetryStrategy {
  68133. /**
  68134. * Function used to defines an exponential back off strategy
  68135. * @param maxRetries defines the maximum number of retries (3 by default)
  68136. * @param baseInterval defines the interval between retries
  68137. * @returns the strategy function to use
  68138. */
  68139. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68140. }
  68141. }
  68142. declare module BABYLON {
  68143. /**
  68144. * @hidden
  68145. */
  68146. export class FileTools {
  68147. /**
  68148. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68149. */
  68150. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68151. /**
  68152. * Gets or sets the base URL to use to load assets
  68153. */
  68154. static BaseUrl: string;
  68155. /**
  68156. * Default behaviour for cors in the application.
  68157. * It can be a string if the expected behavior is identical in the entire app.
  68158. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68159. */
  68160. static CorsBehavior: string | ((url: string | string[]) => string);
  68161. /**
  68162. * Gets or sets a function used to pre-process url before using them to load assets
  68163. */
  68164. static PreprocessUrl: (url: string) => string;
  68165. /**
  68166. * Removes unwanted characters from an url
  68167. * @param url defines the url to clean
  68168. * @returns the cleaned url
  68169. */
  68170. private static _CleanUrl;
  68171. /**
  68172. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68173. * @param url define the url we are trying
  68174. * @param element define the dom element where to configure the cors policy
  68175. */
  68176. static SetCorsBehavior(url: string | string[], element: {
  68177. crossOrigin: string | null;
  68178. }): void;
  68179. /**
  68180. * Loads an image as an HTMLImageElement.
  68181. * @param input url string, ArrayBuffer, or Blob to load
  68182. * @param onLoad callback called when the image successfully loads
  68183. * @param onError callback called when the image fails to load
  68184. * @param offlineProvider offline provider for caching
  68185. * @returns the HTMLImageElement of the loaded image
  68186. */
  68187. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68188. /**
  68189. * Loads a file
  68190. * @param fileToLoad defines the file to load
  68191. * @param callback defines the callback to call when data is loaded
  68192. * @param progressCallBack defines the callback to call during loading process
  68193. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68194. * @returns a file request object
  68195. */
  68196. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68197. /**
  68198. * Loads a file
  68199. * @param url url string, ArrayBuffer, or Blob to load
  68200. * @param onSuccess callback called when the file successfully loads
  68201. * @param onProgress callback called while file is loading (if the server supports this mode)
  68202. * @param offlineProvider defines the offline provider for caching
  68203. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68204. * @param onError callback called when the file fails to load
  68205. * @returns a file request object
  68206. */
  68207. 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;
  68208. /**
  68209. * Checks if the loaded document was accessed via `file:`-Protocol.
  68210. * @returns boolean
  68211. */
  68212. static IsFileURL(): boolean;
  68213. }
  68214. }
  68215. declare module BABYLON {
  68216. /** @hidden */
  68217. export class ShaderProcessor {
  68218. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68219. private static _ProcessPrecision;
  68220. private static _ExtractOperation;
  68221. private static _BuildSubExpression;
  68222. private static _BuildExpression;
  68223. private static _MoveCursorWithinIf;
  68224. private static _MoveCursor;
  68225. private static _EvaluatePreProcessors;
  68226. private static _PreparePreProcessors;
  68227. private static _ProcessShaderConversion;
  68228. private static _ProcessIncludes;
  68229. }
  68230. }
  68231. declare module BABYLON {
  68232. /**
  68233. * @hidden
  68234. */
  68235. export interface IColor4Like {
  68236. r: float;
  68237. g: float;
  68238. b: float;
  68239. a: float;
  68240. }
  68241. /**
  68242. * @hidden
  68243. */
  68244. export interface IColor3Like {
  68245. r: float;
  68246. g: float;
  68247. b: float;
  68248. }
  68249. /**
  68250. * @hidden
  68251. */
  68252. export interface IVector4Like {
  68253. x: float;
  68254. y: float;
  68255. z: float;
  68256. w: float;
  68257. }
  68258. /**
  68259. * @hidden
  68260. */
  68261. export interface IVector3Like {
  68262. x: float;
  68263. y: float;
  68264. z: float;
  68265. }
  68266. /**
  68267. * @hidden
  68268. */
  68269. export interface IVector2Like {
  68270. x: float;
  68271. y: float;
  68272. }
  68273. /**
  68274. * @hidden
  68275. */
  68276. export interface IMatrixLike {
  68277. toArray(): DeepImmutable<Float32Array>;
  68278. updateFlag: int;
  68279. }
  68280. /**
  68281. * @hidden
  68282. */
  68283. export interface IViewportLike {
  68284. x: float;
  68285. y: float;
  68286. width: float;
  68287. height: float;
  68288. }
  68289. /**
  68290. * @hidden
  68291. */
  68292. export interface IPlaneLike {
  68293. normal: IVector3Like;
  68294. d: float;
  68295. normalize(): void;
  68296. }
  68297. }
  68298. declare module BABYLON {
  68299. /**
  68300. * Interface used to define common properties for effect fallbacks
  68301. */
  68302. export interface IEffectFallbacks {
  68303. /**
  68304. * Removes the defines that should be removed when falling back.
  68305. * @param currentDefines defines the current define statements for the shader.
  68306. * @param effect defines the current effect we try to compile
  68307. * @returns The resulting defines with defines of the current rank removed.
  68308. */
  68309. reduce(currentDefines: string, effect: Effect): string;
  68310. /**
  68311. * Removes the fallback from the bound mesh.
  68312. */
  68313. unBindMesh(): void;
  68314. /**
  68315. * Checks to see if more fallbacks are still availible.
  68316. */
  68317. hasMoreFallbacks: boolean;
  68318. }
  68319. }
  68320. declare module BABYLON {
  68321. /**
  68322. * Class used to evalaute queries containing `and` and `or` operators
  68323. */
  68324. export class AndOrNotEvaluator {
  68325. /**
  68326. * Evaluate a query
  68327. * @param query defines the query to evaluate
  68328. * @param evaluateCallback defines the callback used to filter result
  68329. * @returns true if the query matches
  68330. */
  68331. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68332. private static _HandleParenthesisContent;
  68333. private static _SimplifyNegation;
  68334. }
  68335. }
  68336. declare module BABYLON {
  68337. /**
  68338. * Class used to store custom tags
  68339. */
  68340. export class Tags {
  68341. /**
  68342. * Adds support for tags on the given object
  68343. * @param obj defines the object to use
  68344. */
  68345. static EnableFor(obj: any): void;
  68346. /**
  68347. * Removes tags support
  68348. * @param obj defines the object to use
  68349. */
  68350. static DisableFor(obj: any): void;
  68351. /**
  68352. * Gets a boolean indicating if the given object has tags
  68353. * @param obj defines the object to use
  68354. * @returns a boolean
  68355. */
  68356. static HasTags(obj: any): boolean;
  68357. /**
  68358. * Gets the tags available on a given object
  68359. * @param obj defines the object to use
  68360. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68361. * @returns the tags
  68362. */
  68363. static GetTags(obj: any, asString?: boolean): any;
  68364. /**
  68365. * Adds tags to an object
  68366. * @param obj defines the object to use
  68367. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68368. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68369. */
  68370. static AddTagsTo(obj: any, tagsString: string): void;
  68371. /**
  68372. * @hidden
  68373. */
  68374. static _AddTagTo(obj: any, tag: string): void;
  68375. /**
  68376. * Removes specific tags from a specific object
  68377. * @param obj defines the object to use
  68378. * @param tagsString defines the tags to remove
  68379. */
  68380. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68381. /**
  68382. * @hidden
  68383. */
  68384. static _RemoveTagFrom(obj: any, tag: string): void;
  68385. /**
  68386. * Defines if tags hosted on an object match a given query
  68387. * @param obj defines the object to use
  68388. * @param tagsQuery defines the tag query
  68389. * @returns a boolean
  68390. */
  68391. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68392. }
  68393. }
  68394. declare module BABYLON {
  68395. /**
  68396. * Scalar computation library
  68397. */
  68398. export class Scalar {
  68399. /**
  68400. * Two pi constants convenient for computation.
  68401. */
  68402. static TwoPi: number;
  68403. /**
  68404. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68405. * @param a number
  68406. * @param b number
  68407. * @param epsilon (default = 1.401298E-45)
  68408. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68409. */
  68410. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  68411. /**
  68412. * Returns a string : the upper case translation of the number i to hexadecimal.
  68413. * @param i number
  68414. * @returns the upper case translation of the number i to hexadecimal.
  68415. */
  68416. static ToHex(i: number): string;
  68417. /**
  68418. * Returns -1 if value is negative and +1 is value is positive.
  68419. * @param value the value
  68420. * @returns the value itself if it's equal to zero.
  68421. */
  68422. static Sign(value: number): number;
  68423. /**
  68424. * Returns the value itself if it's between min and max.
  68425. * Returns min if the value is lower than min.
  68426. * Returns max if the value is greater than max.
  68427. * @param value the value to clmap
  68428. * @param min the min value to clamp to (default: 0)
  68429. * @param max the max value to clamp to (default: 1)
  68430. * @returns the clamped value
  68431. */
  68432. static Clamp(value: number, min?: number, max?: number): number;
  68433. /**
  68434. * the log2 of value.
  68435. * @param value the value to compute log2 of
  68436. * @returns the log2 of value.
  68437. */
  68438. static Log2(value: number): number;
  68439. /**
  68440. * Loops the value, so that it is never larger than length and never smaller than 0.
  68441. *
  68442. * This is similar to the modulo operator but it works with floating point numbers.
  68443. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68444. * With t = 5 and length = 2.5, the result would be 0.0.
  68445. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68446. * @param value the value
  68447. * @param length the length
  68448. * @returns the looped value
  68449. */
  68450. static Repeat(value: number, length: number): number;
  68451. /**
  68452. * Normalize the value between 0.0 and 1.0 using min and max values
  68453. * @param value value to normalize
  68454. * @param min max to normalize between
  68455. * @param max min to normalize between
  68456. * @returns the normalized value
  68457. */
  68458. static Normalize(value: number, min: number, max: number): number;
  68459. /**
  68460. * Denormalize the value from 0.0 and 1.0 using min and max values
  68461. * @param normalized value to denormalize
  68462. * @param min max to denormalize between
  68463. * @param max min to denormalize between
  68464. * @returns the denormalized value
  68465. */
  68466. static Denormalize(normalized: number, min: number, max: number): number;
  68467. /**
  68468. * Calculates the shortest difference between two given angles given in degrees.
  68469. * @param current current angle in degrees
  68470. * @param target target angle in degrees
  68471. * @returns the delta
  68472. */
  68473. static DeltaAngle(current: number, target: number): number;
  68474. /**
  68475. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68476. * @param tx value
  68477. * @param length length
  68478. * @returns The returned value will move back and forth between 0 and length
  68479. */
  68480. static PingPong(tx: number, length: number): number;
  68481. /**
  68482. * Interpolates between min and max with smoothing at the limits.
  68483. *
  68484. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68485. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68486. * @param from from
  68487. * @param to to
  68488. * @param tx value
  68489. * @returns the smooth stepped value
  68490. */
  68491. static SmoothStep(from: number, to: number, tx: number): number;
  68492. /**
  68493. * Moves a value current towards target.
  68494. *
  68495. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68496. * Negative values of maxDelta pushes the value away from target.
  68497. * @param current current value
  68498. * @param target target value
  68499. * @param maxDelta max distance to move
  68500. * @returns resulting value
  68501. */
  68502. static MoveTowards(current: number, target: number, maxDelta: number): number;
  68503. /**
  68504. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68505. *
  68506. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68507. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68508. * @param current current value
  68509. * @param target target value
  68510. * @param maxDelta max distance to move
  68511. * @returns resulting angle
  68512. */
  68513. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  68514. /**
  68515. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  68516. * @param start start value
  68517. * @param end target value
  68518. * @param amount amount to lerp between
  68519. * @returns the lerped value
  68520. */
  68521. static Lerp(start: number, end: number, amount: number): number;
  68522. /**
  68523. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68524. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  68525. * @param start start value
  68526. * @param end target value
  68527. * @param amount amount to lerp between
  68528. * @returns the lerped value
  68529. */
  68530. static LerpAngle(start: number, end: number, amount: number): number;
  68531. /**
  68532. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  68533. * @param a start value
  68534. * @param b target value
  68535. * @param value value between a and b
  68536. * @returns the inverseLerp value
  68537. */
  68538. static InverseLerp(a: number, b: number, value: number): number;
  68539. /**
  68540. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  68541. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  68542. * @param value1 spline value
  68543. * @param tangent1 spline value
  68544. * @param value2 spline value
  68545. * @param tangent2 spline value
  68546. * @param amount input value
  68547. * @returns hermite result
  68548. */
  68549. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  68550. /**
  68551. * Returns a random float number between and min and max values
  68552. * @param min min value of random
  68553. * @param max max value of random
  68554. * @returns random value
  68555. */
  68556. static RandomRange(min: number, max: number): number;
  68557. /**
  68558. * This function returns percentage of a number in a given range.
  68559. *
  68560. * RangeToPercent(40,20,60) will return 0.5 (50%)
  68561. * RangeToPercent(34,0,100) will return 0.34 (34%)
  68562. * @param number to convert to percentage
  68563. * @param min min range
  68564. * @param max max range
  68565. * @returns the percentage
  68566. */
  68567. static RangeToPercent(number: number, min: number, max: number): number;
  68568. /**
  68569. * This function returns number that corresponds to the percentage in a given range.
  68570. *
  68571. * PercentToRange(0.34,0,100) will return 34.
  68572. * @param percent to convert to number
  68573. * @param min min range
  68574. * @param max max range
  68575. * @returns the number
  68576. */
  68577. static PercentToRange(percent: number, min: number, max: number): number;
  68578. /**
  68579. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  68580. * @param angle The angle to normalize in radian.
  68581. * @return The converted angle.
  68582. */
  68583. static NormalizeRadians(angle: number): number;
  68584. }
  68585. }
  68586. declare module BABYLON {
  68587. /**
  68588. * Constant used to convert a value to gamma space
  68589. * @ignorenaming
  68590. */
  68591. export const ToGammaSpace: number;
  68592. /**
  68593. * Constant used to convert a value to linear space
  68594. * @ignorenaming
  68595. */
  68596. export const ToLinearSpace = 2.2;
  68597. /**
  68598. * Constant used to define the minimal number value in Babylon.js
  68599. * @ignorenaming
  68600. */
  68601. let Epsilon: number;
  68602. }
  68603. declare module BABYLON {
  68604. /**
  68605. * Class used to represent a viewport on screen
  68606. */
  68607. export class Viewport {
  68608. /** viewport left coordinate */
  68609. x: number;
  68610. /** viewport top coordinate */
  68611. y: number;
  68612. /**viewport width */
  68613. width: number;
  68614. /** viewport height */
  68615. height: number;
  68616. /**
  68617. * Creates a Viewport object located at (x, y) and sized (width, height)
  68618. * @param x defines viewport left coordinate
  68619. * @param y defines viewport top coordinate
  68620. * @param width defines the viewport width
  68621. * @param height defines the viewport height
  68622. */
  68623. constructor(
  68624. /** viewport left coordinate */
  68625. x: number,
  68626. /** viewport top coordinate */
  68627. y: number,
  68628. /**viewport width */
  68629. width: number,
  68630. /** viewport height */
  68631. height: number);
  68632. /**
  68633. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  68634. * @param renderWidth defines the rendering width
  68635. * @param renderHeight defines the rendering height
  68636. * @returns a new Viewport
  68637. */
  68638. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  68639. /**
  68640. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  68641. * @param renderWidth defines the rendering width
  68642. * @param renderHeight defines the rendering height
  68643. * @param ref defines the target viewport
  68644. * @returns the current viewport
  68645. */
  68646. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  68647. /**
  68648. * Returns a new Viewport copied from the current one
  68649. * @returns a new Viewport
  68650. */
  68651. clone(): Viewport;
  68652. }
  68653. }
  68654. declare module BABYLON {
  68655. /**
  68656. * Class containing a set of static utilities functions for arrays.
  68657. */
  68658. export class ArrayTools {
  68659. /**
  68660. * Returns an array of the given size filled with element built from the given constructor and the paramters
  68661. * @param size the number of element to construct and put in the array
  68662. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  68663. * @returns a new array filled with new objects
  68664. */
  68665. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  68666. }
  68667. }
  68668. declare module BABYLON {
  68669. /**
  68670. * Class representing a vector containing 2 coordinates
  68671. */
  68672. export class Vector2 {
  68673. /** defines the first coordinate */
  68674. x: number;
  68675. /** defines the second coordinate */
  68676. y: number;
  68677. /**
  68678. * Creates a new Vector2 from the given x and y coordinates
  68679. * @param x defines the first coordinate
  68680. * @param y defines the second coordinate
  68681. */
  68682. constructor(
  68683. /** defines the first coordinate */
  68684. x?: number,
  68685. /** defines the second coordinate */
  68686. y?: number);
  68687. /**
  68688. * Gets a string with the Vector2 coordinates
  68689. * @returns a string with the Vector2 coordinates
  68690. */
  68691. toString(): string;
  68692. /**
  68693. * Gets class name
  68694. * @returns the string "Vector2"
  68695. */
  68696. getClassName(): string;
  68697. /**
  68698. * Gets current vector hash code
  68699. * @returns the Vector2 hash code as a number
  68700. */
  68701. getHashCode(): number;
  68702. /**
  68703. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68704. * @param array defines the source array
  68705. * @param index defines the offset in source array
  68706. * @returns the current Vector2
  68707. */
  68708. toArray(array: FloatArray, index?: number): Vector2;
  68709. /**
  68710. * Copy the current vector to an array
  68711. * @returns a new array with 2 elements: the Vector2 coordinates.
  68712. */
  68713. asArray(): number[];
  68714. /**
  68715. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68716. * @param source defines the source Vector2
  68717. * @returns the current updated Vector2
  68718. */
  68719. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  68720. /**
  68721. * Sets the Vector2 coordinates with the given floats
  68722. * @param x defines the first coordinate
  68723. * @param y defines the second coordinate
  68724. * @returns the current updated Vector2
  68725. */
  68726. copyFromFloats(x: number, y: number): Vector2;
  68727. /**
  68728. * Sets the Vector2 coordinates with the given floats
  68729. * @param x defines the first coordinate
  68730. * @param y defines the second coordinate
  68731. * @returns the current updated Vector2
  68732. */
  68733. set(x: number, y: number): Vector2;
  68734. /**
  68735. * Add another vector with the current one
  68736. * @param otherVector defines the other vector
  68737. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68738. */
  68739. add(otherVector: DeepImmutable<Vector2>): Vector2;
  68740. /**
  68741. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68742. * @param otherVector defines the other vector
  68743. * @param result defines the target vector
  68744. * @returns the unmodified current Vector2
  68745. */
  68746. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68747. /**
  68748. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68749. * @param otherVector defines the other vector
  68750. * @returns the current updated Vector2
  68751. */
  68752. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68753. /**
  68754. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68755. * @param otherVector defines the other vector
  68756. * @returns a new Vector2
  68757. */
  68758. addVector3(otherVector: Vector3): Vector2;
  68759. /**
  68760. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68761. * @param otherVector defines the other vector
  68762. * @returns a new Vector2
  68763. */
  68764. subtract(otherVector: Vector2): Vector2;
  68765. /**
  68766. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68767. * @param otherVector defines the other vector
  68768. * @param result defines the target vector
  68769. * @returns the unmodified current Vector2
  68770. */
  68771. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68772. /**
  68773. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68774. * @param otherVector defines the other vector
  68775. * @returns the current updated Vector2
  68776. */
  68777. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68778. /**
  68779. * Multiplies in place the current Vector2 coordinates by the given ones
  68780. * @param otherVector defines the other vector
  68781. * @returns the current updated Vector2
  68782. */
  68783. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68784. /**
  68785. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68786. * @param otherVector defines the other vector
  68787. * @returns a new Vector2
  68788. */
  68789. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  68790. /**
  68791. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68792. * @param otherVector defines the other vector
  68793. * @param result defines the target vector
  68794. * @returns the unmodified current Vector2
  68795. */
  68796. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68797. /**
  68798. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68799. * @param x defines the first coordinate
  68800. * @param y defines the second coordinate
  68801. * @returns a new Vector2
  68802. */
  68803. multiplyByFloats(x: number, y: number): Vector2;
  68804. /**
  68805. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68806. * @param otherVector defines the other vector
  68807. * @returns a new Vector2
  68808. */
  68809. divide(otherVector: Vector2): Vector2;
  68810. /**
  68811. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68812. * @param otherVector defines the other vector
  68813. * @param result defines the target vector
  68814. * @returns the unmodified current Vector2
  68815. */
  68816. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68817. /**
  68818. * Divides the current Vector2 coordinates by the given ones
  68819. * @param otherVector defines the other vector
  68820. * @returns the current updated Vector2
  68821. */
  68822. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68823. /**
  68824. * Gets a new Vector2 with current Vector2 negated coordinates
  68825. * @returns a new Vector2
  68826. */
  68827. negate(): Vector2;
  68828. /**
  68829. * Multiply the Vector2 coordinates by scale
  68830. * @param scale defines the scaling factor
  68831. * @returns the current updated Vector2
  68832. */
  68833. scaleInPlace(scale: number): Vector2;
  68834. /**
  68835. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68836. * @param scale defines the scaling factor
  68837. * @returns a new Vector2
  68838. */
  68839. scale(scale: number): Vector2;
  68840. /**
  68841. * Scale the current Vector2 values by a factor to a given Vector2
  68842. * @param scale defines the scale factor
  68843. * @param result defines the Vector2 object where to store the result
  68844. * @returns the unmodified current Vector2
  68845. */
  68846. scaleToRef(scale: number, result: Vector2): Vector2;
  68847. /**
  68848. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68849. * @param scale defines the scale factor
  68850. * @param result defines the Vector2 object where to store the result
  68851. * @returns the unmodified current Vector2
  68852. */
  68853. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  68854. /**
  68855. * Gets a boolean if two vectors are equals
  68856. * @param otherVector defines the other vector
  68857. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68858. */
  68859. equals(otherVector: DeepImmutable<Vector2>): boolean;
  68860. /**
  68861. * Gets a boolean if two vectors are equals (using an epsilon value)
  68862. * @param otherVector defines the other vector
  68863. * @param epsilon defines the minimal distance to consider equality
  68864. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68865. */
  68866. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  68867. /**
  68868. * Gets a new Vector2 from current Vector2 floored values
  68869. * @returns a new Vector2
  68870. */
  68871. floor(): Vector2;
  68872. /**
  68873. * Gets a new Vector2 from current Vector2 floored values
  68874. * @returns a new Vector2
  68875. */
  68876. fract(): Vector2;
  68877. /**
  68878. * Gets the length of the vector
  68879. * @returns the vector length (float)
  68880. */
  68881. length(): number;
  68882. /**
  68883. * Gets the vector squared length
  68884. * @returns the vector squared length (float)
  68885. */
  68886. lengthSquared(): number;
  68887. /**
  68888. * Normalize the vector
  68889. * @returns the current updated Vector2
  68890. */
  68891. normalize(): Vector2;
  68892. /**
  68893. * Gets a new Vector2 copied from the Vector2
  68894. * @returns a new Vector2
  68895. */
  68896. clone(): Vector2;
  68897. /**
  68898. * Gets a new Vector2(0, 0)
  68899. * @returns a new Vector2
  68900. */
  68901. static Zero(): Vector2;
  68902. /**
  68903. * Gets a new Vector2(1, 1)
  68904. * @returns a new Vector2
  68905. */
  68906. static One(): Vector2;
  68907. /**
  68908. * Gets a new Vector2 set from the given index element of the given array
  68909. * @param array defines the data source
  68910. * @param offset defines the offset in the data source
  68911. * @returns a new Vector2
  68912. */
  68913. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  68914. /**
  68915. * Sets "result" from the given index element of the given array
  68916. * @param array defines the data source
  68917. * @param offset defines the offset in the data source
  68918. * @param result defines the target vector
  68919. */
  68920. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  68921. /**
  68922. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68923. * @param value1 defines 1st point of control
  68924. * @param value2 defines 2nd point of control
  68925. * @param value3 defines 3rd point of control
  68926. * @param value4 defines 4th point of control
  68927. * @param amount defines the interpolation factor
  68928. * @returns a new Vector2
  68929. */
  68930. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  68931. /**
  68932. * 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".
  68933. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68934. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68935. * @param value defines the value to clamp
  68936. * @param min defines the lower limit
  68937. * @param max defines the upper limit
  68938. * @returns a new Vector2
  68939. */
  68940. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  68941. /**
  68942. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68943. * @param value1 defines the 1st control point
  68944. * @param tangent1 defines the outgoing tangent
  68945. * @param value2 defines the 2nd control point
  68946. * @param tangent2 defines the incoming tangent
  68947. * @param amount defines the interpolation factor
  68948. * @returns a new Vector2
  68949. */
  68950. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  68951. /**
  68952. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68953. * @param start defines the start vector
  68954. * @param end defines the end vector
  68955. * @param amount defines the interpolation factor
  68956. * @returns a new Vector2
  68957. */
  68958. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  68959. /**
  68960. * Gets the dot product of the vector "left" and the vector "right"
  68961. * @param left defines first vector
  68962. * @param right defines second vector
  68963. * @returns the dot product (float)
  68964. */
  68965. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  68966. /**
  68967. * Returns a new Vector2 equal to the normalized given vector
  68968. * @param vector defines the vector to normalize
  68969. * @returns a new Vector2
  68970. */
  68971. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  68972. /**
  68973. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68974. * @param left defines 1st vector
  68975. * @param right defines 2nd vector
  68976. * @returns a new Vector2
  68977. */
  68978. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68979. /**
  68980. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68981. * @param left defines 1st vector
  68982. * @param right defines 2nd vector
  68983. * @returns a new Vector2
  68984. */
  68985. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68986. /**
  68987. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68988. * @param vector defines the vector to transform
  68989. * @param transformation defines the matrix to apply
  68990. * @returns a new Vector2
  68991. */
  68992. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  68993. /**
  68994. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  68995. * @param vector defines the vector to transform
  68996. * @param transformation defines the matrix to apply
  68997. * @param result defines the target vector
  68998. */
  68999. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69000. /**
  69001. * Determines if a given vector is included in a triangle
  69002. * @param p defines the vector to test
  69003. * @param p0 defines 1st triangle point
  69004. * @param p1 defines 2nd triangle point
  69005. * @param p2 defines 3rd triangle point
  69006. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69007. */
  69008. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69009. /**
  69010. * Gets the distance between the vectors "value1" and "value2"
  69011. * @param value1 defines first vector
  69012. * @param value2 defines second vector
  69013. * @returns the distance between vectors
  69014. */
  69015. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69016. /**
  69017. * Returns the squared distance between the vectors "value1" and "value2"
  69018. * @param value1 defines first vector
  69019. * @param value2 defines second vector
  69020. * @returns the squared distance between vectors
  69021. */
  69022. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69023. /**
  69024. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69025. * @param value1 defines first vector
  69026. * @param value2 defines second vector
  69027. * @returns a new Vector2
  69028. */
  69029. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69030. /**
  69031. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69032. * @param p defines the middle point
  69033. * @param segA defines one point of the segment
  69034. * @param segB defines the other point of the segment
  69035. * @returns the shortest distance
  69036. */
  69037. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69038. }
  69039. /**
  69040. * Classed used to store (x,y,z) vector representation
  69041. * A Vector3 is the main object used in 3D geometry
  69042. * It can represent etiher the coordinates of a point the space, either a direction
  69043. * Reminder: js uses a left handed forward facing system
  69044. */
  69045. export class Vector3 {
  69046. /**
  69047. * Defines the first coordinates (on X axis)
  69048. */
  69049. x: number;
  69050. /**
  69051. * Defines the second coordinates (on Y axis)
  69052. */
  69053. y: number;
  69054. /**
  69055. * Defines the third coordinates (on Z axis)
  69056. */
  69057. z: number;
  69058. private static _UpReadOnly;
  69059. private static _ZeroReadOnly;
  69060. /**
  69061. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69062. * @param x defines the first coordinates (on X axis)
  69063. * @param y defines the second coordinates (on Y axis)
  69064. * @param z defines the third coordinates (on Z axis)
  69065. */
  69066. constructor(
  69067. /**
  69068. * Defines the first coordinates (on X axis)
  69069. */
  69070. x?: number,
  69071. /**
  69072. * Defines the second coordinates (on Y axis)
  69073. */
  69074. y?: number,
  69075. /**
  69076. * Defines the third coordinates (on Z axis)
  69077. */
  69078. z?: number);
  69079. /**
  69080. * Creates a string representation of the Vector3
  69081. * @returns a string with the Vector3 coordinates.
  69082. */
  69083. toString(): string;
  69084. /**
  69085. * Gets the class name
  69086. * @returns the string "Vector3"
  69087. */
  69088. getClassName(): string;
  69089. /**
  69090. * Creates the Vector3 hash code
  69091. * @returns a number which tends to be unique between Vector3 instances
  69092. */
  69093. getHashCode(): number;
  69094. /**
  69095. * Creates an array containing three elements : the coordinates of the Vector3
  69096. * @returns a new array of numbers
  69097. */
  69098. asArray(): number[];
  69099. /**
  69100. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69101. * @param array defines the destination array
  69102. * @param index defines the offset in the destination array
  69103. * @returns the current Vector3
  69104. */
  69105. toArray(array: FloatArray, index?: number): Vector3;
  69106. /**
  69107. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69108. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69109. */
  69110. toQuaternion(): Quaternion;
  69111. /**
  69112. * Adds the given vector to the current Vector3
  69113. * @param otherVector defines the second operand
  69114. * @returns the current updated Vector3
  69115. */
  69116. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69117. /**
  69118. * Adds the given coordinates to the current Vector3
  69119. * @param x defines the x coordinate of the operand
  69120. * @param y defines the y coordinate of the operand
  69121. * @param z defines the z coordinate of the operand
  69122. * @returns the current updated Vector3
  69123. */
  69124. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69125. /**
  69126. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69127. * @param otherVector defines the second operand
  69128. * @returns the resulting Vector3
  69129. */
  69130. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69131. /**
  69132. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69133. * @param otherVector defines the second operand
  69134. * @param result defines the Vector3 object where to store the result
  69135. * @returns the current Vector3
  69136. */
  69137. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69138. /**
  69139. * Subtract the given vector from the current Vector3
  69140. * @param otherVector defines the second operand
  69141. * @returns the current updated Vector3
  69142. */
  69143. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69144. /**
  69145. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69146. * @param otherVector defines the second operand
  69147. * @returns the resulting Vector3
  69148. */
  69149. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69150. /**
  69151. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69152. * @param otherVector defines the second operand
  69153. * @param result defines the Vector3 object where to store the result
  69154. * @returns the current Vector3
  69155. */
  69156. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69157. /**
  69158. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69159. * @param x defines the x coordinate of the operand
  69160. * @param y defines the y coordinate of the operand
  69161. * @param z defines the z coordinate of the operand
  69162. * @returns the resulting Vector3
  69163. */
  69164. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69165. /**
  69166. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69167. * @param x defines the x coordinate of the operand
  69168. * @param y defines the y coordinate of the operand
  69169. * @param z defines the z coordinate of the operand
  69170. * @param result defines the Vector3 object where to store the result
  69171. * @returns the current Vector3
  69172. */
  69173. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69174. /**
  69175. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69176. * @returns a new Vector3
  69177. */
  69178. negate(): Vector3;
  69179. /**
  69180. * Multiplies the Vector3 coordinates by the float "scale"
  69181. * @param scale defines the multiplier factor
  69182. * @returns the current updated Vector3
  69183. */
  69184. scaleInPlace(scale: number): Vector3;
  69185. /**
  69186. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69187. * @param scale defines the multiplier factor
  69188. * @returns a new Vector3
  69189. */
  69190. scale(scale: number): Vector3;
  69191. /**
  69192. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69193. * @param scale defines the multiplier factor
  69194. * @param result defines the Vector3 object where to store the result
  69195. * @returns the current Vector3
  69196. */
  69197. scaleToRef(scale: number, result: Vector3): Vector3;
  69198. /**
  69199. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69200. * @param scale defines the scale factor
  69201. * @param result defines the Vector3 object where to store the result
  69202. * @returns the unmodified current Vector3
  69203. */
  69204. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69205. /**
  69206. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69207. * @param otherVector defines the second operand
  69208. * @returns true if both vectors are equals
  69209. */
  69210. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69211. /**
  69212. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69213. * @param otherVector defines the second operand
  69214. * @param epsilon defines the minimal distance to define values as equals
  69215. * @returns true if both vectors are distant less than epsilon
  69216. */
  69217. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69218. /**
  69219. * Returns true if the current Vector3 coordinates equals the given floats
  69220. * @param x defines the x coordinate of the operand
  69221. * @param y defines the y coordinate of the operand
  69222. * @param z defines the z coordinate of the operand
  69223. * @returns true if both vectors are equals
  69224. */
  69225. equalsToFloats(x: number, y: number, z: number): boolean;
  69226. /**
  69227. * Multiplies the current Vector3 coordinates by the given ones
  69228. * @param otherVector defines the second operand
  69229. * @returns the current updated Vector3
  69230. */
  69231. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69232. /**
  69233. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69234. * @param otherVector defines the second operand
  69235. * @returns the new Vector3
  69236. */
  69237. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69238. /**
  69239. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69240. * @param otherVector defines the second operand
  69241. * @param result defines the Vector3 object where to store the result
  69242. * @returns the current Vector3
  69243. */
  69244. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69245. /**
  69246. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69247. * @param x defines the x coordinate of the operand
  69248. * @param y defines the y coordinate of the operand
  69249. * @param z defines the z coordinate of the operand
  69250. * @returns the new Vector3
  69251. */
  69252. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69253. /**
  69254. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69255. * @param otherVector defines the second operand
  69256. * @returns the new Vector3
  69257. */
  69258. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69259. /**
  69260. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69261. * @param otherVector defines the second operand
  69262. * @param result defines the Vector3 object where to store the result
  69263. * @returns the current Vector3
  69264. */
  69265. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69266. /**
  69267. * Divides the current Vector3 coordinates by the given ones.
  69268. * @param otherVector defines the second operand
  69269. * @returns the current updated Vector3
  69270. */
  69271. divideInPlace(otherVector: Vector3): Vector3;
  69272. /**
  69273. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69274. * @param other defines the second operand
  69275. * @returns the current updated Vector3
  69276. */
  69277. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69278. /**
  69279. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69280. * @param other defines the second operand
  69281. * @returns the current updated Vector3
  69282. */
  69283. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69284. /**
  69285. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69286. * @param x defines the x coordinate of the operand
  69287. * @param y defines the y coordinate of the operand
  69288. * @param z defines the z coordinate of the operand
  69289. * @returns the current updated Vector3
  69290. */
  69291. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69292. /**
  69293. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69294. * @param x defines the x coordinate of the operand
  69295. * @param y defines the y coordinate of the operand
  69296. * @param z defines the z coordinate of the operand
  69297. * @returns the current updated Vector3
  69298. */
  69299. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69300. /**
  69301. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69302. * Check if is non uniform within a certain amount of decimal places to account for this
  69303. * @param epsilon the amount the values can differ
  69304. * @returns if the the vector is non uniform to a certain number of decimal places
  69305. */
  69306. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69307. /**
  69308. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69309. */
  69310. readonly isNonUniform: boolean;
  69311. /**
  69312. * Gets a new Vector3 from current Vector3 floored values
  69313. * @returns a new Vector3
  69314. */
  69315. floor(): Vector3;
  69316. /**
  69317. * Gets a new Vector3 from current Vector3 floored values
  69318. * @returns a new Vector3
  69319. */
  69320. fract(): Vector3;
  69321. /**
  69322. * Gets the length of the Vector3
  69323. * @returns the length of the Vector3
  69324. */
  69325. length(): number;
  69326. /**
  69327. * Gets the squared length of the Vector3
  69328. * @returns squared length of the Vector3
  69329. */
  69330. lengthSquared(): number;
  69331. /**
  69332. * Normalize the current Vector3.
  69333. * Please note that this is an in place operation.
  69334. * @returns the current updated Vector3
  69335. */
  69336. normalize(): Vector3;
  69337. /**
  69338. * Reorders the x y z properties of the vector in place
  69339. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69340. * @returns the current updated vector
  69341. */
  69342. reorderInPlace(order: string): this;
  69343. /**
  69344. * Rotates the vector around 0,0,0 by a quaternion
  69345. * @param quaternion the rotation quaternion
  69346. * @param result vector to store the result
  69347. * @returns the resulting vector
  69348. */
  69349. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69350. /**
  69351. * Rotates a vector around a given point
  69352. * @param quaternion the rotation quaternion
  69353. * @param point the point to rotate around
  69354. * @param result vector to store the result
  69355. * @returns the resulting vector
  69356. */
  69357. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69358. /**
  69359. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69360. * The cross product is then orthogonal to both current and "other"
  69361. * @param other defines the right operand
  69362. * @returns the cross product
  69363. */
  69364. cross(other: Vector3): Vector3;
  69365. /**
  69366. * Normalize the current Vector3 with the given input length.
  69367. * Please note that this is an in place operation.
  69368. * @param len the length of the vector
  69369. * @returns the current updated Vector3
  69370. */
  69371. normalizeFromLength(len: number): Vector3;
  69372. /**
  69373. * Normalize the current Vector3 to a new vector
  69374. * @returns the new Vector3
  69375. */
  69376. normalizeToNew(): Vector3;
  69377. /**
  69378. * Normalize the current Vector3 to the reference
  69379. * @param reference define the Vector3 to update
  69380. * @returns the updated Vector3
  69381. */
  69382. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  69383. /**
  69384. * Creates a new Vector3 copied from the current Vector3
  69385. * @returns the new Vector3
  69386. */
  69387. clone(): Vector3;
  69388. /**
  69389. * Copies the given vector coordinates to the current Vector3 ones
  69390. * @param source defines the source Vector3
  69391. * @returns the current updated Vector3
  69392. */
  69393. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  69394. /**
  69395. * Copies the given floats to the current Vector3 coordinates
  69396. * @param x defines the x coordinate of the operand
  69397. * @param y defines the y coordinate of the operand
  69398. * @param z defines the z coordinate of the operand
  69399. * @returns the current updated Vector3
  69400. */
  69401. copyFromFloats(x: number, y: number, z: number): Vector3;
  69402. /**
  69403. * Copies the given floats to the current Vector3 coordinates
  69404. * @param x defines the x coordinate of the operand
  69405. * @param y defines the y coordinate of the operand
  69406. * @param z defines the z coordinate of the operand
  69407. * @returns the current updated Vector3
  69408. */
  69409. set(x: number, y: number, z: number): Vector3;
  69410. /**
  69411. * Copies the given float to the current Vector3 coordinates
  69412. * @param v defines the x, y and z coordinates of the operand
  69413. * @returns the current updated Vector3
  69414. */
  69415. setAll(v: number): Vector3;
  69416. /**
  69417. * Get the clip factor between two vectors
  69418. * @param vector0 defines the first operand
  69419. * @param vector1 defines the second operand
  69420. * @param axis defines the axis to use
  69421. * @param size defines the size along the axis
  69422. * @returns the clip factor
  69423. */
  69424. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  69425. /**
  69426. * Get angle between two vectors
  69427. * @param vector0 angle between vector0 and vector1
  69428. * @param vector1 angle between vector0 and vector1
  69429. * @param normal direction of the normal
  69430. * @return the angle between vector0 and vector1
  69431. */
  69432. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  69433. /**
  69434. * Returns a new Vector3 set from the index "offset" of the given array
  69435. * @param array defines the source array
  69436. * @param offset defines the offset in the source array
  69437. * @returns the new Vector3
  69438. */
  69439. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  69440. /**
  69441. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69442. * This function is deprecated. Use FromArray instead
  69443. * @param array defines the source array
  69444. * @param offset defines the offset in the source array
  69445. * @returns the new Vector3
  69446. */
  69447. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  69448. /**
  69449. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69450. * @param array defines the source array
  69451. * @param offset defines the offset in the source array
  69452. * @param result defines the Vector3 where to store the result
  69453. */
  69454. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  69455. /**
  69456. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69457. * This function is deprecated. Use FromArrayToRef instead.
  69458. * @param array defines the source array
  69459. * @param offset defines the offset in the source array
  69460. * @param result defines the Vector3 where to store the result
  69461. */
  69462. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  69463. /**
  69464. * Sets the given vector "result" with the given floats.
  69465. * @param x defines the x coordinate of the source
  69466. * @param y defines the y coordinate of the source
  69467. * @param z defines the z coordinate of the source
  69468. * @param result defines the Vector3 where to store the result
  69469. */
  69470. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  69471. /**
  69472. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69473. * @returns a new empty Vector3
  69474. */
  69475. static Zero(): Vector3;
  69476. /**
  69477. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69478. * @returns a new unit Vector3
  69479. */
  69480. static One(): Vector3;
  69481. /**
  69482. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69483. * @returns a new up Vector3
  69484. */
  69485. static Up(): Vector3;
  69486. /**
  69487. * Gets a up Vector3 that must not be updated
  69488. */
  69489. static readonly UpReadOnly: DeepImmutable<Vector3>;
  69490. /**
  69491. * Gets a zero Vector3 that must not be updated
  69492. */
  69493. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  69494. /**
  69495. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69496. * @returns a new down Vector3
  69497. */
  69498. static Down(): Vector3;
  69499. /**
  69500. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69501. * @returns a new forward Vector3
  69502. */
  69503. static Forward(): Vector3;
  69504. /**
  69505. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69506. * @returns a new forward Vector3
  69507. */
  69508. static Backward(): Vector3;
  69509. /**
  69510. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69511. * @returns a new right Vector3
  69512. */
  69513. static Right(): Vector3;
  69514. /**
  69515. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69516. * @returns a new left Vector3
  69517. */
  69518. static Left(): Vector3;
  69519. /**
  69520. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69521. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69522. * @param vector defines the Vector3 to transform
  69523. * @param transformation defines the transformation matrix
  69524. * @returns the transformed Vector3
  69525. */
  69526. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69527. /**
  69528. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69529. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69530. * @param vector defines the Vector3 to transform
  69531. * @param transformation defines the transformation matrix
  69532. * @param result defines the Vector3 where to store the result
  69533. */
  69534. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69535. /**
  69536. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69537. * This method computes tranformed coordinates only, not transformed direction vectors
  69538. * @param x define the x coordinate of the source vector
  69539. * @param y define the y coordinate of the source vector
  69540. * @param z define the z coordinate of the source vector
  69541. * @param transformation defines the transformation matrix
  69542. * @param result defines the Vector3 where to store the result
  69543. */
  69544. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69545. /**
  69546. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69547. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69548. * @param vector defines the Vector3 to transform
  69549. * @param transformation defines the transformation matrix
  69550. * @returns the new Vector3
  69551. */
  69552. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69553. /**
  69554. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69555. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69556. * @param vector defines the Vector3 to transform
  69557. * @param transformation defines the transformation matrix
  69558. * @param result defines the Vector3 where to store the result
  69559. */
  69560. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69561. /**
  69562. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69563. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69564. * @param x define the x coordinate of the source vector
  69565. * @param y define the y coordinate of the source vector
  69566. * @param z define the z coordinate of the source vector
  69567. * @param transformation defines the transformation matrix
  69568. * @param result defines the Vector3 where to store the result
  69569. */
  69570. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69571. /**
  69572. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69573. * @param value1 defines the first control point
  69574. * @param value2 defines the second control point
  69575. * @param value3 defines the third control point
  69576. * @param value4 defines the fourth control point
  69577. * @param amount defines the amount on the spline to use
  69578. * @returns the new Vector3
  69579. */
  69580. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  69581. /**
  69582. * 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"
  69583. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69584. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69585. * @param value defines the current value
  69586. * @param min defines the lower range value
  69587. * @param max defines the upper range value
  69588. * @returns the new Vector3
  69589. */
  69590. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  69591. /**
  69592. * 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"
  69593. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69594. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69595. * @param value defines the current value
  69596. * @param min defines the lower range value
  69597. * @param max defines the upper range value
  69598. * @param result defines the Vector3 where to store the result
  69599. */
  69600. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  69601. /**
  69602. * Checks if a given vector is inside a specific range
  69603. * @param v defines the vector to test
  69604. * @param min defines the minimum range
  69605. * @param max defines the maximum range
  69606. */
  69607. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  69608. /**
  69609. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69610. * @param value1 defines the first control point
  69611. * @param tangent1 defines the first tangent vector
  69612. * @param value2 defines the second control point
  69613. * @param tangent2 defines the second tangent vector
  69614. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69615. * @returns the new Vector3
  69616. */
  69617. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  69618. /**
  69619. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69620. * @param start defines the start value
  69621. * @param end defines the end value
  69622. * @param amount max defines amount between both (between 0 and 1)
  69623. * @returns the new Vector3
  69624. */
  69625. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  69626. /**
  69627. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69628. * @param start defines the start value
  69629. * @param end defines the end value
  69630. * @param amount max defines amount between both (between 0 and 1)
  69631. * @param result defines the Vector3 where to store the result
  69632. */
  69633. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  69634. /**
  69635. * Returns the dot product (float) between the vectors "left" and "right"
  69636. * @param left defines the left operand
  69637. * @param right defines the right operand
  69638. * @returns the dot product
  69639. */
  69640. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  69641. /**
  69642. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69643. * The cross product is then orthogonal to both "left" and "right"
  69644. * @param left defines the left operand
  69645. * @param right defines the right operand
  69646. * @returns the cross product
  69647. */
  69648. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69649. /**
  69650. * Sets the given vector "result" with the cross product of "left" and "right"
  69651. * The cross product is then orthogonal to both "left" and "right"
  69652. * @param left defines the left operand
  69653. * @param right defines the right operand
  69654. * @param result defines the Vector3 where to store the result
  69655. */
  69656. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  69657. /**
  69658. * Returns a new Vector3 as the normalization of the given vector
  69659. * @param vector defines the Vector3 to normalize
  69660. * @returns the new Vector3
  69661. */
  69662. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  69663. /**
  69664. * Sets the given vector "result" with the normalization of the given first vector
  69665. * @param vector defines the Vector3 to normalize
  69666. * @param result defines the Vector3 where to store the result
  69667. */
  69668. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  69669. /**
  69670. * Project a Vector3 onto screen space
  69671. * @param vector defines the Vector3 to project
  69672. * @param world defines the world matrix to use
  69673. * @param transform defines the transform (view x projection) matrix to use
  69674. * @param viewport defines the screen viewport to use
  69675. * @returns the new Vector3
  69676. */
  69677. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  69678. /** @hidden */
  69679. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  69680. /**
  69681. * Unproject from screen space to object space
  69682. * @param source defines the screen space Vector3 to use
  69683. * @param viewportWidth defines the current width of the viewport
  69684. * @param viewportHeight defines the current height of the viewport
  69685. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69686. * @param transform defines the transform (view x projection) matrix to use
  69687. * @returns the new Vector3
  69688. */
  69689. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  69690. /**
  69691. * Unproject from screen space to object space
  69692. * @param source defines the screen space Vector3 to use
  69693. * @param viewportWidth defines the current width of the viewport
  69694. * @param viewportHeight defines the current height of the viewport
  69695. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69696. * @param view defines the view matrix to use
  69697. * @param projection defines the projection matrix to use
  69698. * @returns the new Vector3
  69699. */
  69700. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  69701. /**
  69702. * Unproject from screen space to object space
  69703. * @param source defines the screen space Vector3 to use
  69704. * @param viewportWidth defines the current width of the viewport
  69705. * @param viewportHeight defines the current height of the viewport
  69706. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69707. * @param view defines the view matrix to use
  69708. * @param projection defines the projection matrix to use
  69709. * @param result defines the Vector3 where to store the result
  69710. */
  69711. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69712. /**
  69713. * Unproject from screen space to object space
  69714. * @param sourceX defines the screen space x coordinate to use
  69715. * @param sourceY defines the screen space y coordinate to use
  69716. * @param sourceZ defines the screen space z coordinate to use
  69717. * @param viewportWidth defines the current width of the viewport
  69718. * @param viewportHeight defines the current height of the viewport
  69719. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69720. * @param view defines the view matrix to use
  69721. * @param projection defines the projection matrix to use
  69722. * @param result defines the Vector3 where to store the result
  69723. */
  69724. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69725. /**
  69726. * Gets the minimal coordinate values between two Vector3
  69727. * @param left defines the first operand
  69728. * @param right defines the second operand
  69729. * @returns the new Vector3
  69730. */
  69731. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69732. /**
  69733. * Gets the maximal coordinate values between two Vector3
  69734. * @param left defines the first operand
  69735. * @param right defines the second operand
  69736. * @returns the new Vector3
  69737. */
  69738. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69739. /**
  69740. * Returns the distance between the vectors "value1" and "value2"
  69741. * @param value1 defines the first operand
  69742. * @param value2 defines the second operand
  69743. * @returns the distance
  69744. */
  69745. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69746. /**
  69747. * Returns the squared distance between the vectors "value1" and "value2"
  69748. * @param value1 defines the first operand
  69749. * @param value2 defines the second operand
  69750. * @returns the squared distance
  69751. */
  69752. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69753. /**
  69754. * Returns a new Vector3 located at the center between "value1" and "value2"
  69755. * @param value1 defines the first operand
  69756. * @param value2 defines the second operand
  69757. * @returns the new Vector3
  69758. */
  69759. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  69760. /**
  69761. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  69762. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  69763. * to something in order to rotate it from its local system to the given target system
  69764. * Note: axis1, axis2 and axis3 are normalized during this operation
  69765. * @param axis1 defines the first axis
  69766. * @param axis2 defines the second axis
  69767. * @param axis3 defines the third axis
  69768. * @returns a new Vector3
  69769. */
  69770. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  69771. /**
  69772. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  69773. * @param axis1 defines the first axis
  69774. * @param axis2 defines the second axis
  69775. * @param axis3 defines the third axis
  69776. * @param ref defines the Vector3 where to store the result
  69777. */
  69778. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  69779. }
  69780. /**
  69781. * Vector4 class created for EulerAngle class conversion to Quaternion
  69782. */
  69783. export class Vector4 {
  69784. /** x value of the vector */
  69785. x: number;
  69786. /** y value of the vector */
  69787. y: number;
  69788. /** z value of the vector */
  69789. z: number;
  69790. /** w value of the vector */
  69791. w: number;
  69792. /**
  69793. * Creates a Vector4 object from the given floats.
  69794. * @param x x value of the vector
  69795. * @param y y value of the vector
  69796. * @param z z value of the vector
  69797. * @param w w value of the vector
  69798. */
  69799. constructor(
  69800. /** x value of the vector */
  69801. x: number,
  69802. /** y value of the vector */
  69803. y: number,
  69804. /** z value of the vector */
  69805. z: number,
  69806. /** w value of the vector */
  69807. w: number);
  69808. /**
  69809. * Returns the string with the Vector4 coordinates.
  69810. * @returns a string containing all the vector values
  69811. */
  69812. toString(): string;
  69813. /**
  69814. * Returns the string "Vector4".
  69815. * @returns "Vector4"
  69816. */
  69817. getClassName(): string;
  69818. /**
  69819. * Returns the Vector4 hash code.
  69820. * @returns a unique hash code
  69821. */
  69822. getHashCode(): number;
  69823. /**
  69824. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  69825. * @returns the resulting array
  69826. */
  69827. asArray(): number[];
  69828. /**
  69829. * Populates the given array from the given index with the Vector4 coordinates.
  69830. * @param array array to populate
  69831. * @param index index of the array to start at (default: 0)
  69832. * @returns the Vector4.
  69833. */
  69834. toArray(array: FloatArray, index?: number): Vector4;
  69835. /**
  69836. * Adds the given vector to the current Vector4.
  69837. * @param otherVector the vector to add
  69838. * @returns the updated Vector4.
  69839. */
  69840. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69841. /**
  69842. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  69843. * @param otherVector the vector to add
  69844. * @returns the resulting vector
  69845. */
  69846. add(otherVector: DeepImmutable<Vector4>): Vector4;
  69847. /**
  69848. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  69849. * @param otherVector the vector to add
  69850. * @param result the vector to store the result
  69851. * @returns the current Vector4.
  69852. */
  69853. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69854. /**
  69855. * Subtract in place the given vector from the current Vector4.
  69856. * @param otherVector the vector to subtract
  69857. * @returns the updated Vector4.
  69858. */
  69859. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69860. /**
  69861. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  69862. * @param otherVector the vector to add
  69863. * @returns the new vector with the result
  69864. */
  69865. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  69866. /**
  69867. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  69868. * @param otherVector the vector to subtract
  69869. * @param result the vector to store the result
  69870. * @returns the current Vector4.
  69871. */
  69872. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69873. /**
  69874. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69875. */
  69876. /**
  69877. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69878. * @param x value to subtract
  69879. * @param y value to subtract
  69880. * @param z value to subtract
  69881. * @param w value to subtract
  69882. * @returns new vector containing the result
  69883. */
  69884. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  69885. /**
  69886. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69887. * @param x value to subtract
  69888. * @param y value to subtract
  69889. * @param z value to subtract
  69890. * @param w value to subtract
  69891. * @param result the vector to store the result in
  69892. * @returns the current Vector4.
  69893. */
  69894. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  69895. /**
  69896. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  69897. * @returns a new vector with the negated values
  69898. */
  69899. negate(): Vector4;
  69900. /**
  69901. * Multiplies the current Vector4 coordinates by scale (float).
  69902. * @param scale the number to scale with
  69903. * @returns the updated Vector4.
  69904. */
  69905. scaleInPlace(scale: number): Vector4;
  69906. /**
  69907. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  69908. * @param scale the number to scale with
  69909. * @returns a new vector with the result
  69910. */
  69911. scale(scale: number): Vector4;
  69912. /**
  69913. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  69914. * @param scale the number to scale with
  69915. * @param result a vector to store the result in
  69916. * @returns the current Vector4.
  69917. */
  69918. scaleToRef(scale: number, result: Vector4): Vector4;
  69919. /**
  69920. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  69921. * @param scale defines the scale factor
  69922. * @param result defines the Vector4 object where to store the result
  69923. * @returns the unmodified current Vector4
  69924. */
  69925. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  69926. /**
  69927. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  69928. * @param otherVector the vector to compare against
  69929. * @returns true if they are equal
  69930. */
  69931. equals(otherVector: DeepImmutable<Vector4>): boolean;
  69932. /**
  69933. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  69934. * @param otherVector vector to compare against
  69935. * @param epsilon (Default: very small number)
  69936. * @returns true if they are equal
  69937. */
  69938. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  69939. /**
  69940. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  69941. * @param x x value to compare against
  69942. * @param y y value to compare against
  69943. * @param z z value to compare against
  69944. * @param w w value to compare against
  69945. * @returns true if equal
  69946. */
  69947. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  69948. /**
  69949. * Multiplies in place the current Vector4 by the given one.
  69950. * @param otherVector vector to multiple with
  69951. * @returns the updated Vector4.
  69952. */
  69953. multiplyInPlace(otherVector: Vector4): Vector4;
  69954. /**
  69955. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  69956. * @param otherVector vector to multiple with
  69957. * @returns resulting new vector
  69958. */
  69959. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  69960. /**
  69961. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  69962. * @param otherVector vector to multiple with
  69963. * @param result vector to store the result
  69964. * @returns the current Vector4.
  69965. */
  69966. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69967. /**
  69968. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  69969. * @param x x value multiply with
  69970. * @param y y value multiply with
  69971. * @param z z value multiply with
  69972. * @param w w value multiply with
  69973. * @returns resulting new vector
  69974. */
  69975. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  69976. /**
  69977. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  69978. * @param otherVector vector to devide with
  69979. * @returns resulting new vector
  69980. */
  69981. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  69982. /**
  69983. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  69984. * @param otherVector vector to devide with
  69985. * @param result vector to store the result
  69986. * @returns the current Vector4.
  69987. */
  69988. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69989. /**
  69990. * Divides the current Vector3 coordinates by the given ones.
  69991. * @param otherVector vector to devide with
  69992. * @returns the updated Vector3.
  69993. */
  69994. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69995. /**
  69996. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  69997. * @param other defines the second operand
  69998. * @returns the current updated Vector4
  69999. */
  70000. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70001. /**
  70002. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70003. * @param other defines the second operand
  70004. * @returns the current updated Vector4
  70005. */
  70006. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70007. /**
  70008. * Gets a new Vector4 from current Vector4 floored values
  70009. * @returns a new Vector4
  70010. */
  70011. floor(): Vector4;
  70012. /**
  70013. * Gets a new Vector4 from current Vector3 floored values
  70014. * @returns a new Vector4
  70015. */
  70016. fract(): Vector4;
  70017. /**
  70018. * Returns the Vector4 length (float).
  70019. * @returns the length
  70020. */
  70021. length(): number;
  70022. /**
  70023. * Returns the Vector4 squared length (float).
  70024. * @returns the length squared
  70025. */
  70026. lengthSquared(): number;
  70027. /**
  70028. * Normalizes in place the Vector4.
  70029. * @returns the updated Vector4.
  70030. */
  70031. normalize(): Vector4;
  70032. /**
  70033. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70034. * @returns this converted to a new vector3
  70035. */
  70036. toVector3(): Vector3;
  70037. /**
  70038. * Returns a new Vector4 copied from the current one.
  70039. * @returns the new cloned vector
  70040. */
  70041. clone(): Vector4;
  70042. /**
  70043. * Updates the current Vector4 with the given one coordinates.
  70044. * @param source the source vector to copy from
  70045. * @returns the updated Vector4.
  70046. */
  70047. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70048. /**
  70049. * Updates the current Vector4 coordinates with the given floats.
  70050. * @param x float to copy from
  70051. * @param y float to copy from
  70052. * @param z float to copy from
  70053. * @param w float to copy from
  70054. * @returns the updated Vector4.
  70055. */
  70056. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70057. /**
  70058. * Updates the current Vector4 coordinates with the given floats.
  70059. * @param x float to set from
  70060. * @param y float to set from
  70061. * @param z float to set from
  70062. * @param w float to set from
  70063. * @returns the updated Vector4.
  70064. */
  70065. set(x: number, y: number, z: number, w: number): Vector4;
  70066. /**
  70067. * Copies the given float to the current Vector3 coordinates
  70068. * @param v defines the x, y, z and w coordinates of the operand
  70069. * @returns the current updated Vector3
  70070. */
  70071. setAll(v: number): Vector4;
  70072. /**
  70073. * Returns a new Vector4 set from the starting index of the given array.
  70074. * @param array the array to pull values from
  70075. * @param offset the offset into the array to start at
  70076. * @returns the new vector
  70077. */
  70078. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70079. /**
  70080. * Updates the given vector "result" from the starting index of the given array.
  70081. * @param array the array to pull values from
  70082. * @param offset the offset into the array to start at
  70083. * @param result the vector to store the result in
  70084. */
  70085. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70086. /**
  70087. * Updates the given vector "result" from the starting index of the given Float32Array.
  70088. * @param array the array to pull values from
  70089. * @param offset the offset into the array to start at
  70090. * @param result the vector to store the result in
  70091. */
  70092. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70093. /**
  70094. * Updates the given vector "result" coordinates from the given floats.
  70095. * @param x float to set from
  70096. * @param y float to set from
  70097. * @param z float to set from
  70098. * @param w float to set from
  70099. * @param result the vector to the floats in
  70100. */
  70101. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70102. /**
  70103. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70104. * @returns the new vector
  70105. */
  70106. static Zero(): Vector4;
  70107. /**
  70108. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70109. * @returns the new vector
  70110. */
  70111. static One(): Vector4;
  70112. /**
  70113. * Returns a new normalized Vector4 from the given one.
  70114. * @param vector the vector to normalize
  70115. * @returns the vector
  70116. */
  70117. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70118. /**
  70119. * Updates the given vector "result" from the normalization of the given one.
  70120. * @param vector the vector to normalize
  70121. * @param result the vector to store the result in
  70122. */
  70123. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70124. /**
  70125. * Returns a vector with the minimum values from the left and right vectors
  70126. * @param left left vector to minimize
  70127. * @param right right vector to minimize
  70128. * @returns a new vector with the minimum of the left and right vector values
  70129. */
  70130. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70131. /**
  70132. * Returns a vector with the maximum values from the left and right vectors
  70133. * @param left left vector to maximize
  70134. * @param right right vector to maximize
  70135. * @returns a new vector with the maximum of the left and right vector values
  70136. */
  70137. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70138. /**
  70139. * Returns the distance (float) between the vectors "value1" and "value2".
  70140. * @param value1 value to calulate the distance between
  70141. * @param value2 value to calulate the distance between
  70142. * @return the distance between the two vectors
  70143. */
  70144. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70145. /**
  70146. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70147. * @param value1 value to calulate the distance between
  70148. * @param value2 value to calulate the distance between
  70149. * @return the distance between the two vectors squared
  70150. */
  70151. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70152. /**
  70153. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70154. * @param value1 value to calulate the center between
  70155. * @param value2 value to calulate the center between
  70156. * @return the center between the two vectors
  70157. */
  70158. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70159. /**
  70160. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70161. * This methods computes transformed normalized direction vectors only.
  70162. * @param vector the vector to transform
  70163. * @param transformation the transformation matrix to apply
  70164. * @returns the new vector
  70165. */
  70166. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70167. /**
  70168. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70169. * This methods computes transformed normalized direction vectors only.
  70170. * @param vector the vector to transform
  70171. * @param transformation the transformation matrix to apply
  70172. * @param result the vector to store the result in
  70173. */
  70174. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70175. /**
  70176. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70177. * This methods computes transformed normalized direction vectors only.
  70178. * @param x value to transform
  70179. * @param y value to transform
  70180. * @param z value to transform
  70181. * @param w value to transform
  70182. * @param transformation the transformation matrix to apply
  70183. * @param result the vector to store the results in
  70184. */
  70185. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70186. /**
  70187. * Creates a new Vector4 from a Vector3
  70188. * @param source defines the source data
  70189. * @param w defines the 4th component (default is 0)
  70190. * @returns a new Vector4
  70191. */
  70192. static FromVector3(source: Vector3, w?: number): Vector4;
  70193. }
  70194. /**
  70195. * Class used to store quaternion data
  70196. * @see https://en.wikipedia.org/wiki/Quaternion
  70197. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70198. */
  70199. export class Quaternion {
  70200. /** defines the first component (0 by default) */
  70201. x: number;
  70202. /** defines the second component (0 by default) */
  70203. y: number;
  70204. /** defines the third component (0 by default) */
  70205. z: number;
  70206. /** defines the fourth component (1.0 by default) */
  70207. w: number;
  70208. /**
  70209. * Creates a new Quaternion from the given floats
  70210. * @param x defines the first component (0 by default)
  70211. * @param y defines the second component (0 by default)
  70212. * @param z defines the third component (0 by default)
  70213. * @param w defines the fourth component (1.0 by default)
  70214. */
  70215. constructor(
  70216. /** defines the first component (0 by default) */
  70217. x?: number,
  70218. /** defines the second component (0 by default) */
  70219. y?: number,
  70220. /** defines the third component (0 by default) */
  70221. z?: number,
  70222. /** defines the fourth component (1.0 by default) */
  70223. w?: number);
  70224. /**
  70225. * Gets a string representation for the current quaternion
  70226. * @returns a string with the Quaternion coordinates
  70227. */
  70228. toString(): string;
  70229. /**
  70230. * Gets the class name of the quaternion
  70231. * @returns the string "Quaternion"
  70232. */
  70233. getClassName(): string;
  70234. /**
  70235. * Gets a hash code for this quaternion
  70236. * @returns the quaternion hash code
  70237. */
  70238. getHashCode(): number;
  70239. /**
  70240. * Copy the quaternion to an array
  70241. * @returns a new array populated with 4 elements from the quaternion coordinates
  70242. */
  70243. asArray(): number[];
  70244. /**
  70245. * Check if two quaternions are equals
  70246. * @param otherQuaternion defines the second operand
  70247. * @return true if the current quaternion and the given one coordinates are strictly equals
  70248. */
  70249. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70250. /**
  70251. * Clone the current quaternion
  70252. * @returns a new quaternion copied from the current one
  70253. */
  70254. clone(): Quaternion;
  70255. /**
  70256. * Copy a quaternion to the current one
  70257. * @param other defines the other quaternion
  70258. * @returns the updated current quaternion
  70259. */
  70260. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70261. /**
  70262. * Updates the current quaternion with the given float coordinates
  70263. * @param x defines the x coordinate
  70264. * @param y defines the y coordinate
  70265. * @param z defines the z coordinate
  70266. * @param w defines the w coordinate
  70267. * @returns the updated current quaternion
  70268. */
  70269. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70270. /**
  70271. * Updates the current quaternion from the given float coordinates
  70272. * @param x defines the x coordinate
  70273. * @param y defines the y coordinate
  70274. * @param z defines the z coordinate
  70275. * @param w defines the w coordinate
  70276. * @returns the updated current quaternion
  70277. */
  70278. set(x: number, y: number, z: number, w: number): Quaternion;
  70279. /**
  70280. * Adds two quaternions
  70281. * @param other defines the second operand
  70282. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70283. */
  70284. add(other: DeepImmutable<Quaternion>): Quaternion;
  70285. /**
  70286. * Add a quaternion to the current one
  70287. * @param other defines the quaternion to add
  70288. * @returns the current quaternion
  70289. */
  70290. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70291. /**
  70292. * Subtract two quaternions
  70293. * @param other defines the second operand
  70294. * @returns a new quaternion as the subtraction result of the given one from the current one
  70295. */
  70296. subtract(other: Quaternion): Quaternion;
  70297. /**
  70298. * Multiplies the current quaternion by a scale factor
  70299. * @param value defines the scale factor
  70300. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70301. */
  70302. scale(value: number): Quaternion;
  70303. /**
  70304. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70305. * @param scale defines the scale factor
  70306. * @param result defines the Quaternion object where to store the result
  70307. * @returns the unmodified current quaternion
  70308. */
  70309. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70310. /**
  70311. * Multiplies in place the current quaternion by a scale factor
  70312. * @param value defines the scale factor
  70313. * @returns the current modified quaternion
  70314. */
  70315. scaleInPlace(value: number): Quaternion;
  70316. /**
  70317. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70318. * @param scale defines the scale factor
  70319. * @param result defines the Quaternion object where to store the result
  70320. * @returns the unmodified current quaternion
  70321. */
  70322. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70323. /**
  70324. * Multiplies two quaternions
  70325. * @param q1 defines the second operand
  70326. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70327. */
  70328. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70329. /**
  70330. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70331. * @param q1 defines the second operand
  70332. * @param result defines the target quaternion
  70333. * @returns the current quaternion
  70334. */
  70335. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70336. /**
  70337. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70338. * @param q1 defines the second operand
  70339. * @returns the currentupdated quaternion
  70340. */
  70341. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70342. /**
  70343. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70344. * @param ref defines the target quaternion
  70345. * @returns the current quaternion
  70346. */
  70347. conjugateToRef(ref: Quaternion): Quaternion;
  70348. /**
  70349. * Conjugates in place (1-q) the current quaternion
  70350. * @returns the current updated quaternion
  70351. */
  70352. conjugateInPlace(): Quaternion;
  70353. /**
  70354. * Conjugates in place (1-q) the current quaternion
  70355. * @returns a new quaternion
  70356. */
  70357. conjugate(): Quaternion;
  70358. /**
  70359. * Gets length of current quaternion
  70360. * @returns the quaternion length (float)
  70361. */
  70362. length(): number;
  70363. /**
  70364. * Normalize in place the current quaternion
  70365. * @returns the current updated quaternion
  70366. */
  70367. normalize(): Quaternion;
  70368. /**
  70369. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70370. * @param order is a reserved parameter and is ignore for now
  70371. * @returns a new Vector3 containing the Euler angles
  70372. */
  70373. toEulerAngles(order?: string): Vector3;
  70374. /**
  70375. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70376. * @param result defines the vector which will be filled with the Euler angles
  70377. * @param order is a reserved parameter and is ignore for now
  70378. * @returns the current unchanged quaternion
  70379. */
  70380. toEulerAnglesToRef(result: Vector3): Quaternion;
  70381. /**
  70382. * Updates the given rotation matrix with the current quaternion values
  70383. * @param result defines the target matrix
  70384. * @returns the current unchanged quaternion
  70385. */
  70386. toRotationMatrix(result: Matrix): Quaternion;
  70387. /**
  70388. * Updates the current quaternion from the given rotation matrix values
  70389. * @param matrix defines the source matrix
  70390. * @returns the current updated quaternion
  70391. */
  70392. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70393. /**
  70394. * Creates a new quaternion from a rotation matrix
  70395. * @param matrix defines the source matrix
  70396. * @returns a new quaternion created from the given rotation matrix values
  70397. */
  70398. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70399. /**
  70400. * Updates the given quaternion with the given rotation matrix values
  70401. * @param matrix defines the source matrix
  70402. * @param result defines the target quaternion
  70403. */
  70404. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  70405. /**
  70406. * Returns the dot product (float) between the quaternions "left" and "right"
  70407. * @param left defines the left operand
  70408. * @param right defines the right operand
  70409. * @returns the dot product
  70410. */
  70411. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  70412. /**
  70413. * Checks if the two quaternions are close to each other
  70414. * @param quat0 defines the first quaternion to check
  70415. * @param quat1 defines the second quaternion to check
  70416. * @returns true if the two quaternions are close to each other
  70417. */
  70418. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  70419. /**
  70420. * Creates an empty quaternion
  70421. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70422. */
  70423. static Zero(): Quaternion;
  70424. /**
  70425. * Inverse a given quaternion
  70426. * @param q defines the source quaternion
  70427. * @returns a new quaternion as the inverted current quaternion
  70428. */
  70429. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  70430. /**
  70431. * Inverse a given quaternion
  70432. * @param q defines the source quaternion
  70433. * @param result the quaternion the result will be stored in
  70434. * @returns the result quaternion
  70435. */
  70436. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  70437. /**
  70438. * Creates an identity quaternion
  70439. * @returns the identity quaternion
  70440. */
  70441. static Identity(): Quaternion;
  70442. /**
  70443. * Gets a boolean indicating if the given quaternion is identity
  70444. * @param quaternion defines the quaternion to check
  70445. * @returns true if the quaternion is identity
  70446. */
  70447. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  70448. /**
  70449. * Creates a quaternion from a rotation around an axis
  70450. * @param axis defines the axis to use
  70451. * @param angle defines the angle to use
  70452. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70453. */
  70454. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  70455. /**
  70456. * Creates a rotation around an axis and stores it into the given quaternion
  70457. * @param axis defines the axis to use
  70458. * @param angle defines the angle to use
  70459. * @param result defines the target quaternion
  70460. * @returns the target quaternion
  70461. */
  70462. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  70463. /**
  70464. * Creates a new quaternion from data stored into an array
  70465. * @param array defines the data source
  70466. * @param offset defines the offset in the source array where the data starts
  70467. * @returns a new quaternion
  70468. */
  70469. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  70470. /**
  70471. * Create a quaternion from Euler rotation angles
  70472. * @param x Pitch
  70473. * @param y Yaw
  70474. * @param z Roll
  70475. * @returns the new Quaternion
  70476. */
  70477. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  70478. /**
  70479. * Updates a quaternion from Euler rotation angles
  70480. * @param x Pitch
  70481. * @param y Yaw
  70482. * @param z Roll
  70483. * @param result the quaternion to store the result
  70484. * @returns the updated quaternion
  70485. */
  70486. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  70487. /**
  70488. * Create a quaternion from Euler rotation vector
  70489. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70490. * @returns the new Quaternion
  70491. */
  70492. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  70493. /**
  70494. * Updates a quaternion from Euler rotation vector
  70495. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70496. * @param result the quaternion to store the result
  70497. * @returns the updated quaternion
  70498. */
  70499. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  70500. /**
  70501. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70502. * @param yaw defines the rotation around Y axis
  70503. * @param pitch defines the rotation around X axis
  70504. * @param roll defines the rotation around Z axis
  70505. * @returns the new quaternion
  70506. */
  70507. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  70508. /**
  70509. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70510. * @param yaw defines the rotation around Y axis
  70511. * @param pitch defines the rotation around X axis
  70512. * @param roll defines the rotation around Z axis
  70513. * @param result defines the target quaternion
  70514. */
  70515. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  70516. /**
  70517. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70518. * @param alpha defines the rotation around first axis
  70519. * @param beta defines the rotation around second axis
  70520. * @param gamma defines the rotation around third axis
  70521. * @returns the new quaternion
  70522. */
  70523. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  70524. /**
  70525. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70526. * @param alpha defines the rotation around first axis
  70527. * @param beta defines the rotation around second axis
  70528. * @param gamma defines the rotation around third axis
  70529. * @param result defines the target quaternion
  70530. */
  70531. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  70532. /**
  70533. * 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)
  70534. * @param axis1 defines the first axis
  70535. * @param axis2 defines the second axis
  70536. * @param axis3 defines the third axis
  70537. * @returns the new quaternion
  70538. */
  70539. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  70540. /**
  70541. * 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
  70542. * @param axis1 defines the first axis
  70543. * @param axis2 defines the second axis
  70544. * @param axis3 defines the third axis
  70545. * @param ref defines the target quaternion
  70546. */
  70547. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  70548. /**
  70549. * Interpolates between two quaternions
  70550. * @param left defines first quaternion
  70551. * @param right defines second quaternion
  70552. * @param amount defines the gradient to use
  70553. * @returns the new interpolated quaternion
  70554. */
  70555. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70556. /**
  70557. * Interpolates between two quaternions and stores it into a target quaternion
  70558. * @param left defines first quaternion
  70559. * @param right defines second quaternion
  70560. * @param amount defines the gradient to use
  70561. * @param result defines the target quaternion
  70562. */
  70563. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  70564. /**
  70565. * Interpolate between two quaternions using Hermite interpolation
  70566. * @param value1 defines first quaternion
  70567. * @param tangent1 defines the incoming tangent
  70568. * @param value2 defines second quaternion
  70569. * @param tangent2 defines the outgoing tangent
  70570. * @param amount defines the target quaternion
  70571. * @returns the new interpolated quaternion
  70572. */
  70573. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70574. }
  70575. /**
  70576. * Class used to store matrix data (4x4)
  70577. */
  70578. export class Matrix {
  70579. private static _updateFlagSeed;
  70580. private static _identityReadOnly;
  70581. private _isIdentity;
  70582. private _isIdentityDirty;
  70583. private _isIdentity3x2;
  70584. private _isIdentity3x2Dirty;
  70585. /**
  70586. * Gets the update flag of the matrix which is an unique number for the matrix.
  70587. * It will be incremented every time the matrix data change.
  70588. * You can use it to speed the comparison between two versions of the same matrix.
  70589. */
  70590. updateFlag: number;
  70591. private readonly _m;
  70592. /**
  70593. * Gets the internal data of the matrix
  70594. */
  70595. readonly m: DeepImmutable<Float32Array>;
  70596. /** @hidden */
  70597. _markAsUpdated(): void;
  70598. /** @hidden */
  70599. private _updateIdentityStatus;
  70600. /**
  70601. * Creates an empty matrix (filled with zeros)
  70602. */
  70603. constructor();
  70604. /**
  70605. * Check if the current matrix is identity
  70606. * @returns true is the matrix is the identity matrix
  70607. */
  70608. isIdentity(): boolean;
  70609. /**
  70610. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  70611. * @returns true is the matrix is the identity matrix
  70612. */
  70613. isIdentityAs3x2(): boolean;
  70614. /**
  70615. * Gets the determinant of the matrix
  70616. * @returns the matrix determinant
  70617. */
  70618. determinant(): number;
  70619. /**
  70620. * Returns the matrix as a Float32Array
  70621. * @returns the matrix underlying array
  70622. */
  70623. toArray(): DeepImmutable<Float32Array>;
  70624. /**
  70625. * Returns the matrix as a Float32Array
  70626. * @returns the matrix underlying array.
  70627. */
  70628. asArray(): DeepImmutable<Float32Array>;
  70629. /**
  70630. * Inverts the current matrix in place
  70631. * @returns the current inverted matrix
  70632. */
  70633. invert(): Matrix;
  70634. /**
  70635. * Sets all the matrix elements to zero
  70636. * @returns the current matrix
  70637. */
  70638. reset(): Matrix;
  70639. /**
  70640. * Adds the current matrix with a second one
  70641. * @param other defines the matrix to add
  70642. * @returns a new matrix as the addition of the current matrix and the given one
  70643. */
  70644. add(other: DeepImmutable<Matrix>): Matrix;
  70645. /**
  70646. * Sets the given matrix "result" to the addition of the current matrix and the given one
  70647. * @param other defines the matrix to add
  70648. * @param result defines the target matrix
  70649. * @returns the current matrix
  70650. */
  70651. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70652. /**
  70653. * Adds in place the given matrix to the current matrix
  70654. * @param other defines the second operand
  70655. * @returns the current updated matrix
  70656. */
  70657. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  70658. /**
  70659. * Sets the given matrix to the current inverted Matrix
  70660. * @param other defines the target matrix
  70661. * @returns the unmodified current matrix
  70662. */
  70663. invertToRef(other: Matrix): Matrix;
  70664. /**
  70665. * add a value at the specified position in the current Matrix
  70666. * @param index the index of the value within the matrix. between 0 and 15.
  70667. * @param value the value to be added
  70668. * @returns the current updated matrix
  70669. */
  70670. addAtIndex(index: number, value: number): Matrix;
  70671. /**
  70672. * mutiply the specified position in the current Matrix by a value
  70673. * @param index the index of the value within the matrix. between 0 and 15.
  70674. * @param value the value to be added
  70675. * @returns the current updated matrix
  70676. */
  70677. multiplyAtIndex(index: number, value: number): Matrix;
  70678. /**
  70679. * Inserts the translation vector (using 3 floats) in the current matrix
  70680. * @param x defines the 1st component of the translation
  70681. * @param y defines the 2nd component of the translation
  70682. * @param z defines the 3rd component of the translation
  70683. * @returns the current updated matrix
  70684. */
  70685. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70686. /**
  70687. * Adds the translation vector (using 3 floats) in the current matrix
  70688. * @param x defines the 1st component of the translation
  70689. * @param y defines the 2nd component of the translation
  70690. * @param z defines the 3rd component of the translation
  70691. * @returns the current updated matrix
  70692. */
  70693. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70694. /**
  70695. * Inserts the translation vector in the current matrix
  70696. * @param vector3 defines the translation to insert
  70697. * @returns the current updated matrix
  70698. */
  70699. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  70700. /**
  70701. * Gets the translation value of the current matrix
  70702. * @returns a new Vector3 as the extracted translation from the matrix
  70703. */
  70704. getTranslation(): Vector3;
  70705. /**
  70706. * Fill a Vector3 with the extracted translation from the matrix
  70707. * @param result defines the Vector3 where to store the translation
  70708. * @returns the current matrix
  70709. */
  70710. getTranslationToRef(result: Vector3): Matrix;
  70711. /**
  70712. * Remove rotation and scaling part from the matrix
  70713. * @returns the updated matrix
  70714. */
  70715. removeRotationAndScaling(): Matrix;
  70716. /**
  70717. * Multiply two matrices
  70718. * @param other defines the second operand
  70719. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  70720. */
  70721. multiply(other: DeepImmutable<Matrix>): Matrix;
  70722. /**
  70723. * Copy the current matrix from the given one
  70724. * @param other defines the source matrix
  70725. * @returns the current updated matrix
  70726. */
  70727. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  70728. /**
  70729. * Populates the given array from the starting index with the current matrix values
  70730. * @param array defines the target array
  70731. * @param offset defines the offset in the target array where to start storing values
  70732. * @returns the current matrix
  70733. */
  70734. copyToArray(array: Float32Array, offset?: number): Matrix;
  70735. /**
  70736. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  70737. * @param other defines the second operand
  70738. * @param result defines the matrix where to store the multiplication
  70739. * @returns the current matrix
  70740. */
  70741. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70742. /**
  70743. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  70744. * @param other defines the second operand
  70745. * @param result defines the array where to store the multiplication
  70746. * @param offset defines the offset in the target array where to start storing values
  70747. * @returns the current matrix
  70748. */
  70749. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  70750. /**
  70751. * Check equality between this matrix and a second one
  70752. * @param value defines the second matrix to compare
  70753. * @returns true is the current matrix and the given one values are strictly equal
  70754. */
  70755. equals(value: DeepImmutable<Matrix>): boolean;
  70756. /**
  70757. * Clone the current matrix
  70758. * @returns a new matrix from the current matrix
  70759. */
  70760. clone(): Matrix;
  70761. /**
  70762. * Returns the name of the current matrix class
  70763. * @returns the string "Matrix"
  70764. */
  70765. getClassName(): string;
  70766. /**
  70767. * Gets the hash code of the current matrix
  70768. * @returns the hash code
  70769. */
  70770. getHashCode(): number;
  70771. /**
  70772. * Decomposes the current Matrix into a translation, rotation and scaling components
  70773. * @param scale defines the scale vector3 given as a reference to update
  70774. * @param rotation defines the rotation quaternion given as a reference to update
  70775. * @param translation defines the translation vector3 given as a reference to update
  70776. * @returns true if operation was successful
  70777. */
  70778. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  70779. /**
  70780. * Gets specific row of the matrix
  70781. * @param index defines the number of the row to get
  70782. * @returns the index-th row of the current matrix as a new Vector4
  70783. */
  70784. getRow(index: number): Nullable<Vector4>;
  70785. /**
  70786. * Sets the index-th row of the current matrix to the vector4 values
  70787. * @param index defines the number of the row to set
  70788. * @param row defines the target vector4
  70789. * @returns the updated current matrix
  70790. */
  70791. setRow(index: number, row: Vector4): Matrix;
  70792. /**
  70793. * Compute the transpose of the matrix
  70794. * @returns the new transposed matrix
  70795. */
  70796. transpose(): Matrix;
  70797. /**
  70798. * Compute the transpose of the matrix and store it in a given matrix
  70799. * @param result defines the target matrix
  70800. * @returns the current matrix
  70801. */
  70802. transposeToRef(result: Matrix): Matrix;
  70803. /**
  70804. * Sets the index-th row of the current matrix with the given 4 x float values
  70805. * @param index defines the row index
  70806. * @param x defines the x component to set
  70807. * @param y defines the y component to set
  70808. * @param z defines the z component to set
  70809. * @param w defines the w component to set
  70810. * @returns the updated current matrix
  70811. */
  70812. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  70813. /**
  70814. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  70815. * @param scale defines the scale factor
  70816. * @returns a new matrix
  70817. */
  70818. scale(scale: number): Matrix;
  70819. /**
  70820. * Scale the current matrix values by a factor to a given result matrix
  70821. * @param scale defines the scale factor
  70822. * @param result defines the matrix to store the result
  70823. * @returns the current matrix
  70824. */
  70825. scaleToRef(scale: number, result: Matrix): Matrix;
  70826. /**
  70827. * Scale the current matrix values by a factor and add the result to a given matrix
  70828. * @param scale defines the scale factor
  70829. * @param result defines the Matrix to store the result
  70830. * @returns the current matrix
  70831. */
  70832. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  70833. /**
  70834. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  70835. * @param ref matrix to store the result
  70836. */
  70837. toNormalMatrix(ref: Matrix): void;
  70838. /**
  70839. * Gets only rotation part of the current matrix
  70840. * @returns a new matrix sets to the extracted rotation matrix from the current one
  70841. */
  70842. getRotationMatrix(): Matrix;
  70843. /**
  70844. * Extracts the rotation matrix from the current one and sets it as the given "result"
  70845. * @param result defines the target matrix to store data to
  70846. * @returns the current matrix
  70847. */
  70848. getRotationMatrixToRef(result: Matrix): Matrix;
  70849. /**
  70850. * Toggles model matrix from being right handed to left handed in place and vice versa
  70851. */
  70852. toggleModelMatrixHandInPlace(): void;
  70853. /**
  70854. * Toggles projection matrix from being right handed to left handed in place and vice versa
  70855. */
  70856. toggleProjectionMatrixHandInPlace(): void;
  70857. /**
  70858. * Creates a matrix from an array
  70859. * @param array defines the source array
  70860. * @param offset defines an offset in the source array
  70861. * @returns a new Matrix set from the starting index of the given array
  70862. */
  70863. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  70864. /**
  70865. * Copy the content of an array into a given matrix
  70866. * @param array defines the source array
  70867. * @param offset defines an offset in the source array
  70868. * @param result defines the target matrix
  70869. */
  70870. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  70871. /**
  70872. * Stores an array into a matrix after having multiplied each component by a given factor
  70873. * @param array defines the source array
  70874. * @param offset defines the offset in the source array
  70875. * @param scale defines the scaling factor
  70876. * @param result defines the target matrix
  70877. */
  70878. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  70879. /**
  70880. * Gets an identity matrix that must not be updated
  70881. */
  70882. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  70883. /**
  70884. * Stores a list of values (16) inside a given matrix
  70885. * @param initialM11 defines 1st value of 1st row
  70886. * @param initialM12 defines 2nd value of 1st row
  70887. * @param initialM13 defines 3rd value of 1st row
  70888. * @param initialM14 defines 4th value of 1st row
  70889. * @param initialM21 defines 1st value of 2nd row
  70890. * @param initialM22 defines 2nd value of 2nd row
  70891. * @param initialM23 defines 3rd value of 2nd row
  70892. * @param initialM24 defines 4th value of 2nd row
  70893. * @param initialM31 defines 1st value of 3rd row
  70894. * @param initialM32 defines 2nd value of 3rd row
  70895. * @param initialM33 defines 3rd value of 3rd row
  70896. * @param initialM34 defines 4th value of 3rd row
  70897. * @param initialM41 defines 1st value of 4th row
  70898. * @param initialM42 defines 2nd value of 4th row
  70899. * @param initialM43 defines 3rd value of 4th row
  70900. * @param initialM44 defines 4th value of 4th row
  70901. * @param result defines the target matrix
  70902. */
  70903. 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;
  70904. /**
  70905. * Creates new matrix from a list of values (16)
  70906. * @param initialM11 defines 1st value of 1st row
  70907. * @param initialM12 defines 2nd value of 1st row
  70908. * @param initialM13 defines 3rd value of 1st row
  70909. * @param initialM14 defines 4th value of 1st row
  70910. * @param initialM21 defines 1st value of 2nd row
  70911. * @param initialM22 defines 2nd value of 2nd row
  70912. * @param initialM23 defines 3rd value of 2nd row
  70913. * @param initialM24 defines 4th value of 2nd row
  70914. * @param initialM31 defines 1st value of 3rd row
  70915. * @param initialM32 defines 2nd value of 3rd row
  70916. * @param initialM33 defines 3rd value of 3rd row
  70917. * @param initialM34 defines 4th value of 3rd row
  70918. * @param initialM41 defines 1st value of 4th row
  70919. * @param initialM42 defines 2nd value of 4th row
  70920. * @param initialM43 defines 3rd value of 4th row
  70921. * @param initialM44 defines 4th value of 4th row
  70922. * @returns the new matrix
  70923. */
  70924. 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;
  70925. /**
  70926. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70927. * @param scale defines the scale vector3
  70928. * @param rotation defines the rotation quaternion
  70929. * @param translation defines the translation vector3
  70930. * @returns a new matrix
  70931. */
  70932. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  70933. /**
  70934. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70935. * @param scale defines the scale vector3
  70936. * @param rotation defines the rotation quaternion
  70937. * @param translation defines the translation vector3
  70938. * @param result defines the target matrix
  70939. */
  70940. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  70941. /**
  70942. * Creates a new identity matrix
  70943. * @returns a new identity matrix
  70944. */
  70945. static Identity(): Matrix;
  70946. /**
  70947. * Creates a new identity matrix and stores the result in a given matrix
  70948. * @param result defines the target matrix
  70949. */
  70950. static IdentityToRef(result: Matrix): void;
  70951. /**
  70952. * Creates a new zero matrix
  70953. * @returns a new zero matrix
  70954. */
  70955. static Zero(): Matrix;
  70956. /**
  70957. * Creates a new rotation matrix for "angle" radians around the X axis
  70958. * @param angle defines the angle (in radians) to use
  70959. * @return the new matrix
  70960. */
  70961. static RotationX(angle: number): Matrix;
  70962. /**
  70963. * Creates a new matrix as the invert of a given matrix
  70964. * @param source defines the source matrix
  70965. * @returns the new matrix
  70966. */
  70967. static Invert(source: DeepImmutable<Matrix>): Matrix;
  70968. /**
  70969. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  70970. * @param angle defines the angle (in radians) to use
  70971. * @param result defines the target matrix
  70972. */
  70973. static RotationXToRef(angle: number, result: Matrix): void;
  70974. /**
  70975. * Creates a new rotation matrix for "angle" radians around the Y axis
  70976. * @param angle defines the angle (in radians) to use
  70977. * @return the new matrix
  70978. */
  70979. static RotationY(angle: number): Matrix;
  70980. /**
  70981. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  70982. * @param angle defines the angle (in radians) to use
  70983. * @param result defines the target matrix
  70984. */
  70985. static RotationYToRef(angle: number, result: Matrix): void;
  70986. /**
  70987. * Creates a new rotation matrix for "angle" radians around the Z axis
  70988. * @param angle defines the angle (in radians) to use
  70989. * @return the new matrix
  70990. */
  70991. static RotationZ(angle: number): Matrix;
  70992. /**
  70993. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  70994. * @param angle defines the angle (in radians) to use
  70995. * @param result defines the target matrix
  70996. */
  70997. static RotationZToRef(angle: number, result: Matrix): void;
  70998. /**
  70999. * Creates a new rotation matrix for "angle" radians around the given axis
  71000. * @param axis defines the axis to use
  71001. * @param angle defines the angle (in radians) to use
  71002. * @return the new matrix
  71003. */
  71004. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71005. /**
  71006. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71007. * @param axis defines the axis to use
  71008. * @param angle defines the angle (in radians) to use
  71009. * @param result defines the target matrix
  71010. */
  71011. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71012. /**
  71013. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71014. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71015. * @param from defines the vector to align
  71016. * @param to defines the vector to align to
  71017. * @param result defines the target matrix
  71018. */
  71019. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71020. /**
  71021. * Creates a rotation matrix
  71022. * @param yaw defines the yaw angle in radians (Y axis)
  71023. * @param pitch defines the pitch angle in radians (X axis)
  71024. * @param roll defines the roll angle in radians (X axis)
  71025. * @returns the new rotation matrix
  71026. */
  71027. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71028. /**
  71029. * Creates a rotation matrix and stores it in a given matrix
  71030. * @param yaw defines the yaw angle in radians (Y axis)
  71031. * @param pitch defines the pitch angle in radians (X axis)
  71032. * @param roll defines the roll angle in radians (X axis)
  71033. * @param result defines the target matrix
  71034. */
  71035. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71036. /**
  71037. * Creates a scaling matrix
  71038. * @param x defines the scale factor on X axis
  71039. * @param y defines the scale factor on Y axis
  71040. * @param z defines the scale factor on Z axis
  71041. * @returns the new matrix
  71042. */
  71043. static Scaling(x: number, y: number, z: number): Matrix;
  71044. /**
  71045. * Creates a scaling matrix and stores it in a given matrix
  71046. * @param x defines the scale factor on X axis
  71047. * @param y defines the scale factor on Y axis
  71048. * @param z defines the scale factor on Z axis
  71049. * @param result defines the target matrix
  71050. */
  71051. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71052. /**
  71053. * Creates a translation matrix
  71054. * @param x defines the translation on X axis
  71055. * @param y defines the translation on Y axis
  71056. * @param z defines the translationon Z axis
  71057. * @returns the new matrix
  71058. */
  71059. static Translation(x: number, y: number, z: number): Matrix;
  71060. /**
  71061. * Creates a translation matrix and stores it in a given matrix
  71062. * @param x defines the translation on X axis
  71063. * @param y defines the translation on Y axis
  71064. * @param z defines the translationon Z axis
  71065. * @param result defines the target matrix
  71066. */
  71067. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71068. /**
  71069. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71070. * @param startValue defines the start value
  71071. * @param endValue defines the end value
  71072. * @param gradient defines the gradient factor
  71073. * @returns the new matrix
  71074. */
  71075. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71076. /**
  71077. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71078. * @param startValue defines the start value
  71079. * @param endValue defines the end value
  71080. * @param gradient defines the gradient factor
  71081. * @param result defines the Matrix object where to store data
  71082. */
  71083. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71084. /**
  71085. * Builds a new matrix whose values are computed by:
  71086. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71087. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71088. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71089. * @param startValue defines the first matrix
  71090. * @param endValue defines the second matrix
  71091. * @param gradient defines the gradient between the two matrices
  71092. * @returns the new matrix
  71093. */
  71094. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71095. /**
  71096. * Update a matrix to values which are computed by:
  71097. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71098. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71099. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71100. * @param startValue defines the first matrix
  71101. * @param endValue defines the second matrix
  71102. * @param gradient defines the gradient between the two matrices
  71103. * @param result defines the target matrix
  71104. */
  71105. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71106. /**
  71107. * 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"
  71108. * This function works in left handed mode
  71109. * @param eye defines the final position of the entity
  71110. * @param target defines where the entity should look at
  71111. * @param up defines the up vector for the entity
  71112. * @returns the new matrix
  71113. */
  71114. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71115. /**
  71116. * 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".
  71117. * This function works in left handed mode
  71118. * @param eye defines the final position of the entity
  71119. * @param target defines where the entity should look at
  71120. * @param up defines the up vector for the entity
  71121. * @param result defines the target matrix
  71122. */
  71123. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71124. /**
  71125. * 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"
  71126. * This function works in right handed mode
  71127. * @param eye defines the final position of the entity
  71128. * @param target defines where the entity should look at
  71129. * @param up defines the up vector for the entity
  71130. * @returns the new matrix
  71131. */
  71132. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71133. /**
  71134. * 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".
  71135. * This function works in right handed mode
  71136. * @param eye defines the final position of the entity
  71137. * @param target defines where the entity should look at
  71138. * @param up defines the up vector for the entity
  71139. * @param result defines the target matrix
  71140. */
  71141. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71142. /**
  71143. * Create a left-handed orthographic projection matrix
  71144. * @param width defines the viewport width
  71145. * @param height defines the viewport height
  71146. * @param znear defines the near clip plane
  71147. * @param zfar defines the far clip plane
  71148. * @returns a new matrix as a left-handed orthographic projection matrix
  71149. */
  71150. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71151. /**
  71152. * Store a left-handed orthographic projection to a given matrix
  71153. * @param width defines the viewport width
  71154. * @param height defines the viewport height
  71155. * @param znear defines the near clip plane
  71156. * @param zfar defines the far clip plane
  71157. * @param result defines the target matrix
  71158. */
  71159. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71160. /**
  71161. * Create a left-handed orthographic projection matrix
  71162. * @param left defines the viewport left coordinate
  71163. * @param right defines the viewport right coordinate
  71164. * @param bottom defines the viewport bottom coordinate
  71165. * @param top defines the viewport top coordinate
  71166. * @param znear defines the near clip plane
  71167. * @param zfar defines the far clip plane
  71168. * @returns a new matrix as a left-handed orthographic projection matrix
  71169. */
  71170. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71171. /**
  71172. * Stores a left-handed orthographic projection into a given matrix
  71173. * @param left defines the viewport left coordinate
  71174. * @param right defines the viewport right coordinate
  71175. * @param bottom defines the viewport bottom coordinate
  71176. * @param top defines the viewport top coordinate
  71177. * @param znear defines the near clip plane
  71178. * @param zfar defines the far clip plane
  71179. * @param result defines the target matrix
  71180. */
  71181. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71182. /**
  71183. * Creates a right-handed orthographic projection matrix
  71184. * @param left defines the viewport left coordinate
  71185. * @param right defines the viewport right coordinate
  71186. * @param bottom defines the viewport bottom coordinate
  71187. * @param top defines the viewport top coordinate
  71188. * @param znear defines the near clip plane
  71189. * @param zfar defines the far clip plane
  71190. * @returns a new matrix as a right-handed orthographic projection matrix
  71191. */
  71192. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71193. /**
  71194. * Stores a right-handed orthographic projection into a given matrix
  71195. * @param left defines the viewport left coordinate
  71196. * @param right defines the viewport right coordinate
  71197. * @param bottom defines the viewport bottom coordinate
  71198. * @param top defines the viewport top coordinate
  71199. * @param znear defines the near clip plane
  71200. * @param zfar defines the far clip plane
  71201. * @param result defines the target matrix
  71202. */
  71203. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71204. /**
  71205. * Creates a left-handed perspective projection matrix
  71206. * @param width defines the viewport width
  71207. * @param height defines the viewport height
  71208. * @param znear defines the near clip plane
  71209. * @param zfar defines the far clip plane
  71210. * @returns a new matrix as a left-handed perspective projection matrix
  71211. */
  71212. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71213. /**
  71214. * Creates a left-handed perspective projection matrix
  71215. * @param fov defines the horizontal field of view
  71216. * @param aspect defines the aspect ratio
  71217. * @param znear defines the near clip plane
  71218. * @param zfar defines the far clip plane
  71219. * @returns a new matrix as a left-handed perspective projection matrix
  71220. */
  71221. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71222. /**
  71223. * Stores a left-handed perspective projection into a given matrix
  71224. * @param fov defines the horizontal field of view
  71225. * @param aspect defines the aspect ratio
  71226. * @param znear defines the near clip plane
  71227. * @param zfar defines the far clip plane
  71228. * @param result defines the target matrix
  71229. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71230. */
  71231. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71232. /**
  71233. * Creates a right-handed perspective projection matrix
  71234. * @param fov defines the horizontal field of view
  71235. * @param aspect defines the aspect ratio
  71236. * @param znear defines the near clip plane
  71237. * @param zfar defines the far clip plane
  71238. * @returns a new matrix as a right-handed perspective projection matrix
  71239. */
  71240. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71241. /**
  71242. * Stores a right-handed perspective projection into a given matrix
  71243. * @param fov defines the horizontal field of view
  71244. * @param aspect defines the aspect ratio
  71245. * @param znear defines the near clip plane
  71246. * @param zfar defines the far clip plane
  71247. * @param result defines the target matrix
  71248. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71249. */
  71250. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71251. /**
  71252. * Stores a perspective projection for WebVR info a given matrix
  71253. * @param fov defines the field of view
  71254. * @param znear defines the near clip plane
  71255. * @param zfar defines the far clip plane
  71256. * @param result defines the target matrix
  71257. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71258. */
  71259. static PerspectiveFovWebVRToRef(fov: {
  71260. upDegrees: number;
  71261. downDegrees: number;
  71262. leftDegrees: number;
  71263. rightDegrees: number;
  71264. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71265. /**
  71266. * Computes a complete transformation matrix
  71267. * @param viewport defines the viewport to use
  71268. * @param world defines the world matrix
  71269. * @param view defines the view matrix
  71270. * @param projection defines the projection matrix
  71271. * @param zmin defines the near clip plane
  71272. * @param zmax defines the far clip plane
  71273. * @returns the transformation matrix
  71274. */
  71275. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71276. /**
  71277. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71278. * @param matrix defines the matrix to use
  71279. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71280. */
  71281. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71282. /**
  71283. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71284. * @param matrix defines the matrix to use
  71285. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71286. */
  71287. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71288. /**
  71289. * Compute the transpose of a given matrix
  71290. * @param matrix defines the matrix to transpose
  71291. * @returns the new matrix
  71292. */
  71293. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71294. /**
  71295. * Compute the transpose of a matrix and store it in a target matrix
  71296. * @param matrix defines the matrix to transpose
  71297. * @param result defines the target matrix
  71298. */
  71299. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71300. /**
  71301. * Computes a reflection matrix from a plane
  71302. * @param plane defines the reflection plane
  71303. * @returns a new matrix
  71304. */
  71305. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71306. /**
  71307. * Computes a reflection matrix from a plane
  71308. * @param plane defines the reflection plane
  71309. * @param result defines the target matrix
  71310. */
  71311. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71312. /**
  71313. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71314. * @param xaxis defines the value of the 1st axis
  71315. * @param yaxis defines the value of the 2nd axis
  71316. * @param zaxis defines the value of the 3rd axis
  71317. * @param result defines the target matrix
  71318. */
  71319. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71320. /**
  71321. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71322. * @param quat defines the quaternion to use
  71323. * @param result defines the target matrix
  71324. */
  71325. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71326. }
  71327. /**
  71328. * @hidden
  71329. */
  71330. export class TmpVectors {
  71331. static Vector2: Vector2[];
  71332. static Vector3: Vector3[];
  71333. static Vector4: Vector4[];
  71334. static Quaternion: Quaternion[];
  71335. static Matrix: Matrix[];
  71336. }
  71337. }
  71338. declare module BABYLON {
  71339. /**
  71340. * Defines potential orientation for back face culling
  71341. */
  71342. export enum Orientation {
  71343. /**
  71344. * Clockwise
  71345. */
  71346. CW = 0,
  71347. /** Counter clockwise */
  71348. CCW = 1
  71349. }
  71350. /** Class used to represent a Bezier curve */
  71351. export class BezierCurve {
  71352. /**
  71353. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71354. * @param t defines the time
  71355. * @param x1 defines the left coordinate on X axis
  71356. * @param y1 defines the left coordinate on Y axis
  71357. * @param x2 defines the right coordinate on X axis
  71358. * @param y2 defines the right coordinate on Y axis
  71359. * @returns the interpolated value
  71360. */
  71361. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71362. }
  71363. /**
  71364. * Defines angle representation
  71365. */
  71366. export class Angle {
  71367. private _radians;
  71368. /**
  71369. * Creates an Angle object of "radians" radians (float).
  71370. * @param radians the angle in radians
  71371. */
  71372. constructor(radians: number);
  71373. /**
  71374. * Get value in degrees
  71375. * @returns the Angle value in degrees (float)
  71376. */
  71377. degrees(): number;
  71378. /**
  71379. * Get value in radians
  71380. * @returns the Angle value in radians (float)
  71381. */
  71382. radians(): number;
  71383. /**
  71384. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71385. * @param a defines first vector
  71386. * @param b defines second vector
  71387. * @returns a new Angle
  71388. */
  71389. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71390. /**
  71391. * Gets a new Angle object from the given float in radians
  71392. * @param radians defines the angle value in radians
  71393. * @returns a new Angle
  71394. */
  71395. static FromRadians(radians: number): Angle;
  71396. /**
  71397. * Gets a new Angle object from the given float in degrees
  71398. * @param degrees defines the angle value in degrees
  71399. * @returns a new Angle
  71400. */
  71401. static FromDegrees(degrees: number): Angle;
  71402. }
  71403. /**
  71404. * This represents an arc in a 2d space.
  71405. */
  71406. export class Arc2 {
  71407. /** Defines the start point of the arc */
  71408. startPoint: Vector2;
  71409. /** Defines the mid point of the arc */
  71410. midPoint: Vector2;
  71411. /** Defines the end point of the arc */
  71412. endPoint: Vector2;
  71413. /**
  71414. * Defines the center point of the arc.
  71415. */
  71416. centerPoint: Vector2;
  71417. /**
  71418. * Defines the radius of the arc.
  71419. */
  71420. radius: number;
  71421. /**
  71422. * Defines the angle of the arc (from mid point to end point).
  71423. */
  71424. angle: Angle;
  71425. /**
  71426. * Defines the start angle of the arc (from start point to middle point).
  71427. */
  71428. startAngle: Angle;
  71429. /**
  71430. * Defines the orientation of the arc (clock wise/counter clock wise).
  71431. */
  71432. orientation: Orientation;
  71433. /**
  71434. * Creates an Arc object from the three given points : start, middle and end.
  71435. * @param startPoint Defines the start point of the arc
  71436. * @param midPoint Defines the midlle point of the arc
  71437. * @param endPoint Defines the end point of the arc
  71438. */
  71439. constructor(
  71440. /** Defines the start point of the arc */
  71441. startPoint: Vector2,
  71442. /** Defines the mid point of the arc */
  71443. midPoint: Vector2,
  71444. /** Defines the end point of the arc */
  71445. endPoint: Vector2);
  71446. }
  71447. /**
  71448. * Represents a 2D path made up of multiple 2D points
  71449. */
  71450. export class Path2 {
  71451. private _points;
  71452. private _length;
  71453. /**
  71454. * If the path start and end point are the same
  71455. */
  71456. closed: boolean;
  71457. /**
  71458. * Creates a Path2 object from the starting 2D coordinates x and y.
  71459. * @param x the starting points x value
  71460. * @param y the starting points y value
  71461. */
  71462. constructor(x: number, y: number);
  71463. /**
  71464. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71465. * @param x the added points x value
  71466. * @param y the added points y value
  71467. * @returns the updated Path2.
  71468. */
  71469. addLineTo(x: number, y: number): Path2;
  71470. /**
  71471. * 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.
  71472. * @param midX middle point x value
  71473. * @param midY middle point y value
  71474. * @param endX end point x value
  71475. * @param endY end point y value
  71476. * @param numberOfSegments (default: 36)
  71477. * @returns the updated Path2.
  71478. */
  71479. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71480. /**
  71481. * Closes the Path2.
  71482. * @returns the Path2.
  71483. */
  71484. close(): Path2;
  71485. /**
  71486. * Gets the sum of the distance between each sequential point in the path
  71487. * @returns the Path2 total length (float).
  71488. */
  71489. length(): number;
  71490. /**
  71491. * Gets the points which construct the path
  71492. * @returns the Path2 internal array of points.
  71493. */
  71494. getPoints(): Vector2[];
  71495. /**
  71496. * Retreives the point at the distance aways from the starting point
  71497. * @param normalizedLengthPosition the length along the path to retreive the point from
  71498. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71499. */
  71500. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71501. /**
  71502. * Creates a new path starting from an x and y position
  71503. * @param x starting x value
  71504. * @param y starting y value
  71505. * @returns a new Path2 starting at the coordinates (x, y).
  71506. */
  71507. static StartingAt(x: number, y: number): Path2;
  71508. }
  71509. /**
  71510. * Represents a 3D path made up of multiple 3D points
  71511. */
  71512. export class Path3D {
  71513. /**
  71514. * an array of Vector3, the curve axis of the Path3D
  71515. */
  71516. path: Vector3[];
  71517. private _curve;
  71518. private _distances;
  71519. private _tangents;
  71520. private _normals;
  71521. private _binormals;
  71522. private _raw;
  71523. /**
  71524. * new Path3D(path, normal, raw)
  71525. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71526. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71527. * @param path an array of Vector3, the curve axis of the Path3D
  71528. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71529. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71530. */
  71531. constructor(
  71532. /**
  71533. * an array of Vector3, the curve axis of the Path3D
  71534. */
  71535. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71536. /**
  71537. * Returns the Path3D array of successive Vector3 designing its curve.
  71538. * @returns the Path3D array of successive Vector3 designing its curve.
  71539. */
  71540. getCurve(): Vector3[];
  71541. /**
  71542. * Returns an array populated with tangent vectors on each Path3D curve point.
  71543. * @returns an array populated with tangent vectors on each Path3D curve point.
  71544. */
  71545. getTangents(): Vector3[];
  71546. /**
  71547. * Returns an array populated with normal vectors on each Path3D curve point.
  71548. * @returns an array populated with normal vectors on each Path3D curve point.
  71549. */
  71550. getNormals(): Vector3[];
  71551. /**
  71552. * Returns an array populated with binormal vectors on each Path3D curve point.
  71553. * @returns an array populated with binormal vectors on each Path3D curve point.
  71554. */
  71555. getBinormals(): Vector3[];
  71556. /**
  71557. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71558. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71559. */
  71560. getDistances(): number[];
  71561. /**
  71562. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71563. * @param path path which all values are copied into the curves points
  71564. * @param firstNormal which should be projected onto the curve
  71565. * @returns the same object updated.
  71566. */
  71567. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71568. private _compute;
  71569. private _getFirstNonNullVector;
  71570. private _getLastNonNullVector;
  71571. private _normalVector;
  71572. }
  71573. /**
  71574. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71575. * A Curve3 is designed from a series of successive Vector3.
  71576. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71577. */
  71578. export class Curve3 {
  71579. private _points;
  71580. private _length;
  71581. /**
  71582. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71583. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71584. * @param v1 (Vector3) the control point
  71585. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71586. * @param nbPoints (integer) the wanted number of points in the curve
  71587. * @returns the created Curve3
  71588. */
  71589. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71590. /**
  71591. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71592. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71593. * @param v1 (Vector3) the first control point
  71594. * @param v2 (Vector3) the second control point
  71595. * @param v3 (Vector3) the end point of the Cubic Bezier
  71596. * @param nbPoints (integer) the wanted number of points in the curve
  71597. * @returns the created Curve3
  71598. */
  71599. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71600. /**
  71601. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71602. * @param p1 (Vector3) the origin point of the Hermite Spline
  71603. * @param t1 (Vector3) the tangent vector at the origin point
  71604. * @param p2 (Vector3) the end point of the Hermite Spline
  71605. * @param t2 (Vector3) the tangent vector at the end point
  71606. * @param nbPoints (integer) the wanted number of points in the curve
  71607. * @returns the created Curve3
  71608. */
  71609. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71610. /**
  71611. * Returns a Curve3 object along a CatmullRom Spline curve :
  71612. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71613. * @param nbPoints (integer) the wanted number of points between each curve control points
  71614. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71615. * @returns the created Curve3
  71616. */
  71617. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71618. /**
  71619. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71620. * A Curve3 is designed from a series of successive Vector3.
  71621. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71622. * @param points points which make up the curve
  71623. */
  71624. constructor(points: Vector3[]);
  71625. /**
  71626. * @returns the Curve3 stored array of successive Vector3
  71627. */
  71628. getPoints(): Vector3[];
  71629. /**
  71630. * @returns the computed length (float) of the curve.
  71631. */
  71632. length(): number;
  71633. /**
  71634. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71635. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71636. * curveA and curveB keep unchanged.
  71637. * @param curve the curve to continue from this curve
  71638. * @returns the newly constructed curve
  71639. */
  71640. continue(curve: DeepImmutable<Curve3>): Curve3;
  71641. private _computeLength;
  71642. }
  71643. }
  71644. declare module BABYLON {
  71645. /**
  71646. * This represents the main contract an easing function should follow.
  71647. * Easing functions are used throughout the animation system.
  71648. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71649. */
  71650. export interface IEasingFunction {
  71651. /**
  71652. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71653. * of the easing function.
  71654. * The link below provides some of the most common examples of easing functions.
  71655. * @see https://easings.net/
  71656. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71657. * @returns the corresponding value on the curve defined by the easing function
  71658. */
  71659. ease(gradient: number): number;
  71660. }
  71661. /**
  71662. * Base class used for every default easing function.
  71663. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71664. */
  71665. export class EasingFunction implements IEasingFunction {
  71666. /**
  71667. * Interpolation follows the mathematical formula associated with the easing function.
  71668. */
  71669. static readonly EASINGMODE_EASEIN: number;
  71670. /**
  71671. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71672. */
  71673. static readonly EASINGMODE_EASEOUT: number;
  71674. /**
  71675. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71676. */
  71677. static readonly EASINGMODE_EASEINOUT: number;
  71678. private _easingMode;
  71679. /**
  71680. * Sets the easing mode of the current function.
  71681. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71682. */
  71683. setEasingMode(easingMode: number): void;
  71684. /**
  71685. * Gets the current easing mode.
  71686. * @returns the easing mode
  71687. */
  71688. getEasingMode(): number;
  71689. /**
  71690. * @hidden
  71691. */
  71692. easeInCore(gradient: number): number;
  71693. /**
  71694. * Given an input gradient between 0 and 1, this returns the corresponding value
  71695. * of the easing function.
  71696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71697. * @returns the corresponding value on the curve defined by the easing function
  71698. */
  71699. ease(gradient: number): number;
  71700. }
  71701. /**
  71702. * Easing function with a circle shape (see link below).
  71703. * @see https://easings.net/#easeInCirc
  71704. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71705. */
  71706. export class CircleEase extends EasingFunction implements IEasingFunction {
  71707. /** @hidden */
  71708. easeInCore(gradient: number): number;
  71709. }
  71710. /**
  71711. * Easing function with a ease back shape (see link below).
  71712. * @see https://easings.net/#easeInBack
  71713. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71714. */
  71715. export class BackEase extends EasingFunction implements IEasingFunction {
  71716. /** Defines the amplitude of the function */
  71717. amplitude: number;
  71718. /**
  71719. * Instantiates a back ease easing
  71720. * @see https://easings.net/#easeInBack
  71721. * @param amplitude Defines the amplitude of the function
  71722. */
  71723. constructor(
  71724. /** Defines the amplitude of the function */
  71725. amplitude?: number);
  71726. /** @hidden */
  71727. easeInCore(gradient: number): number;
  71728. }
  71729. /**
  71730. * Easing function with a bouncing shape (see link below).
  71731. * @see https://easings.net/#easeInBounce
  71732. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71733. */
  71734. export class BounceEase extends EasingFunction implements IEasingFunction {
  71735. /** Defines the number of bounces */
  71736. bounces: number;
  71737. /** Defines the amplitude of the bounce */
  71738. bounciness: number;
  71739. /**
  71740. * Instantiates a bounce easing
  71741. * @see https://easings.net/#easeInBounce
  71742. * @param bounces Defines the number of bounces
  71743. * @param bounciness Defines the amplitude of the bounce
  71744. */
  71745. constructor(
  71746. /** Defines the number of bounces */
  71747. bounces?: number,
  71748. /** Defines the amplitude of the bounce */
  71749. bounciness?: number);
  71750. /** @hidden */
  71751. easeInCore(gradient: number): number;
  71752. }
  71753. /**
  71754. * Easing function with a power of 3 shape (see link below).
  71755. * @see https://easings.net/#easeInCubic
  71756. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71757. */
  71758. export class CubicEase extends EasingFunction implements IEasingFunction {
  71759. /** @hidden */
  71760. easeInCore(gradient: number): number;
  71761. }
  71762. /**
  71763. * Easing function with an elastic shape (see link below).
  71764. * @see https://easings.net/#easeInElastic
  71765. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71766. */
  71767. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71768. /** Defines the number of oscillations*/
  71769. oscillations: number;
  71770. /** Defines the amplitude of the oscillations*/
  71771. springiness: number;
  71772. /**
  71773. * Instantiates an elastic easing function
  71774. * @see https://easings.net/#easeInElastic
  71775. * @param oscillations Defines the number of oscillations
  71776. * @param springiness Defines the amplitude of the oscillations
  71777. */
  71778. constructor(
  71779. /** Defines the number of oscillations*/
  71780. oscillations?: number,
  71781. /** Defines the amplitude of the oscillations*/
  71782. springiness?: number);
  71783. /** @hidden */
  71784. easeInCore(gradient: number): number;
  71785. }
  71786. /**
  71787. * Easing function with an exponential shape (see link below).
  71788. * @see https://easings.net/#easeInExpo
  71789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71790. */
  71791. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71792. /** Defines the exponent of the function */
  71793. exponent: number;
  71794. /**
  71795. * Instantiates an exponential easing function
  71796. * @see https://easings.net/#easeInExpo
  71797. * @param exponent Defines the exponent of the function
  71798. */
  71799. constructor(
  71800. /** Defines the exponent of the function */
  71801. exponent?: number);
  71802. /** @hidden */
  71803. easeInCore(gradient: number): number;
  71804. }
  71805. /**
  71806. * Easing function with a power shape (see link below).
  71807. * @see https://easings.net/#easeInQuad
  71808. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71809. */
  71810. export class PowerEase extends EasingFunction implements IEasingFunction {
  71811. /** Defines the power of the function */
  71812. power: number;
  71813. /**
  71814. * Instantiates an power base easing function
  71815. * @see https://easings.net/#easeInQuad
  71816. * @param power Defines the power of the function
  71817. */
  71818. constructor(
  71819. /** Defines the power of the function */
  71820. power?: number);
  71821. /** @hidden */
  71822. easeInCore(gradient: number): number;
  71823. }
  71824. /**
  71825. * Easing function with a power of 2 shape (see link below).
  71826. * @see https://easings.net/#easeInQuad
  71827. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71828. */
  71829. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71830. /** @hidden */
  71831. easeInCore(gradient: number): number;
  71832. }
  71833. /**
  71834. * Easing function with a power of 4 shape (see link below).
  71835. * @see https://easings.net/#easeInQuart
  71836. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71837. */
  71838. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71839. /** @hidden */
  71840. easeInCore(gradient: number): number;
  71841. }
  71842. /**
  71843. * Easing function with a power of 5 shape (see link below).
  71844. * @see https://easings.net/#easeInQuint
  71845. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71846. */
  71847. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71848. /** @hidden */
  71849. easeInCore(gradient: number): number;
  71850. }
  71851. /**
  71852. * Easing function with a sin shape (see link below).
  71853. * @see https://easings.net/#easeInSine
  71854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71855. */
  71856. export class SineEase extends EasingFunction implements IEasingFunction {
  71857. /** @hidden */
  71858. easeInCore(gradient: number): number;
  71859. }
  71860. /**
  71861. * Easing function with a bezier shape (see link below).
  71862. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71863. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71864. */
  71865. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71866. /** Defines the x component of the start tangent in the bezier curve */
  71867. x1: number;
  71868. /** Defines the y component of the start tangent in the bezier curve */
  71869. y1: number;
  71870. /** Defines the x component of the end tangent in the bezier curve */
  71871. x2: number;
  71872. /** Defines the y component of the end tangent in the bezier curve */
  71873. y2: number;
  71874. /**
  71875. * Instantiates a bezier function
  71876. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71877. * @param x1 Defines the x component of the start tangent in the bezier curve
  71878. * @param y1 Defines the y component of the start tangent in the bezier curve
  71879. * @param x2 Defines the x component of the end tangent in the bezier curve
  71880. * @param y2 Defines the y component of the end tangent in the bezier curve
  71881. */
  71882. constructor(
  71883. /** Defines the x component of the start tangent in the bezier curve */
  71884. x1?: number,
  71885. /** Defines the y component of the start tangent in the bezier curve */
  71886. y1?: number,
  71887. /** Defines the x component of the end tangent in the bezier curve */
  71888. x2?: number,
  71889. /** Defines the y component of the end tangent in the bezier curve */
  71890. y2?: number);
  71891. /** @hidden */
  71892. easeInCore(gradient: number): number;
  71893. }
  71894. }
  71895. declare module BABYLON {
  71896. /**
  71897. * Class used to hold a RBG color
  71898. */
  71899. export class Color3 {
  71900. /**
  71901. * Defines the red component (between 0 and 1, default is 0)
  71902. */
  71903. r: number;
  71904. /**
  71905. * Defines the green component (between 0 and 1, default is 0)
  71906. */
  71907. g: number;
  71908. /**
  71909. * Defines the blue component (between 0 and 1, default is 0)
  71910. */
  71911. b: number;
  71912. /**
  71913. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  71914. * @param r defines the red component (between 0 and 1, default is 0)
  71915. * @param g defines the green component (between 0 and 1, default is 0)
  71916. * @param b defines the blue component (between 0 and 1, default is 0)
  71917. */
  71918. constructor(
  71919. /**
  71920. * Defines the red component (between 0 and 1, default is 0)
  71921. */
  71922. r?: number,
  71923. /**
  71924. * Defines the green component (between 0 and 1, default is 0)
  71925. */
  71926. g?: number,
  71927. /**
  71928. * Defines the blue component (between 0 and 1, default is 0)
  71929. */
  71930. b?: number);
  71931. /**
  71932. * Creates a string with the Color3 current values
  71933. * @returns the string representation of the Color3 object
  71934. */
  71935. toString(): string;
  71936. /**
  71937. * Returns the string "Color3"
  71938. * @returns "Color3"
  71939. */
  71940. getClassName(): string;
  71941. /**
  71942. * Compute the Color3 hash code
  71943. * @returns an unique number that can be used to hash Color3 objects
  71944. */
  71945. getHashCode(): number;
  71946. /**
  71947. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  71948. * @param array defines the array where to store the r,g,b components
  71949. * @param index defines an optional index in the target array to define where to start storing values
  71950. * @returns the current Color3 object
  71951. */
  71952. toArray(array: FloatArray, index?: number): Color3;
  71953. /**
  71954. * Returns a new Color4 object from the current Color3 and the given alpha
  71955. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  71956. * @returns a new Color4 object
  71957. */
  71958. toColor4(alpha?: number): Color4;
  71959. /**
  71960. * Returns a new array populated with 3 numeric elements : red, green and blue values
  71961. * @returns the new array
  71962. */
  71963. asArray(): number[];
  71964. /**
  71965. * Returns the luminance value
  71966. * @returns a float value
  71967. */
  71968. toLuminance(): number;
  71969. /**
  71970. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  71971. * @param otherColor defines the second operand
  71972. * @returns the new Color3 object
  71973. */
  71974. multiply(otherColor: DeepImmutable<Color3>): Color3;
  71975. /**
  71976. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  71977. * @param otherColor defines the second operand
  71978. * @param result defines the Color3 object where to store the result
  71979. * @returns the current Color3
  71980. */
  71981. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  71982. /**
  71983. * Determines equality between Color3 objects
  71984. * @param otherColor defines the second operand
  71985. * @returns true if the rgb values are equal to the given ones
  71986. */
  71987. equals(otherColor: DeepImmutable<Color3>): boolean;
  71988. /**
  71989. * Determines equality between the current Color3 object and a set of r,b,g values
  71990. * @param r defines the red component to check
  71991. * @param g defines the green component to check
  71992. * @param b defines the blue component to check
  71993. * @returns true if the rgb values are equal to the given ones
  71994. */
  71995. equalsFloats(r: number, g: number, b: number): boolean;
  71996. /**
  71997. * Multiplies in place each rgb value by scale
  71998. * @param scale defines the scaling factor
  71999. * @returns the updated Color3
  72000. */
  72001. scale(scale: number): Color3;
  72002. /**
  72003. * Multiplies the rgb values by scale and stores the result into "result"
  72004. * @param scale defines the scaling factor
  72005. * @param result defines the Color3 object where to store the result
  72006. * @returns the unmodified current Color3
  72007. */
  72008. scaleToRef(scale: number, result: Color3): Color3;
  72009. /**
  72010. * Scale the current Color3 values by a factor and add the result to a given Color3
  72011. * @param scale defines the scale factor
  72012. * @param result defines color to store the result into
  72013. * @returns the unmodified current Color3
  72014. */
  72015. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72016. /**
  72017. * Clamps the rgb values by the min and max values and stores the result into "result"
  72018. * @param min defines minimum clamping value (default is 0)
  72019. * @param max defines maximum clamping value (default is 1)
  72020. * @param result defines color to store the result into
  72021. * @returns the original Color3
  72022. */
  72023. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72024. /**
  72025. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72026. * @param otherColor defines the second operand
  72027. * @returns the new Color3
  72028. */
  72029. add(otherColor: DeepImmutable<Color3>): Color3;
  72030. /**
  72031. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72032. * @param otherColor defines the second operand
  72033. * @param result defines Color3 object to store the result into
  72034. * @returns the unmodified current Color3
  72035. */
  72036. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72037. /**
  72038. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72039. * @param otherColor defines the second operand
  72040. * @returns the new Color3
  72041. */
  72042. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72043. /**
  72044. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72045. * @param otherColor defines the second operand
  72046. * @param result defines Color3 object to store the result into
  72047. * @returns the unmodified current Color3
  72048. */
  72049. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72050. /**
  72051. * Copy the current object
  72052. * @returns a new Color3 copied the current one
  72053. */
  72054. clone(): Color3;
  72055. /**
  72056. * Copies the rgb values from the source in the current Color3
  72057. * @param source defines the source Color3 object
  72058. * @returns the updated Color3 object
  72059. */
  72060. copyFrom(source: DeepImmutable<Color3>): Color3;
  72061. /**
  72062. * Updates the Color3 rgb values from the given floats
  72063. * @param r defines the red component to read from
  72064. * @param g defines the green component to read from
  72065. * @param b defines the blue component to read from
  72066. * @returns the current Color3 object
  72067. */
  72068. copyFromFloats(r: number, g: number, b: number): Color3;
  72069. /**
  72070. * Updates the Color3 rgb values from the given floats
  72071. * @param r defines the red component to read from
  72072. * @param g defines the green component to read from
  72073. * @param b defines the blue component to read from
  72074. * @returns the current Color3 object
  72075. */
  72076. set(r: number, g: number, b: number): Color3;
  72077. /**
  72078. * Compute the Color3 hexadecimal code as a string
  72079. * @returns a string containing the hexadecimal representation of the Color3 object
  72080. */
  72081. toHexString(): string;
  72082. /**
  72083. * Computes a new Color3 converted from the current one to linear space
  72084. * @returns a new Color3 object
  72085. */
  72086. toLinearSpace(): Color3;
  72087. /**
  72088. * Converts current color in rgb space to HSV values
  72089. * @returns a new color3 representing the HSV values
  72090. */
  72091. toHSV(): Color3;
  72092. /**
  72093. * Converts current color in rgb space to HSV values
  72094. * @param result defines the Color3 where to store the HSV values
  72095. */
  72096. toHSVToRef(result: Color3): void;
  72097. /**
  72098. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72099. * @param convertedColor defines the Color3 object where to store the linear space version
  72100. * @returns the unmodified Color3
  72101. */
  72102. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72103. /**
  72104. * Computes a new Color3 converted from the current one to gamma space
  72105. * @returns a new Color3 object
  72106. */
  72107. toGammaSpace(): Color3;
  72108. /**
  72109. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72110. * @param convertedColor defines the Color3 object where to store the gamma space version
  72111. * @returns the unmodified Color3
  72112. */
  72113. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72114. private static _BlackReadOnly;
  72115. /**
  72116. * Convert Hue, saturation and value to a Color3 (RGB)
  72117. * @param hue defines the hue
  72118. * @param saturation defines the saturation
  72119. * @param value defines the value
  72120. * @param result defines the Color3 where to store the RGB values
  72121. */
  72122. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72123. /**
  72124. * Creates a new Color3 from the string containing valid hexadecimal values
  72125. * @param hex defines a string containing valid hexadecimal values
  72126. * @returns a new Color3 object
  72127. */
  72128. static FromHexString(hex: string): Color3;
  72129. /**
  72130. * Creates a new Color3 from the starting index of the given array
  72131. * @param array defines the source array
  72132. * @param offset defines an offset in the source array
  72133. * @returns a new Color3 object
  72134. */
  72135. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72136. /**
  72137. * Creates a new Color3 from integer values (< 256)
  72138. * @param r defines the red component to read from (value between 0 and 255)
  72139. * @param g defines the green component to read from (value between 0 and 255)
  72140. * @param b defines the blue component to read from (value between 0 and 255)
  72141. * @returns a new Color3 object
  72142. */
  72143. static FromInts(r: number, g: number, b: number): Color3;
  72144. /**
  72145. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72146. * @param start defines the start Color3 value
  72147. * @param end defines the end Color3 value
  72148. * @param amount defines the gradient value between start and end
  72149. * @returns a new Color3 object
  72150. */
  72151. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72152. /**
  72153. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72154. * @param left defines the start value
  72155. * @param right defines the end value
  72156. * @param amount defines the gradient factor
  72157. * @param result defines the Color3 object where to store the result
  72158. */
  72159. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72160. /**
  72161. * Returns a Color3 value containing a red color
  72162. * @returns a new Color3 object
  72163. */
  72164. static Red(): Color3;
  72165. /**
  72166. * Returns a Color3 value containing a green color
  72167. * @returns a new Color3 object
  72168. */
  72169. static Green(): Color3;
  72170. /**
  72171. * Returns a Color3 value containing a blue color
  72172. * @returns a new Color3 object
  72173. */
  72174. static Blue(): Color3;
  72175. /**
  72176. * Returns a Color3 value containing a black color
  72177. * @returns a new Color3 object
  72178. */
  72179. static Black(): Color3;
  72180. /**
  72181. * Gets a Color3 value containing a black color that must not be updated
  72182. */
  72183. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72184. /**
  72185. * Returns a Color3 value containing a white color
  72186. * @returns a new Color3 object
  72187. */
  72188. static White(): Color3;
  72189. /**
  72190. * Returns a Color3 value containing a purple color
  72191. * @returns a new Color3 object
  72192. */
  72193. static Purple(): Color3;
  72194. /**
  72195. * Returns a Color3 value containing a magenta color
  72196. * @returns a new Color3 object
  72197. */
  72198. static Magenta(): Color3;
  72199. /**
  72200. * Returns a Color3 value containing a yellow color
  72201. * @returns a new Color3 object
  72202. */
  72203. static Yellow(): Color3;
  72204. /**
  72205. * Returns a Color3 value containing a gray color
  72206. * @returns a new Color3 object
  72207. */
  72208. static Gray(): Color3;
  72209. /**
  72210. * Returns a Color3 value containing a teal color
  72211. * @returns a new Color3 object
  72212. */
  72213. static Teal(): Color3;
  72214. /**
  72215. * Returns a Color3 value containing a random color
  72216. * @returns a new Color3 object
  72217. */
  72218. static Random(): Color3;
  72219. }
  72220. /**
  72221. * Class used to hold a RBGA color
  72222. */
  72223. export class Color4 {
  72224. /**
  72225. * Defines the red component (between 0 and 1, default is 0)
  72226. */
  72227. r: number;
  72228. /**
  72229. * Defines the green component (between 0 and 1, default is 0)
  72230. */
  72231. g: number;
  72232. /**
  72233. * Defines the blue component (between 0 and 1, default is 0)
  72234. */
  72235. b: number;
  72236. /**
  72237. * Defines the alpha component (between 0 and 1, default is 1)
  72238. */
  72239. a: number;
  72240. /**
  72241. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72242. * @param r defines the red component (between 0 and 1, default is 0)
  72243. * @param g defines the green component (between 0 and 1, default is 0)
  72244. * @param b defines the blue component (between 0 and 1, default is 0)
  72245. * @param a defines the alpha component (between 0 and 1, default is 1)
  72246. */
  72247. constructor(
  72248. /**
  72249. * Defines the red component (between 0 and 1, default is 0)
  72250. */
  72251. r?: number,
  72252. /**
  72253. * Defines the green component (between 0 and 1, default is 0)
  72254. */
  72255. g?: number,
  72256. /**
  72257. * Defines the blue component (between 0 and 1, default is 0)
  72258. */
  72259. b?: number,
  72260. /**
  72261. * Defines the alpha component (between 0 and 1, default is 1)
  72262. */
  72263. a?: number);
  72264. /**
  72265. * Adds in place the given Color4 values to the current Color4 object
  72266. * @param right defines the second operand
  72267. * @returns the current updated Color4 object
  72268. */
  72269. addInPlace(right: DeepImmutable<Color4>): Color4;
  72270. /**
  72271. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72272. * @returns the new array
  72273. */
  72274. asArray(): number[];
  72275. /**
  72276. * Stores from the starting index in the given array the Color4 successive values
  72277. * @param array defines the array where to store the r,g,b components
  72278. * @param index defines an optional index in the target array to define where to start storing values
  72279. * @returns the current Color4 object
  72280. */
  72281. toArray(array: number[], index?: number): Color4;
  72282. /**
  72283. * Determines equality between Color4 objects
  72284. * @param otherColor defines the second operand
  72285. * @returns true if the rgba values are equal to the given ones
  72286. */
  72287. equals(otherColor: DeepImmutable<Color4>): boolean;
  72288. /**
  72289. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72290. * @param right defines the second operand
  72291. * @returns a new Color4 object
  72292. */
  72293. add(right: DeepImmutable<Color4>): Color4;
  72294. /**
  72295. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72296. * @param right defines the second operand
  72297. * @returns a new Color4 object
  72298. */
  72299. subtract(right: DeepImmutable<Color4>): Color4;
  72300. /**
  72301. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72302. * @param right defines the second operand
  72303. * @param result defines the Color4 object where to store the result
  72304. * @returns the current Color4 object
  72305. */
  72306. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72307. /**
  72308. * Creates a new Color4 with the current Color4 values multiplied by scale
  72309. * @param scale defines the scaling factor to apply
  72310. * @returns a new Color4 object
  72311. */
  72312. scale(scale: number): Color4;
  72313. /**
  72314. * Multiplies the current Color4 values by scale and stores the result in "result"
  72315. * @param scale defines the scaling factor to apply
  72316. * @param result defines the Color4 object where to store the result
  72317. * @returns the current unmodified Color4
  72318. */
  72319. scaleToRef(scale: number, result: Color4): Color4;
  72320. /**
  72321. * Scale the current Color4 values by a factor and add the result to a given Color4
  72322. * @param scale defines the scale factor
  72323. * @param result defines the Color4 object where to store the result
  72324. * @returns the unmodified current Color4
  72325. */
  72326. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72327. /**
  72328. * Clamps the rgb values by the min and max values and stores the result into "result"
  72329. * @param min defines minimum clamping value (default is 0)
  72330. * @param max defines maximum clamping value (default is 1)
  72331. * @param result defines color to store the result into.
  72332. * @returns the cuurent Color4
  72333. */
  72334. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72335. /**
  72336. * Multipy an Color4 value by another and return a new Color4 object
  72337. * @param color defines the Color4 value to multiply by
  72338. * @returns a new Color4 object
  72339. */
  72340. multiply(color: Color4): Color4;
  72341. /**
  72342. * Multipy a Color4 value by another and push the result in a reference value
  72343. * @param color defines the Color4 value to multiply by
  72344. * @param result defines the Color4 to fill the result in
  72345. * @returns the result Color4
  72346. */
  72347. multiplyToRef(color: Color4, result: Color4): Color4;
  72348. /**
  72349. * Creates a string with the Color4 current values
  72350. * @returns the string representation of the Color4 object
  72351. */
  72352. toString(): string;
  72353. /**
  72354. * Returns the string "Color4"
  72355. * @returns "Color4"
  72356. */
  72357. getClassName(): string;
  72358. /**
  72359. * Compute the Color4 hash code
  72360. * @returns an unique number that can be used to hash Color4 objects
  72361. */
  72362. getHashCode(): number;
  72363. /**
  72364. * Creates a new Color4 copied from the current one
  72365. * @returns a new Color4 object
  72366. */
  72367. clone(): Color4;
  72368. /**
  72369. * Copies the given Color4 values into the current one
  72370. * @param source defines the source Color4 object
  72371. * @returns the current updated Color4 object
  72372. */
  72373. copyFrom(source: Color4): Color4;
  72374. /**
  72375. * Copies the given float values into the current one
  72376. * @param r defines the red component to read from
  72377. * @param g defines the green component to read from
  72378. * @param b defines the blue component to read from
  72379. * @param a defines the alpha component to read from
  72380. * @returns the current updated Color4 object
  72381. */
  72382. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  72383. /**
  72384. * Copies the given float values into the current one
  72385. * @param r defines the red component to read from
  72386. * @param g defines the green component to read from
  72387. * @param b defines the blue component to read from
  72388. * @param a defines the alpha component to read from
  72389. * @returns the current updated Color4 object
  72390. */
  72391. set(r: number, g: number, b: number, a: number): Color4;
  72392. /**
  72393. * Compute the Color4 hexadecimal code as a string
  72394. * @returns a string containing the hexadecimal representation of the Color4 object
  72395. */
  72396. toHexString(): string;
  72397. /**
  72398. * Computes a new Color4 converted from the current one to linear space
  72399. * @returns a new Color4 object
  72400. */
  72401. toLinearSpace(): Color4;
  72402. /**
  72403. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72404. * @param convertedColor defines the Color4 object where to store the linear space version
  72405. * @returns the unmodified Color4
  72406. */
  72407. toLinearSpaceToRef(convertedColor: Color4): Color4;
  72408. /**
  72409. * Computes a new Color4 converted from the current one to gamma space
  72410. * @returns a new Color4 object
  72411. */
  72412. toGammaSpace(): Color4;
  72413. /**
  72414. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72415. * @param convertedColor defines the Color4 object where to store the gamma space version
  72416. * @returns the unmodified Color4
  72417. */
  72418. toGammaSpaceToRef(convertedColor: Color4): Color4;
  72419. /**
  72420. * Creates a new Color4 from the string containing valid hexadecimal values
  72421. * @param hex defines a string containing valid hexadecimal values
  72422. * @returns a new Color4 object
  72423. */
  72424. static FromHexString(hex: string): Color4;
  72425. /**
  72426. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72427. * @param left defines the start value
  72428. * @param right defines the end value
  72429. * @param amount defines the gradient factor
  72430. * @returns a new Color4 object
  72431. */
  72432. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  72433. /**
  72434. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72435. * @param left defines the start value
  72436. * @param right defines the end value
  72437. * @param amount defines the gradient factor
  72438. * @param result defines the Color4 object where to store data
  72439. */
  72440. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  72441. /**
  72442. * Creates a new Color4 from a Color3 and an alpha value
  72443. * @param color3 defines the source Color3 to read from
  72444. * @param alpha defines the alpha component (1.0 by default)
  72445. * @returns a new Color4 object
  72446. */
  72447. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  72448. /**
  72449. * Creates a new Color4 from the starting index element of the given array
  72450. * @param array defines the source array to read from
  72451. * @param offset defines the offset in the source array
  72452. * @returns a new Color4 object
  72453. */
  72454. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  72455. /**
  72456. * Creates a new Color3 from integer values (< 256)
  72457. * @param r defines the red component to read from (value between 0 and 255)
  72458. * @param g defines the green component to read from (value between 0 and 255)
  72459. * @param b defines the blue component to read from (value between 0 and 255)
  72460. * @param a defines the alpha component to read from (value between 0 and 255)
  72461. * @returns a new Color3 object
  72462. */
  72463. static FromInts(r: number, g: number, b: number, a: number): Color4;
  72464. /**
  72465. * Check the content of a given array and convert it to an array containing RGBA data
  72466. * If the original array was already containing count * 4 values then it is returned directly
  72467. * @param colors defines the array to check
  72468. * @param count defines the number of RGBA data to expect
  72469. * @returns an array containing count * 4 values (RGBA)
  72470. */
  72471. static CheckColors4(colors: number[], count: number): number[];
  72472. }
  72473. /**
  72474. * @hidden
  72475. */
  72476. export class TmpColors {
  72477. static Color3: Color3[];
  72478. static Color4: Color4[];
  72479. }
  72480. }
  72481. declare module BABYLON {
  72482. /**
  72483. * Defines an interface which represents an animation key frame
  72484. */
  72485. export interface IAnimationKey {
  72486. /**
  72487. * Frame of the key frame
  72488. */
  72489. frame: number;
  72490. /**
  72491. * Value at the specifies key frame
  72492. */
  72493. value: any;
  72494. /**
  72495. * The input tangent for the cubic hermite spline
  72496. */
  72497. inTangent?: any;
  72498. /**
  72499. * The output tangent for the cubic hermite spline
  72500. */
  72501. outTangent?: any;
  72502. /**
  72503. * The animation interpolation type
  72504. */
  72505. interpolation?: AnimationKeyInterpolation;
  72506. }
  72507. /**
  72508. * Enum for the animation key frame interpolation type
  72509. */
  72510. export enum AnimationKeyInterpolation {
  72511. /**
  72512. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72513. */
  72514. STEP = 1
  72515. }
  72516. }
  72517. declare module BABYLON {
  72518. /**
  72519. * Represents the range of an animation
  72520. */
  72521. export class AnimationRange {
  72522. /**The name of the animation range**/
  72523. name: string;
  72524. /**The starting frame of the animation */
  72525. from: number;
  72526. /**The ending frame of the animation*/
  72527. to: number;
  72528. /**
  72529. * Initializes the range of an animation
  72530. * @param name The name of the animation range
  72531. * @param from The starting frame of the animation
  72532. * @param to The ending frame of the animation
  72533. */
  72534. constructor(
  72535. /**The name of the animation range**/
  72536. name: string,
  72537. /**The starting frame of the animation */
  72538. from: number,
  72539. /**The ending frame of the animation*/
  72540. to: number);
  72541. /**
  72542. * Makes a copy of the animation range
  72543. * @returns A copy of the animation range
  72544. */
  72545. clone(): AnimationRange;
  72546. }
  72547. }
  72548. declare module BABYLON {
  72549. /**
  72550. * Composed of a frame, and an action function
  72551. */
  72552. export class AnimationEvent {
  72553. /** The frame for which the event is triggered **/
  72554. frame: number;
  72555. /** The event to perform when triggered **/
  72556. action: (currentFrame: number) => void;
  72557. /** Specifies if the event should be triggered only once**/
  72558. onlyOnce?: boolean | undefined;
  72559. /**
  72560. * Specifies if the animation event is done
  72561. */
  72562. isDone: boolean;
  72563. /**
  72564. * Initializes the animation event
  72565. * @param frame The frame for which the event is triggered
  72566. * @param action The event to perform when triggered
  72567. * @param onlyOnce Specifies if the event should be triggered only once
  72568. */
  72569. constructor(
  72570. /** The frame for which the event is triggered **/
  72571. frame: number,
  72572. /** The event to perform when triggered **/
  72573. action: (currentFrame: number) => void,
  72574. /** Specifies if the event should be triggered only once**/
  72575. onlyOnce?: boolean | undefined);
  72576. /** @hidden */
  72577. _clone(): AnimationEvent;
  72578. }
  72579. }
  72580. declare module BABYLON {
  72581. /**
  72582. * Interface used to define a behavior
  72583. */
  72584. export interface Behavior<T> {
  72585. /** gets or sets behavior's name */
  72586. name: string;
  72587. /**
  72588. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72589. */
  72590. init(): void;
  72591. /**
  72592. * Called when the behavior is attached to a target
  72593. * @param target defines the target where the behavior is attached to
  72594. */
  72595. attach(target: T): void;
  72596. /**
  72597. * Called when the behavior is detached from its target
  72598. */
  72599. detach(): void;
  72600. }
  72601. /**
  72602. * Interface implemented by classes supporting behaviors
  72603. */
  72604. export interface IBehaviorAware<T> {
  72605. /**
  72606. * Attach a behavior
  72607. * @param behavior defines the behavior to attach
  72608. * @returns the current host
  72609. */
  72610. addBehavior(behavior: Behavior<T>): T;
  72611. /**
  72612. * Remove a behavior from the current object
  72613. * @param behavior defines the behavior to detach
  72614. * @returns the current host
  72615. */
  72616. removeBehavior(behavior: Behavior<T>): T;
  72617. /**
  72618. * Gets a behavior using its name to search
  72619. * @param name defines the name to search
  72620. * @returns the behavior or null if not found
  72621. */
  72622. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72623. }
  72624. }
  72625. declare module BABYLON {
  72626. /**
  72627. * Defines an array and its length.
  72628. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72629. */
  72630. export interface ISmartArrayLike<T> {
  72631. /**
  72632. * The data of the array.
  72633. */
  72634. data: Array<T>;
  72635. /**
  72636. * The active length of the array.
  72637. */
  72638. length: number;
  72639. }
  72640. /**
  72641. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72642. */
  72643. export class SmartArray<T> implements ISmartArrayLike<T> {
  72644. /**
  72645. * The full set of data from the array.
  72646. */
  72647. data: Array<T>;
  72648. /**
  72649. * The active length of the array.
  72650. */
  72651. length: number;
  72652. protected _id: number;
  72653. /**
  72654. * Instantiates a Smart Array.
  72655. * @param capacity defines the default capacity of the array.
  72656. */
  72657. constructor(capacity: number);
  72658. /**
  72659. * Pushes a value at the end of the active data.
  72660. * @param value defines the object to push in the array.
  72661. */
  72662. push(value: T): void;
  72663. /**
  72664. * Iterates over the active data and apply the lambda to them.
  72665. * @param func defines the action to apply on each value.
  72666. */
  72667. forEach(func: (content: T) => void): void;
  72668. /**
  72669. * Sorts the full sets of data.
  72670. * @param compareFn defines the comparison function to apply.
  72671. */
  72672. sort(compareFn: (a: T, b: T) => number): void;
  72673. /**
  72674. * Resets the active data to an empty array.
  72675. */
  72676. reset(): void;
  72677. /**
  72678. * Releases all the data from the array as well as the array.
  72679. */
  72680. dispose(): void;
  72681. /**
  72682. * Concats the active data with a given array.
  72683. * @param array defines the data to concatenate with.
  72684. */
  72685. concat(array: any): void;
  72686. /**
  72687. * Returns the position of a value in the active data.
  72688. * @param value defines the value to find the index for
  72689. * @returns the index if found in the active data otherwise -1
  72690. */
  72691. indexOf(value: T): number;
  72692. /**
  72693. * Returns whether an element is part of the active data.
  72694. * @param value defines the value to look for
  72695. * @returns true if found in the active data otherwise false
  72696. */
  72697. contains(value: T): boolean;
  72698. private static _GlobalId;
  72699. }
  72700. /**
  72701. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72702. * The data in this array can only be present once
  72703. */
  72704. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72705. private _duplicateId;
  72706. /**
  72707. * Pushes a value at the end of the active data.
  72708. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72709. * @param value defines the object to push in the array.
  72710. */
  72711. push(value: T): void;
  72712. /**
  72713. * Pushes a value at the end of the active data.
  72714. * If the data is already present, it won t be added again
  72715. * @param value defines the object to push in the array.
  72716. * @returns true if added false if it was already present
  72717. */
  72718. pushNoDuplicate(value: T): boolean;
  72719. /**
  72720. * Resets the active data to an empty array.
  72721. */
  72722. reset(): void;
  72723. /**
  72724. * Concats the active data with a given array.
  72725. * This ensures no dupplicate will be present in the result.
  72726. * @param array defines the data to concatenate with.
  72727. */
  72728. concatWithNoDuplicate(array: any): void;
  72729. }
  72730. }
  72731. declare module BABYLON {
  72732. /**
  72733. * @ignore
  72734. * This is a list of all the different input types that are available in the application.
  72735. * Fo instance: ArcRotateCameraGamepadInput...
  72736. */
  72737. export var CameraInputTypes: {};
  72738. /**
  72739. * This is the contract to implement in order to create a new input class.
  72740. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72741. */
  72742. export interface ICameraInput<TCamera extends Camera> {
  72743. /**
  72744. * Defines the camera the input is attached to.
  72745. */
  72746. camera: Nullable<TCamera>;
  72747. /**
  72748. * Gets the class name of the current intput.
  72749. * @returns the class name
  72750. */
  72751. getClassName(): string;
  72752. /**
  72753. * Get the friendly name associated with the input class.
  72754. * @returns the input friendly name
  72755. */
  72756. getSimpleName(): string;
  72757. /**
  72758. * Attach the input controls to a specific dom element to get the input from.
  72759. * @param element Defines the element the controls should be listened from
  72760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72761. */
  72762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72763. /**
  72764. * Detach the current controls from the specified dom element.
  72765. * @param element Defines the element to stop listening the inputs from
  72766. */
  72767. detachControl(element: Nullable<HTMLElement>): void;
  72768. /**
  72769. * Update the current camera state depending on the inputs that have been used this frame.
  72770. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72771. */
  72772. checkInputs?: () => void;
  72773. }
  72774. /**
  72775. * Represents a map of input types to input instance or input index to input instance.
  72776. */
  72777. export interface CameraInputsMap<TCamera extends Camera> {
  72778. /**
  72779. * Accessor to the input by input type.
  72780. */
  72781. [name: string]: ICameraInput<TCamera>;
  72782. /**
  72783. * Accessor to the input by input index.
  72784. */
  72785. [idx: number]: ICameraInput<TCamera>;
  72786. }
  72787. /**
  72788. * This represents the input manager used within a camera.
  72789. * It helps dealing with all the different kind of input attached to a camera.
  72790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72791. */
  72792. export class CameraInputsManager<TCamera extends Camera> {
  72793. /**
  72794. * Defines the list of inputs attahed to the camera.
  72795. */
  72796. attached: CameraInputsMap<TCamera>;
  72797. /**
  72798. * Defines the dom element the camera is collecting inputs from.
  72799. * This is null if the controls have not been attached.
  72800. */
  72801. attachedElement: Nullable<HTMLElement>;
  72802. /**
  72803. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72804. */
  72805. noPreventDefault: boolean;
  72806. /**
  72807. * Defined the camera the input manager belongs to.
  72808. */
  72809. camera: TCamera;
  72810. /**
  72811. * Update the current camera state depending on the inputs that have been used this frame.
  72812. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72813. */
  72814. checkInputs: () => void;
  72815. /**
  72816. * Instantiate a new Camera Input Manager.
  72817. * @param camera Defines the camera the input manager blongs to
  72818. */
  72819. constructor(camera: TCamera);
  72820. /**
  72821. * Add an input method to a camera
  72822. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72823. * @param input camera input method
  72824. */
  72825. add(input: ICameraInput<TCamera>): void;
  72826. /**
  72827. * Remove a specific input method from a camera
  72828. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72829. * @param inputToRemove camera input method
  72830. */
  72831. remove(inputToRemove: ICameraInput<TCamera>): void;
  72832. /**
  72833. * Remove a specific input type from a camera
  72834. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72835. * @param inputType the type of the input to remove
  72836. */
  72837. removeByType(inputType: string): void;
  72838. private _addCheckInputs;
  72839. /**
  72840. * Attach the input controls to the currently attached dom element to listen the events from.
  72841. * @param input Defines the input to attach
  72842. */
  72843. attachInput(input: ICameraInput<TCamera>): void;
  72844. /**
  72845. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72846. * @param element Defines the dom element to collect the events from
  72847. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72848. */
  72849. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72850. /**
  72851. * Detach the current manager inputs controls from a specific dom element.
  72852. * @param element Defines the dom element to collect the events from
  72853. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72854. */
  72855. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72856. /**
  72857. * Rebuild the dynamic inputCheck function from the current list of
  72858. * defined inputs in the manager.
  72859. */
  72860. rebuildInputCheck(): void;
  72861. /**
  72862. * Remove all attached input methods from a camera
  72863. */
  72864. clear(): void;
  72865. /**
  72866. * Serialize the current input manager attached to a camera.
  72867. * This ensures than once parsed,
  72868. * the input associated to the camera will be identical to the current ones
  72869. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72870. */
  72871. serialize(serializedCamera: any): void;
  72872. /**
  72873. * Parses an input manager serialized JSON to restore the previous list of inputs
  72874. * and states associated to a camera.
  72875. * @param parsedCamera Defines the JSON to parse
  72876. */
  72877. parse(parsedCamera: any): void;
  72878. }
  72879. }
  72880. declare module BABYLON {
  72881. /**
  72882. * Class used to store data that will be store in GPU memory
  72883. */
  72884. export class Buffer {
  72885. private _engine;
  72886. private _buffer;
  72887. /** @hidden */
  72888. _data: Nullable<DataArray>;
  72889. private _updatable;
  72890. private _instanced;
  72891. /**
  72892. * Gets the byte stride.
  72893. */
  72894. readonly byteStride: number;
  72895. /**
  72896. * Constructor
  72897. * @param engine the engine
  72898. * @param data the data to use for this buffer
  72899. * @param updatable whether the data is updatable
  72900. * @param stride the stride (optional)
  72901. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72902. * @param instanced whether the buffer is instanced (optional)
  72903. * @param useBytes set to true if the stride in in bytes (optional)
  72904. */
  72905. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72906. /**
  72907. * Create a new VertexBuffer based on the current buffer
  72908. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72909. * @param offset defines offset in the buffer (0 by default)
  72910. * @param size defines the size in floats of attributes (position is 3 for instance)
  72911. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72912. * @param instanced defines if the vertex buffer contains indexed data
  72913. * @param useBytes defines if the offset and stride are in bytes
  72914. * @returns the new vertex buffer
  72915. */
  72916. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72917. /**
  72918. * Gets a boolean indicating if the Buffer is updatable?
  72919. * @returns true if the buffer is updatable
  72920. */
  72921. isUpdatable(): boolean;
  72922. /**
  72923. * Gets current buffer's data
  72924. * @returns a DataArray or null
  72925. */
  72926. getData(): Nullable<DataArray>;
  72927. /**
  72928. * Gets underlying native buffer
  72929. * @returns underlying native buffer
  72930. */
  72931. getBuffer(): Nullable<DataBuffer>;
  72932. /**
  72933. * Gets the stride in float32 units (i.e. byte stride / 4).
  72934. * May not be an integer if the byte stride is not divisible by 4.
  72935. * DEPRECATED. Use byteStride instead.
  72936. * @returns the stride in float32 units
  72937. */
  72938. getStrideSize(): number;
  72939. /**
  72940. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72941. * @param data defines the data to store
  72942. */
  72943. create(data?: Nullable<DataArray>): void;
  72944. /** @hidden */
  72945. _rebuild(): void;
  72946. /**
  72947. * Update current buffer data
  72948. * @param data defines the data to store
  72949. */
  72950. update(data: DataArray): void;
  72951. /**
  72952. * Updates the data directly.
  72953. * @param data the new data
  72954. * @param offset the new offset
  72955. * @param vertexCount the vertex count (optional)
  72956. * @param useBytes set to true if the offset is in bytes
  72957. */
  72958. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72959. /**
  72960. * Release all resources
  72961. */
  72962. dispose(): void;
  72963. }
  72964. /**
  72965. * Specialized buffer used to store vertex data
  72966. */
  72967. export class VertexBuffer {
  72968. /** @hidden */
  72969. _buffer: Buffer;
  72970. private _kind;
  72971. private _size;
  72972. private _ownsBuffer;
  72973. private _instanced;
  72974. private _instanceDivisor;
  72975. /**
  72976. * The byte type.
  72977. */
  72978. static readonly BYTE: number;
  72979. /**
  72980. * The unsigned byte type.
  72981. */
  72982. static readonly UNSIGNED_BYTE: number;
  72983. /**
  72984. * The short type.
  72985. */
  72986. static readonly SHORT: number;
  72987. /**
  72988. * The unsigned short type.
  72989. */
  72990. static readonly UNSIGNED_SHORT: number;
  72991. /**
  72992. * The integer type.
  72993. */
  72994. static readonly INT: number;
  72995. /**
  72996. * The unsigned integer type.
  72997. */
  72998. static readonly UNSIGNED_INT: number;
  72999. /**
  73000. * The float type.
  73001. */
  73002. static readonly FLOAT: number;
  73003. /**
  73004. * Gets or sets the instance divisor when in instanced mode
  73005. */
  73006. instanceDivisor: number;
  73007. /**
  73008. * Gets the byte stride.
  73009. */
  73010. readonly byteStride: number;
  73011. /**
  73012. * Gets the byte offset.
  73013. */
  73014. readonly byteOffset: number;
  73015. /**
  73016. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73017. */
  73018. readonly normalized: boolean;
  73019. /**
  73020. * Gets the data type of each component in the array.
  73021. */
  73022. readonly type: number;
  73023. /**
  73024. * Constructor
  73025. * @param engine the engine
  73026. * @param data the data to use for this vertex buffer
  73027. * @param kind the vertex buffer kind
  73028. * @param updatable whether the data is updatable
  73029. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73030. * @param stride the stride (optional)
  73031. * @param instanced whether the buffer is instanced (optional)
  73032. * @param offset the offset of the data (optional)
  73033. * @param size the number of components (optional)
  73034. * @param type the type of the component (optional)
  73035. * @param normalized whether the data contains normalized data (optional)
  73036. * @param useBytes set to true if stride and offset are in bytes (optional)
  73037. */
  73038. 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);
  73039. /** @hidden */
  73040. _rebuild(): void;
  73041. /**
  73042. * Returns the kind of the VertexBuffer (string)
  73043. * @returns a string
  73044. */
  73045. getKind(): string;
  73046. /**
  73047. * Gets a boolean indicating if the VertexBuffer is updatable?
  73048. * @returns true if the buffer is updatable
  73049. */
  73050. isUpdatable(): boolean;
  73051. /**
  73052. * Gets current buffer's data
  73053. * @returns a DataArray or null
  73054. */
  73055. getData(): Nullable<DataArray>;
  73056. /**
  73057. * Gets underlying native buffer
  73058. * @returns underlying native buffer
  73059. */
  73060. getBuffer(): Nullable<DataBuffer>;
  73061. /**
  73062. * Gets the stride in float32 units (i.e. byte stride / 4).
  73063. * May not be an integer if the byte stride is not divisible by 4.
  73064. * DEPRECATED. Use byteStride instead.
  73065. * @returns the stride in float32 units
  73066. */
  73067. getStrideSize(): number;
  73068. /**
  73069. * Returns the offset as a multiple of the type byte length.
  73070. * DEPRECATED. Use byteOffset instead.
  73071. * @returns the offset in bytes
  73072. */
  73073. getOffset(): number;
  73074. /**
  73075. * Returns the number of components per vertex attribute (integer)
  73076. * @returns the size in float
  73077. */
  73078. getSize(): number;
  73079. /**
  73080. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73081. * @returns true if this buffer is instanced
  73082. */
  73083. getIsInstanced(): boolean;
  73084. /**
  73085. * Returns the instancing divisor, zero for non-instanced (integer).
  73086. * @returns a number
  73087. */
  73088. getInstanceDivisor(): number;
  73089. /**
  73090. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73091. * @param data defines the data to store
  73092. */
  73093. create(data?: DataArray): void;
  73094. /**
  73095. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73096. * This function will create a new buffer if the current one is not updatable
  73097. * @param data defines the data to store
  73098. */
  73099. update(data: DataArray): void;
  73100. /**
  73101. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73102. * Returns the directly updated WebGLBuffer.
  73103. * @param data the new data
  73104. * @param offset the new offset
  73105. * @param useBytes set to true if the offset is in bytes
  73106. */
  73107. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73108. /**
  73109. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73110. */
  73111. dispose(): void;
  73112. /**
  73113. * Enumerates each value of this vertex buffer as numbers.
  73114. * @param count the number of values to enumerate
  73115. * @param callback the callback function called for each value
  73116. */
  73117. forEach(count: number, callback: (value: number, index: number) => void): void;
  73118. /**
  73119. * Positions
  73120. */
  73121. static readonly PositionKind: string;
  73122. /**
  73123. * Normals
  73124. */
  73125. static readonly NormalKind: string;
  73126. /**
  73127. * Tangents
  73128. */
  73129. static readonly TangentKind: string;
  73130. /**
  73131. * Texture coordinates
  73132. */
  73133. static readonly UVKind: string;
  73134. /**
  73135. * Texture coordinates 2
  73136. */
  73137. static readonly UV2Kind: string;
  73138. /**
  73139. * Texture coordinates 3
  73140. */
  73141. static readonly UV3Kind: string;
  73142. /**
  73143. * Texture coordinates 4
  73144. */
  73145. static readonly UV4Kind: string;
  73146. /**
  73147. * Texture coordinates 5
  73148. */
  73149. static readonly UV5Kind: string;
  73150. /**
  73151. * Texture coordinates 6
  73152. */
  73153. static readonly UV6Kind: string;
  73154. /**
  73155. * Colors
  73156. */
  73157. static readonly ColorKind: string;
  73158. /**
  73159. * Matrix indices (for bones)
  73160. */
  73161. static readonly MatricesIndicesKind: string;
  73162. /**
  73163. * Matrix weights (for bones)
  73164. */
  73165. static readonly MatricesWeightsKind: string;
  73166. /**
  73167. * Additional matrix indices (for bones)
  73168. */
  73169. static readonly MatricesIndicesExtraKind: string;
  73170. /**
  73171. * Additional matrix weights (for bones)
  73172. */
  73173. static readonly MatricesWeightsExtraKind: string;
  73174. /**
  73175. * Deduces the stride given a kind.
  73176. * @param kind The kind string to deduce
  73177. * @returns The deduced stride
  73178. */
  73179. static DeduceStride(kind: string): number;
  73180. /**
  73181. * Gets the byte length of the given type.
  73182. * @param type the type
  73183. * @returns the number of bytes
  73184. */
  73185. static GetTypeByteLength(type: number): number;
  73186. /**
  73187. * Enumerates each value of the given parameters as numbers.
  73188. * @param data the data to enumerate
  73189. * @param byteOffset the byte offset of the data
  73190. * @param byteStride the byte stride of the data
  73191. * @param componentCount the number of components per element
  73192. * @param componentType the type of the component
  73193. * @param count the number of values to enumerate
  73194. * @param normalized whether the data is normalized
  73195. * @param callback the callback function called for each value
  73196. */
  73197. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73198. private static _GetFloatValue;
  73199. }
  73200. }
  73201. declare module BABYLON {
  73202. /**
  73203. * @hidden
  73204. */
  73205. export class IntersectionInfo {
  73206. bu: Nullable<number>;
  73207. bv: Nullable<number>;
  73208. distance: number;
  73209. faceId: number;
  73210. subMeshId: number;
  73211. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73212. }
  73213. }
  73214. declare module BABYLON {
  73215. /**
  73216. * Represens a plane by the equation ax + by + cz + d = 0
  73217. */
  73218. export class Plane {
  73219. private static _TmpMatrix;
  73220. /**
  73221. * Normal of the plane (a,b,c)
  73222. */
  73223. normal: Vector3;
  73224. /**
  73225. * d component of the plane
  73226. */
  73227. d: number;
  73228. /**
  73229. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73230. * @param a a component of the plane
  73231. * @param b b component of the plane
  73232. * @param c c component of the plane
  73233. * @param d d component of the plane
  73234. */
  73235. constructor(a: number, b: number, c: number, d: number);
  73236. /**
  73237. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73238. */
  73239. asArray(): number[];
  73240. /**
  73241. * @returns a new plane copied from the current Plane.
  73242. */
  73243. clone(): Plane;
  73244. /**
  73245. * @returns the string "Plane".
  73246. */
  73247. getClassName(): string;
  73248. /**
  73249. * @returns the Plane hash code.
  73250. */
  73251. getHashCode(): number;
  73252. /**
  73253. * Normalize the current Plane in place.
  73254. * @returns the updated Plane.
  73255. */
  73256. normalize(): Plane;
  73257. /**
  73258. * Applies a transformation the plane and returns the result
  73259. * @param transformation the transformation matrix to be applied to the plane
  73260. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73261. */
  73262. transform(transformation: DeepImmutable<Matrix>): Plane;
  73263. /**
  73264. * Calcualtte the dot product between the point and the plane normal
  73265. * @param point point to calculate the dot product with
  73266. * @returns the dot product (float) of the point coordinates and the plane normal.
  73267. */
  73268. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73269. /**
  73270. * Updates the current Plane from the plane defined by the three given points.
  73271. * @param point1 one of the points used to contruct the plane
  73272. * @param point2 one of the points used to contruct the plane
  73273. * @param point3 one of the points used to contruct the plane
  73274. * @returns the updated Plane.
  73275. */
  73276. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73277. /**
  73278. * Checks if the plane is facing a given direction
  73279. * @param direction the direction to check if the plane is facing
  73280. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73281. * @returns True is the vector "direction" is the same side than the plane normal.
  73282. */
  73283. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73284. /**
  73285. * Calculates the distance to a point
  73286. * @param point point to calculate distance to
  73287. * @returns the signed distance (float) from the given point to the Plane.
  73288. */
  73289. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73290. /**
  73291. * Creates a plane from an array
  73292. * @param array the array to create a plane from
  73293. * @returns a new Plane from the given array.
  73294. */
  73295. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73296. /**
  73297. * Creates a plane from three points
  73298. * @param point1 point used to create the plane
  73299. * @param point2 point used to create the plane
  73300. * @param point3 point used to create the plane
  73301. * @returns a new Plane defined by the three given points.
  73302. */
  73303. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73304. /**
  73305. * Creates a plane from an origin point and a normal
  73306. * @param origin origin of the plane to be constructed
  73307. * @param normal normal of the plane to be constructed
  73308. * @returns a new Plane the normal vector to this plane at the given origin point.
  73309. * Note : the vector "normal" is updated because normalized.
  73310. */
  73311. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73312. /**
  73313. * Calculates the distance from a plane and a point
  73314. * @param origin origin of the plane to be constructed
  73315. * @param normal normal of the plane to be constructed
  73316. * @param point point to calculate distance to
  73317. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73318. */
  73319. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73320. }
  73321. }
  73322. declare module BABYLON {
  73323. /**
  73324. * Class used to store bounding sphere information
  73325. */
  73326. export class BoundingSphere {
  73327. /**
  73328. * Gets the center of the bounding sphere in local space
  73329. */
  73330. readonly center: Vector3;
  73331. /**
  73332. * Radius of the bounding sphere in local space
  73333. */
  73334. radius: number;
  73335. /**
  73336. * Gets the center of the bounding sphere in world space
  73337. */
  73338. readonly centerWorld: Vector3;
  73339. /**
  73340. * Radius of the bounding sphere in world space
  73341. */
  73342. radiusWorld: number;
  73343. /**
  73344. * Gets the minimum vector in local space
  73345. */
  73346. readonly minimum: Vector3;
  73347. /**
  73348. * Gets the maximum vector in local space
  73349. */
  73350. readonly maximum: Vector3;
  73351. private _worldMatrix;
  73352. private static readonly TmpVector3;
  73353. /**
  73354. * Creates a new bounding sphere
  73355. * @param min defines the minimum vector (in local space)
  73356. * @param max defines the maximum vector (in local space)
  73357. * @param worldMatrix defines the new world matrix
  73358. */
  73359. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73360. /**
  73361. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73362. * @param min defines the new minimum vector (in local space)
  73363. * @param max defines the new maximum vector (in local space)
  73364. * @param worldMatrix defines the new world matrix
  73365. */
  73366. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73367. /**
  73368. * Scale the current bounding sphere by applying a scale factor
  73369. * @param factor defines the scale factor to apply
  73370. * @returns the current bounding box
  73371. */
  73372. scale(factor: number): BoundingSphere;
  73373. /**
  73374. * Gets the world matrix of the bounding box
  73375. * @returns a matrix
  73376. */
  73377. getWorldMatrix(): DeepImmutable<Matrix>;
  73378. /** @hidden */
  73379. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73380. /**
  73381. * Tests if the bounding sphere is intersecting the frustum planes
  73382. * @param frustumPlanes defines the frustum planes to test
  73383. * @returns true if there is an intersection
  73384. */
  73385. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73386. /**
  73387. * Tests if the bounding sphere center is in between the frustum planes.
  73388. * Used for optimistic fast inclusion.
  73389. * @param frustumPlanes defines the frustum planes to test
  73390. * @returns true if the sphere center is in between the frustum planes
  73391. */
  73392. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73393. /**
  73394. * Tests if a point is inside the bounding sphere
  73395. * @param point defines the point to test
  73396. * @returns true if the point is inside the bounding sphere
  73397. */
  73398. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73399. /**
  73400. * Checks if two sphere intersct
  73401. * @param sphere0 sphere 0
  73402. * @param sphere1 sphere 1
  73403. * @returns true if the speres intersect
  73404. */
  73405. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73406. }
  73407. }
  73408. declare module BABYLON {
  73409. /**
  73410. * Class used to store bounding box information
  73411. */
  73412. export class BoundingBox implements ICullable {
  73413. /**
  73414. * Gets the 8 vectors representing the bounding box in local space
  73415. */
  73416. readonly vectors: Vector3[];
  73417. /**
  73418. * Gets the center of the bounding box in local space
  73419. */
  73420. readonly center: Vector3;
  73421. /**
  73422. * Gets the center of the bounding box in world space
  73423. */
  73424. readonly centerWorld: Vector3;
  73425. /**
  73426. * Gets the extend size in local space
  73427. */
  73428. readonly extendSize: Vector3;
  73429. /**
  73430. * Gets the extend size in world space
  73431. */
  73432. readonly extendSizeWorld: Vector3;
  73433. /**
  73434. * Gets the OBB (object bounding box) directions
  73435. */
  73436. readonly directions: Vector3[];
  73437. /**
  73438. * Gets the 8 vectors representing the bounding box in world space
  73439. */
  73440. readonly vectorsWorld: Vector3[];
  73441. /**
  73442. * Gets the minimum vector in world space
  73443. */
  73444. readonly minimumWorld: Vector3;
  73445. /**
  73446. * Gets the maximum vector in world space
  73447. */
  73448. readonly maximumWorld: Vector3;
  73449. /**
  73450. * Gets the minimum vector in local space
  73451. */
  73452. readonly minimum: Vector3;
  73453. /**
  73454. * Gets the maximum vector in local space
  73455. */
  73456. readonly maximum: Vector3;
  73457. private _worldMatrix;
  73458. private static readonly TmpVector3;
  73459. /**
  73460. * @hidden
  73461. */
  73462. _tag: number;
  73463. /**
  73464. * Creates a new bounding box
  73465. * @param min defines the minimum vector (in local space)
  73466. * @param max defines the maximum vector (in local space)
  73467. * @param worldMatrix defines the new world matrix
  73468. */
  73469. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73470. /**
  73471. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73472. * @param min defines the new minimum vector (in local space)
  73473. * @param max defines the new maximum vector (in local space)
  73474. * @param worldMatrix defines the new world matrix
  73475. */
  73476. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73477. /**
  73478. * Scale the current bounding box by applying a scale factor
  73479. * @param factor defines the scale factor to apply
  73480. * @returns the current bounding box
  73481. */
  73482. scale(factor: number): BoundingBox;
  73483. /**
  73484. * Gets the world matrix of the bounding box
  73485. * @returns a matrix
  73486. */
  73487. getWorldMatrix(): DeepImmutable<Matrix>;
  73488. /** @hidden */
  73489. _update(world: DeepImmutable<Matrix>): void;
  73490. /**
  73491. * Tests if the bounding box is intersecting the frustum planes
  73492. * @param frustumPlanes defines the frustum planes to test
  73493. * @returns true if there is an intersection
  73494. */
  73495. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73496. /**
  73497. * Tests if the bounding box is entirely inside the frustum planes
  73498. * @param frustumPlanes defines the frustum planes to test
  73499. * @returns true if there is an inclusion
  73500. */
  73501. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73502. /**
  73503. * Tests if a point is inside the bounding box
  73504. * @param point defines the point to test
  73505. * @returns true if the point is inside the bounding box
  73506. */
  73507. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73508. /**
  73509. * Tests if the bounding box intersects with a bounding sphere
  73510. * @param sphere defines the sphere to test
  73511. * @returns true if there is an intersection
  73512. */
  73513. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73514. /**
  73515. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73516. * @param min defines the min vector to use
  73517. * @param max defines the max vector to use
  73518. * @returns true if there is an intersection
  73519. */
  73520. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73521. /**
  73522. * Tests if two bounding boxes are intersections
  73523. * @param box0 defines the first box to test
  73524. * @param box1 defines the second box to test
  73525. * @returns true if there is an intersection
  73526. */
  73527. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73528. /**
  73529. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73530. * @param minPoint defines the minimum vector of the bounding box
  73531. * @param maxPoint defines the maximum vector of the bounding box
  73532. * @param sphereCenter defines the sphere center
  73533. * @param sphereRadius defines the sphere radius
  73534. * @returns true if there is an intersection
  73535. */
  73536. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73537. /**
  73538. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73539. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73540. * @param frustumPlanes defines the frustum planes to test
  73541. * @return true if there is an inclusion
  73542. */
  73543. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73544. /**
  73545. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73546. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73547. * @param frustumPlanes defines the frustum planes to test
  73548. * @return true if there is an intersection
  73549. */
  73550. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73551. }
  73552. }
  73553. declare module BABYLON {
  73554. /** @hidden */
  73555. export class Collider {
  73556. /** Define if a collision was found */
  73557. collisionFound: boolean;
  73558. /**
  73559. * Define last intersection point in local space
  73560. */
  73561. intersectionPoint: Vector3;
  73562. /**
  73563. * Define last collided mesh
  73564. */
  73565. collidedMesh: Nullable<AbstractMesh>;
  73566. private _collisionPoint;
  73567. private _planeIntersectionPoint;
  73568. private _tempVector;
  73569. private _tempVector2;
  73570. private _tempVector3;
  73571. private _tempVector4;
  73572. private _edge;
  73573. private _baseToVertex;
  73574. private _destinationPoint;
  73575. private _slidePlaneNormal;
  73576. private _displacementVector;
  73577. /** @hidden */
  73578. _radius: Vector3;
  73579. /** @hidden */
  73580. _retry: number;
  73581. private _velocity;
  73582. private _basePoint;
  73583. private _epsilon;
  73584. /** @hidden */
  73585. _velocityWorldLength: number;
  73586. /** @hidden */
  73587. _basePointWorld: Vector3;
  73588. private _velocityWorld;
  73589. private _normalizedVelocity;
  73590. /** @hidden */
  73591. _initialVelocity: Vector3;
  73592. /** @hidden */
  73593. _initialPosition: Vector3;
  73594. private _nearestDistance;
  73595. private _collisionMask;
  73596. collisionMask: number;
  73597. /**
  73598. * Gets the plane normal used to compute the sliding response (in local space)
  73599. */
  73600. readonly slidePlaneNormal: Vector3;
  73601. /** @hidden */
  73602. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73603. /** @hidden */
  73604. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73605. /** @hidden */
  73606. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73607. /** @hidden */
  73608. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73609. /** @hidden */
  73610. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73611. /** @hidden */
  73612. _getResponse(pos: Vector3, vel: Vector3): void;
  73613. }
  73614. }
  73615. declare module BABYLON {
  73616. /**
  73617. * Interface for cullable objects
  73618. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73619. */
  73620. export interface ICullable {
  73621. /**
  73622. * Checks if the object or part of the object is in the frustum
  73623. * @param frustumPlanes Camera near/planes
  73624. * @returns true if the object is in frustum otherwise false
  73625. */
  73626. isInFrustum(frustumPlanes: Plane[]): boolean;
  73627. /**
  73628. * Checks if a cullable object (mesh...) is in the camera frustum
  73629. * Unlike isInFrustum this cheks the full bounding box
  73630. * @param frustumPlanes Camera near/planes
  73631. * @returns true if the object is in frustum otherwise false
  73632. */
  73633. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73634. }
  73635. /**
  73636. * Info for a bounding data of a mesh
  73637. */
  73638. export class BoundingInfo implements ICullable {
  73639. /**
  73640. * Bounding box for the mesh
  73641. */
  73642. readonly boundingBox: BoundingBox;
  73643. /**
  73644. * Bounding sphere for the mesh
  73645. */
  73646. readonly boundingSphere: BoundingSphere;
  73647. private _isLocked;
  73648. private static readonly TmpVector3;
  73649. /**
  73650. * Constructs bounding info
  73651. * @param minimum min vector of the bounding box/sphere
  73652. * @param maximum max vector of the bounding box/sphere
  73653. * @param worldMatrix defines the new world matrix
  73654. */
  73655. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73656. /**
  73657. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73658. * @param min defines the new minimum vector (in local space)
  73659. * @param max defines the new maximum vector (in local space)
  73660. * @param worldMatrix defines the new world matrix
  73661. */
  73662. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73663. /**
  73664. * min vector of the bounding box/sphere
  73665. */
  73666. readonly minimum: Vector3;
  73667. /**
  73668. * max vector of the bounding box/sphere
  73669. */
  73670. readonly maximum: Vector3;
  73671. /**
  73672. * If the info is locked and won't be updated to avoid perf overhead
  73673. */
  73674. isLocked: boolean;
  73675. /**
  73676. * Updates the bounding sphere and box
  73677. * @param world world matrix to be used to update
  73678. */
  73679. update(world: DeepImmutable<Matrix>): void;
  73680. /**
  73681. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73682. * @param center New center of the bounding info
  73683. * @param extend New extend of the bounding info
  73684. * @returns the current bounding info
  73685. */
  73686. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73687. /**
  73688. * Scale the current bounding info by applying a scale factor
  73689. * @param factor defines the scale factor to apply
  73690. * @returns the current bounding info
  73691. */
  73692. scale(factor: number): BoundingInfo;
  73693. /**
  73694. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73695. * @param frustumPlanes defines the frustum to test
  73696. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73697. * @returns true if the bounding info is in the frustum planes
  73698. */
  73699. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73700. /**
  73701. * Gets the world distance between the min and max points of the bounding box
  73702. */
  73703. readonly diagonalLength: number;
  73704. /**
  73705. * Checks if a cullable object (mesh...) is in the camera frustum
  73706. * Unlike isInFrustum this cheks the full bounding box
  73707. * @param frustumPlanes Camera near/planes
  73708. * @returns true if the object is in frustum otherwise false
  73709. */
  73710. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73711. /** @hidden */
  73712. _checkCollision(collider: Collider): boolean;
  73713. /**
  73714. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73715. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73716. * @param point the point to check intersection with
  73717. * @returns if the point intersects
  73718. */
  73719. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73720. /**
  73721. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73722. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73723. * @param boundingInfo the bounding info to check intersection with
  73724. * @param precise if the intersection should be done using OBB
  73725. * @returns if the bounding info intersects
  73726. */
  73727. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73728. }
  73729. }
  73730. declare module BABYLON {
  73731. /**
  73732. * Extracts minimum and maximum values from a list of indexed positions
  73733. * @param positions defines the positions to use
  73734. * @param indices defines the indices to the positions
  73735. * @param indexStart defines the start index
  73736. * @param indexCount defines the end index
  73737. * @param bias defines bias value to add to the result
  73738. * @return minimum and maximum values
  73739. */
  73740. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73741. minimum: Vector3;
  73742. maximum: Vector3;
  73743. };
  73744. /**
  73745. * Extracts minimum and maximum values from a list of positions
  73746. * @param positions defines the positions to use
  73747. * @param start defines the start index in the positions array
  73748. * @param count defines the number of positions to handle
  73749. * @param bias defines bias value to add to the result
  73750. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73751. * @return minimum and maximum values
  73752. */
  73753. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73754. minimum: Vector3;
  73755. maximum: Vector3;
  73756. };
  73757. }
  73758. declare module BABYLON {
  73759. /** @hidden */
  73760. export class WebGLDataBuffer extends DataBuffer {
  73761. private _buffer;
  73762. constructor(resource: WebGLBuffer);
  73763. readonly underlyingResource: any;
  73764. }
  73765. }
  73766. declare module BABYLON {
  73767. /** @hidden */
  73768. export class WebGLPipelineContext implements IPipelineContext {
  73769. engine: ThinEngine;
  73770. program: Nullable<WebGLProgram>;
  73771. context?: WebGLRenderingContext;
  73772. vertexShader?: WebGLShader;
  73773. fragmentShader?: WebGLShader;
  73774. isParallelCompiled: boolean;
  73775. onCompiled?: () => void;
  73776. transformFeedback?: WebGLTransformFeedback | null;
  73777. readonly isAsync: boolean;
  73778. readonly isReady: boolean;
  73779. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73780. }
  73781. }
  73782. declare module BABYLON {
  73783. interface ThinEngine {
  73784. /**
  73785. * Create an uniform buffer
  73786. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73787. * @param elements defines the content of the uniform buffer
  73788. * @returns the webGL uniform buffer
  73789. */
  73790. createUniformBuffer(elements: FloatArray): DataBuffer;
  73791. /**
  73792. * Create a dynamic uniform buffer
  73793. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73794. * @param elements defines the content of the uniform buffer
  73795. * @returns the webGL uniform buffer
  73796. */
  73797. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73798. /**
  73799. * Update an existing uniform buffer
  73800. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73801. * @param uniformBuffer defines the target uniform buffer
  73802. * @param elements defines the content to update
  73803. * @param offset defines the offset in the uniform buffer where update should start
  73804. * @param count defines the size of the data to update
  73805. */
  73806. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73807. /**
  73808. * Bind an uniform buffer to the current webGL context
  73809. * @param buffer defines the buffer to bind
  73810. */
  73811. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73812. /**
  73813. * Bind a buffer to the current webGL context at a given location
  73814. * @param buffer defines the buffer to bind
  73815. * @param location defines the index where to bind the buffer
  73816. */
  73817. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73818. /**
  73819. * Bind a specific block at a given index in a specific shader program
  73820. * @param pipelineContext defines the pipeline context to use
  73821. * @param blockName defines the block name
  73822. * @param index defines the index where to bind the block
  73823. */
  73824. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73825. }
  73826. }
  73827. declare module BABYLON {
  73828. /**
  73829. * Uniform buffer objects.
  73830. *
  73831. * Handles blocks of uniform on the GPU.
  73832. *
  73833. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73834. *
  73835. * For more information, please refer to :
  73836. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73837. */
  73838. export class UniformBuffer {
  73839. private _engine;
  73840. private _buffer;
  73841. private _data;
  73842. private _bufferData;
  73843. private _dynamic?;
  73844. private _uniformLocations;
  73845. private _uniformSizes;
  73846. private _uniformLocationPointer;
  73847. private _needSync;
  73848. private _noUBO;
  73849. private _currentEffect;
  73850. private static _MAX_UNIFORM_SIZE;
  73851. private static _tempBuffer;
  73852. /**
  73853. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73854. * This is dynamic to allow compat with webgl 1 and 2.
  73855. * You will need to pass the name of the uniform as well as the value.
  73856. */
  73857. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73858. /**
  73859. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73860. * This is dynamic to allow compat with webgl 1 and 2.
  73861. * You will need to pass the name of the uniform as well as the value.
  73862. */
  73863. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73864. /**
  73865. * Lambda to Update a single float in a uniform buffer.
  73866. * This is dynamic to allow compat with webgl 1 and 2.
  73867. * You will need to pass the name of the uniform as well as the value.
  73868. */
  73869. updateFloat: (name: string, x: number) => void;
  73870. /**
  73871. * Lambda to Update a vec2 of float in a uniform buffer.
  73872. * This is dynamic to allow compat with webgl 1 and 2.
  73873. * You will need to pass the name of the uniform as well as the value.
  73874. */
  73875. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73876. /**
  73877. * Lambda to Update a vec3 of float in a uniform buffer.
  73878. * This is dynamic to allow compat with webgl 1 and 2.
  73879. * You will need to pass the name of the uniform as well as the value.
  73880. */
  73881. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73882. /**
  73883. * Lambda to Update a vec4 of float in a uniform buffer.
  73884. * This is dynamic to allow compat with webgl 1 and 2.
  73885. * You will need to pass the name of the uniform as well as the value.
  73886. */
  73887. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73888. /**
  73889. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73890. * This is dynamic to allow compat with webgl 1 and 2.
  73891. * You will need to pass the name of the uniform as well as the value.
  73892. */
  73893. updateMatrix: (name: string, mat: Matrix) => void;
  73894. /**
  73895. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73896. * This is dynamic to allow compat with webgl 1 and 2.
  73897. * You will need to pass the name of the uniform as well as the value.
  73898. */
  73899. updateVector3: (name: string, vector: Vector3) => void;
  73900. /**
  73901. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73902. * This is dynamic to allow compat with webgl 1 and 2.
  73903. * You will need to pass the name of the uniform as well as the value.
  73904. */
  73905. updateVector4: (name: string, vector: Vector4) => void;
  73906. /**
  73907. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73908. * This is dynamic to allow compat with webgl 1 and 2.
  73909. * You will need to pass the name of the uniform as well as the value.
  73910. */
  73911. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73912. /**
  73913. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73914. * This is dynamic to allow compat with webgl 1 and 2.
  73915. * You will need to pass the name of the uniform as well as the value.
  73916. */
  73917. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73918. /**
  73919. * Instantiates a new Uniform buffer objects.
  73920. *
  73921. * Handles blocks of uniform on the GPU.
  73922. *
  73923. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73924. *
  73925. * For more information, please refer to :
  73926. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73927. * @param engine Define the engine the buffer is associated with
  73928. * @param data Define the data contained in the buffer
  73929. * @param dynamic Define if the buffer is updatable
  73930. */
  73931. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73932. /**
  73933. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73934. * or just falling back on setUniformXXX calls.
  73935. */
  73936. readonly useUbo: boolean;
  73937. /**
  73938. * Indicates if the WebGL underlying uniform buffer is in sync
  73939. * with the javascript cache data.
  73940. */
  73941. readonly isSync: boolean;
  73942. /**
  73943. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73944. * Also, a dynamic UniformBuffer will disable cache verification and always
  73945. * update the underlying WebGL uniform buffer to the GPU.
  73946. * @returns if Dynamic, otherwise false
  73947. */
  73948. isDynamic(): boolean;
  73949. /**
  73950. * The data cache on JS side.
  73951. * @returns the underlying data as a float array
  73952. */
  73953. getData(): Float32Array;
  73954. /**
  73955. * The underlying WebGL Uniform buffer.
  73956. * @returns the webgl buffer
  73957. */
  73958. getBuffer(): Nullable<DataBuffer>;
  73959. /**
  73960. * std140 layout specifies how to align data within an UBO structure.
  73961. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73962. * for specs.
  73963. */
  73964. private _fillAlignment;
  73965. /**
  73966. * Adds an uniform in the buffer.
  73967. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73968. * for the layout to be correct !
  73969. * @param name Name of the uniform, as used in the uniform block in the shader.
  73970. * @param size Data size, or data directly.
  73971. */
  73972. addUniform(name: string, size: number | number[]): void;
  73973. /**
  73974. * Adds a Matrix 4x4 to the uniform buffer.
  73975. * @param name Name of the uniform, as used in the uniform block in the shader.
  73976. * @param mat A 4x4 matrix.
  73977. */
  73978. addMatrix(name: string, mat: Matrix): void;
  73979. /**
  73980. * Adds a vec2 to the uniform buffer.
  73981. * @param name Name of the uniform, as used in the uniform block in the shader.
  73982. * @param x Define the x component value of the vec2
  73983. * @param y Define the y component value of the vec2
  73984. */
  73985. addFloat2(name: string, x: number, y: number): void;
  73986. /**
  73987. * Adds a vec3 to the uniform buffer.
  73988. * @param name Name of the uniform, as used in the uniform block in the shader.
  73989. * @param x Define the x component value of the vec3
  73990. * @param y Define the y component value of the vec3
  73991. * @param z Define the z component value of the vec3
  73992. */
  73993. addFloat3(name: string, x: number, y: number, z: number): void;
  73994. /**
  73995. * Adds a vec3 to the uniform buffer.
  73996. * @param name Name of the uniform, as used in the uniform block in the shader.
  73997. * @param color Define the vec3 from a Color
  73998. */
  73999. addColor3(name: string, color: Color3): void;
  74000. /**
  74001. * Adds a vec4 to the uniform buffer.
  74002. * @param name Name of the uniform, as used in the uniform block in the shader.
  74003. * @param color Define the rgb components from a Color
  74004. * @param alpha Define the a component of the vec4
  74005. */
  74006. addColor4(name: string, color: Color3, alpha: number): void;
  74007. /**
  74008. * Adds a vec3 to the uniform buffer.
  74009. * @param name Name of the uniform, as used in the uniform block in the shader.
  74010. * @param vector Define the vec3 components from a Vector
  74011. */
  74012. addVector3(name: string, vector: Vector3): void;
  74013. /**
  74014. * Adds a Matrix 3x3 to the uniform buffer.
  74015. * @param name Name of the uniform, as used in the uniform block in the shader.
  74016. */
  74017. addMatrix3x3(name: string): void;
  74018. /**
  74019. * Adds a Matrix 2x2 to the uniform buffer.
  74020. * @param name Name of the uniform, as used in the uniform block in the shader.
  74021. */
  74022. addMatrix2x2(name: string): void;
  74023. /**
  74024. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74025. */
  74026. create(): void;
  74027. /** @hidden */
  74028. _rebuild(): void;
  74029. /**
  74030. * Updates the WebGL Uniform Buffer on the GPU.
  74031. * If the `dynamic` flag is set to true, no cache comparison is done.
  74032. * Otherwise, the buffer will be updated only if the cache differs.
  74033. */
  74034. update(): void;
  74035. /**
  74036. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74037. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74038. * @param data Define the flattened data
  74039. * @param size Define the size of the data.
  74040. */
  74041. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74042. private _valueCache;
  74043. private _cacheMatrix;
  74044. private _updateMatrix3x3ForUniform;
  74045. private _updateMatrix3x3ForEffect;
  74046. private _updateMatrix2x2ForEffect;
  74047. private _updateMatrix2x2ForUniform;
  74048. private _updateFloatForEffect;
  74049. private _updateFloatForUniform;
  74050. private _updateFloat2ForEffect;
  74051. private _updateFloat2ForUniform;
  74052. private _updateFloat3ForEffect;
  74053. private _updateFloat3ForUniform;
  74054. private _updateFloat4ForEffect;
  74055. private _updateFloat4ForUniform;
  74056. private _updateMatrixForEffect;
  74057. private _updateMatrixForUniform;
  74058. private _updateVector3ForEffect;
  74059. private _updateVector3ForUniform;
  74060. private _updateVector4ForEffect;
  74061. private _updateVector4ForUniform;
  74062. private _updateColor3ForEffect;
  74063. private _updateColor3ForUniform;
  74064. private _updateColor4ForEffect;
  74065. private _updateColor4ForUniform;
  74066. /**
  74067. * Sets a sampler uniform on the effect.
  74068. * @param name Define the name of the sampler.
  74069. * @param texture Define the texture to set in the sampler
  74070. */
  74071. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74072. /**
  74073. * Directly updates the value of the uniform in the cache AND on the GPU.
  74074. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74075. * @param data Define the flattened data
  74076. */
  74077. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74078. /**
  74079. * Binds this uniform buffer to an effect.
  74080. * @param effect Define the effect to bind the buffer to
  74081. * @param name Name of the uniform block in the shader.
  74082. */
  74083. bindToEffect(effect: Effect, name: string): void;
  74084. /**
  74085. * Disposes the uniform buffer.
  74086. */
  74087. dispose(): void;
  74088. }
  74089. }
  74090. declare module BABYLON {
  74091. /**
  74092. * Enum that determines the text-wrapping mode to use.
  74093. */
  74094. export enum InspectableType {
  74095. /**
  74096. * Checkbox for booleans
  74097. */
  74098. Checkbox = 0,
  74099. /**
  74100. * Sliders for numbers
  74101. */
  74102. Slider = 1,
  74103. /**
  74104. * Vector3
  74105. */
  74106. Vector3 = 2,
  74107. /**
  74108. * Quaternions
  74109. */
  74110. Quaternion = 3,
  74111. /**
  74112. * Color3
  74113. */
  74114. Color3 = 4,
  74115. /**
  74116. * String
  74117. */
  74118. String = 5
  74119. }
  74120. /**
  74121. * Interface used to define custom inspectable properties.
  74122. * This interface is used by the inspector to display custom property grids
  74123. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74124. */
  74125. export interface IInspectable {
  74126. /**
  74127. * Gets the label to display
  74128. */
  74129. label: string;
  74130. /**
  74131. * Gets the name of the property to edit
  74132. */
  74133. propertyName: string;
  74134. /**
  74135. * Gets the type of the editor to use
  74136. */
  74137. type: InspectableType;
  74138. /**
  74139. * Gets the minimum value of the property when using in "slider" mode
  74140. */
  74141. min?: number;
  74142. /**
  74143. * Gets the maximum value of the property when using in "slider" mode
  74144. */
  74145. max?: number;
  74146. /**
  74147. * Gets the setp to use when using in "slider" mode
  74148. */
  74149. step?: number;
  74150. }
  74151. }
  74152. declare module BABYLON {
  74153. /**
  74154. * Class used to provide helper for timing
  74155. */
  74156. export class TimingTools {
  74157. /**
  74158. * Polyfill for setImmediate
  74159. * @param action defines the action to execute after the current execution block
  74160. */
  74161. static SetImmediate(action: () => void): void;
  74162. }
  74163. }
  74164. declare module BABYLON {
  74165. /**
  74166. * Class used to enable instatition of objects by class name
  74167. */
  74168. export class InstantiationTools {
  74169. /**
  74170. * Use this object to register external classes like custom textures or material
  74171. * to allow the laoders to instantiate them
  74172. */
  74173. static RegisteredExternalClasses: {
  74174. [key: string]: Object;
  74175. };
  74176. /**
  74177. * Tries to instantiate a new object from a given class name
  74178. * @param className defines the class name to instantiate
  74179. * @returns the new object or null if the system was not able to do the instantiation
  74180. */
  74181. static Instantiate(className: string): any;
  74182. }
  74183. }
  74184. declare module BABYLON {
  74185. /**
  74186. * Define options used to create a depth texture
  74187. */
  74188. export class DepthTextureCreationOptions {
  74189. /** Specifies whether or not a stencil should be allocated in the texture */
  74190. generateStencil?: boolean;
  74191. /** Specifies whether or not bilinear filtering is enable on the texture */
  74192. bilinearFiltering?: boolean;
  74193. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74194. comparisonFunction?: number;
  74195. /** Specifies if the created texture is a cube texture */
  74196. isCube?: boolean;
  74197. }
  74198. }
  74199. declare module BABYLON {
  74200. interface ThinEngine {
  74201. /**
  74202. * Creates a depth stencil cube texture.
  74203. * This is only available in WebGL 2.
  74204. * @param size The size of face edge in the cube texture.
  74205. * @param options The options defining the cube texture.
  74206. * @returns The cube texture
  74207. */
  74208. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74209. /**
  74210. * Creates a cube texture
  74211. * @param rootUrl defines the url where the files to load is located
  74212. * @param scene defines the current scene
  74213. * @param files defines the list of files to load (1 per face)
  74214. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74215. * @param onLoad defines an optional callback raised when the texture is loaded
  74216. * @param onError defines an optional callback raised if there is an issue to load the texture
  74217. * @param format defines the format of the data
  74218. * @param forcedExtension defines the extension to use to pick the right loader
  74219. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74220. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74221. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74222. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74223. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74224. * @returns the cube texture as an InternalTexture
  74225. */
  74226. 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;
  74227. /**
  74228. * Creates a cube texture
  74229. * @param rootUrl defines the url where the files to load is located
  74230. * @param scene defines the current scene
  74231. * @param files defines the list of files to load (1 per face)
  74232. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74233. * @param onLoad defines an optional callback raised when the texture is loaded
  74234. * @param onError defines an optional callback raised if there is an issue to load the texture
  74235. * @param format defines the format of the data
  74236. * @param forcedExtension defines the extension to use to pick the right loader
  74237. * @returns the cube texture as an InternalTexture
  74238. */
  74239. 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;
  74240. /**
  74241. * Creates a cube texture
  74242. * @param rootUrl defines the url where the files to load is located
  74243. * @param scene defines the current scene
  74244. * @param files defines the list of files to load (1 per face)
  74245. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74246. * @param onLoad defines an optional callback raised when the texture is loaded
  74247. * @param onError defines an optional callback raised if there is an issue to load the texture
  74248. * @param format defines the format of the data
  74249. * @param forcedExtension defines the extension to use to pick the right loader
  74250. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74251. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74252. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74253. * @returns the cube texture as an InternalTexture
  74254. */
  74255. 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;
  74256. /** @hidden */
  74257. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74258. /** @hidden */
  74259. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74260. /** @hidden */
  74261. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74262. /** @hidden */
  74263. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74264. }
  74265. }
  74266. declare module BABYLON {
  74267. /**
  74268. * Class for creating a cube texture
  74269. */
  74270. export class CubeTexture extends BaseTexture {
  74271. private _delayedOnLoad;
  74272. /**
  74273. * The url of the texture
  74274. */
  74275. url: string;
  74276. /**
  74277. * Gets or sets the center of the bounding box associated with the cube texture.
  74278. * It must define where the camera used to render the texture was set
  74279. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74280. */
  74281. boundingBoxPosition: Vector3;
  74282. private _boundingBoxSize;
  74283. /**
  74284. * Gets or sets the size of the bounding box associated with the cube texture
  74285. * When defined, the cubemap will switch to local mode
  74286. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74287. * @example https://www.babylonjs-playground.com/#RNASML
  74288. */
  74289. /**
  74290. * Returns the bounding box size
  74291. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74292. */
  74293. boundingBoxSize: Vector3;
  74294. protected _rotationY: number;
  74295. /**
  74296. * Sets texture matrix rotation angle around Y axis in radians.
  74297. */
  74298. /**
  74299. * Gets texture matrix rotation angle around Y axis radians.
  74300. */
  74301. rotationY: number;
  74302. /**
  74303. * Are mip maps generated for this texture or not.
  74304. */
  74305. readonly noMipmap: boolean;
  74306. private _noMipmap;
  74307. private _files;
  74308. protected _forcedExtension: Nullable<string>;
  74309. private _extensions;
  74310. private _textureMatrix;
  74311. private _format;
  74312. private _createPolynomials;
  74313. /** @hidden */
  74314. _prefiltered: boolean;
  74315. /**
  74316. * Creates a cube texture from an array of image urls
  74317. * @param files defines an array of image urls
  74318. * @param scene defines the hosting scene
  74319. * @param noMipmap specifies if mip maps are not used
  74320. * @returns a cube texture
  74321. */
  74322. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74323. /**
  74324. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74325. * @param url defines the url of the prefiltered texture
  74326. * @param scene defines the scene the texture is attached to
  74327. * @param forcedExtension defines the extension of the file if different from the url
  74328. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74329. * @return the prefiltered texture
  74330. */
  74331. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74332. /**
  74333. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74334. * as prefiltered data.
  74335. * @param rootUrl defines the url of the texture or the root name of the six images
  74336. * @param scene defines the scene the texture is attached to
  74337. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74338. * @param noMipmap defines if mipmaps should be created or not
  74339. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74340. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74341. * @param onError defines a callback triggered in case of error during load
  74342. * @param format defines the internal format to use for the texture once loaded
  74343. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74344. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74345. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74346. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74347. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74348. * @return the cube texture
  74349. */
  74350. 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);
  74351. /**
  74352. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74353. */
  74354. readonly isPrefiltered: boolean;
  74355. /**
  74356. * Get the current class name of the texture useful for serialization or dynamic coding.
  74357. * @returns "CubeTexture"
  74358. */
  74359. getClassName(): string;
  74360. /**
  74361. * Update the url (and optional buffer) of this texture if url was null during construction.
  74362. * @param url the url of the texture
  74363. * @param forcedExtension defines the extension to use
  74364. * @param onLoad callback called when the texture is loaded (defaults to null)
  74365. */
  74366. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74367. /**
  74368. * Delays loading of the cube texture
  74369. * @param forcedExtension defines the extension to use
  74370. */
  74371. delayLoad(forcedExtension?: string): void;
  74372. /**
  74373. * Returns the reflection texture matrix
  74374. * @returns the reflection texture matrix
  74375. */
  74376. getReflectionTextureMatrix(): Matrix;
  74377. /**
  74378. * Sets the reflection texture matrix
  74379. * @param value Reflection texture matrix
  74380. */
  74381. setReflectionTextureMatrix(value: Matrix): void;
  74382. /**
  74383. * Parses text to create a cube texture
  74384. * @param parsedTexture define the serialized text to read from
  74385. * @param scene defines the hosting scene
  74386. * @param rootUrl defines the root url of the cube texture
  74387. * @returns a cube texture
  74388. */
  74389. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74390. /**
  74391. * Makes a clone, or deep copy, of the cube texture
  74392. * @returns a new cube texture
  74393. */
  74394. clone(): CubeTexture;
  74395. }
  74396. }
  74397. declare module BABYLON {
  74398. /**
  74399. * Manages the defines for the Material
  74400. */
  74401. export class MaterialDefines {
  74402. /** @hidden */
  74403. protected _keys: string[];
  74404. private _isDirty;
  74405. /** @hidden */
  74406. _renderId: number;
  74407. /** @hidden */
  74408. _areLightsDirty: boolean;
  74409. /** @hidden */
  74410. _areLightsDisposed: boolean;
  74411. /** @hidden */
  74412. _areAttributesDirty: boolean;
  74413. /** @hidden */
  74414. _areTexturesDirty: boolean;
  74415. /** @hidden */
  74416. _areFresnelDirty: boolean;
  74417. /** @hidden */
  74418. _areMiscDirty: boolean;
  74419. /** @hidden */
  74420. _areImageProcessingDirty: boolean;
  74421. /** @hidden */
  74422. _normals: boolean;
  74423. /** @hidden */
  74424. _uvs: boolean;
  74425. /** @hidden */
  74426. _needNormals: boolean;
  74427. /** @hidden */
  74428. _needUVs: boolean;
  74429. [id: string]: any;
  74430. /**
  74431. * Specifies if the material needs to be re-calculated
  74432. */
  74433. readonly isDirty: boolean;
  74434. /**
  74435. * Marks the material to indicate that it has been re-calculated
  74436. */
  74437. markAsProcessed(): void;
  74438. /**
  74439. * Marks the material to indicate that it needs to be re-calculated
  74440. */
  74441. markAsUnprocessed(): void;
  74442. /**
  74443. * Marks the material to indicate all of its defines need to be re-calculated
  74444. */
  74445. markAllAsDirty(): void;
  74446. /**
  74447. * Marks the material to indicate that image processing needs to be re-calculated
  74448. */
  74449. markAsImageProcessingDirty(): void;
  74450. /**
  74451. * Marks the material to indicate the lights need to be re-calculated
  74452. * @param disposed Defines whether the light is dirty due to dispose or not
  74453. */
  74454. markAsLightDirty(disposed?: boolean): void;
  74455. /**
  74456. * Marks the attribute state as changed
  74457. */
  74458. markAsAttributesDirty(): void;
  74459. /**
  74460. * Marks the texture state as changed
  74461. */
  74462. markAsTexturesDirty(): void;
  74463. /**
  74464. * Marks the fresnel state as changed
  74465. */
  74466. markAsFresnelDirty(): void;
  74467. /**
  74468. * Marks the misc state as changed
  74469. */
  74470. markAsMiscDirty(): void;
  74471. /**
  74472. * Rebuilds the material defines
  74473. */
  74474. rebuild(): void;
  74475. /**
  74476. * Specifies if two material defines are equal
  74477. * @param other - A material define instance to compare to
  74478. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74479. */
  74480. isEqual(other: MaterialDefines): boolean;
  74481. /**
  74482. * Clones this instance's defines to another instance
  74483. * @param other - material defines to clone values to
  74484. */
  74485. cloneTo(other: MaterialDefines): void;
  74486. /**
  74487. * Resets the material define values
  74488. */
  74489. reset(): void;
  74490. /**
  74491. * Converts the material define values to a string
  74492. * @returns - String of material define information
  74493. */
  74494. toString(): string;
  74495. }
  74496. }
  74497. declare module BABYLON {
  74498. /**
  74499. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74500. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74501. * 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;
  74502. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74503. */
  74504. export class ColorCurves {
  74505. private _dirty;
  74506. private _tempColor;
  74507. private _globalCurve;
  74508. private _highlightsCurve;
  74509. private _midtonesCurve;
  74510. private _shadowsCurve;
  74511. private _positiveCurve;
  74512. private _negativeCurve;
  74513. private _globalHue;
  74514. private _globalDensity;
  74515. private _globalSaturation;
  74516. private _globalExposure;
  74517. /**
  74518. * Gets the global Hue value.
  74519. * 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).
  74520. */
  74521. /**
  74522. * Sets the global Hue value.
  74523. * 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).
  74524. */
  74525. globalHue: number;
  74526. /**
  74527. * Gets the global Density value.
  74528. * 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.
  74529. * Values less than zero provide a filter of opposite hue.
  74530. */
  74531. /**
  74532. * Sets the global Density value.
  74533. * 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.
  74534. * Values less than zero provide a filter of opposite hue.
  74535. */
  74536. globalDensity: number;
  74537. /**
  74538. * Gets the global Saturation value.
  74539. * 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.
  74540. */
  74541. /**
  74542. * Sets the global Saturation value.
  74543. * 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.
  74544. */
  74545. globalSaturation: number;
  74546. /**
  74547. * Gets the global Exposure value.
  74548. * 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.
  74549. */
  74550. /**
  74551. * Sets the global Exposure value.
  74552. * 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.
  74553. */
  74554. globalExposure: number;
  74555. private _highlightsHue;
  74556. private _highlightsDensity;
  74557. private _highlightsSaturation;
  74558. private _highlightsExposure;
  74559. /**
  74560. * Gets the highlights Hue value.
  74561. * 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).
  74562. */
  74563. /**
  74564. * Sets the highlights Hue value.
  74565. * 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).
  74566. */
  74567. highlightsHue: number;
  74568. /**
  74569. * Gets the highlights Density value.
  74570. * 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.
  74571. * Values less than zero provide a filter of opposite hue.
  74572. */
  74573. /**
  74574. * Sets the highlights Density value.
  74575. * 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.
  74576. * Values less than zero provide a filter of opposite hue.
  74577. */
  74578. highlightsDensity: number;
  74579. /**
  74580. * Gets the highlights Saturation value.
  74581. * 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.
  74582. */
  74583. /**
  74584. * Sets the highlights Saturation value.
  74585. * 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.
  74586. */
  74587. highlightsSaturation: number;
  74588. /**
  74589. * Gets the highlights Exposure value.
  74590. * 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.
  74591. */
  74592. /**
  74593. * Sets the highlights Exposure value.
  74594. * 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.
  74595. */
  74596. highlightsExposure: number;
  74597. private _midtonesHue;
  74598. private _midtonesDensity;
  74599. private _midtonesSaturation;
  74600. private _midtonesExposure;
  74601. /**
  74602. * Gets the midtones Hue value.
  74603. * 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).
  74604. */
  74605. /**
  74606. * Sets the midtones Hue value.
  74607. * 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).
  74608. */
  74609. midtonesHue: number;
  74610. /**
  74611. * Gets the midtones Density value.
  74612. * 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.
  74613. * Values less than zero provide a filter of opposite hue.
  74614. */
  74615. /**
  74616. * Sets the midtones Density value.
  74617. * 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.
  74618. * Values less than zero provide a filter of opposite hue.
  74619. */
  74620. midtonesDensity: number;
  74621. /**
  74622. * Gets the midtones Saturation value.
  74623. * 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.
  74624. */
  74625. /**
  74626. * Sets the midtones Saturation value.
  74627. * 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.
  74628. */
  74629. midtonesSaturation: number;
  74630. /**
  74631. * Gets the midtones Exposure value.
  74632. * 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.
  74633. */
  74634. /**
  74635. * Sets the midtones Exposure value.
  74636. * 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.
  74637. */
  74638. midtonesExposure: number;
  74639. private _shadowsHue;
  74640. private _shadowsDensity;
  74641. private _shadowsSaturation;
  74642. private _shadowsExposure;
  74643. /**
  74644. * Gets the shadows Hue value.
  74645. * 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).
  74646. */
  74647. /**
  74648. * Sets the shadows Hue value.
  74649. * 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).
  74650. */
  74651. shadowsHue: number;
  74652. /**
  74653. * Gets the shadows Density value.
  74654. * 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.
  74655. * Values less than zero provide a filter of opposite hue.
  74656. */
  74657. /**
  74658. * Sets the shadows Density value.
  74659. * 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.
  74660. * Values less than zero provide a filter of opposite hue.
  74661. */
  74662. shadowsDensity: number;
  74663. /**
  74664. * Gets the shadows Saturation value.
  74665. * 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.
  74666. */
  74667. /**
  74668. * Sets the shadows Saturation value.
  74669. * 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.
  74670. */
  74671. shadowsSaturation: number;
  74672. /**
  74673. * Gets the shadows Exposure value.
  74674. * 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.
  74675. */
  74676. /**
  74677. * Sets the shadows Exposure value.
  74678. * 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.
  74679. */
  74680. shadowsExposure: number;
  74681. /**
  74682. * Returns the class name
  74683. * @returns The class name
  74684. */
  74685. getClassName(): string;
  74686. /**
  74687. * Binds the color curves to the shader.
  74688. * @param colorCurves The color curve to bind
  74689. * @param effect The effect to bind to
  74690. * @param positiveUniform The positive uniform shader parameter
  74691. * @param neutralUniform The neutral uniform shader parameter
  74692. * @param negativeUniform The negative uniform shader parameter
  74693. */
  74694. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74695. /**
  74696. * Prepare the list of uniforms associated with the ColorCurves effects.
  74697. * @param uniformsList The list of uniforms used in the effect
  74698. */
  74699. static PrepareUniforms(uniformsList: string[]): void;
  74700. /**
  74701. * Returns color grading data based on a hue, density, saturation and exposure value.
  74702. * @param filterHue The hue of the color filter.
  74703. * @param filterDensity The density of the color filter.
  74704. * @param saturation The saturation.
  74705. * @param exposure The exposure.
  74706. * @param result The result data container.
  74707. */
  74708. private getColorGradingDataToRef;
  74709. /**
  74710. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74711. * @param value The input slider value in range [-100,100].
  74712. * @returns Adjusted value.
  74713. */
  74714. private static applyColorGradingSliderNonlinear;
  74715. /**
  74716. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74717. * @param hue The hue (H) input.
  74718. * @param saturation The saturation (S) input.
  74719. * @param brightness The brightness (B) input.
  74720. * @result An RGBA color represented as Vector4.
  74721. */
  74722. private static fromHSBToRef;
  74723. /**
  74724. * Returns a value clamped between min and max
  74725. * @param value The value to clamp
  74726. * @param min The minimum of value
  74727. * @param max The maximum of value
  74728. * @returns The clamped value.
  74729. */
  74730. private static clamp;
  74731. /**
  74732. * Clones the current color curve instance.
  74733. * @return The cloned curves
  74734. */
  74735. clone(): ColorCurves;
  74736. /**
  74737. * Serializes the current color curve instance to a json representation.
  74738. * @return a JSON representation
  74739. */
  74740. serialize(): any;
  74741. /**
  74742. * Parses the color curve from a json representation.
  74743. * @param source the JSON source to parse
  74744. * @return The parsed curves
  74745. */
  74746. static Parse(source: any): ColorCurves;
  74747. }
  74748. }
  74749. declare module BABYLON {
  74750. /**
  74751. * Interface to follow in your material defines to integrate easily the
  74752. * Image proccessing functions.
  74753. * @hidden
  74754. */
  74755. export interface IImageProcessingConfigurationDefines {
  74756. IMAGEPROCESSING: boolean;
  74757. VIGNETTE: boolean;
  74758. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74759. VIGNETTEBLENDMODEOPAQUE: boolean;
  74760. TONEMAPPING: boolean;
  74761. TONEMAPPING_ACES: boolean;
  74762. CONTRAST: boolean;
  74763. EXPOSURE: boolean;
  74764. COLORCURVES: boolean;
  74765. COLORGRADING: boolean;
  74766. COLORGRADING3D: boolean;
  74767. SAMPLER3DGREENDEPTH: boolean;
  74768. SAMPLER3DBGRMAP: boolean;
  74769. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74770. }
  74771. /**
  74772. * @hidden
  74773. */
  74774. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74775. IMAGEPROCESSING: boolean;
  74776. VIGNETTE: boolean;
  74777. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74778. VIGNETTEBLENDMODEOPAQUE: boolean;
  74779. TONEMAPPING: boolean;
  74780. TONEMAPPING_ACES: boolean;
  74781. CONTRAST: boolean;
  74782. COLORCURVES: boolean;
  74783. COLORGRADING: boolean;
  74784. COLORGRADING3D: boolean;
  74785. SAMPLER3DGREENDEPTH: boolean;
  74786. SAMPLER3DBGRMAP: boolean;
  74787. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74788. EXPOSURE: boolean;
  74789. constructor();
  74790. }
  74791. /**
  74792. * This groups together the common properties used for image processing either in direct forward pass
  74793. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74794. * or not.
  74795. */
  74796. export class ImageProcessingConfiguration {
  74797. /**
  74798. * Default tone mapping applied in BabylonJS.
  74799. */
  74800. static readonly TONEMAPPING_STANDARD: number;
  74801. /**
  74802. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74803. * to other engines rendering to increase portability.
  74804. */
  74805. static readonly TONEMAPPING_ACES: number;
  74806. /**
  74807. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74808. */
  74809. colorCurves: Nullable<ColorCurves>;
  74810. private _colorCurvesEnabled;
  74811. /**
  74812. * Gets wether the color curves effect is enabled.
  74813. */
  74814. /**
  74815. * Sets wether the color curves effect is enabled.
  74816. */
  74817. colorCurvesEnabled: boolean;
  74818. private _colorGradingTexture;
  74819. /**
  74820. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74821. */
  74822. /**
  74823. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74824. */
  74825. colorGradingTexture: Nullable<BaseTexture>;
  74826. private _colorGradingEnabled;
  74827. /**
  74828. * Gets wether the color grading effect is enabled.
  74829. */
  74830. /**
  74831. * Sets wether the color grading effect is enabled.
  74832. */
  74833. colorGradingEnabled: boolean;
  74834. private _colorGradingWithGreenDepth;
  74835. /**
  74836. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74837. */
  74838. /**
  74839. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74840. */
  74841. colorGradingWithGreenDepth: boolean;
  74842. private _colorGradingBGR;
  74843. /**
  74844. * Gets wether the color grading texture contains BGR values.
  74845. */
  74846. /**
  74847. * Sets wether the color grading texture contains BGR values.
  74848. */
  74849. colorGradingBGR: boolean;
  74850. /** @hidden */
  74851. _exposure: number;
  74852. /**
  74853. * Gets the Exposure used in the effect.
  74854. */
  74855. /**
  74856. * Sets the Exposure used in the effect.
  74857. */
  74858. exposure: number;
  74859. private _toneMappingEnabled;
  74860. /**
  74861. * Gets wether the tone mapping effect is enabled.
  74862. */
  74863. /**
  74864. * Sets wether the tone mapping effect is enabled.
  74865. */
  74866. toneMappingEnabled: boolean;
  74867. private _toneMappingType;
  74868. /**
  74869. * Gets the type of tone mapping effect.
  74870. */
  74871. /**
  74872. * Sets the type of tone mapping effect used in BabylonJS.
  74873. */
  74874. toneMappingType: number;
  74875. protected _contrast: number;
  74876. /**
  74877. * Gets the contrast used in the effect.
  74878. */
  74879. /**
  74880. * Sets the contrast used in the effect.
  74881. */
  74882. contrast: number;
  74883. /**
  74884. * Vignette stretch size.
  74885. */
  74886. vignetteStretch: number;
  74887. /**
  74888. * Vignette centre X Offset.
  74889. */
  74890. vignetteCentreX: number;
  74891. /**
  74892. * Vignette centre Y Offset.
  74893. */
  74894. vignetteCentreY: number;
  74895. /**
  74896. * Vignette weight or intensity of the vignette effect.
  74897. */
  74898. vignetteWeight: number;
  74899. /**
  74900. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74901. * if vignetteEnabled is set to true.
  74902. */
  74903. vignetteColor: Color4;
  74904. /**
  74905. * Camera field of view used by the Vignette effect.
  74906. */
  74907. vignetteCameraFov: number;
  74908. private _vignetteBlendMode;
  74909. /**
  74910. * Gets the vignette blend mode allowing different kind of effect.
  74911. */
  74912. /**
  74913. * Sets the vignette blend mode allowing different kind of effect.
  74914. */
  74915. vignetteBlendMode: number;
  74916. private _vignetteEnabled;
  74917. /**
  74918. * Gets wether the vignette effect is enabled.
  74919. */
  74920. /**
  74921. * Sets wether the vignette effect is enabled.
  74922. */
  74923. vignetteEnabled: boolean;
  74924. private _applyByPostProcess;
  74925. /**
  74926. * Gets wether the image processing is applied through a post process or not.
  74927. */
  74928. /**
  74929. * Sets wether the image processing is applied through a post process or not.
  74930. */
  74931. applyByPostProcess: boolean;
  74932. private _isEnabled;
  74933. /**
  74934. * Gets wether the image processing is enabled or not.
  74935. */
  74936. /**
  74937. * Sets wether the image processing is enabled or not.
  74938. */
  74939. isEnabled: boolean;
  74940. /**
  74941. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74942. */
  74943. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74944. /**
  74945. * Method called each time the image processing information changes requires to recompile the effect.
  74946. */
  74947. protected _updateParameters(): void;
  74948. /**
  74949. * Gets the current class name.
  74950. * @return "ImageProcessingConfiguration"
  74951. */
  74952. getClassName(): string;
  74953. /**
  74954. * Prepare the list of uniforms associated with the Image Processing effects.
  74955. * @param uniforms The list of uniforms used in the effect
  74956. * @param defines the list of defines currently in use
  74957. */
  74958. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74959. /**
  74960. * Prepare the list of samplers associated with the Image Processing effects.
  74961. * @param samplersList The list of uniforms used in the effect
  74962. * @param defines the list of defines currently in use
  74963. */
  74964. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74965. /**
  74966. * Prepare the list of defines associated to the shader.
  74967. * @param defines the list of defines to complete
  74968. * @param forPostProcess Define if we are currently in post process mode or not
  74969. */
  74970. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74971. /**
  74972. * Returns true if all the image processing information are ready.
  74973. * @returns True if ready, otherwise, false
  74974. */
  74975. isReady(): boolean;
  74976. /**
  74977. * Binds the image processing to the shader.
  74978. * @param effect The effect to bind to
  74979. * @param aspectRatio Define the current aspect ratio of the effect
  74980. */
  74981. bind(effect: Effect, aspectRatio?: number): void;
  74982. /**
  74983. * Clones the current image processing instance.
  74984. * @return The cloned image processing
  74985. */
  74986. clone(): ImageProcessingConfiguration;
  74987. /**
  74988. * Serializes the current image processing instance to a json representation.
  74989. * @return a JSON representation
  74990. */
  74991. serialize(): any;
  74992. /**
  74993. * Parses the image processing from a json representation.
  74994. * @param source the JSON source to parse
  74995. * @return The parsed image processing
  74996. */
  74997. static Parse(source: any): ImageProcessingConfiguration;
  74998. private static _VIGNETTEMODE_MULTIPLY;
  74999. private static _VIGNETTEMODE_OPAQUE;
  75000. /**
  75001. * Used to apply the vignette as a mix with the pixel color.
  75002. */
  75003. static readonly VIGNETTEMODE_MULTIPLY: number;
  75004. /**
  75005. * Used to apply the vignette as a replacement of the pixel color.
  75006. */
  75007. static readonly VIGNETTEMODE_OPAQUE: number;
  75008. }
  75009. }
  75010. declare module BABYLON {
  75011. /** @hidden */
  75012. export var postprocessVertexShader: {
  75013. name: string;
  75014. shader: string;
  75015. };
  75016. }
  75017. declare module BABYLON {
  75018. interface ThinEngine {
  75019. /**
  75020. * Creates a new render target texture
  75021. * @param size defines the size of the texture
  75022. * @param options defines the options used to create the texture
  75023. * @returns a new render target texture stored in an InternalTexture
  75024. */
  75025. createRenderTargetTexture(size: number | {
  75026. width: number;
  75027. height: number;
  75028. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75029. }
  75030. }
  75031. declare module BABYLON {
  75032. /** Defines supported spaces */
  75033. export enum Space {
  75034. /** Local (object) space */
  75035. LOCAL = 0,
  75036. /** World space */
  75037. WORLD = 1,
  75038. /** Bone space */
  75039. BONE = 2
  75040. }
  75041. /** Defines the 3 main axes */
  75042. export class Axis {
  75043. /** X axis */
  75044. static X: Vector3;
  75045. /** Y axis */
  75046. static Y: Vector3;
  75047. /** Z axis */
  75048. static Z: Vector3;
  75049. }
  75050. }
  75051. declare module BABYLON {
  75052. /**
  75053. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75054. * This is the base of the follow, arc rotate cameras and Free camera
  75055. * @see http://doc.babylonjs.com/features/cameras
  75056. */
  75057. export class TargetCamera extends Camera {
  75058. private static _RigCamTransformMatrix;
  75059. private static _TargetTransformMatrix;
  75060. private static _TargetFocalPoint;
  75061. /**
  75062. * Define the current direction the camera is moving to
  75063. */
  75064. cameraDirection: Vector3;
  75065. /**
  75066. * Define the current rotation the camera is rotating to
  75067. */
  75068. cameraRotation: Vector2;
  75069. /**
  75070. * When set, the up vector of the camera will be updated by the rotation of the camera
  75071. */
  75072. updateUpVectorFromRotation: boolean;
  75073. private _tmpQuaternion;
  75074. /**
  75075. * Define the current rotation of the camera
  75076. */
  75077. rotation: Vector3;
  75078. /**
  75079. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75080. */
  75081. rotationQuaternion: Quaternion;
  75082. /**
  75083. * Define the current speed of the camera
  75084. */
  75085. speed: number;
  75086. /**
  75087. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75088. * around all axis.
  75089. */
  75090. noRotationConstraint: boolean;
  75091. /**
  75092. * Define the current target of the camera as an object or a position.
  75093. */
  75094. lockedTarget: any;
  75095. /** @hidden */
  75096. _currentTarget: Vector3;
  75097. /** @hidden */
  75098. _initialFocalDistance: number;
  75099. /** @hidden */
  75100. _viewMatrix: Matrix;
  75101. /** @hidden */
  75102. _camMatrix: Matrix;
  75103. /** @hidden */
  75104. _cameraTransformMatrix: Matrix;
  75105. /** @hidden */
  75106. _cameraRotationMatrix: Matrix;
  75107. /** @hidden */
  75108. _referencePoint: Vector3;
  75109. /** @hidden */
  75110. _transformedReferencePoint: Vector3;
  75111. protected _globalCurrentTarget: Vector3;
  75112. protected _globalCurrentUpVector: Vector3;
  75113. /** @hidden */
  75114. _reset: () => void;
  75115. private _defaultUp;
  75116. /**
  75117. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75118. * This is the base of the follow, arc rotate cameras and Free camera
  75119. * @see http://doc.babylonjs.com/features/cameras
  75120. * @param name Defines the name of the camera in the scene
  75121. * @param position Defines the start position of the camera in the scene
  75122. * @param scene Defines the scene the camera belongs to
  75123. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75124. */
  75125. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75126. /**
  75127. * Gets the position in front of the camera at a given distance.
  75128. * @param distance The distance from the camera we want the position to be
  75129. * @returns the position
  75130. */
  75131. getFrontPosition(distance: number): Vector3;
  75132. /** @hidden */
  75133. _getLockedTargetPosition(): Nullable<Vector3>;
  75134. private _storedPosition;
  75135. private _storedRotation;
  75136. private _storedRotationQuaternion;
  75137. /**
  75138. * Store current camera state of the camera (fov, position, rotation, etc..)
  75139. * @returns the camera
  75140. */
  75141. storeState(): Camera;
  75142. /**
  75143. * Restored camera state. You must call storeState() first
  75144. * @returns whether it was successful or not
  75145. * @hidden
  75146. */
  75147. _restoreStateValues(): boolean;
  75148. /** @hidden */
  75149. _initCache(): void;
  75150. /** @hidden */
  75151. _updateCache(ignoreParentClass?: boolean): void;
  75152. /** @hidden */
  75153. _isSynchronizedViewMatrix(): boolean;
  75154. /** @hidden */
  75155. _computeLocalCameraSpeed(): number;
  75156. /**
  75157. * Defines the target the camera should look at.
  75158. * @param target Defines the new target as a Vector or a mesh
  75159. */
  75160. setTarget(target: Vector3): void;
  75161. /**
  75162. * Return the current target position of the camera. This value is expressed in local space.
  75163. * @returns the target position
  75164. */
  75165. getTarget(): Vector3;
  75166. /** @hidden */
  75167. _decideIfNeedsToMove(): boolean;
  75168. /** @hidden */
  75169. _updatePosition(): void;
  75170. /** @hidden */
  75171. _checkInputs(): void;
  75172. protected _updateCameraRotationMatrix(): void;
  75173. /**
  75174. * 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)
  75175. * @returns the current camera
  75176. */
  75177. private _rotateUpVectorWithCameraRotationMatrix;
  75178. private _cachedRotationZ;
  75179. private _cachedQuaternionRotationZ;
  75180. /** @hidden */
  75181. _getViewMatrix(): Matrix;
  75182. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75183. /**
  75184. * @hidden
  75185. */
  75186. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75187. /**
  75188. * @hidden
  75189. */
  75190. _updateRigCameras(): void;
  75191. private _getRigCamPositionAndTarget;
  75192. /**
  75193. * Gets the current object class name.
  75194. * @return the class name
  75195. */
  75196. getClassName(): string;
  75197. }
  75198. }
  75199. declare module BABYLON {
  75200. /**
  75201. * Gather the list of keyboard event types as constants.
  75202. */
  75203. export class KeyboardEventTypes {
  75204. /**
  75205. * The keydown event is fired when a key becomes active (pressed).
  75206. */
  75207. static readonly KEYDOWN: number;
  75208. /**
  75209. * The keyup event is fired when a key has been released.
  75210. */
  75211. static readonly KEYUP: number;
  75212. }
  75213. /**
  75214. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75215. */
  75216. export class KeyboardInfo {
  75217. /**
  75218. * Defines the type of event (KeyboardEventTypes)
  75219. */
  75220. type: number;
  75221. /**
  75222. * Defines the related dom event
  75223. */
  75224. event: KeyboardEvent;
  75225. /**
  75226. * Instantiates a new keyboard info.
  75227. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75228. * @param type Defines the type of event (KeyboardEventTypes)
  75229. * @param event Defines the related dom event
  75230. */
  75231. constructor(
  75232. /**
  75233. * Defines the type of event (KeyboardEventTypes)
  75234. */
  75235. type: number,
  75236. /**
  75237. * Defines the related dom event
  75238. */
  75239. event: KeyboardEvent);
  75240. }
  75241. /**
  75242. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75243. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75244. */
  75245. export class KeyboardInfoPre extends KeyboardInfo {
  75246. /**
  75247. * Defines the type of event (KeyboardEventTypes)
  75248. */
  75249. type: number;
  75250. /**
  75251. * Defines the related dom event
  75252. */
  75253. event: KeyboardEvent;
  75254. /**
  75255. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75256. */
  75257. skipOnPointerObservable: boolean;
  75258. /**
  75259. * Instantiates a new keyboard pre info.
  75260. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75261. * @param type Defines the type of event (KeyboardEventTypes)
  75262. * @param event Defines the related dom event
  75263. */
  75264. constructor(
  75265. /**
  75266. * Defines the type of event (KeyboardEventTypes)
  75267. */
  75268. type: number,
  75269. /**
  75270. * Defines the related dom event
  75271. */
  75272. event: KeyboardEvent);
  75273. }
  75274. }
  75275. declare module BABYLON {
  75276. /**
  75277. * Manage the keyboard inputs to control the movement of a free camera.
  75278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75279. */
  75280. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75281. /**
  75282. * Defines the camera the input is attached to.
  75283. */
  75284. camera: FreeCamera;
  75285. /**
  75286. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75287. */
  75288. keysUp: number[];
  75289. /**
  75290. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75291. */
  75292. keysDown: number[];
  75293. /**
  75294. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75295. */
  75296. keysLeft: number[];
  75297. /**
  75298. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75299. */
  75300. keysRight: number[];
  75301. private _keys;
  75302. private _onCanvasBlurObserver;
  75303. private _onKeyboardObserver;
  75304. private _engine;
  75305. private _scene;
  75306. /**
  75307. * Attach the input controls to a specific dom element to get the input from.
  75308. * @param element Defines the element the controls should be listened from
  75309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75310. */
  75311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75312. /**
  75313. * Detach the current controls from the specified dom element.
  75314. * @param element Defines the element to stop listening the inputs from
  75315. */
  75316. detachControl(element: Nullable<HTMLElement>): void;
  75317. /**
  75318. * Update the current camera state depending on the inputs that have been used this frame.
  75319. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75320. */
  75321. checkInputs(): void;
  75322. /**
  75323. * Gets the class name of the current intput.
  75324. * @returns the class name
  75325. */
  75326. getClassName(): string;
  75327. /** @hidden */
  75328. _onLostFocus(): void;
  75329. /**
  75330. * Get the friendly name associated with the input class.
  75331. * @returns the input friendly name
  75332. */
  75333. getSimpleName(): string;
  75334. }
  75335. }
  75336. declare module BABYLON {
  75337. /**
  75338. * Interface describing all the common properties and methods a shadow light needs to implement.
  75339. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75340. * as well as binding the different shadow properties to the effects.
  75341. */
  75342. export interface IShadowLight extends Light {
  75343. /**
  75344. * The light id in the scene (used in scene.findLighById for instance)
  75345. */
  75346. id: string;
  75347. /**
  75348. * The position the shdow will be casted from.
  75349. */
  75350. position: Vector3;
  75351. /**
  75352. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75353. */
  75354. direction: Vector3;
  75355. /**
  75356. * The transformed position. Position of the light in world space taking parenting in account.
  75357. */
  75358. transformedPosition: Vector3;
  75359. /**
  75360. * The transformed direction. Direction of the light in world space taking parenting in account.
  75361. */
  75362. transformedDirection: Vector3;
  75363. /**
  75364. * The friendly name of the light in the scene.
  75365. */
  75366. name: string;
  75367. /**
  75368. * Defines the shadow projection clipping minimum z value.
  75369. */
  75370. shadowMinZ: number;
  75371. /**
  75372. * Defines the shadow projection clipping maximum z value.
  75373. */
  75374. shadowMaxZ: number;
  75375. /**
  75376. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75377. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75378. */
  75379. computeTransformedInformation(): boolean;
  75380. /**
  75381. * Gets the scene the light belongs to.
  75382. * @returns The scene
  75383. */
  75384. getScene(): Scene;
  75385. /**
  75386. * Callback defining a custom Projection Matrix Builder.
  75387. * This can be used to override the default projection matrix computation.
  75388. */
  75389. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75390. /**
  75391. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75392. * @param matrix The materix to updated with the projection information
  75393. * @param viewMatrix The transform matrix of the light
  75394. * @param renderList The list of mesh to render in the map
  75395. * @returns The current light
  75396. */
  75397. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75398. /**
  75399. * Gets the current depth scale used in ESM.
  75400. * @returns The scale
  75401. */
  75402. getDepthScale(): number;
  75403. /**
  75404. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75405. * @returns true if a cube texture needs to be use
  75406. */
  75407. needCube(): boolean;
  75408. /**
  75409. * Detects if the projection matrix requires to be recomputed this frame.
  75410. * @returns true if it requires to be recomputed otherwise, false.
  75411. */
  75412. needProjectionMatrixCompute(): boolean;
  75413. /**
  75414. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75415. */
  75416. forceProjectionMatrixCompute(): void;
  75417. /**
  75418. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75419. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75420. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75421. */
  75422. getShadowDirection(faceIndex?: number): Vector3;
  75423. /**
  75424. * Gets the minZ used for shadow according to both the scene and the light.
  75425. * @param activeCamera The camera we are returning the min for
  75426. * @returns the depth min z
  75427. */
  75428. getDepthMinZ(activeCamera: Camera): number;
  75429. /**
  75430. * Gets the maxZ used for shadow according to both the scene and the light.
  75431. * @param activeCamera The camera we are returning the max for
  75432. * @returns the depth max z
  75433. */
  75434. getDepthMaxZ(activeCamera: Camera): number;
  75435. }
  75436. /**
  75437. * Base implementation IShadowLight
  75438. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75439. */
  75440. export abstract class ShadowLight extends Light implements IShadowLight {
  75441. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75442. protected _position: Vector3;
  75443. protected _setPosition(value: Vector3): void;
  75444. /**
  75445. * Sets the position the shadow will be casted from. Also use as the light position for both
  75446. * point and spot lights.
  75447. */
  75448. /**
  75449. * Sets the position the shadow will be casted from. Also use as the light position for both
  75450. * point and spot lights.
  75451. */
  75452. position: Vector3;
  75453. protected _direction: Vector3;
  75454. protected _setDirection(value: Vector3): void;
  75455. /**
  75456. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75457. * Also use as the light direction on spot and directional lights.
  75458. */
  75459. /**
  75460. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75461. * Also use as the light direction on spot and directional lights.
  75462. */
  75463. direction: Vector3;
  75464. private _shadowMinZ;
  75465. /**
  75466. * Gets the shadow projection clipping minimum z value.
  75467. */
  75468. /**
  75469. * Sets the shadow projection clipping minimum z value.
  75470. */
  75471. shadowMinZ: number;
  75472. private _shadowMaxZ;
  75473. /**
  75474. * Sets the shadow projection clipping maximum z value.
  75475. */
  75476. /**
  75477. * Gets the shadow projection clipping maximum z value.
  75478. */
  75479. shadowMaxZ: number;
  75480. /**
  75481. * Callback defining a custom Projection Matrix Builder.
  75482. * This can be used to override the default projection matrix computation.
  75483. */
  75484. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75485. /**
  75486. * The transformed position. Position of the light in world space taking parenting in account.
  75487. */
  75488. transformedPosition: Vector3;
  75489. /**
  75490. * The transformed direction. Direction of the light in world space taking parenting in account.
  75491. */
  75492. transformedDirection: Vector3;
  75493. private _needProjectionMatrixCompute;
  75494. /**
  75495. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75496. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75497. */
  75498. computeTransformedInformation(): boolean;
  75499. /**
  75500. * Return the depth scale used for the shadow map.
  75501. * @returns the depth scale.
  75502. */
  75503. getDepthScale(): number;
  75504. /**
  75505. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75506. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75507. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75508. */
  75509. getShadowDirection(faceIndex?: number): Vector3;
  75510. /**
  75511. * Returns the ShadowLight absolute position in the World.
  75512. * @returns the position vector in world space
  75513. */
  75514. getAbsolutePosition(): Vector3;
  75515. /**
  75516. * Sets the ShadowLight direction toward the passed target.
  75517. * @param target The point to target in local space
  75518. * @returns the updated ShadowLight direction
  75519. */
  75520. setDirectionToTarget(target: Vector3): Vector3;
  75521. /**
  75522. * Returns the light rotation in euler definition.
  75523. * @returns the x y z rotation in local space.
  75524. */
  75525. getRotation(): Vector3;
  75526. /**
  75527. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75528. * @returns true if a cube texture needs to be use
  75529. */
  75530. needCube(): boolean;
  75531. /**
  75532. * Detects if the projection matrix requires to be recomputed this frame.
  75533. * @returns true if it requires to be recomputed otherwise, false.
  75534. */
  75535. needProjectionMatrixCompute(): boolean;
  75536. /**
  75537. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75538. */
  75539. forceProjectionMatrixCompute(): void;
  75540. /** @hidden */
  75541. _initCache(): void;
  75542. /** @hidden */
  75543. _isSynchronized(): boolean;
  75544. /**
  75545. * Computes the world matrix of the node
  75546. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75547. * @returns the world matrix
  75548. */
  75549. computeWorldMatrix(force?: boolean): Matrix;
  75550. /**
  75551. * Gets the minZ used for shadow according to both the scene and the light.
  75552. * @param activeCamera The camera we are returning the min for
  75553. * @returns the depth min z
  75554. */
  75555. getDepthMinZ(activeCamera: Camera): number;
  75556. /**
  75557. * Gets the maxZ used for shadow according to both the scene and the light.
  75558. * @param activeCamera The camera we are returning the max for
  75559. * @returns the depth max z
  75560. */
  75561. getDepthMaxZ(activeCamera: Camera): number;
  75562. /**
  75563. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75564. * @param matrix The materix to updated with the projection information
  75565. * @param viewMatrix The transform matrix of the light
  75566. * @param renderList The list of mesh to render in the map
  75567. * @returns The current light
  75568. */
  75569. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75570. }
  75571. }
  75572. declare module BABYLON {
  75573. /**
  75574. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75575. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75576. */
  75577. export class EffectFallbacks implements IEffectFallbacks {
  75578. private _defines;
  75579. private _currentRank;
  75580. private _maxRank;
  75581. private _mesh;
  75582. /**
  75583. * Removes the fallback from the bound mesh.
  75584. */
  75585. unBindMesh(): void;
  75586. /**
  75587. * Adds a fallback on the specified property.
  75588. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75589. * @param define The name of the define in the shader
  75590. */
  75591. addFallback(rank: number, define: string): void;
  75592. /**
  75593. * Sets the mesh to use CPU skinning when needing to fallback.
  75594. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75595. * @param mesh The mesh to use the fallbacks.
  75596. */
  75597. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75598. /**
  75599. * Checks to see if more fallbacks are still availible.
  75600. */
  75601. readonly hasMoreFallbacks: boolean;
  75602. /**
  75603. * Removes the defines that should be removed when falling back.
  75604. * @param currentDefines defines the current define statements for the shader.
  75605. * @param effect defines the current effect we try to compile
  75606. * @returns The resulting defines with defines of the current rank removed.
  75607. */
  75608. reduce(currentDefines: string, effect: Effect): string;
  75609. }
  75610. }
  75611. declare module BABYLON {
  75612. /**
  75613. * "Static Class" containing the most commonly used helper while dealing with material for
  75614. * rendering purpose.
  75615. *
  75616. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75617. *
  75618. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75619. */
  75620. export class MaterialHelper {
  75621. /**
  75622. * Bind the current view position to an effect.
  75623. * @param effect The effect to be bound
  75624. * @param scene The scene the eyes position is used from
  75625. */
  75626. static BindEyePosition(effect: Effect, scene: Scene): void;
  75627. /**
  75628. * Helps preparing the defines values about the UVs in used in the effect.
  75629. * UVs are shared as much as we can accross channels in the shaders.
  75630. * @param texture The texture we are preparing the UVs for
  75631. * @param defines The defines to update
  75632. * @param key The channel key "diffuse", "specular"... used in the shader
  75633. */
  75634. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75635. /**
  75636. * Binds a texture matrix value to its corrsponding uniform
  75637. * @param texture The texture to bind the matrix for
  75638. * @param uniformBuffer The uniform buffer receivin the data
  75639. * @param key The channel key "diffuse", "specular"... used in the shader
  75640. */
  75641. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75642. /**
  75643. * Gets the current status of the fog (should it be enabled?)
  75644. * @param mesh defines the mesh to evaluate for fog support
  75645. * @param scene defines the hosting scene
  75646. * @returns true if fog must be enabled
  75647. */
  75648. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75649. /**
  75650. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75651. * @param mesh defines the current mesh
  75652. * @param scene defines the current scene
  75653. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75654. * @param pointsCloud defines if point cloud rendering has to be turned on
  75655. * @param fogEnabled defines if fog has to be turned on
  75656. * @param alphaTest defines if alpha testing has to be turned on
  75657. * @param defines defines the current list of defines
  75658. */
  75659. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75660. /**
  75661. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75662. * @param scene defines the current scene
  75663. * @param engine defines the current engine
  75664. * @param defines specifies the list of active defines
  75665. * @param useInstances defines if instances have to be turned on
  75666. * @param useClipPlane defines if clip plane have to be turned on
  75667. */
  75668. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75669. /**
  75670. * Prepares the defines for bones
  75671. * @param mesh The mesh containing the geometry data we will draw
  75672. * @param defines The defines to update
  75673. */
  75674. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75675. /**
  75676. * Prepares the defines for morph targets
  75677. * @param mesh The mesh containing the geometry data we will draw
  75678. * @param defines The defines to update
  75679. */
  75680. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75681. /**
  75682. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75683. * @param mesh The mesh containing the geometry data we will draw
  75684. * @param defines The defines to update
  75685. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75686. * @param useBones Precise whether bones should be used or not (override mesh info)
  75687. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75688. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75689. * @returns false if defines are considered not dirty and have not been checked
  75690. */
  75691. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75692. /**
  75693. * Prepares the defines related to multiview
  75694. * @param scene The scene we are intending to draw
  75695. * @param defines The defines to update
  75696. */
  75697. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75698. /**
  75699. * Prepares the defines related to the light information passed in parameter
  75700. * @param scene The scene we are intending to draw
  75701. * @param mesh The mesh the effect is compiling for
  75702. * @param light The light the effect is compiling for
  75703. * @param lightIndex The index of the light
  75704. * @param defines The defines to update
  75705. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75706. * @param state Defines the current state regarding what is needed (normals, etc...)
  75707. */
  75708. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75709. needNormals: boolean;
  75710. needRebuild: boolean;
  75711. shadowEnabled: boolean;
  75712. specularEnabled: boolean;
  75713. lightmapMode: boolean;
  75714. }): void;
  75715. /**
  75716. * Prepares the defines related to the light information passed in parameter
  75717. * @param scene The scene we are intending to draw
  75718. * @param mesh The mesh the effect is compiling for
  75719. * @param defines The defines to update
  75720. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75721. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75722. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75723. * @returns true if normals will be required for the rest of the effect
  75724. */
  75725. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75726. /**
  75727. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75728. * @param lightIndex defines the light index
  75729. * @param uniformsList The uniform list
  75730. * @param samplersList The sampler list
  75731. * @param projectedLightTexture defines if projected texture must be used
  75732. * @param uniformBuffersList defines an optional list of uniform buffers
  75733. */
  75734. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75735. /**
  75736. * Prepares the uniforms and samplers list to be used in the effect
  75737. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75738. * @param samplersList The sampler list
  75739. * @param defines The defines helping in the list generation
  75740. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75741. */
  75742. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75743. /**
  75744. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75745. * @param defines The defines to update while falling back
  75746. * @param fallbacks The authorized effect fallbacks
  75747. * @param maxSimultaneousLights The maximum number of lights allowed
  75748. * @param rank the current rank of the Effect
  75749. * @returns The newly affected rank
  75750. */
  75751. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75752. private static _TmpMorphInfluencers;
  75753. /**
  75754. * Prepares the list of attributes required for morph targets according to the effect defines.
  75755. * @param attribs The current list of supported attribs
  75756. * @param mesh The mesh to prepare the morph targets attributes for
  75757. * @param influencers The number of influencers
  75758. */
  75759. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75760. /**
  75761. * Prepares the list of attributes required for morph targets according to the effect defines.
  75762. * @param attribs The current list of supported attribs
  75763. * @param mesh The mesh to prepare the morph targets attributes for
  75764. * @param defines The current Defines of the effect
  75765. */
  75766. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75767. /**
  75768. * Prepares the list of attributes required for bones according to the effect defines.
  75769. * @param attribs The current list of supported attribs
  75770. * @param mesh The mesh to prepare the bones attributes for
  75771. * @param defines The current Defines of the effect
  75772. * @param fallbacks The current efffect fallback strategy
  75773. */
  75774. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75775. /**
  75776. * Check and prepare the list of attributes required for instances according to the effect defines.
  75777. * @param attribs The current list of supported attribs
  75778. * @param defines The current MaterialDefines of the effect
  75779. */
  75780. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75781. /**
  75782. * Add the list of attributes required for instances to the attribs array.
  75783. * @param attribs The current list of supported attribs
  75784. */
  75785. static PushAttributesForInstances(attribs: string[]): void;
  75786. /**
  75787. * Binds the light shadow information to the effect for the given mesh.
  75788. * @param light The light containing the generator
  75789. * @param scene The scene the lights belongs to
  75790. * @param mesh The mesh we are binding the information to render
  75791. * @param lightIndex The light index in the effect used to render the mesh
  75792. * @param effect The effect we are binding the data to
  75793. */
  75794. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75795. /**
  75796. * Binds the light information to the effect.
  75797. * @param light The light containing the generator
  75798. * @param effect The effect we are binding the data to
  75799. * @param lightIndex The light index in the effect used to render
  75800. */
  75801. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75802. /**
  75803. * Binds the lights information from the scene to the effect for the given mesh.
  75804. * @param light Light to bind
  75805. * @param lightIndex Light index
  75806. * @param scene The scene where the light belongs to
  75807. * @param mesh The mesh we are binding the information to render
  75808. * @param effect The effect we are binding the data to
  75809. * @param useSpecular Defines if specular is supported
  75810. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75811. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75812. */
  75813. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75814. /**
  75815. * Binds the lights information from the scene to the effect for the given mesh.
  75816. * @param scene The scene the lights belongs to
  75817. * @param mesh The mesh we are binding the information to render
  75818. * @param effect The effect we are binding the data to
  75819. * @param defines The generated defines for the effect
  75820. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75821. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75823. */
  75824. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75825. private static _tempFogColor;
  75826. /**
  75827. * Binds the fog information from the scene to the effect for the given mesh.
  75828. * @param scene The scene the lights belongs to
  75829. * @param mesh The mesh we are binding the information to render
  75830. * @param effect The effect we are binding the data to
  75831. * @param linearSpace Defines if the fog effect is applied in linear space
  75832. */
  75833. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75834. /**
  75835. * Binds the bones information from the mesh to the effect.
  75836. * @param mesh The mesh we are binding the information to render
  75837. * @param effect The effect we are binding the data to
  75838. */
  75839. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75840. /**
  75841. * Binds the morph targets information from the mesh to the effect.
  75842. * @param abstractMesh The mesh we are binding the information to render
  75843. * @param effect The effect we are binding the data to
  75844. */
  75845. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75846. /**
  75847. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75848. * @param defines The generated defines used in the effect
  75849. * @param effect The effect we are binding the data to
  75850. * @param scene The scene we are willing to render with logarithmic scale for
  75851. */
  75852. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75853. /**
  75854. * Binds the clip plane information from the scene to the effect.
  75855. * @param scene The scene the clip plane information are extracted from
  75856. * @param effect The effect we are binding the data to
  75857. */
  75858. static BindClipPlane(effect: Effect, scene: Scene): void;
  75859. }
  75860. }
  75861. declare module BABYLON {
  75862. /** @hidden */
  75863. export var packingFunctions: {
  75864. name: string;
  75865. shader: string;
  75866. };
  75867. }
  75868. declare module BABYLON {
  75869. /** @hidden */
  75870. export var shadowMapPixelShader: {
  75871. name: string;
  75872. shader: string;
  75873. };
  75874. }
  75875. declare module BABYLON {
  75876. /** @hidden */
  75877. export var bonesDeclaration: {
  75878. name: string;
  75879. shader: string;
  75880. };
  75881. }
  75882. declare module BABYLON {
  75883. /** @hidden */
  75884. export var morphTargetsVertexGlobalDeclaration: {
  75885. name: string;
  75886. shader: string;
  75887. };
  75888. }
  75889. declare module BABYLON {
  75890. /** @hidden */
  75891. export var morphTargetsVertexDeclaration: {
  75892. name: string;
  75893. shader: string;
  75894. };
  75895. }
  75896. declare module BABYLON {
  75897. /** @hidden */
  75898. export var instancesDeclaration: {
  75899. name: string;
  75900. shader: string;
  75901. };
  75902. }
  75903. declare module BABYLON {
  75904. /** @hidden */
  75905. export var helperFunctions: {
  75906. name: string;
  75907. shader: string;
  75908. };
  75909. }
  75910. declare module BABYLON {
  75911. /** @hidden */
  75912. export var morphTargetsVertex: {
  75913. name: string;
  75914. shader: string;
  75915. };
  75916. }
  75917. declare module BABYLON {
  75918. /** @hidden */
  75919. export var instancesVertex: {
  75920. name: string;
  75921. shader: string;
  75922. };
  75923. }
  75924. declare module BABYLON {
  75925. /** @hidden */
  75926. export var bonesVertex: {
  75927. name: string;
  75928. shader: string;
  75929. };
  75930. }
  75931. declare module BABYLON {
  75932. /** @hidden */
  75933. export var shadowMapVertexShader: {
  75934. name: string;
  75935. shader: string;
  75936. };
  75937. }
  75938. declare module BABYLON {
  75939. /** @hidden */
  75940. export var depthBoxBlurPixelShader: {
  75941. name: string;
  75942. shader: string;
  75943. };
  75944. }
  75945. declare module BABYLON {
  75946. /**
  75947. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75948. */
  75949. export interface ICustomShaderOptions {
  75950. /**
  75951. * Gets or sets the custom shader name to use
  75952. */
  75953. shaderName: string;
  75954. /**
  75955. * The list of attribute names used in the shader
  75956. */
  75957. attributes?: string[];
  75958. /**
  75959. * The list of unifrom names used in the shader
  75960. */
  75961. uniforms?: string[];
  75962. /**
  75963. * The list of sampler names used in the shader
  75964. */
  75965. samplers?: string[];
  75966. /**
  75967. * The list of defines used in the shader
  75968. */
  75969. defines?: string[];
  75970. }
  75971. /**
  75972. * Interface to implement to create a shadow generator compatible with BJS.
  75973. */
  75974. export interface IShadowGenerator {
  75975. /**
  75976. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75977. * @returns The render target texture if present otherwise, null
  75978. */
  75979. getShadowMap(): Nullable<RenderTargetTexture>;
  75980. /**
  75981. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75982. * @returns The render target texture if the shadow map is present otherwise, null
  75983. */
  75984. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75985. /**
  75986. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75987. * @param subMesh The submesh we want to render in the shadow map
  75988. * @param useInstances Defines wether will draw in the map using instances
  75989. * @returns true if ready otherwise, false
  75990. */
  75991. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75992. /**
  75993. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75994. * @param defines Defines of the material we want to update
  75995. * @param lightIndex Index of the light in the enabled light list of the material
  75996. */
  75997. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75998. /**
  75999. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76000. * defined in the generator but impacting the effect).
  76001. * It implies the unifroms available on the materials are the standard BJS ones.
  76002. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76003. * @param effect The effect we are binfing the information for
  76004. */
  76005. bindShadowLight(lightIndex: string, effect: Effect): void;
  76006. /**
  76007. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76008. * (eq to shadow prjection matrix * light transform matrix)
  76009. * @returns The transform matrix used to create the shadow map
  76010. */
  76011. getTransformMatrix(): Matrix;
  76012. /**
  76013. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76014. * Cube and 2D textures for instance.
  76015. */
  76016. recreateShadowMap(): void;
  76017. /**
  76018. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76019. * @param onCompiled Callback triggered at the and of the effects compilation
  76020. * @param options Sets of optional options forcing the compilation with different modes
  76021. */
  76022. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76023. useInstances: boolean;
  76024. }>): void;
  76025. /**
  76026. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76027. * @param options Sets of optional options forcing the compilation with different modes
  76028. * @returns A promise that resolves when the compilation completes
  76029. */
  76030. forceCompilationAsync(options?: Partial<{
  76031. useInstances: boolean;
  76032. }>): Promise<void>;
  76033. /**
  76034. * Serializes the shadow generator setup to a json object.
  76035. * @returns The serialized JSON object
  76036. */
  76037. serialize(): any;
  76038. /**
  76039. * Disposes the Shadow map and related Textures and effects.
  76040. */
  76041. dispose(): void;
  76042. }
  76043. /**
  76044. * Default implementation IShadowGenerator.
  76045. * This is the main object responsible of generating shadows in the framework.
  76046. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76047. */
  76048. export class ShadowGenerator implements IShadowGenerator {
  76049. /**
  76050. * Shadow generator mode None: no filtering applied.
  76051. */
  76052. static readonly FILTER_NONE: number;
  76053. /**
  76054. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76055. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76056. */
  76057. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76058. /**
  76059. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76060. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76061. */
  76062. static readonly FILTER_POISSONSAMPLING: number;
  76063. /**
  76064. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76065. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76066. */
  76067. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76068. /**
  76069. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76070. * edge artifacts on steep falloff.
  76071. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76072. */
  76073. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76074. /**
  76075. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76076. * edge artifacts on steep falloff.
  76077. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76078. */
  76079. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76080. /**
  76081. * Shadow generator mode PCF: Percentage Closer Filtering
  76082. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76083. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76084. */
  76085. static readonly FILTER_PCF: number;
  76086. /**
  76087. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76088. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76089. * Contact Hardening
  76090. */
  76091. static readonly FILTER_PCSS: number;
  76092. /**
  76093. * Reserved for PCF and PCSS
  76094. * Highest Quality.
  76095. *
  76096. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76097. *
  76098. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76099. */
  76100. static readonly QUALITY_HIGH: number;
  76101. /**
  76102. * Reserved for PCF and PCSS
  76103. * Good tradeoff for quality/perf cross devices
  76104. *
  76105. * Execute PCF on a 3*3 kernel.
  76106. *
  76107. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76108. */
  76109. static readonly QUALITY_MEDIUM: number;
  76110. /**
  76111. * Reserved for PCF and PCSS
  76112. * The lowest quality but the fastest.
  76113. *
  76114. * Execute PCF on a 1*1 kernel.
  76115. *
  76116. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76117. */
  76118. static readonly QUALITY_LOW: number;
  76119. /** Gets or sets the custom shader name to use */
  76120. customShaderOptions: ICustomShaderOptions;
  76121. /**
  76122. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76123. */
  76124. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76125. /**
  76126. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76127. */
  76128. onAfterShadowMapRenderObservable: Observable<Effect>;
  76129. /**
  76130. * Observable triggered before a mesh is rendered in the shadow map.
  76131. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76132. */
  76133. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76134. /**
  76135. * Observable triggered after a mesh is rendered in the shadow map.
  76136. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76137. */
  76138. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76139. private _bias;
  76140. /**
  76141. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76142. */
  76143. /**
  76144. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76145. */
  76146. bias: number;
  76147. private _normalBias;
  76148. /**
  76149. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76150. */
  76151. /**
  76152. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76153. */
  76154. normalBias: number;
  76155. private _blurBoxOffset;
  76156. /**
  76157. * Gets the blur box offset: offset applied during the blur pass.
  76158. * Only useful if useKernelBlur = false
  76159. */
  76160. /**
  76161. * Sets the blur box offset: offset applied during the blur pass.
  76162. * Only useful if useKernelBlur = false
  76163. */
  76164. blurBoxOffset: number;
  76165. private _blurScale;
  76166. /**
  76167. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76168. * 2 means half of the size.
  76169. */
  76170. /**
  76171. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76172. * 2 means half of the size.
  76173. */
  76174. blurScale: number;
  76175. private _blurKernel;
  76176. /**
  76177. * Gets the blur kernel: kernel size of the blur pass.
  76178. * Only useful if useKernelBlur = true
  76179. */
  76180. /**
  76181. * Sets the blur kernel: kernel size of the blur pass.
  76182. * Only useful if useKernelBlur = true
  76183. */
  76184. blurKernel: number;
  76185. private _useKernelBlur;
  76186. /**
  76187. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76188. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76189. */
  76190. /**
  76191. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76192. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76193. */
  76194. useKernelBlur: boolean;
  76195. private _depthScale;
  76196. /**
  76197. * Gets the depth scale used in ESM mode.
  76198. */
  76199. /**
  76200. * Sets the depth scale used in ESM mode.
  76201. * This can override the scale stored on the light.
  76202. */
  76203. depthScale: number;
  76204. private _filter;
  76205. /**
  76206. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76207. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76208. */
  76209. /**
  76210. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76211. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76212. */
  76213. filter: number;
  76214. /**
  76215. * Gets if the current filter is set to Poisson Sampling.
  76216. */
  76217. /**
  76218. * Sets the current filter to Poisson Sampling.
  76219. */
  76220. usePoissonSampling: boolean;
  76221. /**
  76222. * Gets if the current filter is set to ESM.
  76223. */
  76224. /**
  76225. * Sets the current filter is to ESM.
  76226. */
  76227. useExponentialShadowMap: boolean;
  76228. /**
  76229. * Gets if the current filter is set to filtered ESM.
  76230. */
  76231. /**
  76232. * Gets if the current filter is set to filtered ESM.
  76233. */
  76234. useBlurExponentialShadowMap: boolean;
  76235. /**
  76236. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76237. * exponential to prevent steep falloff artifacts).
  76238. */
  76239. /**
  76240. * Sets the current filter to "close ESM" (using the inverse of the
  76241. * exponential to prevent steep falloff artifacts).
  76242. */
  76243. useCloseExponentialShadowMap: boolean;
  76244. /**
  76245. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76246. * exponential to prevent steep falloff artifacts).
  76247. */
  76248. /**
  76249. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76250. * exponential to prevent steep falloff artifacts).
  76251. */
  76252. useBlurCloseExponentialShadowMap: boolean;
  76253. /**
  76254. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76255. */
  76256. /**
  76257. * Sets the current filter to "PCF" (percentage closer filtering).
  76258. */
  76259. usePercentageCloserFiltering: boolean;
  76260. private _filteringQuality;
  76261. /**
  76262. * Gets the PCF or PCSS Quality.
  76263. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76264. */
  76265. /**
  76266. * Sets the PCF or PCSS Quality.
  76267. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76268. */
  76269. filteringQuality: number;
  76270. /**
  76271. * Gets if the current filter is set to "PCSS" (contact hardening).
  76272. */
  76273. /**
  76274. * Sets the current filter to "PCSS" (contact hardening).
  76275. */
  76276. useContactHardeningShadow: boolean;
  76277. private _contactHardeningLightSizeUVRatio;
  76278. /**
  76279. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76280. * Using a ratio helps keeping shape stability independently of the map size.
  76281. *
  76282. * It does not account for the light projection as it was having too much
  76283. * instability during the light setup or during light position changes.
  76284. *
  76285. * Only valid if useContactHardeningShadow is true.
  76286. */
  76287. /**
  76288. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76289. * Using a ratio helps keeping shape stability independently of the map size.
  76290. *
  76291. * It does not account for the light projection as it was having too much
  76292. * instability during the light setup or during light position changes.
  76293. *
  76294. * Only valid if useContactHardeningShadow is true.
  76295. */
  76296. contactHardeningLightSizeUVRatio: number;
  76297. private _darkness;
  76298. /** Gets or sets the actual darkness of a shadow */
  76299. darkness: number;
  76300. /**
  76301. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76302. * 0 means strongest and 1 would means no shadow.
  76303. * @returns the darkness.
  76304. */
  76305. getDarkness(): number;
  76306. /**
  76307. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76308. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76309. * @returns the shadow generator allowing fluent coding.
  76310. */
  76311. setDarkness(darkness: number): ShadowGenerator;
  76312. private _transparencyShadow;
  76313. /** Gets or sets the ability to have transparent shadow */
  76314. transparencyShadow: boolean;
  76315. /**
  76316. * Sets the ability to have transparent shadow (boolean).
  76317. * @param transparent True if transparent else False
  76318. * @returns the shadow generator allowing fluent coding
  76319. */
  76320. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76321. private _shadowMap;
  76322. private _shadowMap2;
  76323. /**
  76324. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76325. * @returns The render target texture if present otherwise, null
  76326. */
  76327. getShadowMap(): Nullable<RenderTargetTexture>;
  76328. /**
  76329. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76330. * @returns The render target texture if the shadow map is present otherwise, null
  76331. */
  76332. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76333. /**
  76334. * Gets the class name of that object
  76335. * @returns "ShadowGenerator"
  76336. */
  76337. getClassName(): string;
  76338. /**
  76339. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76340. * @param mesh Mesh to add
  76341. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76342. * @returns the Shadow Generator itself
  76343. */
  76344. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76345. /**
  76346. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76347. * @param mesh Mesh to remove
  76348. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76349. * @returns the Shadow Generator itself
  76350. */
  76351. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76352. /**
  76353. * Controls the extent to which the shadows fade out at the edge of the frustum
  76354. * Used only by directionals and spots
  76355. */
  76356. frustumEdgeFalloff: number;
  76357. private _light;
  76358. /**
  76359. * Returns the associated light object.
  76360. * @returns the light generating the shadow
  76361. */
  76362. getLight(): IShadowLight;
  76363. /**
  76364. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76365. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76366. * It might on the other hand introduce peter panning.
  76367. */
  76368. forceBackFacesOnly: boolean;
  76369. private _scene;
  76370. private _lightDirection;
  76371. private _effect;
  76372. private _viewMatrix;
  76373. private _projectionMatrix;
  76374. private _transformMatrix;
  76375. private _cachedPosition;
  76376. private _cachedDirection;
  76377. private _cachedDefines;
  76378. private _currentRenderID;
  76379. private _boxBlurPostprocess;
  76380. private _kernelBlurXPostprocess;
  76381. private _kernelBlurYPostprocess;
  76382. private _blurPostProcesses;
  76383. private _mapSize;
  76384. private _currentFaceIndex;
  76385. private _currentFaceIndexCache;
  76386. private _textureType;
  76387. private _defaultTextureMatrix;
  76388. private _storedUniqueId;
  76389. /** @hidden */
  76390. static _SceneComponentInitialization: (scene: Scene) => void;
  76391. /**
  76392. * Creates a ShadowGenerator object.
  76393. * A ShadowGenerator is the required tool to use the shadows.
  76394. * Each light casting shadows needs to use its own ShadowGenerator.
  76395. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76396. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76397. * @param light The light object generating the shadows.
  76398. * @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.
  76399. */
  76400. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76401. private _initializeGenerator;
  76402. private _initializeShadowMap;
  76403. private _initializeBlurRTTAndPostProcesses;
  76404. private _renderForShadowMap;
  76405. private _renderSubMeshForShadowMap;
  76406. private _applyFilterValues;
  76407. /**
  76408. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76409. * @param onCompiled Callback triggered at the and of the effects compilation
  76410. * @param options Sets of optional options forcing the compilation with different modes
  76411. */
  76412. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76413. useInstances: boolean;
  76414. }>): void;
  76415. /**
  76416. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76417. * @param options Sets of optional options forcing the compilation with different modes
  76418. * @returns A promise that resolves when the compilation completes
  76419. */
  76420. forceCompilationAsync(options?: Partial<{
  76421. useInstances: boolean;
  76422. }>): Promise<void>;
  76423. /**
  76424. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76425. * @param subMesh The submesh we want to render in the shadow map
  76426. * @param useInstances Defines wether will draw in the map using instances
  76427. * @returns true if ready otherwise, false
  76428. */
  76429. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76430. /**
  76431. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76432. * @param defines Defines of the material we want to update
  76433. * @param lightIndex Index of the light in the enabled light list of the material
  76434. */
  76435. prepareDefines(defines: any, lightIndex: number): void;
  76436. /**
  76437. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76438. * defined in the generator but impacting the effect).
  76439. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76440. * @param effect The effect we are binfing the information for
  76441. */
  76442. bindShadowLight(lightIndex: string, effect: Effect): void;
  76443. /**
  76444. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76445. * (eq to shadow prjection matrix * light transform matrix)
  76446. * @returns The transform matrix used to create the shadow map
  76447. */
  76448. getTransformMatrix(): Matrix;
  76449. /**
  76450. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76451. * Cube and 2D textures for instance.
  76452. */
  76453. recreateShadowMap(): void;
  76454. private _disposeBlurPostProcesses;
  76455. private _disposeRTTandPostProcesses;
  76456. /**
  76457. * Disposes the ShadowGenerator.
  76458. * Returns nothing.
  76459. */
  76460. dispose(): void;
  76461. /**
  76462. * Serializes the shadow generator setup to a json object.
  76463. * @returns The serialized JSON object
  76464. */
  76465. serialize(): any;
  76466. /**
  76467. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76468. * @param parsedShadowGenerator The JSON object to parse
  76469. * @param scene The scene to create the shadow map for
  76470. * @returns The parsed shadow generator
  76471. */
  76472. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76473. }
  76474. }
  76475. declare module BABYLON {
  76476. /**
  76477. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76478. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76479. * 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.
  76480. */
  76481. export abstract class Light extends Node {
  76482. /**
  76483. * Falloff Default: light is falling off following the material specification:
  76484. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76485. */
  76486. static readonly FALLOFF_DEFAULT: number;
  76487. /**
  76488. * Falloff Physical: light is falling off following the inverse squared distance law.
  76489. */
  76490. static readonly FALLOFF_PHYSICAL: number;
  76491. /**
  76492. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76493. * to enhance interoperability with other engines.
  76494. */
  76495. static readonly FALLOFF_GLTF: number;
  76496. /**
  76497. * Falloff Standard: light is falling off like in the standard material
  76498. * to enhance interoperability with other materials.
  76499. */
  76500. static readonly FALLOFF_STANDARD: number;
  76501. /**
  76502. * If every light affecting the material is in this lightmapMode,
  76503. * material.lightmapTexture adds or multiplies
  76504. * (depends on material.useLightmapAsShadowmap)
  76505. * after every other light calculations.
  76506. */
  76507. static readonly LIGHTMAP_DEFAULT: number;
  76508. /**
  76509. * material.lightmapTexture as only diffuse lighting from this light
  76510. * adds only specular lighting from this light
  76511. * adds dynamic shadows
  76512. */
  76513. static readonly LIGHTMAP_SPECULAR: number;
  76514. /**
  76515. * material.lightmapTexture as only lighting
  76516. * no light calculation from this light
  76517. * only adds dynamic shadows from this light
  76518. */
  76519. static readonly LIGHTMAP_SHADOWSONLY: number;
  76520. /**
  76521. * Each light type uses the default quantity according to its type:
  76522. * point/spot lights use luminous intensity
  76523. * directional lights use illuminance
  76524. */
  76525. static readonly INTENSITYMODE_AUTOMATIC: number;
  76526. /**
  76527. * lumen (lm)
  76528. */
  76529. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76530. /**
  76531. * candela (lm/sr)
  76532. */
  76533. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76534. /**
  76535. * lux (lm/m^2)
  76536. */
  76537. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76538. /**
  76539. * nit (cd/m^2)
  76540. */
  76541. static readonly INTENSITYMODE_LUMINANCE: number;
  76542. /**
  76543. * Light type const id of the point light.
  76544. */
  76545. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76546. /**
  76547. * Light type const id of the directional light.
  76548. */
  76549. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76550. /**
  76551. * Light type const id of the spot light.
  76552. */
  76553. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76554. /**
  76555. * Light type const id of the hemispheric light.
  76556. */
  76557. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76558. /**
  76559. * Diffuse gives the basic color to an object.
  76560. */
  76561. diffuse: Color3;
  76562. /**
  76563. * Specular produces a highlight color on an object.
  76564. * Note: This is note affecting PBR materials.
  76565. */
  76566. specular: Color3;
  76567. /**
  76568. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76569. * falling off base on range or angle.
  76570. * This can be set to any values in Light.FALLOFF_x.
  76571. *
  76572. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76573. * other types of materials.
  76574. */
  76575. falloffType: number;
  76576. /**
  76577. * Strength of the light.
  76578. * Note: By default it is define in the framework own unit.
  76579. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76580. */
  76581. intensity: number;
  76582. private _range;
  76583. protected _inverseSquaredRange: number;
  76584. /**
  76585. * Defines how far from the source the light is impacting in scene units.
  76586. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76587. */
  76588. /**
  76589. * Defines how far from the source the light is impacting in scene units.
  76590. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76591. */
  76592. range: number;
  76593. /**
  76594. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76595. * of light.
  76596. */
  76597. private _photometricScale;
  76598. private _intensityMode;
  76599. /**
  76600. * Gets the photometric scale used to interpret the intensity.
  76601. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76602. */
  76603. /**
  76604. * Sets the photometric scale used to interpret the intensity.
  76605. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76606. */
  76607. intensityMode: number;
  76608. private _radius;
  76609. /**
  76610. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76611. */
  76612. /**
  76613. * sets the light radius used by PBR Materials to simulate soft area lights.
  76614. */
  76615. radius: number;
  76616. private _renderPriority;
  76617. /**
  76618. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76619. * exceeding the number allowed of the materials.
  76620. */
  76621. renderPriority: number;
  76622. private _shadowEnabled;
  76623. /**
  76624. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76625. * the current shadow generator.
  76626. */
  76627. /**
  76628. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76629. * the current shadow generator.
  76630. */
  76631. shadowEnabled: boolean;
  76632. private _includedOnlyMeshes;
  76633. /**
  76634. * Gets the only meshes impacted by this light.
  76635. */
  76636. /**
  76637. * Sets the only meshes impacted by this light.
  76638. */
  76639. includedOnlyMeshes: AbstractMesh[];
  76640. private _excludedMeshes;
  76641. /**
  76642. * Gets the meshes not impacted by this light.
  76643. */
  76644. /**
  76645. * Sets the meshes not impacted by this light.
  76646. */
  76647. excludedMeshes: AbstractMesh[];
  76648. private _excludeWithLayerMask;
  76649. /**
  76650. * Gets the layer id use to find what meshes are not impacted by the light.
  76651. * Inactive if 0
  76652. */
  76653. /**
  76654. * Sets the layer id use to find what meshes are not impacted by the light.
  76655. * Inactive if 0
  76656. */
  76657. excludeWithLayerMask: number;
  76658. private _includeOnlyWithLayerMask;
  76659. /**
  76660. * Gets the layer id use to find what meshes are impacted by the light.
  76661. * Inactive if 0
  76662. */
  76663. /**
  76664. * Sets the layer id use to find what meshes are impacted by the light.
  76665. * Inactive if 0
  76666. */
  76667. includeOnlyWithLayerMask: number;
  76668. private _lightmapMode;
  76669. /**
  76670. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76671. */
  76672. /**
  76673. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76674. */
  76675. lightmapMode: number;
  76676. /**
  76677. * Shadow generator associted to the light.
  76678. * @hidden Internal use only.
  76679. */
  76680. _shadowGenerator: Nullable<IShadowGenerator>;
  76681. /**
  76682. * @hidden Internal use only.
  76683. */
  76684. _excludedMeshesIds: string[];
  76685. /**
  76686. * @hidden Internal use only.
  76687. */
  76688. _includedOnlyMeshesIds: string[];
  76689. /**
  76690. * The current light unifom buffer.
  76691. * @hidden Internal use only.
  76692. */
  76693. _uniformBuffer: UniformBuffer;
  76694. /**
  76695. * Creates a Light object in the scene.
  76696. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76697. * @param name The firendly name of the light
  76698. * @param scene The scene the light belongs too
  76699. */
  76700. constructor(name: string, scene: Scene);
  76701. protected abstract _buildUniformLayout(): void;
  76702. /**
  76703. * Sets the passed Effect "effect" with the Light information.
  76704. * @param effect The effect to update
  76705. * @param lightIndex The index of the light in the effect to update
  76706. * @returns The light
  76707. */
  76708. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76709. /**
  76710. * Sets the passed Effect "effect" with the Light information.
  76711. * @param effect The effect to update
  76712. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76713. * @returns The light
  76714. */
  76715. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76716. /**
  76717. * Returns the string "Light".
  76718. * @returns the class name
  76719. */
  76720. getClassName(): string;
  76721. /** @hidden */
  76722. readonly _isLight: boolean;
  76723. /**
  76724. * Converts the light information to a readable string for debug purpose.
  76725. * @param fullDetails Supports for multiple levels of logging within scene loading
  76726. * @returns the human readable light info
  76727. */
  76728. toString(fullDetails?: boolean): string;
  76729. /** @hidden */
  76730. protected _syncParentEnabledState(): void;
  76731. /**
  76732. * Set the enabled state of this node.
  76733. * @param value - the new enabled state
  76734. */
  76735. setEnabled(value: boolean): void;
  76736. /**
  76737. * Returns the Light associated shadow generator if any.
  76738. * @return the associated shadow generator.
  76739. */
  76740. getShadowGenerator(): Nullable<IShadowGenerator>;
  76741. /**
  76742. * Returns a Vector3, the absolute light position in the World.
  76743. * @returns the world space position of the light
  76744. */
  76745. getAbsolutePosition(): Vector3;
  76746. /**
  76747. * Specifies if the light will affect the passed mesh.
  76748. * @param mesh The mesh to test against the light
  76749. * @return true the mesh is affected otherwise, false.
  76750. */
  76751. canAffectMesh(mesh: AbstractMesh): boolean;
  76752. /**
  76753. * Sort function to order lights for rendering.
  76754. * @param a First Light object to compare to second.
  76755. * @param b Second Light object to compare first.
  76756. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76757. */
  76758. static CompareLightsPriority(a: Light, b: Light): number;
  76759. /**
  76760. * Releases resources associated with this node.
  76761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76763. */
  76764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76765. /**
  76766. * Returns the light type ID (integer).
  76767. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76768. */
  76769. getTypeID(): number;
  76770. /**
  76771. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76772. * @returns the scaled intensity in intensity mode unit
  76773. */
  76774. getScaledIntensity(): number;
  76775. /**
  76776. * Returns a new Light object, named "name", from the current one.
  76777. * @param name The name of the cloned light
  76778. * @returns the new created light
  76779. */
  76780. clone(name: string): Nullable<Light>;
  76781. /**
  76782. * Serializes the current light into a Serialization object.
  76783. * @returns the serialized object.
  76784. */
  76785. serialize(): any;
  76786. /**
  76787. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76788. * This new light is named "name" and added to the passed scene.
  76789. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76790. * @param name The friendly name of the light
  76791. * @param scene The scene the new light will belong to
  76792. * @returns the constructor function
  76793. */
  76794. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76795. /**
  76796. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76797. * @param parsedLight The JSON representation of the light
  76798. * @param scene The scene to create the parsed light in
  76799. * @returns the created light after parsing
  76800. */
  76801. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76802. private _hookArrayForExcluded;
  76803. private _hookArrayForIncludedOnly;
  76804. private _resyncMeshes;
  76805. /**
  76806. * Forces the meshes to update their light related information in their rendering used effects
  76807. * @hidden Internal Use Only
  76808. */
  76809. _markMeshesAsLightDirty(): void;
  76810. /**
  76811. * Recomputes the cached photometric scale if needed.
  76812. */
  76813. private _computePhotometricScale;
  76814. /**
  76815. * Returns the Photometric Scale according to the light type and intensity mode.
  76816. */
  76817. private _getPhotometricScale;
  76818. /**
  76819. * Reorder the light in the scene according to their defined priority.
  76820. * @hidden Internal Use Only
  76821. */
  76822. _reorderLightsInScene(): void;
  76823. /**
  76824. * Prepares the list of defines specific to the light type.
  76825. * @param defines the list of defines
  76826. * @param lightIndex defines the index of the light for the effect
  76827. */
  76828. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76829. }
  76830. }
  76831. declare module BABYLON {
  76832. /**
  76833. * Interface used to define Action
  76834. */
  76835. export interface IAction {
  76836. /**
  76837. * Trigger for the action
  76838. */
  76839. trigger: number;
  76840. /** Options of the trigger */
  76841. triggerOptions: any;
  76842. /**
  76843. * Gets the trigger parameters
  76844. * @returns the trigger parameters
  76845. */
  76846. getTriggerParameter(): any;
  76847. /**
  76848. * Internal only - executes current action event
  76849. * @hidden
  76850. */
  76851. _executeCurrent(evt?: ActionEvent): void;
  76852. /**
  76853. * Serialize placeholder for child classes
  76854. * @param parent of child
  76855. * @returns the serialized object
  76856. */
  76857. serialize(parent: any): any;
  76858. /**
  76859. * Internal only
  76860. * @hidden
  76861. */
  76862. _prepare(): void;
  76863. /**
  76864. * Internal only - manager for action
  76865. * @hidden
  76866. */
  76867. _actionManager: AbstractActionManager;
  76868. /**
  76869. * Adds action to chain of actions, may be a DoNothingAction
  76870. * @param action defines the next action to execute
  76871. * @returns The action passed in
  76872. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76873. */
  76874. then(action: IAction): IAction;
  76875. }
  76876. /**
  76877. * The action to be carried out following a trigger
  76878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76879. */
  76880. export class Action implements IAction {
  76881. /** the trigger, with or without parameters, for the action */
  76882. triggerOptions: any;
  76883. /**
  76884. * Trigger for the action
  76885. */
  76886. trigger: number;
  76887. /**
  76888. * Internal only - manager for action
  76889. * @hidden
  76890. */
  76891. _actionManager: ActionManager;
  76892. private _nextActiveAction;
  76893. private _child;
  76894. private _condition?;
  76895. private _triggerParameter;
  76896. /**
  76897. * An event triggered prior to action being executed.
  76898. */
  76899. onBeforeExecuteObservable: Observable<Action>;
  76900. /**
  76901. * Creates a new Action
  76902. * @param triggerOptions the trigger, with or without parameters, for the action
  76903. * @param condition an optional determinant of action
  76904. */
  76905. constructor(
  76906. /** the trigger, with or without parameters, for the action */
  76907. triggerOptions: any, condition?: Condition);
  76908. /**
  76909. * Internal only
  76910. * @hidden
  76911. */
  76912. _prepare(): void;
  76913. /**
  76914. * Gets the trigger parameters
  76915. * @returns the trigger parameters
  76916. */
  76917. getTriggerParameter(): any;
  76918. /**
  76919. * Internal only - executes current action event
  76920. * @hidden
  76921. */
  76922. _executeCurrent(evt?: ActionEvent): void;
  76923. /**
  76924. * Execute placeholder for child classes
  76925. * @param evt optional action event
  76926. */
  76927. execute(evt?: ActionEvent): void;
  76928. /**
  76929. * Skips to next active action
  76930. */
  76931. skipToNextActiveAction(): void;
  76932. /**
  76933. * Adds action to chain of actions, may be a DoNothingAction
  76934. * @param action defines the next action to execute
  76935. * @returns The action passed in
  76936. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76937. */
  76938. then(action: Action): Action;
  76939. /**
  76940. * Internal only
  76941. * @hidden
  76942. */
  76943. _getProperty(propertyPath: string): string;
  76944. /**
  76945. * Internal only
  76946. * @hidden
  76947. */
  76948. _getEffectiveTarget(target: any, propertyPath: string): any;
  76949. /**
  76950. * Serialize placeholder for child classes
  76951. * @param parent of child
  76952. * @returns the serialized object
  76953. */
  76954. serialize(parent: any): any;
  76955. /**
  76956. * Internal only called by serialize
  76957. * @hidden
  76958. */
  76959. protected _serialize(serializedAction: any, parent?: any): any;
  76960. /**
  76961. * Internal only
  76962. * @hidden
  76963. */
  76964. static _SerializeValueAsString: (value: any) => string;
  76965. /**
  76966. * Internal only
  76967. * @hidden
  76968. */
  76969. static _GetTargetProperty: (target: Node | Scene) => {
  76970. name: string;
  76971. targetType: string;
  76972. value: string;
  76973. };
  76974. }
  76975. }
  76976. declare module BABYLON {
  76977. /**
  76978. * A Condition applied to an Action
  76979. */
  76980. export class Condition {
  76981. /**
  76982. * Internal only - manager for action
  76983. * @hidden
  76984. */
  76985. _actionManager: ActionManager;
  76986. /**
  76987. * Internal only
  76988. * @hidden
  76989. */
  76990. _evaluationId: number;
  76991. /**
  76992. * Internal only
  76993. * @hidden
  76994. */
  76995. _currentResult: boolean;
  76996. /**
  76997. * Creates a new Condition
  76998. * @param actionManager the manager of the action the condition is applied to
  76999. */
  77000. constructor(actionManager: ActionManager);
  77001. /**
  77002. * Check if the current condition is valid
  77003. * @returns a boolean
  77004. */
  77005. isValid(): boolean;
  77006. /**
  77007. * Internal only
  77008. * @hidden
  77009. */
  77010. _getProperty(propertyPath: string): string;
  77011. /**
  77012. * Internal only
  77013. * @hidden
  77014. */
  77015. _getEffectiveTarget(target: any, propertyPath: string): any;
  77016. /**
  77017. * Serialize placeholder for child classes
  77018. * @returns the serialized object
  77019. */
  77020. serialize(): any;
  77021. /**
  77022. * Internal only
  77023. * @hidden
  77024. */
  77025. protected _serialize(serializedCondition: any): any;
  77026. }
  77027. /**
  77028. * Defines specific conditional operators as extensions of Condition
  77029. */
  77030. export class ValueCondition extends Condition {
  77031. /** path to specify the property of the target the conditional operator uses */
  77032. propertyPath: string;
  77033. /** the value compared by the conditional operator against the current value of the property */
  77034. value: any;
  77035. /** the conditional operator, default ValueCondition.IsEqual */
  77036. operator: number;
  77037. /**
  77038. * Internal only
  77039. * @hidden
  77040. */
  77041. private static _IsEqual;
  77042. /**
  77043. * Internal only
  77044. * @hidden
  77045. */
  77046. private static _IsDifferent;
  77047. /**
  77048. * Internal only
  77049. * @hidden
  77050. */
  77051. private static _IsGreater;
  77052. /**
  77053. * Internal only
  77054. * @hidden
  77055. */
  77056. private static _IsLesser;
  77057. /**
  77058. * returns the number for IsEqual
  77059. */
  77060. static readonly IsEqual: number;
  77061. /**
  77062. * Returns the number for IsDifferent
  77063. */
  77064. static readonly IsDifferent: number;
  77065. /**
  77066. * Returns the number for IsGreater
  77067. */
  77068. static readonly IsGreater: number;
  77069. /**
  77070. * Returns the number for IsLesser
  77071. */
  77072. static readonly IsLesser: number;
  77073. /**
  77074. * Internal only The action manager for the condition
  77075. * @hidden
  77076. */
  77077. _actionManager: ActionManager;
  77078. /**
  77079. * Internal only
  77080. * @hidden
  77081. */
  77082. private _target;
  77083. /**
  77084. * Internal only
  77085. * @hidden
  77086. */
  77087. private _effectiveTarget;
  77088. /**
  77089. * Internal only
  77090. * @hidden
  77091. */
  77092. private _property;
  77093. /**
  77094. * Creates a new ValueCondition
  77095. * @param actionManager manager for the action the condition applies to
  77096. * @param target for the action
  77097. * @param propertyPath path to specify the property of the target the conditional operator uses
  77098. * @param value the value compared by the conditional operator against the current value of the property
  77099. * @param operator the conditional operator, default ValueCondition.IsEqual
  77100. */
  77101. constructor(actionManager: ActionManager, target: any,
  77102. /** path to specify the property of the target the conditional operator uses */
  77103. propertyPath: string,
  77104. /** the value compared by the conditional operator against the current value of the property */
  77105. value: any,
  77106. /** the conditional operator, default ValueCondition.IsEqual */
  77107. operator?: number);
  77108. /**
  77109. * Compares the given value with the property value for the specified conditional operator
  77110. * @returns the result of the comparison
  77111. */
  77112. isValid(): boolean;
  77113. /**
  77114. * Serialize the ValueCondition into a JSON compatible object
  77115. * @returns serialization object
  77116. */
  77117. serialize(): any;
  77118. /**
  77119. * Gets the name of the conditional operator for the ValueCondition
  77120. * @param operator the conditional operator
  77121. * @returns the name
  77122. */
  77123. static GetOperatorName(operator: number): string;
  77124. }
  77125. /**
  77126. * Defines a predicate condition as an extension of Condition
  77127. */
  77128. export class PredicateCondition extends Condition {
  77129. /** defines the predicate function used to validate the condition */
  77130. predicate: () => boolean;
  77131. /**
  77132. * Internal only - manager for action
  77133. * @hidden
  77134. */
  77135. _actionManager: ActionManager;
  77136. /**
  77137. * Creates a new PredicateCondition
  77138. * @param actionManager manager for the action the condition applies to
  77139. * @param predicate defines the predicate function used to validate the condition
  77140. */
  77141. constructor(actionManager: ActionManager,
  77142. /** defines the predicate function used to validate the condition */
  77143. predicate: () => boolean);
  77144. /**
  77145. * @returns the validity of the predicate condition
  77146. */
  77147. isValid(): boolean;
  77148. }
  77149. /**
  77150. * Defines a state condition as an extension of Condition
  77151. */
  77152. export class StateCondition extends Condition {
  77153. /** Value to compare with target state */
  77154. value: string;
  77155. /**
  77156. * Internal only - manager for action
  77157. * @hidden
  77158. */
  77159. _actionManager: ActionManager;
  77160. /**
  77161. * Internal only
  77162. * @hidden
  77163. */
  77164. private _target;
  77165. /**
  77166. * Creates a new StateCondition
  77167. * @param actionManager manager for the action the condition applies to
  77168. * @param target of the condition
  77169. * @param value to compare with target state
  77170. */
  77171. constructor(actionManager: ActionManager, target: any,
  77172. /** Value to compare with target state */
  77173. value: string);
  77174. /**
  77175. * Gets a boolean indicating if the current condition is met
  77176. * @returns the validity of the state
  77177. */
  77178. isValid(): boolean;
  77179. /**
  77180. * Serialize the StateCondition into a JSON compatible object
  77181. * @returns serialization object
  77182. */
  77183. serialize(): any;
  77184. }
  77185. }
  77186. declare module BABYLON {
  77187. /**
  77188. * This defines an action responsible to toggle a boolean once triggered.
  77189. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77190. */
  77191. export class SwitchBooleanAction extends Action {
  77192. /**
  77193. * The path to the boolean property in the target object
  77194. */
  77195. propertyPath: string;
  77196. private _target;
  77197. private _effectiveTarget;
  77198. private _property;
  77199. /**
  77200. * Instantiate the action
  77201. * @param triggerOptions defines the trigger options
  77202. * @param target defines the object containing the boolean
  77203. * @param propertyPath defines the path to the boolean property in the target object
  77204. * @param condition defines the trigger related conditions
  77205. */
  77206. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77207. /** @hidden */
  77208. _prepare(): void;
  77209. /**
  77210. * Execute the action toggle the boolean value.
  77211. */
  77212. execute(): void;
  77213. /**
  77214. * Serializes the actions and its related information.
  77215. * @param parent defines the object to serialize in
  77216. * @returns the serialized object
  77217. */
  77218. serialize(parent: any): any;
  77219. }
  77220. /**
  77221. * This defines an action responsible to set a the state field of the target
  77222. * to a desired value once triggered.
  77223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77224. */
  77225. export class SetStateAction extends Action {
  77226. /**
  77227. * The value to store in the state field.
  77228. */
  77229. value: string;
  77230. private _target;
  77231. /**
  77232. * Instantiate the action
  77233. * @param triggerOptions defines the trigger options
  77234. * @param target defines the object containing the state property
  77235. * @param value defines the value to store in the state field
  77236. * @param condition defines the trigger related conditions
  77237. */
  77238. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77239. /**
  77240. * Execute the action and store the value on the target state property.
  77241. */
  77242. execute(): void;
  77243. /**
  77244. * Serializes the actions and its related information.
  77245. * @param parent defines the object to serialize in
  77246. * @returns the serialized object
  77247. */
  77248. serialize(parent: any): any;
  77249. }
  77250. /**
  77251. * This defines an action responsible to set a property of the target
  77252. * to a desired value once triggered.
  77253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77254. */
  77255. export class SetValueAction extends Action {
  77256. /**
  77257. * The path of the property to set in the target.
  77258. */
  77259. propertyPath: string;
  77260. /**
  77261. * The value to set in the property
  77262. */
  77263. value: any;
  77264. private _target;
  77265. private _effectiveTarget;
  77266. private _property;
  77267. /**
  77268. * Instantiate the action
  77269. * @param triggerOptions defines the trigger options
  77270. * @param target defines the object containing the property
  77271. * @param propertyPath defines the path of the property to set in the target
  77272. * @param value defines the value to set in the property
  77273. * @param condition defines the trigger related conditions
  77274. */
  77275. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77276. /** @hidden */
  77277. _prepare(): void;
  77278. /**
  77279. * Execute the action and set the targetted property to the desired value.
  77280. */
  77281. execute(): void;
  77282. /**
  77283. * Serializes the actions and its related information.
  77284. * @param parent defines the object to serialize in
  77285. * @returns the serialized object
  77286. */
  77287. serialize(parent: any): any;
  77288. }
  77289. /**
  77290. * This defines an action responsible to increment the target value
  77291. * to a desired value once triggered.
  77292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77293. */
  77294. export class IncrementValueAction extends Action {
  77295. /**
  77296. * The path of the property to increment in the target.
  77297. */
  77298. propertyPath: string;
  77299. /**
  77300. * The value we should increment the property by.
  77301. */
  77302. value: any;
  77303. private _target;
  77304. private _effectiveTarget;
  77305. private _property;
  77306. /**
  77307. * Instantiate the action
  77308. * @param triggerOptions defines the trigger options
  77309. * @param target defines the object containing the property
  77310. * @param propertyPath defines the path of the property to increment in the target
  77311. * @param value defines the value value we should increment the property by
  77312. * @param condition defines the trigger related conditions
  77313. */
  77314. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77315. /** @hidden */
  77316. _prepare(): void;
  77317. /**
  77318. * Execute the action and increment the target of the value amount.
  77319. */
  77320. execute(): void;
  77321. /**
  77322. * Serializes the actions and its related information.
  77323. * @param parent defines the object to serialize in
  77324. * @returns the serialized object
  77325. */
  77326. serialize(parent: any): any;
  77327. }
  77328. /**
  77329. * This defines an action responsible to start an animation once triggered.
  77330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77331. */
  77332. export class PlayAnimationAction extends Action {
  77333. /**
  77334. * Where the animation should start (animation frame)
  77335. */
  77336. from: number;
  77337. /**
  77338. * Where the animation should stop (animation frame)
  77339. */
  77340. to: number;
  77341. /**
  77342. * Define if the animation should loop or stop after the first play.
  77343. */
  77344. loop?: boolean;
  77345. private _target;
  77346. /**
  77347. * Instantiate the action
  77348. * @param triggerOptions defines the trigger options
  77349. * @param target defines the target animation or animation name
  77350. * @param from defines from where the animation should start (animation frame)
  77351. * @param end defines where the animation should stop (animation frame)
  77352. * @param loop defines if the animation should loop or stop after the first play
  77353. * @param condition defines the trigger related conditions
  77354. */
  77355. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77356. /** @hidden */
  77357. _prepare(): void;
  77358. /**
  77359. * Execute the action and play the animation.
  77360. */
  77361. execute(): void;
  77362. /**
  77363. * Serializes the actions and its related information.
  77364. * @param parent defines the object to serialize in
  77365. * @returns the serialized object
  77366. */
  77367. serialize(parent: any): any;
  77368. }
  77369. /**
  77370. * This defines an action responsible to stop an animation once triggered.
  77371. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77372. */
  77373. export class StopAnimationAction extends Action {
  77374. private _target;
  77375. /**
  77376. * Instantiate the action
  77377. * @param triggerOptions defines the trigger options
  77378. * @param target defines the target animation or animation name
  77379. * @param condition defines the trigger related conditions
  77380. */
  77381. constructor(triggerOptions: any, target: any, condition?: Condition);
  77382. /** @hidden */
  77383. _prepare(): void;
  77384. /**
  77385. * Execute the action and stop the animation.
  77386. */
  77387. execute(): void;
  77388. /**
  77389. * Serializes the actions and its related information.
  77390. * @param parent defines the object to serialize in
  77391. * @returns the serialized object
  77392. */
  77393. serialize(parent: any): any;
  77394. }
  77395. /**
  77396. * This defines an action responsible that does nothing once triggered.
  77397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77398. */
  77399. export class DoNothingAction extends Action {
  77400. /**
  77401. * Instantiate the action
  77402. * @param triggerOptions defines the trigger options
  77403. * @param condition defines the trigger related conditions
  77404. */
  77405. constructor(triggerOptions?: any, condition?: Condition);
  77406. /**
  77407. * Execute the action and do nothing.
  77408. */
  77409. execute(): void;
  77410. /**
  77411. * Serializes the actions and its related information.
  77412. * @param parent defines the object to serialize in
  77413. * @returns the serialized object
  77414. */
  77415. serialize(parent: any): any;
  77416. }
  77417. /**
  77418. * This defines an action responsible to trigger several actions once triggered.
  77419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77420. */
  77421. export class CombineAction extends Action {
  77422. /**
  77423. * The list of aggregated animations to run.
  77424. */
  77425. children: Action[];
  77426. /**
  77427. * Instantiate the action
  77428. * @param triggerOptions defines the trigger options
  77429. * @param children defines the list of aggregated animations to run
  77430. * @param condition defines the trigger related conditions
  77431. */
  77432. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77433. /** @hidden */
  77434. _prepare(): void;
  77435. /**
  77436. * Execute the action and executes all the aggregated actions.
  77437. */
  77438. execute(evt: ActionEvent): void;
  77439. /**
  77440. * Serializes the actions and its related information.
  77441. * @param parent defines the object to serialize in
  77442. * @returns the serialized object
  77443. */
  77444. serialize(parent: any): any;
  77445. }
  77446. /**
  77447. * This defines an action responsible to run code (external event) once triggered.
  77448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77449. */
  77450. export class ExecuteCodeAction extends Action {
  77451. /**
  77452. * The callback function to run.
  77453. */
  77454. func: (evt: ActionEvent) => void;
  77455. /**
  77456. * Instantiate the action
  77457. * @param triggerOptions defines the trigger options
  77458. * @param func defines the callback function to run
  77459. * @param condition defines the trigger related conditions
  77460. */
  77461. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77462. /**
  77463. * Execute the action and run the attached code.
  77464. */
  77465. execute(evt: ActionEvent): void;
  77466. }
  77467. /**
  77468. * This defines an action responsible to set the parent property of the target once triggered.
  77469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77470. */
  77471. export class SetParentAction extends Action {
  77472. private _parent;
  77473. private _target;
  77474. /**
  77475. * Instantiate the action
  77476. * @param triggerOptions defines the trigger options
  77477. * @param target defines the target containing the parent property
  77478. * @param parent defines from where the animation should start (animation frame)
  77479. * @param condition defines the trigger related conditions
  77480. */
  77481. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77482. /** @hidden */
  77483. _prepare(): void;
  77484. /**
  77485. * Execute the action and set the parent property.
  77486. */
  77487. execute(): void;
  77488. /**
  77489. * Serializes the actions and its related information.
  77490. * @param parent defines the object to serialize in
  77491. * @returns the serialized object
  77492. */
  77493. serialize(parent: any): any;
  77494. }
  77495. }
  77496. declare module BABYLON {
  77497. /**
  77498. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77499. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77501. */
  77502. export class ActionManager extends AbstractActionManager {
  77503. /**
  77504. * Nothing
  77505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77506. */
  77507. static readonly NothingTrigger: number;
  77508. /**
  77509. * On pick
  77510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77511. */
  77512. static readonly OnPickTrigger: number;
  77513. /**
  77514. * On left pick
  77515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77516. */
  77517. static readonly OnLeftPickTrigger: number;
  77518. /**
  77519. * On right pick
  77520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77521. */
  77522. static readonly OnRightPickTrigger: number;
  77523. /**
  77524. * On center pick
  77525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77526. */
  77527. static readonly OnCenterPickTrigger: number;
  77528. /**
  77529. * On pick down
  77530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77531. */
  77532. static readonly OnPickDownTrigger: number;
  77533. /**
  77534. * On double pick
  77535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77536. */
  77537. static readonly OnDoublePickTrigger: number;
  77538. /**
  77539. * On pick up
  77540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77541. */
  77542. static readonly OnPickUpTrigger: number;
  77543. /**
  77544. * On pick out.
  77545. * This trigger will only be raised if you also declared a OnPickDown
  77546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77547. */
  77548. static readonly OnPickOutTrigger: number;
  77549. /**
  77550. * On long press
  77551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77552. */
  77553. static readonly OnLongPressTrigger: number;
  77554. /**
  77555. * On pointer over
  77556. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77557. */
  77558. static readonly OnPointerOverTrigger: number;
  77559. /**
  77560. * On pointer out
  77561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77562. */
  77563. static readonly OnPointerOutTrigger: number;
  77564. /**
  77565. * On every frame
  77566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77567. */
  77568. static readonly OnEveryFrameTrigger: number;
  77569. /**
  77570. * On intersection enter
  77571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77572. */
  77573. static readonly OnIntersectionEnterTrigger: number;
  77574. /**
  77575. * On intersection exit
  77576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77577. */
  77578. static readonly OnIntersectionExitTrigger: number;
  77579. /**
  77580. * On key down
  77581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77582. */
  77583. static readonly OnKeyDownTrigger: number;
  77584. /**
  77585. * On key up
  77586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77587. */
  77588. static readonly OnKeyUpTrigger: number;
  77589. private _scene;
  77590. /**
  77591. * Creates a new action manager
  77592. * @param scene defines the hosting scene
  77593. */
  77594. constructor(scene: Scene);
  77595. /**
  77596. * Releases all associated resources
  77597. */
  77598. dispose(): void;
  77599. /**
  77600. * Gets hosting scene
  77601. * @returns the hosting scene
  77602. */
  77603. getScene(): Scene;
  77604. /**
  77605. * Does this action manager handles actions of any of the given triggers
  77606. * @param triggers defines the triggers to be tested
  77607. * @return a boolean indicating whether one (or more) of the triggers is handled
  77608. */
  77609. hasSpecificTriggers(triggers: number[]): boolean;
  77610. /**
  77611. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77612. * speed.
  77613. * @param triggerA defines the trigger to be tested
  77614. * @param triggerB defines the trigger to be tested
  77615. * @return a boolean indicating whether one (or more) of the triggers is handled
  77616. */
  77617. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77618. /**
  77619. * Does this action manager handles actions of a given trigger
  77620. * @param trigger defines the trigger to be tested
  77621. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77622. * @return whether the trigger is handled
  77623. */
  77624. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77625. /**
  77626. * Does this action manager has pointer triggers
  77627. */
  77628. readonly hasPointerTriggers: boolean;
  77629. /**
  77630. * Does this action manager has pick triggers
  77631. */
  77632. readonly hasPickTriggers: boolean;
  77633. /**
  77634. * Registers an action to this action manager
  77635. * @param action defines the action to be registered
  77636. * @return the action amended (prepared) after registration
  77637. */
  77638. registerAction(action: IAction): Nullable<IAction>;
  77639. /**
  77640. * Unregisters an action to this action manager
  77641. * @param action defines the action to be unregistered
  77642. * @return a boolean indicating whether the action has been unregistered
  77643. */
  77644. unregisterAction(action: IAction): Boolean;
  77645. /**
  77646. * Process a specific trigger
  77647. * @param trigger defines the trigger to process
  77648. * @param evt defines the event details to be processed
  77649. */
  77650. processTrigger(trigger: number, evt?: IActionEvent): void;
  77651. /** @hidden */
  77652. _getEffectiveTarget(target: any, propertyPath: string): any;
  77653. /** @hidden */
  77654. _getProperty(propertyPath: string): string;
  77655. /**
  77656. * Serialize this manager to a JSON object
  77657. * @param name defines the property name to store this manager
  77658. * @returns a JSON representation of this manager
  77659. */
  77660. serialize(name: string): any;
  77661. /**
  77662. * Creates a new ActionManager from a JSON data
  77663. * @param parsedActions defines the JSON data to read from
  77664. * @param object defines the hosting mesh
  77665. * @param scene defines the hosting scene
  77666. */
  77667. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77668. /**
  77669. * Get a trigger name by index
  77670. * @param trigger defines the trigger index
  77671. * @returns a trigger name
  77672. */
  77673. static GetTriggerName(trigger: number): string;
  77674. }
  77675. }
  77676. declare module BABYLON {
  77677. /**
  77678. * Class representing a ray with position and direction
  77679. */
  77680. export class Ray {
  77681. /** origin point */
  77682. origin: Vector3;
  77683. /** direction */
  77684. direction: Vector3;
  77685. /** length of the ray */
  77686. length: number;
  77687. private static readonly TmpVector3;
  77688. private _tmpRay;
  77689. /**
  77690. * Creates a new ray
  77691. * @param origin origin point
  77692. * @param direction direction
  77693. * @param length length of the ray
  77694. */
  77695. constructor(
  77696. /** origin point */
  77697. origin: Vector3,
  77698. /** direction */
  77699. direction: Vector3,
  77700. /** length of the ray */
  77701. length?: number);
  77702. /**
  77703. * Checks if the ray intersects a box
  77704. * @param minimum bound of the box
  77705. * @param maximum bound of the box
  77706. * @param intersectionTreshold extra extend to be added to the box in all direction
  77707. * @returns if the box was hit
  77708. */
  77709. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77710. /**
  77711. * Checks if the ray intersects a box
  77712. * @param box the bounding box to check
  77713. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77714. * @returns if the box was hit
  77715. */
  77716. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77717. /**
  77718. * If the ray hits a sphere
  77719. * @param sphere the bounding sphere to check
  77720. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77721. * @returns true if it hits the sphere
  77722. */
  77723. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77724. /**
  77725. * If the ray hits a triange
  77726. * @param vertex0 triangle vertex
  77727. * @param vertex1 triangle vertex
  77728. * @param vertex2 triangle vertex
  77729. * @returns intersection information if hit
  77730. */
  77731. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77732. /**
  77733. * Checks if ray intersects a plane
  77734. * @param plane the plane to check
  77735. * @returns the distance away it was hit
  77736. */
  77737. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77738. /**
  77739. * Calculate the intercept of a ray on a given axis
  77740. * @param axis to check 'x' | 'y' | 'z'
  77741. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77742. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77743. */
  77744. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77745. /**
  77746. * Checks if ray intersects a mesh
  77747. * @param mesh the mesh to check
  77748. * @param fastCheck if only the bounding box should checked
  77749. * @returns picking info of the intersecton
  77750. */
  77751. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77752. /**
  77753. * Checks if ray intersects a mesh
  77754. * @param meshes the meshes to check
  77755. * @param fastCheck if only the bounding box should checked
  77756. * @param results array to store result in
  77757. * @returns Array of picking infos
  77758. */
  77759. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77760. private _comparePickingInfo;
  77761. private static smallnum;
  77762. private static rayl;
  77763. /**
  77764. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77765. * @param sega the first point of the segment to test the intersection against
  77766. * @param segb the second point of the segment to test the intersection against
  77767. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77768. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77769. */
  77770. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77771. /**
  77772. * Update the ray from viewport position
  77773. * @param x position
  77774. * @param y y position
  77775. * @param viewportWidth viewport width
  77776. * @param viewportHeight viewport height
  77777. * @param world world matrix
  77778. * @param view view matrix
  77779. * @param projection projection matrix
  77780. * @returns this ray updated
  77781. */
  77782. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77783. /**
  77784. * Creates a ray with origin and direction of 0,0,0
  77785. * @returns the new ray
  77786. */
  77787. static Zero(): Ray;
  77788. /**
  77789. * Creates a new ray from screen space and viewport
  77790. * @param x position
  77791. * @param y y position
  77792. * @param viewportWidth viewport width
  77793. * @param viewportHeight viewport height
  77794. * @param world world matrix
  77795. * @param view view matrix
  77796. * @param projection projection matrix
  77797. * @returns new ray
  77798. */
  77799. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77800. /**
  77801. * 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
  77802. * transformed to the given world matrix.
  77803. * @param origin The origin point
  77804. * @param end The end point
  77805. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77806. * @returns the new ray
  77807. */
  77808. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77809. /**
  77810. * Transforms a ray by a matrix
  77811. * @param ray ray to transform
  77812. * @param matrix matrix to apply
  77813. * @returns the resulting new ray
  77814. */
  77815. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77816. /**
  77817. * Transforms a ray by a matrix
  77818. * @param ray ray to transform
  77819. * @param matrix matrix to apply
  77820. * @param result ray to store result in
  77821. */
  77822. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77823. /**
  77824. * Unproject a ray from screen space to object space
  77825. * @param sourceX defines the screen space x coordinate to use
  77826. * @param sourceY defines the screen space y coordinate to use
  77827. * @param viewportWidth defines the current width of the viewport
  77828. * @param viewportHeight defines the current height of the viewport
  77829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77830. * @param view defines the view matrix to use
  77831. * @param projection defines the projection matrix to use
  77832. */
  77833. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77834. }
  77835. /**
  77836. * Type used to define predicate used to select faces when a mesh intersection is detected
  77837. */
  77838. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77839. interface Scene {
  77840. /** @hidden */
  77841. _tempPickingRay: Nullable<Ray>;
  77842. /** @hidden */
  77843. _cachedRayForTransform: Ray;
  77844. /** @hidden */
  77845. _pickWithRayInverseMatrix: Matrix;
  77846. /** @hidden */
  77847. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77848. /** @hidden */
  77849. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77850. }
  77851. }
  77852. declare module BABYLON {
  77853. /**
  77854. * Groups all the scene component constants in one place to ease maintenance.
  77855. * @hidden
  77856. */
  77857. export class SceneComponentConstants {
  77858. static readonly NAME_EFFECTLAYER: string;
  77859. static readonly NAME_LAYER: string;
  77860. static readonly NAME_LENSFLARESYSTEM: string;
  77861. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77862. static readonly NAME_PARTICLESYSTEM: string;
  77863. static readonly NAME_GAMEPAD: string;
  77864. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77865. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77866. static readonly NAME_DEPTHRENDERER: string;
  77867. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77868. static readonly NAME_SPRITE: string;
  77869. static readonly NAME_OUTLINERENDERER: string;
  77870. static readonly NAME_PROCEDURALTEXTURE: string;
  77871. static readonly NAME_SHADOWGENERATOR: string;
  77872. static readonly NAME_OCTREE: string;
  77873. static readonly NAME_PHYSICSENGINE: string;
  77874. static readonly NAME_AUDIO: string;
  77875. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77876. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77877. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77878. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77879. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77880. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77881. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77882. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77883. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77884. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77885. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77886. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77887. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77888. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77889. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77890. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77891. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77892. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77893. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77894. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77895. static readonly STEP_AFTERRENDER_AUDIO: number;
  77896. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77897. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77898. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77899. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77900. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77901. static readonly STEP_POINTERMOVE_SPRITE: number;
  77902. static readonly STEP_POINTERDOWN_SPRITE: number;
  77903. static readonly STEP_POINTERUP_SPRITE: number;
  77904. }
  77905. /**
  77906. * This represents a scene component.
  77907. *
  77908. * This is used to decouple the dependency the scene is having on the different workloads like
  77909. * layers, post processes...
  77910. */
  77911. export interface ISceneComponent {
  77912. /**
  77913. * The name of the component. Each component must have a unique name.
  77914. */
  77915. name: string;
  77916. /**
  77917. * The scene the component belongs to.
  77918. */
  77919. scene: Scene;
  77920. /**
  77921. * Register the component to one instance of a scene.
  77922. */
  77923. register(): void;
  77924. /**
  77925. * Rebuilds the elements related to this component in case of
  77926. * context lost for instance.
  77927. */
  77928. rebuild(): void;
  77929. /**
  77930. * Disposes the component and the associated ressources.
  77931. */
  77932. dispose(): void;
  77933. }
  77934. /**
  77935. * This represents a SERIALIZABLE scene component.
  77936. *
  77937. * This extends Scene Component to add Serialization methods on top.
  77938. */
  77939. export interface ISceneSerializableComponent extends ISceneComponent {
  77940. /**
  77941. * Adds all the elements from the container to the scene
  77942. * @param container the container holding the elements
  77943. */
  77944. addFromContainer(container: AbstractScene): void;
  77945. /**
  77946. * Removes all the elements in the container from the scene
  77947. * @param container contains the elements to remove
  77948. * @param dispose if the removed element should be disposed (default: false)
  77949. */
  77950. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77951. /**
  77952. * Serializes the component data to the specified json object
  77953. * @param serializationObject The object to serialize to
  77954. */
  77955. serialize(serializationObject: any): void;
  77956. }
  77957. /**
  77958. * Strong typing of a Mesh related stage step action
  77959. */
  77960. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77961. /**
  77962. * Strong typing of a Evaluate Sub Mesh related stage step action
  77963. */
  77964. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77965. /**
  77966. * Strong typing of a Active Mesh related stage step action
  77967. */
  77968. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77969. /**
  77970. * Strong typing of a Camera related stage step action
  77971. */
  77972. export type CameraStageAction = (camera: Camera) => void;
  77973. /**
  77974. * Strong typing of a Camera Frame buffer related stage step action
  77975. */
  77976. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77977. /**
  77978. * Strong typing of a Render Target related stage step action
  77979. */
  77980. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77981. /**
  77982. * Strong typing of a RenderingGroup related stage step action
  77983. */
  77984. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77985. /**
  77986. * Strong typing of a Mesh Render related stage step action
  77987. */
  77988. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77989. /**
  77990. * Strong typing of a simple stage step action
  77991. */
  77992. export type SimpleStageAction = () => void;
  77993. /**
  77994. * Strong typing of a render target action.
  77995. */
  77996. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77997. /**
  77998. * Strong typing of a pointer move action.
  77999. */
  78000. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78001. /**
  78002. * Strong typing of a pointer up/down action.
  78003. */
  78004. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78005. /**
  78006. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78007. * @hidden
  78008. */
  78009. export class Stage<T extends Function> extends Array<{
  78010. index: number;
  78011. component: ISceneComponent;
  78012. action: T;
  78013. }> {
  78014. /**
  78015. * Hide ctor from the rest of the world.
  78016. * @param items The items to add.
  78017. */
  78018. private constructor();
  78019. /**
  78020. * Creates a new Stage.
  78021. * @returns A new instance of a Stage
  78022. */
  78023. static Create<T extends Function>(): Stage<T>;
  78024. /**
  78025. * Registers a step in an ordered way in the targeted stage.
  78026. * @param index Defines the position to register the step in
  78027. * @param component Defines the component attached to the step
  78028. * @param action Defines the action to launch during the step
  78029. */
  78030. registerStep(index: number, component: ISceneComponent, action: T): void;
  78031. /**
  78032. * Clears all the steps from the stage.
  78033. */
  78034. clear(): void;
  78035. }
  78036. }
  78037. declare module BABYLON {
  78038. interface Scene {
  78039. /** @hidden */
  78040. _pointerOverSprite: Nullable<Sprite>;
  78041. /** @hidden */
  78042. _pickedDownSprite: Nullable<Sprite>;
  78043. /** @hidden */
  78044. _tempSpritePickingRay: Nullable<Ray>;
  78045. /**
  78046. * All of the sprite managers added to this scene
  78047. * @see http://doc.babylonjs.com/babylon101/sprites
  78048. */
  78049. spriteManagers: Array<ISpriteManager>;
  78050. /**
  78051. * An event triggered when sprites rendering is about to start
  78052. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78053. */
  78054. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78055. /**
  78056. * An event triggered when sprites rendering is done
  78057. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78058. */
  78059. onAfterSpritesRenderingObservable: Observable<Scene>;
  78060. /** @hidden */
  78061. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78062. /** Launch a ray to try to pick a sprite in the scene
  78063. * @param x position on screen
  78064. * @param y position on screen
  78065. * @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
  78066. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78067. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78068. * @returns a PickingInfo
  78069. */
  78070. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78071. /** Use the given ray to pick a sprite in the scene
  78072. * @param ray The ray (in world space) to use to pick meshes
  78073. * @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
  78074. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78075. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78076. * @returns a PickingInfo
  78077. */
  78078. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78079. /** @hidden */
  78080. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78081. /** Launch a ray to try to pick sprites in the scene
  78082. * @param x position on screen
  78083. * @param y position on screen
  78084. * @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
  78085. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78086. * @returns a PickingInfo array
  78087. */
  78088. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78089. /** Use the given ray to pick sprites in the scene
  78090. * @param ray The ray (in world space) to use to pick meshes
  78091. * @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
  78092. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78093. * @returns a PickingInfo array
  78094. */
  78095. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78096. /**
  78097. * Force the sprite under the pointer
  78098. * @param sprite defines the sprite to use
  78099. */
  78100. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78101. /**
  78102. * Gets the sprite under the pointer
  78103. * @returns a Sprite or null if no sprite is under the pointer
  78104. */
  78105. getPointerOverSprite(): Nullable<Sprite>;
  78106. }
  78107. /**
  78108. * Defines the sprite scene component responsible to manage sprites
  78109. * in a given scene.
  78110. */
  78111. export class SpriteSceneComponent implements ISceneComponent {
  78112. /**
  78113. * The component name helpfull to identify the component in the list of scene components.
  78114. */
  78115. readonly name: string;
  78116. /**
  78117. * The scene the component belongs to.
  78118. */
  78119. scene: Scene;
  78120. /** @hidden */
  78121. private _spritePredicate;
  78122. /**
  78123. * Creates a new instance of the component for the given scene
  78124. * @param scene Defines the scene to register the component in
  78125. */
  78126. constructor(scene: Scene);
  78127. /**
  78128. * Registers the component in a given scene
  78129. */
  78130. register(): void;
  78131. /**
  78132. * Rebuilds the elements related to this component in case of
  78133. * context lost for instance.
  78134. */
  78135. rebuild(): void;
  78136. /**
  78137. * Disposes the component and the associated ressources.
  78138. */
  78139. dispose(): void;
  78140. private _pickSpriteButKeepRay;
  78141. private _pointerMove;
  78142. private _pointerDown;
  78143. private _pointerUp;
  78144. }
  78145. }
  78146. declare module BABYLON {
  78147. /** @hidden */
  78148. export var fogFragmentDeclaration: {
  78149. name: string;
  78150. shader: string;
  78151. };
  78152. }
  78153. declare module BABYLON {
  78154. /** @hidden */
  78155. export var fogFragment: {
  78156. name: string;
  78157. shader: string;
  78158. };
  78159. }
  78160. declare module BABYLON {
  78161. /** @hidden */
  78162. export var spritesPixelShader: {
  78163. name: string;
  78164. shader: string;
  78165. };
  78166. }
  78167. declare module BABYLON {
  78168. /** @hidden */
  78169. export var fogVertexDeclaration: {
  78170. name: string;
  78171. shader: string;
  78172. };
  78173. }
  78174. declare module BABYLON {
  78175. /** @hidden */
  78176. export var spritesVertexShader: {
  78177. name: string;
  78178. shader: string;
  78179. };
  78180. }
  78181. declare module BABYLON {
  78182. /**
  78183. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78184. */
  78185. export interface ISpriteManager extends IDisposable {
  78186. /**
  78187. * Restricts the camera to viewing objects with the same layerMask.
  78188. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78189. */
  78190. layerMask: number;
  78191. /**
  78192. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78193. */
  78194. isPickable: boolean;
  78195. /**
  78196. * Specifies the rendering group id for this mesh (0 by default)
  78197. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78198. */
  78199. renderingGroupId: number;
  78200. /**
  78201. * Defines the list of sprites managed by the manager.
  78202. */
  78203. sprites: Array<Sprite>;
  78204. /**
  78205. * Tests the intersection of a sprite with a specific ray.
  78206. * @param ray The ray we are sending to test the collision
  78207. * @param camera The camera space we are sending rays in
  78208. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78209. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78210. * @returns picking info or null.
  78211. */
  78212. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78213. /**
  78214. * Intersects the sprites with a ray
  78215. * @param ray defines the ray to intersect with
  78216. * @param camera defines the current active camera
  78217. * @param predicate defines a predicate used to select candidate sprites
  78218. * @returns null if no hit or a PickingInfo array
  78219. */
  78220. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78221. /**
  78222. * Renders the list of sprites on screen.
  78223. */
  78224. render(): void;
  78225. }
  78226. /**
  78227. * Class used to manage multiple sprites on the same spritesheet
  78228. * @see http://doc.babylonjs.com/babylon101/sprites
  78229. */
  78230. export class SpriteManager implements ISpriteManager {
  78231. /** defines the manager's name */
  78232. name: string;
  78233. /** Gets the list of sprites */
  78234. sprites: Sprite[];
  78235. /** Gets or sets the rendering group id (0 by default) */
  78236. renderingGroupId: number;
  78237. /** Gets or sets camera layer mask */
  78238. layerMask: number;
  78239. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78240. fogEnabled: boolean;
  78241. /** Gets or sets a boolean indicating if the sprites are pickable */
  78242. isPickable: boolean;
  78243. /** Defines the default width of a cell in the spritesheet */
  78244. cellWidth: number;
  78245. /** Defines the default height of a cell in the spritesheet */
  78246. cellHeight: number;
  78247. /** Associative array from JSON sprite data file */
  78248. private _cellData;
  78249. /** Array of sprite names from JSON sprite data file */
  78250. private _spriteMap;
  78251. /** True when packed cell data from JSON file is ready*/
  78252. private _packedAndReady;
  78253. /**
  78254. * An event triggered when the manager is disposed.
  78255. */
  78256. onDisposeObservable: Observable<SpriteManager>;
  78257. private _onDisposeObserver;
  78258. /**
  78259. * Callback called when the manager is disposed
  78260. */
  78261. onDispose: () => void;
  78262. private _capacity;
  78263. private _fromPacked;
  78264. private _spriteTexture;
  78265. private _epsilon;
  78266. private _scene;
  78267. private _vertexData;
  78268. private _buffer;
  78269. private _vertexBuffers;
  78270. private _indexBuffer;
  78271. private _effectBase;
  78272. private _effectFog;
  78273. /**
  78274. * Gets or sets the spritesheet texture
  78275. */
  78276. texture: Texture;
  78277. /**
  78278. * Creates a new sprite manager
  78279. * @param name defines the manager's name
  78280. * @param imgUrl defines the sprite sheet url
  78281. * @param capacity defines the maximum allowed number of sprites
  78282. * @param cellSize defines the size of a sprite cell
  78283. * @param scene defines the hosting scene
  78284. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78285. * @param samplingMode defines the smapling mode to use with spritesheet
  78286. * @param fromPacked set to false; do not alter
  78287. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78288. */
  78289. constructor(
  78290. /** defines the manager's name */
  78291. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78292. private _makePacked;
  78293. private _appendSpriteVertex;
  78294. /**
  78295. * Intersects the sprites with a ray
  78296. * @param ray defines the ray to intersect with
  78297. * @param camera defines the current active camera
  78298. * @param predicate defines a predicate used to select candidate sprites
  78299. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78300. * @returns null if no hit or a PickingInfo
  78301. */
  78302. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78303. /**
  78304. * Intersects the sprites with a ray
  78305. * @param ray defines the ray to intersect with
  78306. * @param camera defines the current active camera
  78307. * @param predicate defines a predicate used to select candidate sprites
  78308. * @returns null if no hit or a PickingInfo array
  78309. */
  78310. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78311. /**
  78312. * Render all child sprites
  78313. */
  78314. render(): void;
  78315. /**
  78316. * Release associated resources
  78317. */
  78318. dispose(): void;
  78319. }
  78320. }
  78321. declare module BABYLON {
  78322. /**
  78323. * Class used to represent a sprite
  78324. * @see http://doc.babylonjs.com/babylon101/sprites
  78325. */
  78326. export class Sprite {
  78327. /** defines the name */
  78328. name: string;
  78329. /** Gets or sets the current world position */
  78330. position: Vector3;
  78331. /** Gets or sets the main color */
  78332. color: Color4;
  78333. /** Gets or sets the width */
  78334. width: number;
  78335. /** Gets or sets the height */
  78336. height: number;
  78337. /** Gets or sets rotation angle */
  78338. angle: number;
  78339. /** Gets or sets the cell index in the sprite sheet */
  78340. cellIndex: number;
  78341. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78342. cellRef: string;
  78343. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78344. invertU: number;
  78345. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78346. invertV: number;
  78347. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78348. disposeWhenFinishedAnimating: boolean;
  78349. /** Gets the list of attached animations */
  78350. animations: Animation[];
  78351. /** Gets or sets a boolean indicating if the sprite can be picked */
  78352. isPickable: boolean;
  78353. /**
  78354. * Gets or sets the associated action manager
  78355. */
  78356. actionManager: Nullable<ActionManager>;
  78357. private _animationStarted;
  78358. private _loopAnimation;
  78359. private _fromIndex;
  78360. private _toIndex;
  78361. private _delay;
  78362. private _direction;
  78363. private _manager;
  78364. private _time;
  78365. private _onAnimationEnd;
  78366. /**
  78367. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78368. */
  78369. isVisible: boolean;
  78370. /**
  78371. * Gets or sets the sprite size
  78372. */
  78373. size: number;
  78374. /**
  78375. * Creates a new Sprite
  78376. * @param name defines the name
  78377. * @param manager defines the manager
  78378. */
  78379. constructor(
  78380. /** defines the name */
  78381. name: string, manager: ISpriteManager);
  78382. /**
  78383. * Starts an animation
  78384. * @param from defines the initial key
  78385. * @param to defines the end key
  78386. * @param loop defines if the animation must loop
  78387. * @param delay defines the start delay (in ms)
  78388. * @param onAnimationEnd defines a callback to call when animation ends
  78389. */
  78390. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78391. /** Stops current animation (if any) */
  78392. stopAnimation(): void;
  78393. /** @hidden */
  78394. _animate(deltaTime: number): void;
  78395. /** Release associated resources */
  78396. dispose(): void;
  78397. }
  78398. }
  78399. declare module BABYLON {
  78400. /**
  78401. * Information about the result of picking within a scene
  78402. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78403. */
  78404. export class PickingInfo {
  78405. /** @hidden */
  78406. _pickingUnavailable: boolean;
  78407. /**
  78408. * If the pick collided with an object
  78409. */
  78410. hit: boolean;
  78411. /**
  78412. * Distance away where the pick collided
  78413. */
  78414. distance: number;
  78415. /**
  78416. * The location of pick collision
  78417. */
  78418. pickedPoint: Nullable<Vector3>;
  78419. /**
  78420. * The mesh corresponding the the pick collision
  78421. */
  78422. pickedMesh: Nullable<AbstractMesh>;
  78423. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78424. bu: number;
  78425. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78426. bv: number;
  78427. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78428. faceId: number;
  78429. /** Id of the the submesh that was picked */
  78430. subMeshId: number;
  78431. /** If a sprite was picked, this will be the sprite the pick collided with */
  78432. pickedSprite: Nullable<Sprite>;
  78433. /**
  78434. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78435. */
  78436. originMesh: Nullable<AbstractMesh>;
  78437. /**
  78438. * The ray that was used to perform the picking.
  78439. */
  78440. ray: Nullable<Ray>;
  78441. /**
  78442. * Gets the normal correspodning to the face the pick collided with
  78443. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78444. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78445. * @returns The normal correspodning to the face the pick collided with
  78446. */
  78447. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78448. /**
  78449. * Gets the texture coordinates of where the pick occured
  78450. * @returns the vector containing the coordnates of the texture
  78451. */
  78452. getTextureCoordinates(): Nullable<Vector2>;
  78453. }
  78454. }
  78455. declare module BABYLON {
  78456. /**
  78457. * Gather the list of pointer event types as constants.
  78458. */
  78459. export class PointerEventTypes {
  78460. /**
  78461. * 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.
  78462. */
  78463. static readonly POINTERDOWN: number;
  78464. /**
  78465. * The pointerup event is fired when a pointer is no longer active.
  78466. */
  78467. static readonly POINTERUP: number;
  78468. /**
  78469. * The pointermove event is fired when a pointer changes coordinates.
  78470. */
  78471. static readonly POINTERMOVE: number;
  78472. /**
  78473. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78474. */
  78475. static readonly POINTERWHEEL: number;
  78476. /**
  78477. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78478. */
  78479. static readonly POINTERPICK: number;
  78480. /**
  78481. * The pointertap event is fired when a the object has been touched and released without drag.
  78482. */
  78483. static readonly POINTERTAP: number;
  78484. /**
  78485. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78486. */
  78487. static readonly POINTERDOUBLETAP: number;
  78488. }
  78489. /**
  78490. * Base class of pointer info types.
  78491. */
  78492. export class PointerInfoBase {
  78493. /**
  78494. * Defines the type of event (PointerEventTypes)
  78495. */
  78496. type: number;
  78497. /**
  78498. * Defines the related dom event
  78499. */
  78500. event: PointerEvent | MouseWheelEvent;
  78501. /**
  78502. * Instantiates the base class of pointers info.
  78503. * @param type Defines the type of event (PointerEventTypes)
  78504. * @param event Defines the related dom event
  78505. */
  78506. constructor(
  78507. /**
  78508. * Defines the type of event (PointerEventTypes)
  78509. */
  78510. type: number,
  78511. /**
  78512. * Defines the related dom event
  78513. */
  78514. event: PointerEvent | MouseWheelEvent);
  78515. }
  78516. /**
  78517. * This class is used to store pointer related info for the onPrePointerObservable event.
  78518. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78519. */
  78520. export class PointerInfoPre extends PointerInfoBase {
  78521. /**
  78522. * Ray from a pointer if availible (eg. 6dof controller)
  78523. */
  78524. ray: Nullable<Ray>;
  78525. /**
  78526. * Defines the local position of the pointer on the canvas.
  78527. */
  78528. localPosition: Vector2;
  78529. /**
  78530. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78531. */
  78532. skipOnPointerObservable: boolean;
  78533. /**
  78534. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78535. * @param type Defines the type of event (PointerEventTypes)
  78536. * @param event Defines the related dom event
  78537. * @param localX Defines the local x coordinates of the pointer when the event occured
  78538. * @param localY Defines the local y coordinates of the pointer when the event occured
  78539. */
  78540. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78541. }
  78542. /**
  78543. * This type contains all the data related to a pointer event in Babylon.js.
  78544. * 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.
  78545. */
  78546. export class PointerInfo extends PointerInfoBase {
  78547. /**
  78548. * Defines the picking info associated to the info (if any)\
  78549. */
  78550. pickInfo: Nullable<PickingInfo>;
  78551. /**
  78552. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78553. * @param type Defines the type of event (PointerEventTypes)
  78554. * @param event Defines the related dom event
  78555. * @param pickInfo Defines the picking info associated to the info (if any)\
  78556. */
  78557. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78558. /**
  78559. * Defines the picking info associated to the info (if any)\
  78560. */
  78561. pickInfo: Nullable<PickingInfo>);
  78562. }
  78563. /**
  78564. * Data relating to a touch event on the screen.
  78565. */
  78566. export interface PointerTouch {
  78567. /**
  78568. * X coordinate of touch.
  78569. */
  78570. x: number;
  78571. /**
  78572. * Y coordinate of touch.
  78573. */
  78574. y: number;
  78575. /**
  78576. * Id of touch. Unique for each finger.
  78577. */
  78578. pointerId: number;
  78579. /**
  78580. * Event type passed from DOM.
  78581. */
  78582. type: any;
  78583. }
  78584. }
  78585. declare module BABYLON {
  78586. /**
  78587. * Manage the mouse inputs to control the movement of a free camera.
  78588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78589. */
  78590. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78591. /**
  78592. * Define if touch is enabled in the mouse input
  78593. */
  78594. touchEnabled: boolean;
  78595. /**
  78596. * Defines the camera the input is attached to.
  78597. */
  78598. camera: FreeCamera;
  78599. /**
  78600. * Defines the buttons associated with the input to handle camera move.
  78601. */
  78602. buttons: number[];
  78603. /**
  78604. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78605. */
  78606. angularSensibility: number;
  78607. private _pointerInput;
  78608. private _onMouseMove;
  78609. private _observer;
  78610. private previousPosition;
  78611. /**
  78612. * Observable for when a pointer move event occurs containing the move offset
  78613. */
  78614. onPointerMovedObservable: Observable<{
  78615. offsetX: number;
  78616. offsetY: number;
  78617. }>;
  78618. /**
  78619. * @hidden
  78620. * If the camera should be rotated automatically based on pointer movement
  78621. */
  78622. _allowCameraRotation: boolean;
  78623. /**
  78624. * Manage the mouse inputs to control the movement of a free camera.
  78625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78626. * @param touchEnabled Defines if touch is enabled or not
  78627. */
  78628. constructor(
  78629. /**
  78630. * Define if touch is enabled in the mouse input
  78631. */
  78632. touchEnabled?: boolean);
  78633. /**
  78634. * Attach the input controls to a specific dom element to get the input from.
  78635. * @param element Defines the element the controls should be listened from
  78636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78637. */
  78638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78639. /**
  78640. * Called on JS contextmenu event.
  78641. * Override this method to provide functionality.
  78642. */
  78643. protected onContextMenu(evt: PointerEvent): void;
  78644. /**
  78645. * Detach the current controls from the specified dom element.
  78646. * @param element Defines the element to stop listening the inputs from
  78647. */
  78648. detachControl(element: Nullable<HTMLElement>): void;
  78649. /**
  78650. * Gets the class name of the current intput.
  78651. * @returns the class name
  78652. */
  78653. getClassName(): string;
  78654. /**
  78655. * Get the friendly name associated with the input class.
  78656. * @returns the input friendly name
  78657. */
  78658. getSimpleName(): string;
  78659. }
  78660. }
  78661. declare module BABYLON {
  78662. /**
  78663. * Manage the touch inputs to control the movement of a free camera.
  78664. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78665. */
  78666. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78667. /**
  78668. * Defines the camera the input is attached to.
  78669. */
  78670. camera: FreeCamera;
  78671. /**
  78672. * Defines the touch sensibility for rotation.
  78673. * The higher the faster.
  78674. */
  78675. touchAngularSensibility: number;
  78676. /**
  78677. * Defines the touch sensibility for move.
  78678. * The higher the faster.
  78679. */
  78680. touchMoveSensibility: number;
  78681. private _offsetX;
  78682. private _offsetY;
  78683. private _pointerPressed;
  78684. private _pointerInput;
  78685. private _observer;
  78686. private _onLostFocus;
  78687. /**
  78688. * Attach the input controls to a specific dom element to get the input from.
  78689. * @param element Defines the element the controls should be listened from
  78690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78691. */
  78692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78693. /**
  78694. * Detach the current controls from the specified dom element.
  78695. * @param element Defines the element to stop listening the inputs from
  78696. */
  78697. detachControl(element: Nullable<HTMLElement>): void;
  78698. /**
  78699. * Update the current camera state depending on the inputs that have been used this frame.
  78700. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78701. */
  78702. checkInputs(): void;
  78703. /**
  78704. * Gets the class name of the current intput.
  78705. * @returns the class name
  78706. */
  78707. getClassName(): string;
  78708. /**
  78709. * Get the friendly name associated with the input class.
  78710. * @returns the input friendly name
  78711. */
  78712. getSimpleName(): string;
  78713. }
  78714. }
  78715. declare module BABYLON {
  78716. /**
  78717. * Default Inputs manager for the FreeCamera.
  78718. * It groups all the default supported inputs for ease of use.
  78719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78720. */
  78721. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78722. /**
  78723. * @hidden
  78724. */
  78725. _mouseInput: Nullable<FreeCameraMouseInput>;
  78726. /**
  78727. * Instantiates a new FreeCameraInputsManager.
  78728. * @param camera Defines the camera the inputs belong to
  78729. */
  78730. constructor(camera: FreeCamera);
  78731. /**
  78732. * Add keyboard input support to the input manager.
  78733. * @returns the current input manager
  78734. */
  78735. addKeyboard(): FreeCameraInputsManager;
  78736. /**
  78737. * Add mouse input support to the input manager.
  78738. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78739. * @returns the current input manager
  78740. */
  78741. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78742. /**
  78743. * Removes the mouse input support from the manager
  78744. * @returns the current input manager
  78745. */
  78746. removeMouse(): FreeCameraInputsManager;
  78747. /**
  78748. * Add touch input support to the input manager.
  78749. * @returns the current input manager
  78750. */
  78751. addTouch(): FreeCameraInputsManager;
  78752. /**
  78753. * Remove all attached input methods from a camera
  78754. */
  78755. clear(): void;
  78756. }
  78757. }
  78758. declare module BABYLON {
  78759. /**
  78760. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78761. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78762. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78763. */
  78764. export class FreeCamera extends TargetCamera {
  78765. /**
  78766. * Define the collision ellipsoid of the camera.
  78767. * This is helpful to simulate a camera body like the player body around the camera
  78768. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78769. */
  78770. ellipsoid: Vector3;
  78771. /**
  78772. * Define an offset for the position of the ellipsoid around the camera.
  78773. * This can be helpful to determine the center of the body near the gravity center of the body
  78774. * instead of its head.
  78775. */
  78776. ellipsoidOffset: Vector3;
  78777. /**
  78778. * Enable or disable collisions of the camera with the rest of the scene objects.
  78779. */
  78780. checkCollisions: boolean;
  78781. /**
  78782. * Enable or disable gravity on the camera.
  78783. */
  78784. applyGravity: boolean;
  78785. /**
  78786. * Define the input manager associated to the camera.
  78787. */
  78788. inputs: FreeCameraInputsManager;
  78789. /**
  78790. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78791. * Higher values reduce sensitivity.
  78792. */
  78793. /**
  78794. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78795. * Higher values reduce sensitivity.
  78796. */
  78797. angularSensibility: number;
  78798. /**
  78799. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78800. */
  78801. keysUp: number[];
  78802. /**
  78803. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78804. */
  78805. keysDown: number[];
  78806. /**
  78807. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78808. */
  78809. keysLeft: number[];
  78810. /**
  78811. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78812. */
  78813. keysRight: number[];
  78814. /**
  78815. * Event raised when the camera collide with a mesh in the scene.
  78816. */
  78817. onCollide: (collidedMesh: AbstractMesh) => void;
  78818. private _collider;
  78819. private _needMoveForGravity;
  78820. private _oldPosition;
  78821. private _diffPosition;
  78822. private _newPosition;
  78823. /** @hidden */
  78824. _localDirection: Vector3;
  78825. /** @hidden */
  78826. _transformedDirection: Vector3;
  78827. /**
  78828. * Instantiates a Free Camera.
  78829. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78830. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78832. * @param name Define the name of the camera in the scene
  78833. * @param position Define the start position of the camera in the scene
  78834. * @param scene Define the scene the camera belongs to
  78835. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78836. */
  78837. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78838. /**
  78839. * Attached controls to the current camera.
  78840. * @param element Defines the element the controls should be listened from
  78841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78842. */
  78843. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78844. /**
  78845. * Detach the current controls from the camera.
  78846. * The camera will stop reacting to inputs.
  78847. * @param element Defines the element to stop listening the inputs from
  78848. */
  78849. detachControl(element: HTMLElement): void;
  78850. private _collisionMask;
  78851. /**
  78852. * Define a collision mask to limit the list of object the camera can collide with
  78853. */
  78854. collisionMask: number;
  78855. /** @hidden */
  78856. _collideWithWorld(displacement: Vector3): void;
  78857. private _onCollisionPositionChange;
  78858. /** @hidden */
  78859. _checkInputs(): void;
  78860. /** @hidden */
  78861. _decideIfNeedsToMove(): boolean;
  78862. /** @hidden */
  78863. _updatePosition(): void;
  78864. /**
  78865. * Destroy the camera and release the current resources hold by it.
  78866. */
  78867. dispose(): void;
  78868. /**
  78869. * Gets the current object class name.
  78870. * @return the class name
  78871. */
  78872. getClassName(): string;
  78873. }
  78874. }
  78875. declare module BABYLON {
  78876. /**
  78877. * Represents a gamepad control stick position
  78878. */
  78879. export class StickValues {
  78880. /**
  78881. * The x component of the control stick
  78882. */
  78883. x: number;
  78884. /**
  78885. * The y component of the control stick
  78886. */
  78887. y: number;
  78888. /**
  78889. * Initializes the gamepad x and y control stick values
  78890. * @param x The x component of the gamepad control stick value
  78891. * @param y The y component of the gamepad control stick value
  78892. */
  78893. constructor(
  78894. /**
  78895. * The x component of the control stick
  78896. */
  78897. x: number,
  78898. /**
  78899. * The y component of the control stick
  78900. */
  78901. y: number);
  78902. }
  78903. /**
  78904. * An interface which manages callbacks for gamepad button changes
  78905. */
  78906. export interface GamepadButtonChanges {
  78907. /**
  78908. * Called when a gamepad has been changed
  78909. */
  78910. changed: boolean;
  78911. /**
  78912. * Called when a gamepad press event has been triggered
  78913. */
  78914. pressChanged: boolean;
  78915. /**
  78916. * Called when a touch event has been triggered
  78917. */
  78918. touchChanged: boolean;
  78919. /**
  78920. * Called when a value has changed
  78921. */
  78922. valueChanged: boolean;
  78923. }
  78924. /**
  78925. * Represents a gamepad
  78926. */
  78927. export class Gamepad {
  78928. /**
  78929. * The id of the gamepad
  78930. */
  78931. id: string;
  78932. /**
  78933. * The index of the gamepad
  78934. */
  78935. index: number;
  78936. /**
  78937. * The browser gamepad
  78938. */
  78939. browserGamepad: any;
  78940. /**
  78941. * Specifies what type of gamepad this represents
  78942. */
  78943. type: number;
  78944. private _leftStick;
  78945. private _rightStick;
  78946. /** @hidden */
  78947. _isConnected: boolean;
  78948. private _leftStickAxisX;
  78949. private _leftStickAxisY;
  78950. private _rightStickAxisX;
  78951. private _rightStickAxisY;
  78952. /**
  78953. * Triggered when the left control stick has been changed
  78954. */
  78955. private _onleftstickchanged;
  78956. /**
  78957. * Triggered when the right control stick has been changed
  78958. */
  78959. private _onrightstickchanged;
  78960. /**
  78961. * Represents a gamepad controller
  78962. */
  78963. static GAMEPAD: number;
  78964. /**
  78965. * Represents a generic controller
  78966. */
  78967. static GENERIC: number;
  78968. /**
  78969. * Represents an XBox controller
  78970. */
  78971. static XBOX: number;
  78972. /**
  78973. * Represents a pose-enabled controller
  78974. */
  78975. static POSE_ENABLED: number;
  78976. /**
  78977. * Represents an Dual Shock controller
  78978. */
  78979. static DUALSHOCK: number;
  78980. /**
  78981. * Specifies whether the left control stick should be Y-inverted
  78982. */
  78983. protected _invertLeftStickY: boolean;
  78984. /**
  78985. * Specifies if the gamepad has been connected
  78986. */
  78987. readonly isConnected: boolean;
  78988. /**
  78989. * Initializes the gamepad
  78990. * @param id The id of the gamepad
  78991. * @param index The index of the gamepad
  78992. * @param browserGamepad The browser gamepad
  78993. * @param leftStickX The x component of the left joystick
  78994. * @param leftStickY The y component of the left joystick
  78995. * @param rightStickX The x component of the right joystick
  78996. * @param rightStickY The y component of the right joystick
  78997. */
  78998. constructor(
  78999. /**
  79000. * The id of the gamepad
  79001. */
  79002. id: string,
  79003. /**
  79004. * The index of the gamepad
  79005. */
  79006. index: number,
  79007. /**
  79008. * The browser gamepad
  79009. */
  79010. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79011. /**
  79012. * Callback triggered when the left joystick has changed
  79013. * @param callback
  79014. */
  79015. onleftstickchanged(callback: (values: StickValues) => void): void;
  79016. /**
  79017. * Callback triggered when the right joystick has changed
  79018. * @param callback
  79019. */
  79020. onrightstickchanged(callback: (values: StickValues) => void): void;
  79021. /**
  79022. * Gets the left joystick
  79023. */
  79024. /**
  79025. * Sets the left joystick values
  79026. */
  79027. leftStick: StickValues;
  79028. /**
  79029. * Gets the right joystick
  79030. */
  79031. /**
  79032. * Sets the right joystick value
  79033. */
  79034. rightStick: StickValues;
  79035. /**
  79036. * Updates the gamepad joystick positions
  79037. */
  79038. update(): void;
  79039. /**
  79040. * Disposes the gamepad
  79041. */
  79042. dispose(): void;
  79043. }
  79044. /**
  79045. * Represents a generic gamepad
  79046. */
  79047. export class GenericPad extends Gamepad {
  79048. private _buttons;
  79049. private _onbuttondown;
  79050. private _onbuttonup;
  79051. /**
  79052. * Observable triggered when a button has been pressed
  79053. */
  79054. onButtonDownObservable: Observable<number>;
  79055. /**
  79056. * Observable triggered when a button has been released
  79057. */
  79058. onButtonUpObservable: Observable<number>;
  79059. /**
  79060. * Callback triggered when a button has been pressed
  79061. * @param callback Called when a button has been pressed
  79062. */
  79063. onbuttondown(callback: (buttonPressed: number) => void): void;
  79064. /**
  79065. * Callback triggered when a button has been released
  79066. * @param callback Called when a button has been released
  79067. */
  79068. onbuttonup(callback: (buttonReleased: number) => void): void;
  79069. /**
  79070. * Initializes the generic gamepad
  79071. * @param id The id of the generic gamepad
  79072. * @param index The index of the generic gamepad
  79073. * @param browserGamepad The browser gamepad
  79074. */
  79075. constructor(id: string, index: number, browserGamepad: any);
  79076. private _setButtonValue;
  79077. /**
  79078. * Updates the generic gamepad
  79079. */
  79080. update(): void;
  79081. /**
  79082. * Disposes the generic gamepad
  79083. */
  79084. dispose(): void;
  79085. }
  79086. }
  79087. declare module BABYLON {
  79088. interface Engine {
  79089. /**
  79090. * Creates a raw texture
  79091. * @param data defines the data to store in the texture
  79092. * @param width defines the width of the texture
  79093. * @param height defines the height of the texture
  79094. * @param format defines the format of the data
  79095. * @param generateMipMaps defines if the engine should generate the mip levels
  79096. * @param invertY defines if data must be stored with Y axis inverted
  79097. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79098. * @param compression defines the compression used (null by default)
  79099. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79100. * @returns the raw texture inside an InternalTexture
  79101. */
  79102. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79103. /**
  79104. * Update a raw texture
  79105. * @param texture defines the texture to update
  79106. * @param data defines the data to store in the texture
  79107. * @param format defines the format of the data
  79108. * @param invertY defines if data must be stored with Y axis inverted
  79109. */
  79110. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79111. /**
  79112. * Update a raw texture
  79113. * @param texture defines the texture to update
  79114. * @param data defines the data to store in the texture
  79115. * @param format defines the format of the data
  79116. * @param invertY defines if data must be stored with Y axis inverted
  79117. * @param compression defines the compression used (null by default)
  79118. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79119. */
  79120. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79121. /**
  79122. * Creates a new raw cube texture
  79123. * @param data defines the array of data to use to create each face
  79124. * @param size defines the size of the textures
  79125. * @param format defines the format of the data
  79126. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79127. * @param generateMipMaps defines if the engine should generate the mip levels
  79128. * @param invertY defines if data must be stored with Y axis inverted
  79129. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79130. * @param compression defines the compression used (null by default)
  79131. * @returns the cube texture as an InternalTexture
  79132. */
  79133. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79134. /**
  79135. * Update a raw cube texture
  79136. * @param texture defines the texture to udpdate
  79137. * @param data defines the data to store
  79138. * @param format defines the data format
  79139. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79140. * @param invertY defines if data must be stored with Y axis inverted
  79141. */
  79142. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79143. /**
  79144. * Update a raw cube texture
  79145. * @param texture defines the texture to udpdate
  79146. * @param data defines the data to store
  79147. * @param format defines the data format
  79148. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79149. * @param invertY defines if data must be stored with Y axis inverted
  79150. * @param compression defines the compression used (null by default)
  79151. */
  79152. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79153. /**
  79154. * Update a raw cube texture
  79155. * @param texture defines the texture to udpdate
  79156. * @param data defines the data to store
  79157. * @param format defines the data format
  79158. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79159. * @param invertY defines if data must be stored with Y axis inverted
  79160. * @param compression defines the compression used (null by default)
  79161. * @param level defines which level of the texture to update
  79162. */
  79163. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79164. /**
  79165. * Creates a new raw cube texture from a specified url
  79166. * @param url defines the url where the data is located
  79167. * @param scene defines the current scene
  79168. * @param size defines the size of the textures
  79169. * @param format defines the format of the data
  79170. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79171. * @param noMipmap defines if the engine should avoid generating the mip levels
  79172. * @param callback defines a callback used to extract texture data from loaded data
  79173. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79174. * @param onLoad defines a callback called when texture is loaded
  79175. * @param onError defines a callback called if there is an error
  79176. * @returns the cube texture as an InternalTexture
  79177. */
  79178. 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;
  79179. /**
  79180. * Creates a new raw cube texture from a specified url
  79181. * @param url defines the url where the data is located
  79182. * @param scene defines the current scene
  79183. * @param size defines the size of the textures
  79184. * @param format defines the format of the data
  79185. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79186. * @param noMipmap defines if the engine should avoid generating the mip levels
  79187. * @param callback defines a callback used to extract texture data from loaded data
  79188. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79189. * @param onLoad defines a callback called when texture is loaded
  79190. * @param onError defines a callback called if there is an error
  79191. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79192. * @param invertY defines if data must be stored with Y axis inverted
  79193. * @returns the cube texture as an InternalTexture
  79194. */
  79195. 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;
  79196. /**
  79197. * Creates a new raw 3D texture
  79198. * @param data defines the data used to create the texture
  79199. * @param width defines the width of the texture
  79200. * @param height defines the height of the texture
  79201. * @param depth defines the depth of the texture
  79202. * @param format defines the format of the texture
  79203. * @param generateMipMaps defines if the engine must generate mip levels
  79204. * @param invertY defines if data must be stored with Y axis inverted
  79205. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79206. * @param compression defines the compressed used (can be null)
  79207. * @param textureType defines the compressed used (can be null)
  79208. * @returns a new raw 3D texture (stored in an InternalTexture)
  79209. */
  79210. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79211. /**
  79212. * Update a raw 3D texture
  79213. * @param texture defines the texture to update
  79214. * @param data defines the data to store
  79215. * @param format defines the data format
  79216. * @param invertY defines if data must be stored with Y axis inverted
  79217. */
  79218. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79219. /**
  79220. * Update a raw 3D texture
  79221. * @param texture defines the texture to update
  79222. * @param data defines the data to store
  79223. * @param format defines the data format
  79224. * @param invertY defines if data must be stored with Y axis inverted
  79225. * @param compression defines the used compression (can be null)
  79226. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79227. */
  79228. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79229. }
  79230. }
  79231. declare module BABYLON {
  79232. /**
  79233. * Raw texture can help creating a texture directly from an array of data.
  79234. * This can be super useful if you either get the data from an uncompressed source or
  79235. * if you wish to create your texture pixel by pixel.
  79236. */
  79237. export class RawTexture extends Texture {
  79238. /**
  79239. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79240. */
  79241. format: number;
  79242. private _engine;
  79243. /**
  79244. * Instantiates a new RawTexture.
  79245. * Raw texture can help creating a texture directly from an array of data.
  79246. * This can be super useful if you either get the data from an uncompressed source or
  79247. * if you wish to create your texture pixel by pixel.
  79248. * @param data define the array of data to use to create the texture
  79249. * @param width define the width of the texture
  79250. * @param height define the height of the texture
  79251. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79252. * @param scene define the scene the texture belongs to
  79253. * @param generateMipMaps define whether mip maps should be generated or not
  79254. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79255. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79256. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79257. */
  79258. constructor(data: ArrayBufferView, width: number, height: number,
  79259. /**
  79260. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79261. */
  79262. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79263. /**
  79264. * Updates the texture underlying data.
  79265. * @param data Define the new data of the texture
  79266. */
  79267. update(data: ArrayBufferView): void;
  79268. /**
  79269. * Creates a luminance texture from some data.
  79270. * @param data Define the texture data
  79271. * @param width Define the width of the texture
  79272. * @param height Define the height of the texture
  79273. * @param scene Define the scene the texture belongs to
  79274. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79275. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79276. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79277. * @returns the luminance texture
  79278. */
  79279. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79280. /**
  79281. * Creates a luminance alpha texture from some data.
  79282. * @param data Define the texture data
  79283. * @param width Define the width of the texture
  79284. * @param height Define the height of the texture
  79285. * @param scene Define the scene the texture belongs to
  79286. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79287. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79288. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79289. * @returns the luminance alpha texture
  79290. */
  79291. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79292. /**
  79293. * Creates an alpha texture from some data.
  79294. * @param data Define the texture data
  79295. * @param width Define the width of the texture
  79296. * @param height Define the height of the texture
  79297. * @param scene Define the scene the texture belongs to
  79298. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79299. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79300. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79301. * @returns the alpha texture
  79302. */
  79303. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79304. /**
  79305. * Creates a RGB texture from some data.
  79306. * @param data Define the texture data
  79307. * @param width Define the width of the texture
  79308. * @param height Define the height of the texture
  79309. * @param scene Define the scene the texture belongs to
  79310. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79311. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79312. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79313. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79314. * @returns the RGB alpha texture
  79315. */
  79316. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79317. /**
  79318. * Creates a RGBA texture from some data.
  79319. * @param data Define the texture data
  79320. * @param width Define the width of the texture
  79321. * @param height Define the height of the texture
  79322. * @param scene Define the scene the texture belongs to
  79323. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79324. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79325. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79326. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79327. * @returns the RGBA texture
  79328. */
  79329. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79330. /**
  79331. * Creates a R texture from some data.
  79332. * @param data Define the texture data
  79333. * @param width Define the width of the texture
  79334. * @param height Define the height of the texture
  79335. * @param scene Define the scene the texture belongs to
  79336. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79337. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79338. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79339. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79340. * @returns the R texture
  79341. */
  79342. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79343. }
  79344. }
  79345. declare module BABYLON {
  79346. /**
  79347. * Interface for the size containing width and height
  79348. */
  79349. export interface ISize {
  79350. /**
  79351. * Width
  79352. */
  79353. width: number;
  79354. /**
  79355. * Heighht
  79356. */
  79357. height: number;
  79358. }
  79359. /**
  79360. * Size containing widht and height
  79361. */
  79362. export class Size implements ISize {
  79363. /**
  79364. * Width
  79365. */
  79366. width: number;
  79367. /**
  79368. * Height
  79369. */
  79370. height: number;
  79371. /**
  79372. * Creates a Size object from the given width and height (floats).
  79373. * @param width width of the new size
  79374. * @param height height of the new size
  79375. */
  79376. constructor(width: number, height: number);
  79377. /**
  79378. * Returns a string with the Size width and height
  79379. * @returns a string with the Size width and height
  79380. */
  79381. toString(): string;
  79382. /**
  79383. * "Size"
  79384. * @returns the string "Size"
  79385. */
  79386. getClassName(): string;
  79387. /**
  79388. * Returns the Size hash code.
  79389. * @returns a hash code for a unique width and height
  79390. */
  79391. getHashCode(): number;
  79392. /**
  79393. * Updates the current size from the given one.
  79394. * @param src the given size
  79395. */
  79396. copyFrom(src: Size): void;
  79397. /**
  79398. * Updates in place the current Size from the given floats.
  79399. * @param width width of the new size
  79400. * @param height height of the new size
  79401. * @returns the updated Size.
  79402. */
  79403. copyFromFloats(width: number, height: number): Size;
  79404. /**
  79405. * Updates in place the current Size from the given floats.
  79406. * @param width width to set
  79407. * @param height height to set
  79408. * @returns the updated Size.
  79409. */
  79410. set(width: number, height: number): Size;
  79411. /**
  79412. * Multiplies the width and height by numbers
  79413. * @param w factor to multiple the width by
  79414. * @param h factor to multiple the height by
  79415. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79416. */
  79417. multiplyByFloats(w: number, h: number): Size;
  79418. /**
  79419. * Clones the size
  79420. * @returns a new Size copied from the given one.
  79421. */
  79422. clone(): Size;
  79423. /**
  79424. * True if the current Size and the given one width and height are strictly equal.
  79425. * @param other the other size to compare against
  79426. * @returns True if the current Size and the given one width and height are strictly equal.
  79427. */
  79428. equals(other: Size): boolean;
  79429. /**
  79430. * The surface of the Size : width * height (float).
  79431. */
  79432. readonly surface: number;
  79433. /**
  79434. * Create a new size of zero
  79435. * @returns a new Size set to (0.0, 0.0)
  79436. */
  79437. static Zero(): Size;
  79438. /**
  79439. * Sums the width and height of two sizes
  79440. * @param otherSize size to add to this size
  79441. * @returns a new Size set as the addition result of the current Size and the given one.
  79442. */
  79443. add(otherSize: Size): Size;
  79444. /**
  79445. * Subtracts the width and height of two
  79446. * @param otherSize size to subtract to this size
  79447. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79448. */
  79449. subtract(otherSize: Size): Size;
  79450. /**
  79451. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79452. * @param start starting size to lerp between
  79453. * @param end end size to lerp between
  79454. * @param amount amount to lerp between the start and end values
  79455. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79456. */
  79457. static Lerp(start: Size, end: Size, amount: number): Size;
  79458. }
  79459. }
  79460. declare module BABYLON {
  79461. /**
  79462. * Defines a runtime animation
  79463. */
  79464. export class RuntimeAnimation {
  79465. private _events;
  79466. /**
  79467. * The current frame of the runtime animation
  79468. */
  79469. private _currentFrame;
  79470. /**
  79471. * The animation used by the runtime animation
  79472. */
  79473. private _animation;
  79474. /**
  79475. * The target of the runtime animation
  79476. */
  79477. private _target;
  79478. /**
  79479. * The initiating animatable
  79480. */
  79481. private _host;
  79482. /**
  79483. * The original value of the runtime animation
  79484. */
  79485. private _originalValue;
  79486. /**
  79487. * The original blend value of the runtime animation
  79488. */
  79489. private _originalBlendValue;
  79490. /**
  79491. * The offsets cache of the runtime animation
  79492. */
  79493. private _offsetsCache;
  79494. /**
  79495. * The high limits cache of the runtime animation
  79496. */
  79497. private _highLimitsCache;
  79498. /**
  79499. * Specifies if the runtime animation has been stopped
  79500. */
  79501. private _stopped;
  79502. /**
  79503. * The blending factor of the runtime animation
  79504. */
  79505. private _blendingFactor;
  79506. /**
  79507. * The BabylonJS scene
  79508. */
  79509. private _scene;
  79510. /**
  79511. * The current value of the runtime animation
  79512. */
  79513. private _currentValue;
  79514. /** @hidden */
  79515. _animationState: _IAnimationState;
  79516. /**
  79517. * The active target of the runtime animation
  79518. */
  79519. private _activeTargets;
  79520. private _currentActiveTarget;
  79521. private _directTarget;
  79522. /**
  79523. * The target path of the runtime animation
  79524. */
  79525. private _targetPath;
  79526. /**
  79527. * The weight of the runtime animation
  79528. */
  79529. private _weight;
  79530. /**
  79531. * The ratio offset of the runtime animation
  79532. */
  79533. private _ratioOffset;
  79534. /**
  79535. * The previous delay of the runtime animation
  79536. */
  79537. private _previousDelay;
  79538. /**
  79539. * The previous ratio of the runtime animation
  79540. */
  79541. private _previousRatio;
  79542. private _enableBlending;
  79543. private _keys;
  79544. private _minFrame;
  79545. private _maxFrame;
  79546. private _minValue;
  79547. private _maxValue;
  79548. private _targetIsArray;
  79549. /**
  79550. * Gets the current frame of the runtime animation
  79551. */
  79552. readonly currentFrame: number;
  79553. /**
  79554. * Gets the weight of the runtime animation
  79555. */
  79556. readonly weight: number;
  79557. /**
  79558. * Gets the current value of the runtime animation
  79559. */
  79560. readonly currentValue: any;
  79561. /**
  79562. * Gets the target path of the runtime animation
  79563. */
  79564. readonly targetPath: string;
  79565. /**
  79566. * Gets the actual target of the runtime animation
  79567. */
  79568. readonly target: any;
  79569. /** @hidden */
  79570. _onLoop: () => void;
  79571. /**
  79572. * Create a new RuntimeAnimation object
  79573. * @param target defines the target of the animation
  79574. * @param animation defines the source animation object
  79575. * @param scene defines the hosting scene
  79576. * @param host defines the initiating Animatable
  79577. */
  79578. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79579. private _preparePath;
  79580. /**
  79581. * Gets the animation from the runtime animation
  79582. */
  79583. readonly animation: Animation;
  79584. /**
  79585. * Resets the runtime animation to the beginning
  79586. * @param restoreOriginal defines whether to restore the target property to the original value
  79587. */
  79588. reset(restoreOriginal?: boolean): void;
  79589. /**
  79590. * Specifies if the runtime animation is stopped
  79591. * @returns Boolean specifying if the runtime animation is stopped
  79592. */
  79593. isStopped(): boolean;
  79594. /**
  79595. * Disposes of the runtime animation
  79596. */
  79597. dispose(): void;
  79598. /**
  79599. * Apply the interpolated value to the target
  79600. * @param currentValue defines the value computed by the animation
  79601. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79602. */
  79603. setValue(currentValue: any, weight: number): void;
  79604. private _getOriginalValues;
  79605. private _setValue;
  79606. /**
  79607. * Gets the loop pmode of the runtime animation
  79608. * @returns Loop Mode
  79609. */
  79610. private _getCorrectLoopMode;
  79611. /**
  79612. * Move the current animation to a given frame
  79613. * @param frame defines the frame to move to
  79614. */
  79615. goToFrame(frame: number): void;
  79616. /**
  79617. * @hidden Internal use only
  79618. */
  79619. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79620. /**
  79621. * Execute the current animation
  79622. * @param delay defines the delay to add to the current frame
  79623. * @param from defines the lower bound of the animation range
  79624. * @param to defines the upper bound of the animation range
  79625. * @param loop defines if the current animation must loop
  79626. * @param speedRatio defines the current speed ratio
  79627. * @param weight defines the weight of the animation (default is -1 so no weight)
  79628. * @param onLoop optional callback called when animation loops
  79629. * @returns a boolean indicating if the animation is running
  79630. */
  79631. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79632. }
  79633. }
  79634. declare module BABYLON {
  79635. /**
  79636. * Class used to store an actual running animation
  79637. */
  79638. export class Animatable {
  79639. /** defines the target object */
  79640. target: any;
  79641. /** defines the starting frame number (default is 0) */
  79642. fromFrame: number;
  79643. /** defines the ending frame number (default is 100) */
  79644. toFrame: number;
  79645. /** defines if the animation must loop (default is false) */
  79646. loopAnimation: boolean;
  79647. /** defines a callback to call when animation ends if it is not looping */
  79648. onAnimationEnd?: (() => void) | null | undefined;
  79649. /** defines a callback to call when animation loops */
  79650. onAnimationLoop?: (() => void) | null | undefined;
  79651. private _localDelayOffset;
  79652. private _pausedDelay;
  79653. private _runtimeAnimations;
  79654. private _paused;
  79655. private _scene;
  79656. private _speedRatio;
  79657. private _weight;
  79658. private _syncRoot;
  79659. /**
  79660. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79661. * This will only apply for non looping animation (default is true)
  79662. */
  79663. disposeOnEnd: boolean;
  79664. /**
  79665. * Gets a boolean indicating if the animation has started
  79666. */
  79667. animationStarted: boolean;
  79668. /**
  79669. * Observer raised when the animation ends
  79670. */
  79671. onAnimationEndObservable: Observable<Animatable>;
  79672. /**
  79673. * Observer raised when the animation loops
  79674. */
  79675. onAnimationLoopObservable: Observable<Animatable>;
  79676. /**
  79677. * Gets the root Animatable used to synchronize and normalize animations
  79678. */
  79679. readonly syncRoot: Nullable<Animatable>;
  79680. /**
  79681. * Gets the current frame of the first RuntimeAnimation
  79682. * Used to synchronize Animatables
  79683. */
  79684. readonly masterFrame: number;
  79685. /**
  79686. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79687. */
  79688. weight: number;
  79689. /**
  79690. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79691. */
  79692. speedRatio: number;
  79693. /**
  79694. * Creates a new Animatable
  79695. * @param scene defines the hosting scene
  79696. * @param target defines the target object
  79697. * @param fromFrame defines the starting frame number (default is 0)
  79698. * @param toFrame defines the ending frame number (default is 100)
  79699. * @param loopAnimation defines if the animation must loop (default is false)
  79700. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79701. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79702. * @param animations defines a group of animation to add to the new Animatable
  79703. * @param onAnimationLoop defines a callback to call when animation loops
  79704. */
  79705. constructor(scene: Scene,
  79706. /** defines the target object */
  79707. target: any,
  79708. /** defines the starting frame number (default is 0) */
  79709. fromFrame?: number,
  79710. /** defines the ending frame number (default is 100) */
  79711. toFrame?: number,
  79712. /** defines if the animation must loop (default is false) */
  79713. loopAnimation?: boolean, speedRatio?: number,
  79714. /** defines a callback to call when animation ends if it is not looping */
  79715. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79716. /** defines a callback to call when animation loops */
  79717. onAnimationLoop?: (() => void) | null | undefined);
  79718. /**
  79719. * Synchronize and normalize current Animatable with a source Animatable
  79720. * This is useful when using animation weights and when animations are not of the same length
  79721. * @param root defines the root Animatable to synchronize with
  79722. * @returns the current Animatable
  79723. */
  79724. syncWith(root: Animatable): Animatable;
  79725. /**
  79726. * Gets the list of runtime animations
  79727. * @returns an array of RuntimeAnimation
  79728. */
  79729. getAnimations(): RuntimeAnimation[];
  79730. /**
  79731. * Adds more animations to the current animatable
  79732. * @param target defines the target of the animations
  79733. * @param animations defines the new animations to add
  79734. */
  79735. appendAnimations(target: any, animations: Animation[]): void;
  79736. /**
  79737. * Gets the source animation for a specific property
  79738. * @param property defines the propertyu to look for
  79739. * @returns null or the source animation for the given property
  79740. */
  79741. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79742. /**
  79743. * Gets the runtime animation for a specific property
  79744. * @param property defines the propertyu to look for
  79745. * @returns null or the runtime animation for the given property
  79746. */
  79747. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79748. /**
  79749. * Resets the animatable to its original state
  79750. */
  79751. reset(): void;
  79752. /**
  79753. * Allows the animatable to blend with current running animations
  79754. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79755. * @param blendingSpeed defines the blending speed to use
  79756. */
  79757. enableBlending(blendingSpeed: number): void;
  79758. /**
  79759. * Disable animation blending
  79760. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79761. */
  79762. disableBlending(): void;
  79763. /**
  79764. * Jump directly to a given frame
  79765. * @param frame defines the frame to jump to
  79766. */
  79767. goToFrame(frame: number): void;
  79768. /**
  79769. * Pause the animation
  79770. */
  79771. pause(): void;
  79772. /**
  79773. * Restart the animation
  79774. */
  79775. restart(): void;
  79776. private _raiseOnAnimationEnd;
  79777. /**
  79778. * Stop and delete the current animation
  79779. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79780. * @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)
  79781. */
  79782. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79783. /**
  79784. * Wait asynchronously for the animation to end
  79785. * @returns a promise which will be fullfilled when the animation ends
  79786. */
  79787. waitAsync(): Promise<Animatable>;
  79788. /** @hidden */
  79789. _animate(delay: number): boolean;
  79790. }
  79791. interface Scene {
  79792. /** @hidden */
  79793. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79794. /** @hidden */
  79795. _processLateAnimationBindingsForMatrices(holder: {
  79796. totalWeight: number;
  79797. animations: RuntimeAnimation[];
  79798. originalValue: Matrix;
  79799. }): any;
  79800. /** @hidden */
  79801. _processLateAnimationBindingsForQuaternions(holder: {
  79802. totalWeight: number;
  79803. animations: RuntimeAnimation[];
  79804. originalValue: Quaternion;
  79805. }, refQuaternion: Quaternion): Quaternion;
  79806. /** @hidden */
  79807. _processLateAnimationBindings(): void;
  79808. /**
  79809. * Will start the animation sequence of a given target
  79810. * @param target defines the target
  79811. * @param from defines from which frame should animation start
  79812. * @param to defines until which frame should animation run.
  79813. * @param weight defines the weight to apply to the animation (1.0 by default)
  79814. * @param loop defines if the animation loops
  79815. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79816. * @param onAnimationEnd defines the function to be executed when the animation ends
  79817. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79818. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79819. * @param onAnimationLoop defines the callback to call when an animation loops
  79820. * @returns the animatable object created for this animation
  79821. */
  79822. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79823. /**
  79824. * Will start the animation sequence of a given target
  79825. * @param target defines the target
  79826. * @param from defines from which frame should animation start
  79827. * @param to defines until which frame should animation run.
  79828. * @param loop defines if the animation loops
  79829. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79830. * @param onAnimationEnd defines the function to be executed when the animation ends
  79831. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79832. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79833. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79834. * @param onAnimationLoop defines the callback to call when an animation loops
  79835. * @returns the animatable object created for this animation
  79836. */
  79837. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79838. /**
  79839. * Will start the animation sequence of a given target and its hierarchy
  79840. * @param target defines the target
  79841. * @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.
  79842. * @param from defines from which frame should animation start
  79843. * @param to defines until which frame should animation run.
  79844. * @param loop defines if the animation loops
  79845. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79846. * @param onAnimationEnd defines the function to be executed when the animation ends
  79847. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79848. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79849. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79850. * @param onAnimationLoop defines the callback to call when an animation loops
  79851. * @returns the list of created animatables
  79852. */
  79853. 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[];
  79854. /**
  79855. * Begin a new animation on a given node
  79856. * @param target defines the target where the animation will take place
  79857. * @param animations defines the list of animations to start
  79858. * @param from defines the initial value
  79859. * @param to defines the final value
  79860. * @param loop defines if you want animation to loop (off by default)
  79861. * @param speedRatio defines the speed ratio to apply to all animations
  79862. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79863. * @param onAnimationLoop defines the callback to call when an animation loops
  79864. * @returns the list of created animatables
  79865. */
  79866. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79867. /**
  79868. * Begin a new animation on a given node and its hierarchy
  79869. * @param target defines the root node where the animation will take place
  79870. * @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.
  79871. * @param animations defines the list of animations to start
  79872. * @param from defines the initial value
  79873. * @param to defines the final value
  79874. * @param loop defines if you want animation to loop (off by default)
  79875. * @param speedRatio defines the speed ratio to apply to all animations
  79876. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79877. * @param onAnimationLoop defines the callback to call when an animation loops
  79878. * @returns the list of animatables created for all nodes
  79879. */
  79880. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79881. /**
  79882. * Gets the animatable associated with a specific target
  79883. * @param target defines the target of the animatable
  79884. * @returns the required animatable if found
  79885. */
  79886. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79887. /**
  79888. * Gets all animatables associated with a given target
  79889. * @param target defines the target to look animatables for
  79890. * @returns an array of Animatables
  79891. */
  79892. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79893. /**
  79894. * Stops and removes all animations that have been applied to the scene
  79895. */
  79896. stopAllAnimations(): void;
  79897. /**
  79898. * Gets the current delta time used by animation engine
  79899. */
  79900. deltaTime: number;
  79901. }
  79902. interface Bone {
  79903. /**
  79904. * Copy an animation range from another bone
  79905. * @param source defines the source bone
  79906. * @param rangeName defines the range name to copy
  79907. * @param frameOffset defines the frame offset
  79908. * @param rescaleAsRequired defines if rescaling must be applied if required
  79909. * @param skelDimensionsRatio defines the scaling ratio
  79910. * @returns true if operation was successful
  79911. */
  79912. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79913. }
  79914. }
  79915. declare module BABYLON {
  79916. /**
  79917. * Class used to override all child animations of a given target
  79918. */
  79919. export class AnimationPropertiesOverride {
  79920. /**
  79921. * Gets or sets a value indicating if animation blending must be used
  79922. */
  79923. enableBlending: boolean;
  79924. /**
  79925. * Gets or sets the blending speed to use when enableBlending is true
  79926. */
  79927. blendingSpeed: number;
  79928. /**
  79929. * Gets or sets the default loop mode to use
  79930. */
  79931. loopMode: number;
  79932. }
  79933. }
  79934. declare module BABYLON {
  79935. /**
  79936. * Class used to handle skinning animations
  79937. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79938. */
  79939. export class Skeleton implements IAnimatable {
  79940. /** defines the skeleton name */
  79941. name: string;
  79942. /** defines the skeleton Id */
  79943. id: string;
  79944. /**
  79945. * Defines the list of child bones
  79946. */
  79947. bones: Bone[];
  79948. /**
  79949. * Defines an estimate of the dimension of the skeleton at rest
  79950. */
  79951. dimensionsAtRest: Vector3;
  79952. /**
  79953. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79954. */
  79955. needInitialSkinMatrix: boolean;
  79956. /**
  79957. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79958. */
  79959. overrideMesh: Nullable<AbstractMesh>;
  79960. /**
  79961. * Gets the list of animations attached to this skeleton
  79962. */
  79963. animations: Array<Animation>;
  79964. private _scene;
  79965. private _isDirty;
  79966. private _transformMatrices;
  79967. private _transformMatrixTexture;
  79968. private _meshesWithPoseMatrix;
  79969. private _animatables;
  79970. private _identity;
  79971. private _synchronizedWithMesh;
  79972. private _ranges;
  79973. private _lastAbsoluteTransformsUpdateId;
  79974. private _canUseTextureForBones;
  79975. private _uniqueId;
  79976. /** @hidden */
  79977. _numBonesWithLinkedTransformNode: number;
  79978. /** @hidden */
  79979. _hasWaitingData: Nullable<boolean>;
  79980. /**
  79981. * Specifies if the skeleton should be serialized
  79982. */
  79983. doNotSerialize: boolean;
  79984. private _useTextureToStoreBoneMatrices;
  79985. /**
  79986. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79987. * Please note that this option is not available if the hardware does not support it
  79988. */
  79989. useTextureToStoreBoneMatrices: boolean;
  79990. private _animationPropertiesOverride;
  79991. /**
  79992. * Gets or sets the animation properties override
  79993. */
  79994. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79995. /**
  79996. * List of inspectable custom properties (used by the Inspector)
  79997. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79998. */
  79999. inspectableCustomProperties: IInspectable[];
  80000. /**
  80001. * An observable triggered before computing the skeleton's matrices
  80002. */
  80003. onBeforeComputeObservable: Observable<Skeleton>;
  80004. /**
  80005. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80006. */
  80007. readonly isUsingTextureForMatrices: boolean;
  80008. /**
  80009. * Gets the unique ID of this skeleton
  80010. */
  80011. readonly uniqueId: number;
  80012. /**
  80013. * Creates a new skeleton
  80014. * @param name defines the skeleton name
  80015. * @param id defines the skeleton Id
  80016. * @param scene defines the hosting scene
  80017. */
  80018. constructor(
  80019. /** defines the skeleton name */
  80020. name: string,
  80021. /** defines the skeleton Id */
  80022. id: string, scene: Scene);
  80023. /**
  80024. * Gets the current object class name.
  80025. * @return the class name
  80026. */
  80027. getClassName(): string;
  80028. /**
  80029. * Returns an array containing the root bones
  80030. * @returns an array containing the root bones
  80031. */
  80032. getChildren(): Array<Bone>;
  80033. /**
  80034. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80035. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80036. * @returns a Float32Array containing matrices data
  80037. */
  80038. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80039. /**
  80040. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80041. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80042. * @returns a raw texture containing the data
  80043. */
  80044. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80045. /**
  80046. * Gets the current hosting scene
  80047. * @returns a scene object
  80048. */
  80049. getScene(): Scene;
  80050. /**
  80051. * Gets a string representing the current skeleton data
  80052. * @param fullDetails defines a boolean indicating if we want a verbose version
  80053. * @returns a string representing the current skeleton data
  80054. */
  80055. toString(fullDetails?: boolean): string;
  80056. /**
  80057. * Get bone's index searching by name
  80058. * @param name defines bone's name to search for
  80059. * @return the indice of the bone. Returns -1 if not found
  80060. */
  80061. getBoneIndexByName(name: string): number;
  80062. /**
  80063. * Creater a new animation range
  80064. * @param name defines the name of the range
  80065. * @param from defines the start key
  80066. * @param to defines the end key
  80067. */
  80068. createAnimationRange(name: string, from: number, to: number): void;
  80069. /**
  80070. * Delete a specific animation range
  80071. * @param name defines the name of the range
  80072. * @param deleteFrames defines if frames must be removed as well
  80073. */
  80074. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80075. /**
  80076. * Gets a specific animation range
  80077. * @param name defines the name of the range to look for
  80078. * @returns the requested animation range or null if not found
  80079. */
  80080. getAnimationRange(name: string): Nullable<AnimationRange>;
  80081. /**
  80082. * Gets the list of all animation ranges defined on this skeleton
  80083. * @returns an array
  80084. */
  80085. getAnimationRanges(): Nullable<AnimationRange>[];
  80086. /**
  80087. * Copy animation range from a source skeleton.
  80088. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80089. * @param source defines the source skeleton
  80090. * @param name defines the name of the range to copy
  80091. * @param rescaleAsRequired defines if rescaling must be applied if required
  80092. * @returns true if operation was successful
  80093. */
  80094. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80095. /**
  80096. * Forces the skeleton to go to rest pose
  80097. */
  80098. returnToRest(): void;
  80099. private _getHighestAnimationFrame;
  80100. /**
  80101. * Begin a specific animation range
  80102. * @param name defines the name of the range to start
  80103. * @param loop defines if looping must be turned on (false by default)
  80104. * @param speedRatio defines the speed ratio to apply (1 by default)
  80105. * @param onAnimationEnd defines a callback which will be called when animation will end
  80106. * @returns a new animatable
  80107. */
  80108. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80109. /** @hidden */
  80110. _markAsDirty(): void;
  80111. /** @hidden */
  80112. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80113. /** @hidden */
  80114. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80115. private _computeTransformMatrices;
  80116. /**
  80117. * Build all resources required to render a skeleton
  80118. */
  80119. prepare(): void;
  80120. /**
  80121. * Gets the list of animatables currently running for this skeleton
  80122. * @returns an array of animatables
  80123. */
  80124. getAnimatables(): IAnimatable[];
  80125. /**
  80126. * Clone the current skeleton
  80127. * @param name defines the name of the new skeleton
  80128. * @param id defines the id of the new skeleton
  80129. * @returns the new skeleton
  80130. */
  80131. clone(name: string, id: string): Skeleton;
  80132. /**
  80133. * Enable animation blending for this skeleton
  80134. * @param blendingSpeed defines the blending speed to apply
  80135. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80136. */
  80137. enableBlending(blendingSpeed?: number): void;
  80138. /**
  80139. * Releases all resources associated with the current skeleton
  80140. */
  80141. dispose(): void;
  80142. /**
  80143. * Serialize the skeleton in a JSON object
  80144. * @returns a JSON object
  80145. */
  80146. serialize(): any;
  80147. /**
  80148. * Creates a new skeleton from serialized data
  80149. * @param parsedSkeleton defines the serialized data
  80150. * @param scene defines the hosting scene
  80151. * @returns a new skeleton
  80152. */
  80153. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80154. /**
  80155. * Compute all node absolute transforms
  80156. * @param forceUpdate defines if computation must be done even if cache is up to date
  80157. */
  80158. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80159. /**
  80160. * Gets the root pose matrix
  80161. * @returns a matrix
  80162. */
  80163. getPoseMatrix(): Nullable<Matrix>;
  80164. /**
  80165. * Sorts bones per internal index
  80166. */
  80167. sortBones(): void;
  80168. private _sortBones;
  80169. }
  80170. }
  80171. declare module BABYLON {
  80172. /**
  80173. * Class used to store bone information
  80174. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80175. */
  80176. export class Bone extends Node {
  80177. /**
  80178. * defines the bone name
  80179. */
  80180. name: string;
  80181. private static _tmpVecs;
  80182. private static _tmpQuat;
  80183. private static _tmpMats;
  80184. /**
  80185. * Gets the list of child bones
  80186. */
  80187. children: Bone[];
  80188. /** Gets the animations associated with this bone */
  80189. animations: Animation[];
  80190. /**
  80191. * Gets or sets bone length
  80192. */
  80193. length: number;
  80194. /**
  80195. * @hidden Internal only
  80196. * Set this value to map this bone to a different index in the transform matrices
  80197. * Set this value to -1 to exclude the bone from the transform matrices
  80198. */
  80199. _index: Nullable<number>;
  80200. private _skeleton;
  80201. private _localMatrix;
  80202. private _restPose;
  80203. private _baseMatrix;
  80204. private _absoluteTransform;
  80205. private _invertedAbsoluteTransform;
  80206. private _parent;
  80207. private _scalingDeterminant;
  80208. private _worldTransform;
  80209. private _localScaling;
  80210. private _localRotation;
  80211. private _localPosition;
  80212. private _needToDecompose;
  80213. private _needToCompose;
  80214. /** @hidden */
  80215. _linkedTransformNode: Nullable<TransformNode>;
  80216. /** @hidden */
  80217. _waitingTransformNodeId: Nullable<string>;
  80218. /** @hidden */
  80219. /** @hidden */
  80220. _matrix: Matrix;
  80221. /**
  80222. * Create a new bone
  80223. * @param name defines the bone name
  80224. * @param skeleton defines the parent skeleton
  80225. * @param parentBone defines the parent (can be null if the bone is the root)
  80226. * @param localMatrix defines the local matrix
  80227. * @param restPose defines the rest pose matrix
  80228. * @param baseMatrix defines the base matrix
  80229. * @param index defines index of the bone in the hiearchy
  80230. */
  80231. constructor(
  80232. /**
  80233. * defines the bone name
  80234. */
  80235. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80236. /**
  80237. * Gets the current object class name.
  80238. * @return the class name
  80239. */
  80240. getClassName(): string;
  80241. /**
  80242. * Gets the parent skeleton
  80243. * @returns a skeleton
  80244. */
  80245. getSkeleton(): Skeleton;
  80246. /**
  80247. * Gets parent bone
  80248. * @returns a bone or null if the bone is the root of the bone hierarchy
  80249. */
  80250. getParent(): Nullable<Bone>;
  80251. /**
  80252. * Returns an array containing the root bones
  80253. * @returns an array containing the root bones
  80254. */
  80255. getChildren(): Array<Bone>;
  80256. /**
  80257. * Sets the parent bone
  80258. * @param parent defines the parent (can be null if the bone is the root)
  80259. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80260. */
  80261. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80262. /**
  80263. * Gets the local matrix
  80264. * @returns a matrix
  80265. */
  80266. getLocalMatrix(): Matrix;
  80267. /**
  80268. * Gets the base matrix (initial matrix which remains unchanged)
  80269. * @returns a matrix
  80270. */
  80271. getBaseMatrix(): Matrix;
  80272. /**
  80273. * Gets the rest pose matrix
  80274. * @returns a matrix
  80275. */
  80276. getRestPose(): Matrix;
  80277. /**
  80278. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80279. */
  80280. getWorldMatrix(): Matrix;
  80281. /**
  80282. * Sets the local matrix to rest pose matrix
  80283. */
  80284. returnToRest(): void;
  80285. /**
  80286. * Gets the inverse of the absolute transform matrix.
  80287. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80288. * @returns a matrix
  80289. */
  80290. getInvertedAbsoluteTransform(): Matrix;
  80291. /**
  80292. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80293. * @returns a matrix
  80294. */
  80295. getAbsoluteTransform(): Matrix;
  80296. /**
  80297. * Links with the given transform node.
  80298. * The local matrix of this bone is copied from the transform node every frame.
  80299. * @param transformNode defines the transform node to link to
  80300. */
  80301. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80302. /**
  80303. * Gets the node used to drive the bone's transformation
  80304. * @returns a transform node or null
  80305. */
  80306. getTransformNode(): Nullable<TransformNode>;
  80307. /** Gets or sets current position (in local space) */
  80308. position: Vector3;
  80309. /** Gets or sets current rotation (in local space) */
  80310. rotation: Vector3;
  80311. /** Gets or sets current rotation quaternion (in local space) */
  80312. rotationQuaternion: Quaternion;
  80313. /** Gets or sets current scaling (in local space) */
  80314. scaling: Vector3;
  80315. /**
  80316. * Gets the animation properties override
  80317. */
  80318. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80319. private _decompose;
  80320. private _compose;
  80321. /**
  80322. * Update the base and local matrices
  80323. * @param matrix defines the new base or local matrix
  80324. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80325. * @param updateLocalMatrix defines if the local matrix should be updated
  80326. */
  80327. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80328. /** @hidden */
  80329. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80330. /**
  80331. * Flag the bone as dirty (Forcing it to update everything)
  80332. */
  80333. markAsDirty(): void;
  80334. /** @hidden */
  80335. _markAsDirtyAndCompose(): void;
  80336. private _markAsDirtyAndDecompose;
  80337. /**
  80338. * Translate the bone in local or world space
  80339. * @param vec The amount to translate the bone
  80340. * @param space The space that the translation is in
  80341. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80342. */
  80343. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80344. /**
  80345. * Set the postion of the bone in local or world space
  80346. * @param position The position to set the bone
  80347. * @param space The space that the position is in
  80348. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80349. */
  80350. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80351. /**
  80352. * Set the absolute position of the bone (world space)
  80353. * @param position The position to set the bone
  80354. * @param mesh The mesh that this bone is attached to
  80355. */
  80356. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80357. /**
  80358. * Scale the bone on the x, y and z axes (in local space)
  80359. * @param x The amount to scale the bone on the x axis
  80360. * @param y The amount to scale the bone on the y axis
  80361. * @param z The amount to scale the bone on the z axis
  80362. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80363. */
  80364. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80365. /**
  80366. * Set the bone scaling in local space
  80367. * @param scale defines the scaling vector
  80368. */
  80369. setScale(scale: Vector3): void;
  80370. /**
  80371. * Gets the current scaling in local space
  80372. * @returns the current scaling vector
  80373. */
  80374. getScale(): Vector3;
  80375. /**
  80376. * Gets the current scaling in local space and stores it in a target vector
  80377. * @param result defines the target vector
  80378. */
  80379. getScaleToRef(result: Vector3): void;
  80380. /**
  80381. * Set the yaw, pitch, and roll of the bone in local or world space
  80382. * @param yaw The rotation of the bone on the y axis
  80383. * @param pitch The rotation of the bone on the x axis
  80384. * @param roll The rotation of the bone on the z axis
  80385. * @param space The space that the axes of rotation are in
  80386. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80387. */
  80388. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80389. /**
  80390. * Add a rotation to the bone on an axis in local or world space
  80391. * @param axis The axis to rotate the bone on
  80392. * @param amount The amount to rotate the bone
  80393. * @param space The space that the axis is in
  80394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80395. */
  80396. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80397. /**
  80398. * Set the rotation of the bone to a particular axis angle in local or world space
  80399. * @param axis The axis to rotate the bone on
  80400. * @param angle The angle that the bone should be rotated to
  80401. * @param space The space that the axis is in
  80402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80403. */
  80404. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80405. /**
  80406. * Set the euler rotation of the bone in local of world space
  80407. * @param rotation The euler rotation that the bone should be set to
  80408. * @param space The space that the rotation is in
  80409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80410. */
  80411. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80412. /**
  80413. * Set the quaternion rotation of the bone in local of world space
  80414. * @param quat The quaternion rotation that the bone should be set to
  80415. * @param space The space that the rotation is in
  80416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80417. */
  80418. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80419. /**
  80420. * Set the rotation matrix of the bone in local of world space
  80421. * @param rotMat The rotation matrix that the bone should be set to
  80422. * @param space The space that the rotation is in
  80423. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80424. */
  80425. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80426. private _rotateWithMatrix;
  80427. private _getNegativeRotationToRef;
  80428. /**
  80429. * Get the position of the bone in local or world space
  80430. * @param space The space that the returned position is in
  80431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80432. * @returns The position of the bone
  80433. */
  80434. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80435. /**
  80436. * Copy the position of the bone to a vector3 in local or world space
  80437. * @param space The space that the returned position is in
  80438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80439. * @param result The vector3 to copy the position to
  80440. */
  80441. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80442. /**
  80443. * Get the absolute position of the bone (world space)
  80444. * @param mesh The mesh that this bone is attached to
  80445. * @returns The absolute position of the bone
  80446. */
  80447. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80448. /**
  80449. * Copy the absolute position of the bone (world space) to the result param
  80450. * @param mesh The mesh that this bone is attached to
  80451. * @param result The vector3 to copy the absolute position to
  80452. */
  80453. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80454. /**
  80455. * Compute the absolute transforms of this bone and its children
  80456. */
  80457. computeAbsoluteTransforms(): void;
  80458. /**
  80459. * Get the world direction from an axis that is in the local space of the bone
  80460. * @param localAxis The local direction that is used to compute the world direction
  80461. * @param mesh The mesh that this bone is attached to
  80462. * @returns The world direction
  80463. */
  80464. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80465. /**
  80466. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80467. * @param localAxis The local direction that is used to compute the world direction
  80468. * @param mesh The mesh that this bone is attached to
  80469. * @param result The vector3 that the world direction will be copied to
  80470. */
  80471. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80472. /**
  80473. * Get the euler rotation of the bone in local or world space
  80474. * @param space The space that the rotation should be in
  80475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80476. * @returns The euler rotation
  80477. */
  80478. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80479. /**
  80480. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80481. * @param space The space that the rotation should be in
  80482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80483. * @param result The vector3 that the rotation should be copied to
  80484. */
  80485. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80486. /**
  80487. * Get the quaternion rotation of the bone in either local or world space
  80488. * @param space The space that the rotation should be in
  80489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80490. * @returns The quaternion rotation
  80491. */
  80492. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80493. /**
  80494. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80495. * @param space The space that the rotation should be in
  80496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80497. * @param result The quaternion that the rotation should be copied to
  80498. */
  80499. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80500. /**
  80501. * Get the rotation matrix of the bone in local or world space
  80502. * @param space The space that the rotation should be in
  80503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80504. * @returns The rotation matrix
  80505. */
  80506. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80507. /**
  80508. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80509. * @param space The space that the rotation should be in
  80510. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80511. * @param result The quaternion that the rotation should be copied to
  80512. */
  80513. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80514. /**
  80515. * Get the world position of a point that is in the local space of the bone
  80516. * @param position The local position
  80517. * @param mesh The mesh that this bone is attached to
  80518. * @returns The world position
  80519. */
  80520. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80521. /**
  80522. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80523. * @param position The local position
  80524. * @param mesh The mesh that this bone is attached to
  80525. * @param result The vector3 that the world position should be copied to
  80526. */
  80527. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80528. /**
  80529. * Get the local position of a point that is in world space
  80530. * @param position The world position
  80531. * @param mesh The mesh that this bone is attached to
  80532. * @returns The local position
  80533. */
  80534. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80535. /**
  80536. * Get the local position of a point that is in world space and copy it to the result param
  80537. * @param position The world position
  80538. * @param mesh The mesh that this bone is attached to
  80539. * @param result The vector3 that the local position should be copied to
  80540. */
  80541. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80542. }
  80543. }
  80544. declare module BABYLON {
  80545. /**
  80546. * 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.
  80547. * @see https://doc.babylonjs.com/how_to/transformnode
  80548. */
  80549. export class TransformNode extends Node {
  80550. /**
  80551. * Object will not rotate to face the camera
  80552. */
  80553. static BILLBOARDMODE_NONE: number;
  80554. /**
  80555. * Object will rotate to face the camera but only on the x axis
  80556. */
  80557. static BILLBOARDMODE_X: number;
  80558. /**
  80559. * Object will rotate to face the camera but only on the y axis
  80560. */
  80561. static BILLBOARDMODE_Y: number;
  80562. /**
  80563. * Object will rotate to face the camera but only on the z axis
  80564. */
  80565. static BILLBOARDMODE_Z: number;
  80566. /**
  80567. * Object will rotate to face the camera
  80568. */
  80569. static BILLBOARDMODE_ALL: number;
  80570. /**
  80571. * Object will rotate to face the camera's position instead of orientation
  80572. */
  80573. static BILLBOARDMODE_USE_POSITION: number;
  80574. private _forward;
  80575. private _forwardInverted;
  80576. private _up;
  80577. private _right;
  80578. private _rightInverted;
  80579. private _position;
  80580. private _rotation;
  80581. private _rotationQuaternion;
  80582. protected _scaling: Vector3;
  80583. protected _isDirty: boolean;
  80584. private _transformToBoneReferal;
  80585. private _isAbsoluteSynced;
  80586. private _billboardMode;
  80587. /**
  80588. * Gets or sets the billboard mode. Default is 0.
  80589. *
  80590. * | Value | Type | Description |
  80591. * | --- | --- | --- |
  80592. * | 0 | BILLBOARDMODE_NONE | |
  80593. * | 1 | BILLBOARDMODE_X | |
  80594. * | 2 | BILLBOARDMODE_Y | |
  80595. * | 4 | BILLBOARDMODE_Z | |
  80596. * | 7 | BILLBOARDMODE_ALL | |
  80597. *
  80598. */
  80599. billboardMode: number;
  80600. private _preserveParentRotationForBillboard;
  80601. /**
  80602. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80603. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80604. */
  80605. preserveParentRotationForBillboard: boolean;
  80606. /**
  80607. * 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
  80608. */
  80609. scalingDeterminant: number;
  80610. private _infiniteDistance;
  80611. /**
  80612. * Gets or sets the distance of the object to max, often used by skybox
  80613. */
  80614. infiniteDistance: boolean;
  80615. /**
  80616. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80617. * By default the system will update normals to compensate
  80618. */
  80619. ignoreNonUniformScaling: boolean;
  80620. /**
  80621. * 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
  80622. */
  80623. reIntegrateRotationIntoRotationQuaternion: boolean;
  80624. /** @hidden */
  80625. _poseMatrix: Nullable<Matrix>;
  80626. /** @hidden */
  80627. _localMatrix: Matrix;
  80628. private _usePivotMatrix;
  80629. private _absolutePosition;
  80630. private _absoluteScaling;
  80631. private _absoluteRotationQuaternion;
  80632. private _pivotMatrix;
  80633. private _pivotMatrixInverse;
  80634. protected _postMultiplyPivotMatrix: boolean;
  80635. protected _isWorldMatrixFrozen: boolean;
  80636. /** @hidden */
  80637. _indexInSceneTransformNodesArray: number;
  80638. /**
  80639. * An event triggered after the world matrix is updated
  80640. */
  80641. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80642. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80643. /**
  80644. * Gets a string identifying the name of the class
  80645. * @returns "TransformNode" string
  80646. */
  80647. getClassName(): string;
  80648. /**
  80649. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80650. */
  80651. position: Vector3;
  80652. /**
  80653. * 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)).
  80654. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80655. */
  80656. rotation: Vector3;
  80657. /**
  80658. * 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)).
  80659. */
  80660. scaling: Vector3;
  80661. /**
  80662. * 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).
  80663. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80664. */
  80665. rotationQuaternion: Nullable<Quaternion>;
  80666. /**
  80667. * The forward direction of that transform in world space.
  80668. */
  80669. readonly forward: Vector3;
  80670. /**
  80671. * The up direction of that transform in world space.
  80672. */
  80673. readonly up: Vector3;
  80674. /**
  80675. * The right direction of that transform in world space.
  80676. */
  80677. readonly right: Vector3;
  80678. /**
  80679. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80680. * @param matrix the matrix to copy the pose from
  80681. * @returns this TransformNode.
  80682. */
  80683. updatePoseMatrix(matrix: Matrix): TransformNode;
  80684. /**
  80685. * Returns the mesh Pose matrix.
  80686. * @returns the pose matrix
  80687. */
  80688. getPoseMatrix(): Matrix;
  80689. /** @hidden */
  80690. _isSynchronized(): boolean;
  80691. /** @hidden */
  80692. _initCache(): void;
  80693. /**
  80694. * Flag the transform node as dirty (Forcing it to update everything)
  80695. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80696. * @returns this transform node
  80697. */
  80698. markAsDirty(property: string): TransformNode;
  80699. /**
  80700. * Returns the current mesh absolute position.
  80701. * Returns a Vector3.
  80702. */
  80703. readonly absolutePosition: Vector3;
  80704. /**
  80705. * Returns the current mesh absolute scaling.
  80706. * Returns a Vector3.
  80707. */
  80708. readonly absoluteScaling: Vector3;
  80709. /**
  80710. * Returns the current mesh absolute rotation.
  80711. * Returns a Quaternion.
  80712. */
  80713. readonly absoluteRotationQuaternion: Quaternion;
  80714. /**
  80715. * Sets a new matrix to apply before all other transformation
  80716. * @param matrix defines the transform matrix
  80717. * @returns the current TransformNode
  80718. */
  80719. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80720. /**
  80721. * Sets a new pivot matrix to the current node
  80722. * @param matrix defines the new pivot matrix to use
  80723. * @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
  80724. * @returns the current TransformNode
  80725. */
  80726. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80727. /**
  80728. * Returns the mesh pivot matrix.
  80729. * Default : Identity.
  80730. * @returns the matrix
  80731. */
  80732. getPivotMatrix(): Matrix;
  80733. /**
  80734. * Instantiate (when possible) or clone that node with its hierarchy
  80735. * @param newParent defines the new parent to use for the instance (or clone)
  80736. * @returns an instance (or a clone) of the current node with its hiearchy
  80737. */
  80738. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80739. /**
  80740. * Prevents the World matrix to be computed any longer
  80741. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80742. * @returns the TransformNode.
  80743. */
  80744. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80745. /**
  80746. * Allows back the World matrix computation.
  80747. * @returns the TransformNode.
  80748. */
  80749. unfreezeWorldMatrix(): this;
  80750. /**
  80751. * True if the World matrix has been frozen.
  80752. */
  80753. readonly isWorldMatrixFrozen: boolean;
  80754. /**
  80755. * Retuns the mesh absolute position in the World.
  80756. * @returns a Vector3.
  80757. */
  80758. getAbsolutePosition(): Vector3;
  80759. /**
  80760. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80761. * @param absolutePosition the absolute position to set
  80762. * @returns the TransformNode.
  80763. */
  80764. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80765. /**
  80766. * Sets the mesh position in its local space.
  80767. * @param vector3 the position to set in localspace
  80768. * @returns the TransformNode.
  80769. */
  80770. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80771. /**
  80772. * Returns the mesh position in the local space from the current World matrix values.
  80773. * @returns a new Vector3.
  80774. */
  80775. getPositionExpressedInLocalSpace(): Vector3;
  80776. /**
  80777. * Translates the mesh along the passed Vector3 in its local space.
  80778. * @param vector3 the distance to translate in localspace
  80779. * @returns the TransformNode.
  80780. */
  80781. locallyTranslate(vector3: Vector3): TransformNode;
  80782. private static _lookAtVectorCache;
  80783. /**
  80784. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80785. * @param targetPoint the position (must be in same space as current mesh) to look at
  80786. * @param yawCor optional yaw (y-axis) correction in radians
  80787. * @param pitchCor optional pitch (x-axis) correction in radians
  80788. * @param rollCor optional roll (z-axis) correction in radians
  80789. * @param space the choosen space of the target
  80790. * @returns the TransformNode.
  80791. */
  80792. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80793. /**
  80794. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80795. * This Vector3 is expressed in the World space.
  80796. * @param localAxis axis to rotate
  80797. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80798. */
  80799. getDirection(localAxis: Vector3): Vector3;
  80800. /**
  80801. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80802. * localAxis is expressed in the mesh local space.
  80803. * result is computed in the Wordl space from the mesh World matrix.
  80804. * @param localAxis axis to rotate
  80805. * @param result the resulting transformnode
  80806. * @returns this TransformNode.
  80807. */
  80808. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80809. /**
  80810. * Sets this transform node rotation to the given local axis.
  80811. * @param localAxis the axis in local space
  80812. * @param yawCor optional yaw (y-axis) correction in radians
  80813. * @param pitchCor optional pitch (x-axis) correction in radians
  80814. * @param rollCor optional roll (z-axis) correction in radians
  80815. * @returns this TransformNode
  80816. */
  80817. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80818. /**
  80819. * Sets a new pivot point to the current node
  80820. * @param point defines the new pivot point to use
  80821. * @param space defines if the point is in world or local space (local by default)
  80822. * @returns the current TransformNode
  80823. */
  80824. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80825. /**
  80826. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80827. * @returns the pivot point
  80828. */
  80829. getPivotPoint(): Vector3;
  80830. /**
  80831. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80832. * @param result the vector3 to store the result
  80833. * @returns this TransformNode.
  80834. */
  80835. getPivotPointToRef(result: Vector3): TransformNode;
  80836. /**
  80837. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80838. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80839. */
  80840. getAbsolutePivotPoint(): Vector3;
  80841. /**
  80842. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80843. * @param result vector3 to store the result
  80844. * @returns this TransformNode.
  80845. */
  80846. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80847. /**
  80848. * Defines the passed node as the parent of the current node.
  80849. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80850. * @see https://doc.babylonjs.com/how_to/parenting
  80851. * @param node the node ot set as the parent
  80852. * @returns this TransformNode.
  80853. */
  80854. setParent(node: Nullable<Node>): TransformNode;
  80855. private _nonUniformScaling;
  80856. /**
  80857. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80858. */
  80859. readonly nonUniformScaling: boolean;
  80860. /** @hidden */
  80861. _updateNonUniformScalingState(value: boolean): boolean;
  80862. /**
  80863. * Attach the current TransformNode to another TransformNode associated with a bone
  80864. * @param bone Bone affecting the TransformNode
  80865. * @param affectedTransformNode TransformNode associated with the bone
  80866. * @returns this object
  80867. */
  80868. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80869. /**
  80870. * Detach the transform node if its associated with a bone
  80871. * @returns this object
  80872. */
  80873. detachFromBone(): TransformNode;
  80874. private static _rotationAxisCache;
  80875. /**
  80876. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80877. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80878. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80879. * The passed axis is also normalized.
  80880. * @param axis the axis to rotate around
  80881. * @param amount the amount to rotate in radians
  80882. * @param space Space to rotate in (Default: local)
  80883. * @returns the TransformNode.
  80884. */
  80885. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80886. /**
  80887. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80888. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80889. * The passed axis is also normalized. .
  80890. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80891. * @param point the point to rotate around
  80892. * @param axis the axis to rotate around
  80893. * @param amount the amount to rotate in radians
  80894. * @returns the TransformNode
  80895. */
  80896. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80897. /**
  80898. * Translates the mesh along the axis vector for the passed distance in the given space.
  80899. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80900. * @param axis the axis to translate in
  80901. * @param distance the distance to translate
  80902. * @param space Space to rotate in (Default: local)
  80903. * @returns the TransformNode.
  80904. */
  80905. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80906. /**
  80907. * Adds a rotation step to the mesh current rotation.
  80908. * x, y, z are Euler angles expressed in radians.
  80909. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80910. * This means this rotation is made in the mesh local space only.
  80911. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80912. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80913. * ```javascript
  80914. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80915. * ```
  80916. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80917. * 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.
  80918. * @param x Rotation to add
  80919. * @param y Rotation to add
  80920. * @param z Rotation to add
  80921. * @returns the TransformNode.
  80922. */
  80923. addRotation(x: number, y: number, z: number): TransformNode;
  80924. /**
  80925. * @hidden
  80926. */
  80927. protected _getEffectiveParent(): Nullable<Node>;
  80928. /**
  80929. * Computes the world matrix of the node
  80930. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80931. * @returns the world matrix
  80932. */
  80933. computeWorldMatrix(force?: boolean): Matrix;
  80934. protected _afterComputeWorldMatrix(): void;
  80935. /**
  80936. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80937. * @param func callback function to add
  80938. *
  80939. * @returns the TransformNode.
  80940. */
  80941. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80942. /**
  80943. * Removes a registered callback function.
  80944. * @param func callback function to remove
  80945. * @returns the TransformNode.
  80946. */
  80947. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80948. /**
  80949. * Gets the position of the current mesh in camera space
  80950. * @param camera defines the camera to use
  80951. * @returns a position
  80952. */
  80953. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80954. /**
  80955. * Returns the distance from the mesh to the active camera
  80956. * @param camera defines the camera to use
  80957. * @returns the distance
  80958. */
  80959. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80960. /**
  80961. * Clone the current transform node
  80962. * @param name Name of the new clone
  80963. * @param newParent New parent for the clone
  80964. * @param doNotCloneChildren Do not clone children hierarchy
  80965. * @returns the new transform node
  80966. */
  80967. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80968. /**
  80969. * Serializes the objects information.
  80970. * @param currentSerializationObject defines the object to serialize in
  80971. * @returns the serialized object
  80972. */
  80973. serialize(currentSerializationObject?: any): any;
  80974. /**
  80975. * Returns a new TransformNode object parsed from the source provided.
  80976. * @param parsedTransformNode is the source.
  80977. * @param scene the scne the object belongs to
  80978. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80979. * @returns a new TransformNode object parsed from the source provided.
  80980. */
  80981. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80982. /**
  80983. * Get all child-transformNodes of this node
  80984. * @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
  80985. * @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
  80986. * @returns an array of TransformNode
  80987. */
  80988. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80989. /**
  80990. * Releases resources associated with this transform node.
  80991. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80992. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80993. */
  80994. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80995. /**
  80996. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80997. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80998. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80999. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81000. * @returns the current mesh
  81001. */
  81002. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81003. private _syncAbsoluteScalingAndRotation;
  81004. }
  81005. }
  81006. declare module BABYLON {
  81007. /**
  81008. * Defines the types of pose enabled controllers that are supported
  81009. */
  81010. export enum PoseEnabledControllerType {
  81011. /**
  81012. * HTC Vive
  81013. */
  81014. VIVE = 0,
  81015. /**
  81016. * Oculus Rift
  81017. */
  81018. OCULUS = 1,
  81019. /**
  81020. * Windows mixed reality
  81021. */
  81022. WINDOWS = 2,
  81023. /**
  81024. * Samsung gear VR
  81025. */
  81026. GEAR_VR = 3,
  81027. /**
  81028. * Google Daydream
  81029. */
  81030. DAYDREAM = 4,
  81031. /**
  81032. * Generic
  81033. */
  81034. GENERIC = 5
  81035. }
  81036. /**
  81037. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81038. */
  81039. export interface MutableGamepadButton {
  81040. /**
  81041. * Value of the button/trigger
  81042. */
  81043. value: number;
  81044. /**
  81045. * If the button/trigger is currently touched
  81046. */
  81047. touched: boolean;
  81048. /**
  81049. * If the button/trigger is currently pressed
  81050. */
  81051. pressed: boolean;
  81052. }
  81053. /**
  81054. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81055. * @hidden
  81056. */
  81057. export interface ExtendedGamepadButton extends GamepadButton {
  81058. /**
  81059. * If the button/trigger is currently pressed
  81060. */
  81061. readonly pressed: boolean;
  81062. /**
  81063. * If the button/trigger is currently touched
  81064. */
  81065. readonly touched: boolean;
  81066. /**
  81067. * Value of the button/trigger
  81068. */
  81069. readonly value: number;
  81070. }
  81071. /** @hidden */
  81072. export interface _GamePadFactory {
  81073. /**
  81074. * Returns wether or not the current gamepad can be created for this type of controller.
  81075. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81076. * @returns true if it can be created, otherwise false
  81077. */
  81078. canCreate(gamepadInfo: any): boolean;
  81079. /**
  81080. * Creates a new instance of the Gamepad.
  81081. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81082. * @returns the new gamepad instance
  81083. */
  81084. create(gamepadInfo: any): Gamepad;
  81085. }
  81086. /**
  81087. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81088. */
  81089. export class PoseEnabledControllerHelper {
  81090. /** @hidden */
  81091. static _ControllerFactories: _GamePadFactory[];
  81092. /** @hidden */
  81093. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81094. /**
  81095. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81096. * @param vrGamepad the gamepad to initialized
  81097. * @returns a vr controller of the type the gamepad identified as
  81098. */
  81099. static InitiateController(vrGamepad: any): Gamepad;
  81100. }
  81101. /**
  81102. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81103. */
  81104. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81105. /**
  81106. * If the controller is used in a webXR session
  81107. */
  81108. isXR: boolean;
  81109. private _deviceRoomPosition;
  81110. private _deviceRoomRotationQuaternion;
  81111. /**
  81112. * The device position in babylon space
  81113. */
  81114. devicePosition: Vector3;
  81115. /**
  81116. * The device rotation in babylon space
  81117. */
  81118. deviceRotationQuaternion: Quaternion;
  81119. /**
  81120. * The scale factor of the device in babylon space
  81121. */
  81122. deviceScaleFactor: number;
  81123. /**
  81124. * (Likely devicePosition should be used instead) The device position in its room space
  81125. */
  81126. position: Vector3;
  81127. /**
  81128. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81129. */
  81130. rotationQuaternion: Quaternion;
  81131. /**
  81132. * The type of controller (Eg. Windows mixed reality)
  81133. */
  81134. controllerType: PoseEnabledControllerType;
  81135. protected _calculatedPosition: Vector3;
  81136. private _calculatedRotation;
  81137. /**
  81138. * The raw pose from the device
  81139. */
  81140. rawPose: DevicePose;
  81141. private _trackPosition;
  81142. private _maxRotationDistFromHeadset;
  81143. private _draggedRoomRotation;
  81144. /**
  81145. * @hidden
  81146. */
  81147. _disableTrackPosition(fixedPosition: Vector3): void;
  81148. /**
  81149. * Internal, the mesh attached to the controller
  81150. * @hidden
  81151. */
  81152. _mesh: Nullable<AbstractMesh>;
  81153. private _poseControlledCamera;
  81154. private _leftHandSystemQuaternion;
  81155. /**
  81156. * Internal, matrix used to convert room space to babylon space
  81157. * @hidden
  81158. */
  81159. _deviceToWorld: Matrix;
  81160. /**
  81161. * Node to be used when casting a ray from the controller
  81162. * @hidden
  81163. */
  81164. _pointingPoseNode: Nullable<TransformNode>;
  81165. /**
  81166. * Name of the child mesh that can be used to cast a ray from the controller
  81167. */
  81168. static readonly POINTING_POSE: string;
  81169. /**
  81170. * Creates a new PoseEnabledController from a gamepad
  81171. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81172. */
  81173. constructor(browserGamepad: any);
  81174. private _workingMatrix;
  81175. /**
  81176. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81177. */
  81178. update(): void;
  81179. /**
  81180. * Updates only the pose device and mesh without doing any button event checking
  81181. */
  81182. protected _updatePoseAndMesh(): void;
  81183. /**
  81184. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81185. * @param poseData raw pose fromthe device
  81186. */
  81187. updateFromDevice(poseData: DevicePose): void;
  81188. /**
  81189. * @hidden
  81190. */
  81191. _meshAttachedObservable: Observable<AbstractMesh>;
  81192. /**
  81193. * Attaches a mesh to the controller
  81194. * @param mesh the mesh to be attached
  81195. */
  81196. attachToMesh(mesh: AbstractMesh): void;
  81197. /**
  81198. * Attaches the controllers mesh to a camera
  81199. * @param camera the camera the mesh should be attached to
  81200. */
  81201. attachToPoseControlledCamera(camera: TargetCamera): void;
  81202. /**
  81203. * Disposes of the controller
  81204. */
  81205. dispose(): void;
  81206. /**
  81207. * The mesh that is attached to the controller
  81208. */
  81209. readonly mesh: Nullable<AbstractMesh>;
  81210. /**
  81211. * Gets the ray of the controller in the direction the controller is pointing
  81212. * @param length the length the resulting ray should be
  81213. * @returns a ray in the direction the controller is pointing
  81214. */
  81215. getForwardRay(length?: number): Ray;
  81216. }
  81217. }
  81218. declare module BABYLON {
  81219. /**
  81220. * Defines the WebVRController object that represents controllers tracked in 3D space
  81221. */
  81222. export abstract class WebVRController extends PoseEnabledController {
  81223. /**
  81224. * Internal, the default controller model for the controller
  81225. */
  81226. protected _defaultModel: Nullable<AbstractMesh>;
  81227. /**
  81228. * Fired when the trigger state has changed
  81229. */
  81230. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81231. /**
  81232. * Fired when the main button state has changed
  81233. */
  81234. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81235. /**
  81236. * Fired when the secondary button state has changed
  81237. */
  81238. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81239. /**
  81240. * Fired when the pad state has changed
  81241. */
  81242. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81243. /**
  81244. * Fired when controllers stick values have changed
  81245. */
  81246. onPadValuesChangedObservable: Observable<StickValues>;
  81247. /**
  81248. * Array of button availible on the controller
  81249. */
  81250. protected _buttons: Array<MutableGamepadButton>;
  81251. private _onButtonStateChange;
  81252. /**
  81253. * Fired when a controller button's state has changed
  81254. * @param callback the callback containing the button that was modified
  81255. */
  81256. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81257. /**
  81258. * X and Y axis corresponding to the controllers joystick
  81259. */
  81260. pad: StickValues;
  81261. /**
  81262. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81263. */
  81264. hand: string;
  81265. /**
  81266. * The default controller model for the controller
  81267. */
  81268. readonly defaultModel: Nullable<AbstractMesh>;
  81269. /**
  81270. * Creates a new WebVRController from a gamepad
  81271. * @param vrGamepad the gamepad that the WebVRController should be created from
  81272. */
  81273. constructor(vrGamepad: any);
  81274. /**
  81275. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81276. */
  81277. update(): void;
  81278. /**
  81279. * Function to be called when a button is modified
  81280. */
  81281. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81282. /**
  81283. * Loads a mesh and attaches it to the controller
  81284. * @param scene the scene the mesh should be added to
  81285. * @param meshLoaded callback for when the mesh has been loaded
  81286. */
  81287. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81288. private _setButtonValue;
  81289. private _changes;
  81290. private _checkChanges;
  81291. /**
  81292. * Disposes of th webVRCOntroller
  81293. */
  81294. dispose(): void;
  81295. }
  81296. }
  81297. declare module BABYLON {
  81298. /**
  81299. * The HemisphericLight simulates the ambient environment light,
  81300. * so the passed direction is the light reflection direction, not the incoming direction.
  81301. */
  81302. export class HemisphericLight extends Light {
  81303. /**
  81304. * The groundColor is the light in the opposite direction to the one specified during creation.
  81305. * 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.
  81306. */
  81307. groundColor: Color3;
  81308. /**
  81309. * The light reflection direction, not the incoming direction.
  81310. */
  81311. direction: Vector3;
  81312. /**
  81313. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81314. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81315. * The HemisphericLight can't cast shadows.
  81316. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81317. * @param name The friendly name of the light
  81318. * @param direction The direction of the light reflection
  81319. * @param scene The scene the light belongs to
  81320. */
  81321. constructor(name: string, direction: Vector3, scene: Scene);
  81322. protected _buildUniformLayout(): void;
  81323. /**
  81324. * Returns the string "HemisphericLight".
  81325. * @return The class name
  81326. */
  81327. getClassName(): string;
  81328. /**
  81329. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81330. * Returns the updated direction.
  81331. * @param target The target the direction should point to
  81332. * @return The computed direction
  81333. */
  81334. setDirectionToTarget(target: Vector3): Vector3;
  81335. /**
  81336. * Returns the shadow generator associated to the light.
  81337. * @returns Always null for hemispheric lights because it does not support shadows.
  81338. */
  81339. getShadowGenerator(): Nullable<IShadowGenerator>;
  81340. /**
  81341. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81342. * @param effect The effect to update
  81343. * @param lightIndex The index of the light in the effect to update
  81344. * @returns The hemispheric light
  81345. */
  81346. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81347. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81348. /**
  81349. * Computes the world matrix of the node
  81350. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81351. * @param useWasUpdatedFlag defines a reserved property
  81352. * @returns the world matrix
  81353. */
  81354. computeWorldMatrix(): Matrix;
  81355. /**
  81356. * Returns the integer 3.
  81357. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81358. */
  81359. getTypeID(): number;
  81360. /**
  81361. * Prepares the list of defines specific to the light type.
  81362. * @param defines the list of defines
  81363. * @param lightIndex defines the index of the light for the effect
  81364. */
  81365. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81366. }
  81367. }
  81368. declare module BABYLON {
  81369. /** @hidden */
  81370. export var vrMultiviewToSingleviewPixelShader: {
  81371. name: string;
  81372. shader: string;
  81373. };
  81374. }
  81375. declare module BABYLON {
  81376. /**
  81377. * Renders to multiple views with a single draw call
  81378. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81379. */
  81380. export class MultiviewRenderTarget extends RenderTargetTexture {
  81381. /**
  81382. * Creates a multiview render target
  81383. * @param scene scene used with the render target
  81384. * @param size the size of the render target (used for each view)
  81385. */
  81386. constructor(scene: Scene, size?: number | {
  81387. width: number;
  81388. height: number;
  81389. } | {
  81390. ratio: number;
  81391. });
  81392. /**
  81393. * @hidden
  81394. * @param faceIndex the face index, if its a cube texture
  81395. */
  81396. _bindFrameBuffer(faceIndex?: number): void;
  81397. /**
  81398. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81399. * @returns the view count
  81400. */
  81401. getViewCount(): number;
  81402. }
  81403. }
  81404. declare module BABYLON {
  81405. /**
  81406. * Represents a camera frustum
  81407. */
  81408. export class Frustum {
  81409. /**
  81410. * Gets the planes representing the frustum
  81411. * @param transform matrix to be applied to the returned planes
  81412. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81413. */
  81414. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81415. /**
  81416. * Gets the near frustum plane transformed by the transform matrix
  81417. * @param transform transformation matrix to be applied to the resulting frustum plane
  81418. * @param frustumPlane the resuling frustum plane
  81419. */
  81420. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81421. /**
  81422. * Gets the far frustum plane transformed by the transform matrix
  81423. * @param transform transformation matrix to be applied to the resulting frustum plane
  81424. * @param frustumPlane the resuling frustum plane
  81425. */
  81426. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81427. /**
  81428. * Gets the left frustum plane transformed by the transform matrix
  81429. * @param transform transformation matrix to be applied to the resulting frustum plane
  81430. * @param frustumPlane the resuling frustum plane
  81431. */
  81432. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81433. /**
  81434. * Gets the right frustum plane transformed by the transform matrix
  81435. * @param transform transformation matrix to be applied to the resulting frustum plane
  81436. * @param frustumPlane the resuling frustum plane
  81437. */
  81438. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81439. /**
  81440. * Gets the top frustum plane transformed by the transform matrix
  81441. * @param transform transformation matrix to be applied to the resulting frustum plane
  81442. * @param frustumPlane the resuling frustum plane
  81443. */
  81444. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81445. /**
  81446. * Gets the bottom frustum plane transformed by the transform matrix
  81447. * @param transform transformation matrix to be applied to the resulting frustum plane
  81448. * @param frustumPlane the resuling frustum plane
  81449. */
  81450. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81451. /**
  81452. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81453. * @param transform transformation matrix to be applied to the resulting frustum planes
  81454. * @param frustumPlanes the resuling frustum planes
  81455. */
  81456. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81457. }
  81458. }
  81459. declare module BABYLON {
  81460. interface Engine {
  81461. /**
  81462. * Creates a new multiview render target
  81463. * @param width defines the width of the texture
  81464. * @param height defines the height of the texture
  81465. * @returns the created multiview texture
  81466. */
  81467. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81468. /**
  81469. * Binds a multiview framebuffer to be drawn to
  81470. * @param multiviewTexture texture to bind
  81471. */
  81472. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81473. }
  81474. interface Camera {
  81475. /**
  81476. * @hidden
  81477. * 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)
  81478. */
  81479. _useMultiviewToSingleView: boolean;
  81480. /**
  81481. * @hidden
  81482. * 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)
  81483. */
  81484. _multiviewTexture: Nullable<RenderTargetTexture>;
  81485. /**
  81486. * @hidden
  81487. * ensures the multiview texture of the camera exists and has the specified width/height
  81488. * @param width height to set on the multiview texture
  81489. * @param height width to set on the multiview texture
  81490. */
  81491. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81492. }
  81493. interface Scene {
  81494. /** @hidden */
  81495. _transformMatrixR: Matrix;
  81496. /** @hidden */
  81497. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81498. /** @hidden */
  81499. _createMultiviewUbo(): void;
  81500. /** @hidden */
  81501. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81502. /** @hidden */
  81503. _renderMultiviewToSingleView(camera: Camera): void;
  81504. }
  81505. }
  81506. declare module BABYLON {
  81507. /**
  81508. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81509. * This will not be used for webXR as it supports displaying texture arrays directly
  81510. */
  81511. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81512. /**
  81513. * Initializes a VRMultiviewToSingleview
  81514. * @param name name of the post process
  81515. * @param camera camera to be applied to
  81516. * @param scaleFactor scaling factor to the size of the output texture
  81517. */
  81518. constructor(name: string, camera: Camera, scaleFactor: number);
  81519. }
  81520. }
  81521. declare module BABYLON {
  81522. interface Engine {
  81523. /** @hidden */
  81524. _vrDisplay: any;
  81525. /** @hidden */
  81526. _vrSupported: boolean;
  81527. /** @hidden */
  81528. _oldSize: Size;
  81529. /** @hidden */
  81530. _oldHardwareScaleFactor: number;
  81531. /** @hidden */
  81532. _vrExclusivePointerMode: boolean;
  81533. /** @hidden */
  81534. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81535. /** @hidden */
  81536. _onVRDisplayPointerRestricted: () => void;
  81537. /** @hidden */
  81538. _onVRDisplayPointerUnrestricted: () => void;
  81539. /** @hidden */
  81540. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81541. /** @hidden */
  81542. _onVrDisplayDisconnect: Nullable<() => void>;
  81543. /** @hidden */
  81544. _onVrDisplayPresentChange: Nullable<() => void>;
  81545. /**
  81546. * Observable signaled when VR display mode changes
  81547. */
  81548. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81549. /**
  81550. * Observable signaled when VR request present is complete
  81551. */
  81552. onVRRequestPresentComplete: Observable<boolean>;
  81553. /**
  81554. * Observable signaled when VR request present starts
  81555. */
  81556. onVRRequestPresentStart: Observable<Engine>;
  81557. /**
  81558. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81559. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81560. */
  81561. isInVRExclusivePointerMode: boolean;
  81562. /**
  81563. * Gets a boolean indicating if a webVR device was detected
  81564. * @returns true if a webVR device was detected
  81565. */
  81566. isVRDevicePresent(): boolean;
  81567. /**
  81568. * Gets the current webVR device
  81569. * @returns the current webVR device (or null)
  81570. */
  81571. getVRDevice(): any;
  81572. /**
  81573. * Initializes a webVR display and starts listening to display change events
  81574. * The onVRDisplayChangedObservable will be notified upon these changes
  81575. * @returns A promise containing a VRDisplay and if vr is supported
  81576. */
  81577. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81578. /** @hidden */
  81579. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81580. /**
  81581. * Call this function to switch to webVR mode
  81582. * Will do nothing if webVR is not supported or if there is no webVR device
  81583. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81584. */
  81585. enableVR(): void;
  81586. /** @hidden */
  81587. _onVRFullScreenTriggered(): void;
  81588. }
  81589. }
  81590. declare module BABYLON {
  81591. /**
  81592. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81593. * IMPORTANT!! The data is right-hand data.
  81594. * @export
  81595. * @interface DevicePose
  81596. */
  81597. export interface DevicePose {
  81598. /**
  81599. * The position of the device, values in array are [x,y,z].
  81600. */
  81601. readonly position: Nullable<Float32Array>;
  81602. /**
  81603. * The linearVelocity of the device, values in array are [x,y,z].
  81604. */
  81605. readonly linearVelocity: Nullable<Float32Array>;
  81606. /**
  81607. * The linearAcceleration of the device, values in array are [x,y,z].
  81608. */
  81609. readonly linearAcceleration: Nullable<Float32Array>;
  81610. /**
  81611. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81612. */
  81613. readonly orientation: Nullable<Float32Array>;
  81614. /**
  81615. * The angularVelocity of the device, values in array are [x,y,z].
  81616. */
  81617. readonly angularVelocity: Nullable<Float32Array>;
  81618. /**
  81619. * The angularAcceleration of the device, values in array are [x,y,z].
  81620. */
  81621. readonly angularAcceleration: Nullable<Float32Array>;
  81622. }
  81623. /**
  81624. * Interface representing a pose controlled object in Babylon.
  81625. * A pose controlled object has both regular pose values as well as pose values
  81626. * from an external device such as a VR head mounted display
  81627. */
  81628. export interface PoseControlled {
  81629. /**
  81630. * The position of the object in babylon space.
  81631. */
  81632. position: Vector3;
  81633. /**
  81634. * The rotation quaternion of the object in babylon space.
  81635. */
  81636. rotationQuaternion: Quaternion;
  81637. /**
  81638. * The position of the device in babylon space.
  81639. */
  81640. devicePosition?: Vector3;
  81641. /**
  81642. * The rotation quaternion of the device in babylon space.
  81643. */
  81644. deviceRotationQuaternion: Quaternion;
  81645. /**
  81646. * The raw pose coming from the device.
  81647. */
  81648. rawPose: Nullable<DevicePose>;
  81649. /**
  81650. * The scale of the device to be used when translating from device space to babylon space.
  81651. */
  81652. deviceScaleFactor: number;
  81653. /**
  81654. * Updates the poseControlled values based on the input device pose.
  81655. * @param poseData the pose data to update the object with
  81656. */
  81657. updateFromDevice(poseData: DevicePose): void;
  81658. }
  81659. /**
  81660. * Set of options to customize the webVRCamera
  81661. */
  81662. export interface WebVROptions {
  81663. /**
  81664. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81665. */
  81666. trackPosition?: boolean;
  81667. /**
  81668. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81669. */
  81670. positionScale?: number;
  81671. /**
  81672. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81673. */
  81674. displayName?: string;
  81675. /**
  81676. * Should the native controller meshes be initialized. (default: true)
  81677. */
  81678. controllerMeshes?: boolean;
  81679. /**
  81680. * Creating a default HemiLight only on controllers. (default: true)
  81681. */
  81682. defaultLightingOnControllers?: boolean;
  81683. /**
  81684. * If you don't want to use the default VR button of the helper. (default: false)
  81685. */
  81686. useCustomVRButton?: boolean;
  81687. /**
  81688. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81689. */
  81690. customVRButton?: HTMLButtonElement;
  81691. /**
  81692. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81693. */
  81694. rayLength?: number;
  81695. /**
  81696. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81697. */
  81698. defaultHeight?: number;
  81699. /**
  81700. * If multiview should be used if availible (default: false)
  81701. */
  81702. useMultiview?: boolean;
  81703. }
  81704. /**
  81705. * This represents a WebVR camera.
  81706. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81707. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81708. */
  81709. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81710. private webVROptions;
  81711. /**
  81712. * @hidden
  81713. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81714. */
  81715. _vrDevice: any;
  81716. /**
  81717. * The rawPose of the vrDevice.
  81718. */
  81719. rawPose: Nullable<DevicePose>;
  81720. private _onVREnabled;
  81721. private _specsVersion;
  81722. private _attached;
  81723. private _frameData;
  81724. protected _descendants: Array<Node>;
  81725. private _deviceRoomPosition;
  81726. /** @hidden */
  81727. _deviceRoomRotationQuaternion: Quaternion;
  81728. private _standingMatrix;
  81729. /**
  81730. * Represents device position in babylon space.
  81731. */
  81732. devicePosition: Vector3;
  81733. /**
  81734. * Represents device rotation in babylon space.
  81735. */
  81736. deviceRotationQuaternion: Quaternion;
  81737. /**
  81738. * The scale of the device to be used when translating from device space to babylon space.
  81739. */
  81740. deviceScaleFactor: number;
  81741. private _deviceToWorld;
  81742. private _worldToDevice;
  81743. /**
  81744. * References to the webVR controllers for the vrDevice.
  81745. */
  81746. controllers: Array<WebVRController>;
  81747. /**
  81748. * Emits an event when a controller is attached.
  81749. */
  81750. onControllersAttachedObservable: Observable<WebVRController[]>;
  81751. /**
  81752. * Emits an event when a controller's mesh has been loaded;
  81753. */
  81754. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81755. /**
  81756. * Emits an event when the HMD's pose has been updated.
  81757. */
  81758. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81759. private _poseSet;
  81760. /**
  81761. * If the rig cameras be used as parent instead of this camera.
  81762. */
  81763. rigParenting: boolean;
  81764. private _lightOnControllers;
  81765. private _defaultHeight?;
  81766. /**
  81767. * Instantiates a WebVRFreeCamera.
  81768. * @param name The name of the WebVRFreeCamera
  81769. * @param position The starting anchor position for the camera
  81770. * @param scene The scene the camera belongs to
  81771. * @param webVROptions a set of customizable options for the webVRCamera
  81772. */
  81773. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81774. /**
  81775. * Gets the device distance from the ground in meters.
  81776. * @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.
  81777. */
  81778. deviceDistanceToRoomGround(): number;
  81779. /**
  81780. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81781. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81782. */
  81783. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81784. /**
  81785. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81786. * @returns A promise with a boolean set to if the standing matrix is supported.
  81787. */
  81788. useStandingMatrixAsync(): Promise<boolean>;
  81789. /**
  81790. * Disposes the camera
  81791. */
  81792. dispose(): void;
  81793. /**
  81794. * Gets a vrController by name.
  81795. * @param name The name of the controller to retreive
  81796. * @returns the controller matching the name specified or null if not found
  81797. */
  81798. getControllerByName(name: string): Nullable<WebVRController>;
  81799. private _leftController;
  81800. /**
  81801. * The controller corresponding to the users left hand.
  81802. */
  81803. readonly leftController: Nullable<WebVRController>;
  81804. private _rightController;
  81805. /**
  81806. * The controller corresponding to the users right hand.
  81807. */
  81808. readonly rightController: Nullable<WebVRController>;
  81809. /**
  81810. * Casts a ray forward from the vrCamera's gaze.
  81811. * @param length Length of the ray (default: 100)
  81812. * @returns the ray corresponding to the gaze
  81813. */
  81814. getForwardRay(length?: number): Ray;
  81815. /**
  81816. * @hidden
  81817. * Updates the camera based on device's frame data
  81818. */
  81819. _checkInputs(): void;
  81820. /**
  81821. * Updates the poseControlled values based on the input device pose.
  81822. * @param poseData Pose coming from the device
  81823. */
  81824. updateFromDevice(poseData: DevicePose): void;
  81825. private _htmlElementAttached;
  81826. private _detachIfAttached;
  81827. /**
  81828. * WebVR's attach control will start broadcasting frames to the device.
  81829. * Note that in certain browsers (chrome for example) this function must be called
  81830. * within a user-interaction callback. Example:
  81831. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81832. *
  81833. * @param element html element to attach the vrDevice to
  81834. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81835. */
  81836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81837. /**
  81838. * Detaches the camera from the html element and disables VR
  81839. *
  81840. * @param element html element to detach from
  81841. */
  81842. detachControl(element: HTMLElement): void;
  81843. /**
  81844. * @returns the name of this class
  81845. */
  81846. getClassName(): string;
  81847. /**
  81848. * Calls resetPose on the vrDisplay
  81849. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81850. */
  81851. resetToCurrentRotation(): void;
  81852. /**
  81853. * @hidden
  81854. * Updates the rig cameras (left and right eye)
  81855. */
  81856. _updateRigCameras(): void;
  81857. private _workingVector;
  81858. private _oneVector;
  81859. private _workingMatrix;
  81860. private updateCacheCalled;
  81861. private _correctPositionIfNotTrackPosition;
  81862. /**
  81863. * @hidden
  81864. * Updates the cached values of the camera
  81865. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81866. */
  81867. _updateCache(ignoreParentClass?: boolean): void;
  81868. /**
  81869. * @hidden
  81870. * Get current device position in babylon world
  81871. */
  81872. _computeDevicePosition(): void;
  81873. /**
  81874. * Updates the current device position and rotation in the babylon world
  81875. */
  81876. update(): void;
  81877. /**
  81878. * @hidden
  81879. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81880. * @returns an identity matrix
  81881. */
  81882. _getViewMatrix(): Matrix;
  81883. private _tmpMatrix;
  81884. /**
  81885. * This function is called by the two RIG cameras.
  81886. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81887. * @hidden
  81888. */
  81889. _getWebVRViewMatrix(): Matrix;
  81890. /** @hidden */
  81891. _getWebVRProjectionMatrix(): Matrix;
  81892. private _onGamepadConnectedObserver;
  81893. private _onGamepadDisconnectedObserver;
  81894. private _updateCacheWhenTrackingDisabledObserver;
  81895. /**
  81896. * Initializes the controllers and their meshes
  81897. */
  81898. initControllers(): void;
  81899. }
  81900. }
  81901. declare module BABYLON {
  81902. /**
  81903. * Size options for a post process
  81904. */
  81905. export type PostProcessOptions = {
  81906. width: number;
  81907. height: number;
  81908. };
  81909. /**
  81910. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81911. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81912. */
  81913. export class PostProcess {
  81914. /** Name of the PostProcess. */
  81915. name: string;
  81916. /**
  81917. * Gets or sets the unique id of the post process
  81918. */
  81919. uniqueId: number;
  81920. /**
  81921. * Width of the texture to apply the post process on
  81922. */
  81923. width: number;
  81924. /**
  81925. * Height of the texture to apply the post process on
  81926. */
  81927. height: number;
  81928. /**
  81929. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81930. * @hidden
  81931. */
  81932. _outputTexture: Nullable<InternalTexture>;
  81933. /**
  81934. * Sampling mode used by the shader
  81935. * See https://doc.babylonjs.com/classes/3.1/texture
  81936. */
  81937. renderTargetSamplingMode: number;
  81938. /**
  81939. * Clear color to use when screen clearing
  81940. */
  81941. clearColor: Color4;
  81942. /**
  81943. * If the buffer needs to be cleared before applying the post process. (default: true)
  81944. * Should be set to false if shader will overwrite all previous pixels.
  81945. */
  81946. autoClear: boolean;
  81947. /**
  81948. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81949. */
  81950. alphaMode: number;
  81951. /**
  81952. * Sets the setAlphaBlendConstants of the babylon engine
  81953. */
  81954. alphaConstants: Color4;
  81955. /**
  81956. * Animations to be used for the post processing
  81957. */
  81958. animations: Animation[];
  81959. /**
  81960. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81961. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81962. */
  81963. enablePixelPerfectMode: boolean;
  81964. /**
  81965. * Force the postprocess to be applied without taking in account viewport
  81966. */
  81967. forceFullscreenViewport: boolean;
  81968. /**
  81969. * List of inspectable custom properties (used by the Inspector)
  81970. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81971. */
  81972. inspectableCustomProperties: IInspectable[];
  81973. /**
  81974. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81975. *
  81976. * | Value | Type | Description |
  81977. * | ----- | ----------------------------------- | ----------- |
  81978. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81979. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81980. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81981. *
  81982. */
  81983. scaleMode: number;
  81984. /**
  81985. * Force textures to be a power of two (default: false)
  81986. */
  81987. alwaysForcePOT: boolean;
  81988. private _samples;
  81989. /**
  81990. * Number of sample textures (default: 1)
  81991. */
  81992. samples: number;
  81993. /**
  81994. * Modify the scale of the post process to be the same as the viewport (default: false)
  81995. */
  81996. adaptScaleToCurrentViewport: boolean;
  81997. private _camera;
  81998. private _scene;
  81999. private _engine;
  82000. private _options;
  82001. private _reusable;
  82002. private _textureType;
  82003. /**
  82004. * Smart array of input and output textures for the post process.
  82005. * @hidden
  82006. */
  82007. _textures: SmartArray<InternalTexture>;
  82008. /**
  82009. * The index in _textures that corresponds to the output texture.
  82010. * @hidden
  82011. */
  82012. _currentRenderTextureInd: number;
  82013. private _effect;
  82014. private _samplers;
  82015. private _fragmentUrl;
  82016. private _vertexUrl;
  82017. private _parameters;
  82018. private _scaleRatio;
  82019. protected _indexParameters: any;
  82020. private _shareOutputWithPostProcess;
  82021. private _texelSize;
  82022. private _forcedOutputTexture;
  82023. /**
  82024. * Returns the fragment url or shader name used in the post process.
  82025. * @returns the fragment url or name in the shader store.
  82026. */
  82027. getEffectName(): string;
  82028. /**
  82029. * An event triggered when the postprocess is activated.
  82030. */
  82031. onActivateObservable: Observable<Camera>;
  82032. private _onActivateObserver;
  82033. /**
  82034. * A function that is added to the onActivateObservable
  82035. */
  82036. onActivate: Nullable<(camera: Camera) => void>;
  82037. /**
  82038. * An event triggered when the postprocess changes its size.
  82039. */
  82040. onSizeChangedObservable: Observable<PostProcess>;
  82041. private _onSizeChangedObserver;
  82042. /**
  82043. * A function that is added to the onSizeChangedObservable
  82044. */
  82045. onSizeChanged: (postProcess: PostProcess) => void;
  82046. /**
  82047. * An event triggered when the postprocess applies its effect.
  82048. */
  82049. onApplyObservable: Observable<Effect>;
  82050. private _onApplyObserver;
  82051. /**
  82052. * A function that is added to the onApplyObservable
  82053. */
  82054. onApply: (effect: Effect) => void;
  82055. /**
  82056. * An event triggered before rendering the postprocess
  82057. */
  82058. onBeforeRenderObservable: Observable<Effect>;
  82059. private _onBeforeRenderObserver;
  82060. /**
  82061. * A function that is added to the onBeforeRenderObservable
  82062. */
  82063. onBeforeRender: (effect: Effect) => void;
  82064. /**
  82065. * An event triggered after rendering the postprocess
  82066. */
  82067. onAfterRenderObservable: Observable<Effect>;
  82068. private _onAfterRenderObserver;
  82069. /**
  82070. * A function that is added to the onAfterRenderObservable
  82071. */
  82072. onAfterRender: (efect: Effect) => void;
  82073. /**
  82074. * 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
  82075. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82076. */
  82077. inputTexture: InternalTexture;
  82078. /**
  82079. * Gets the camera which post process is applied to.
  82080. * @returns The camera the post process is applied to.
  82081. */
  82082. getCamera(): Camera;
  82083. /**
  82084. * Gets the texel size of the postprocess.
  82085. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82086. */
  82087. readonly texelSize: Vector2;
  82088. /**
  82089. * Creates a new instance PostProcess
  82090. * @param name The name of the PostProcess.
  82091. * @param fragmentUrl The url of the fragment shader to be used.
  82092. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82093. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82094. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82095. * @param camera The camera to apply the render pass to.
  82096. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82097. * @param engine The engine which the post process will be applied. (default: current engine)
  82098. * @param reusable If the post process can be reused on the same frame. (default: false)
  82099. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82100. * @param textureType Type of textures used when performing the post process. (default: 0)
  82101. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82102. * @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
  82103. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82104. */
  82105. constructor(
  82106. /** Name of the PostProcess. */
  82107. 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);
  82108. /**
  82109. * Gets a string idenfifying the name of the class
  82110. * @returns "PostProcess" string
  82111. */
  82112. getClassName(): string;
  82113. /**
  82114. * Gets the engine which this post process belongs to.
  82115. * @returns The engine the post process was enabled with.
  82116. */
  82117. getEngine(): Engine;
  82118. /**
  82119. * The effect that is created when initializing the post process.
  82120. * @returns The created effect corresponding the the postprocess.
  82121. */
  82122. getEffect(): Effect;
  82123. /**
  82124. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82125. * @param postProcess The post process to share the output with.
  82126. * @returns This post process.
  82127. */
  82128. shareOutputWith(postProcess: PostProcess): PostProcess;
  82129. /**
  82130. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82131. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82132. */
  82133. useOwnOutput(): void;
  82134. /**
  82135. * Updates the effect with the current post process compile time values and recompiles the shader.
  82136. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82137. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82138. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82139. * @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
  82140. * @param onCompiled Called when the shader has been compiled.
  82141. * @param onError Called if there is an error when compiling a shader.
  82142. */
  82143. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82144. /**
  82145. * The post process is reusable if it can be used multiple times within one frame.
  82146. * @returns If the post process is reusable
  82147. */
  82148. isReusable(): boolean;
  82149. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82150. markTextureDirty(): void;
  82151. /**
  82152. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82153. * 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.
  82154. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82155. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82156. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82157. * @returns The target texture that was bound to be written to.
  82158. */
  82159. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82160. /**
  82161. * If the post process is supported.
  82162. */
  82163. readonly isSupported: boolean;
  82164. /**
  82165. * The aspect ratio of the output texture.
  82166. */
  82167. readonly aspectRatio: number;
  82168. /**
  82169. * Get a value indicating if the post-process is ready to be used
  82170. * @returns true if the post-process is ready (shader is compiled)
  82171. */
  82172. isReady(): boolean;
  82173. /**
  82174. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82175. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82176. */
  82177. apply(): Nullable<Effect>;
  82178. private _disposeTextures;
  82179. /**
  82180. * Disposes the post process.
  82181. * @param camera The camera to dispose the post process on.
  82182. */
  82183. dispose(camera?: Camera): void;
  82184. }
  82185. }
  82186. declare module BABYLON {
  82187. /** @hidden */
  82188. export var kernelBlurVaryingDeclaration: {
  82189. name: string;
  82190. shader: string;
  82191. };
  82192. }
  82193. declare module BABYLON {
  82194. /** @hidden */
  82195. export var kernelBlurFragment: {
  82196. name: string;
  82197. shader: string;
  82198. };
  82199. }
  82200. declare module BABYLON {
  82201. /** @hidden */
  82202. export var kernelBlurFragment2: {
  82203. name: string;
  82204. shader: string;
  82205. };
  82206. }
  82207. declare module BABYLON {
  82208. /** @hidden */
  82209. export var kernelBlurPixelShader: {
  82210. name: string;
  82211. shader: string;
  82212. };
  82213. }
  82214. declare module BABYLON {
  82215. /** @hidden */
  82216. export var kernelBlurVertex: {
  82217. name: string;
  82218. shader: string;
  82219. };
  82220. }
  82221. declare module BABYLON {
  82222. /** @hidden */
  82223. export var kernelBlurVertexShader: {
  82224. name: string;
  82225. shader: string;
  82226. };
  82227. }
  82228. declare module BABYLON {
  82229. /**
  82230. * The Blur Post Process which blurs an image based on a kernel and direction.
  82231. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82232. */
  82233. export class BlurPostProcess extends PostProcess {
  82234. /** The direction in which to blur the image. */
  82235. direction: Vector2;
  82236. private blockCompilation;
  82237. protected _kernel: number;
  82238. protected _idealKernel: number;
  82239. protected _packedFloat: boolean;
  82240. private _staticDefines;
  82241. /**
  82242. * Sets the length in pixels of the blur sample region
  82243. */
  82244. /**
  82245. * Gets the length in pixels of the blur sample region
  82246. */
  82247. kernel: number;
  82248. /**
  82249. * Sets wether or not the blur needs to unpack/repack floats
  82250. */
  82251. /**
  82252. * Gets wether or not the blur is unpacking/repacking floats
  82253. */
  82254. packedFloat: boolean;
  82255. /**
  82256. * Creates a new instance BlurPostProcess
  82257. * @param name The name of the effect.
  82258. * @param direction The direction in which to blur the image.
  82259. * @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.
  82260. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82261. * @param camera The camera to apply the render pass to.
  82262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82263. * @param engine The engine which the post process will be applied. (default: current engine)
  82264. * @param reusable If the post process can be reused on the same frame. (default: false)
  82265. * @param textureType Type of textures used when performing the post process. (default: 0)
  82266. * @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)
  82267. */
  82268. constructor(name: string,
  82269. /** The direction in which to blur the image. */
  82270. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82271. /**
  82272. * Updates the effect with the current post process compile time values and recompiles the shader.
  82273. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82274. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82275. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82276. * @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
  82277. * @param onCompiled Called when the shader has been compiled.
  82278. * @param onError Called if there is an error when compiling a shader.
  82279. */
  82280. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82281. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82282. /**
  82283. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82284. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82285. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82286. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82287. * The gaps between physical kernels are compensated for in the weighting of the samples
  82288. * @param idealKernel Ideal blur kernel.
  82289. * @return Nearest best kernel.
  82290. */
  82291. protected _nearestBestKernel(idealKernel: number): number;
  82292. /**
  82293. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82294. * @param x The point on the Gaussian distribution to sample.
  82295. * @return the value of the Gaussian function at x.
  82296. */
  82297. protected _gaussianWeight(x: number): number;
  82298. /**
  82299. * Generates a string that can be used as a floating point number in GLSL.
  82300. * @param x Value to print.
  82301. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82302. * @return GLSL float string.
  82303. */
  82304. protected _glslFloat(x: number, decimalFigures?: number): string;
  82305. }
  82306. }
  82307. declare module BABYLON {
  82308. /**
  82309. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82310. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82311. * You can then easily use it as a reflectionTexture on a flat surface.
  82312. * In case the surface is not a plane, please consider relying on reflection probes.
  82313. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82314. */
  82315. export class MirrorTexture extends RenderTargetTexture {
  82316. private scene;
  82317. /**
  82318. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82319. * 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.
  82320. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82321. */
  82322. mirrorPlane: Plane;
  82323. /**
  82324. * Define the blur ratio used to blur the reflection if needed.
  82325. */
  82326. blurRatio: number;
  82327. /**
  82328. * Define the adaptive blur kernel used to blur the reflection if needed.
  82329. * This will autocompute the closest best match for the `blurKernel`
  82330. */
  82331. adaptiveBlurKernel: number;
  82332. /**
  82333. * Define the blur kernel used to blur the reflection if needed.
  82334. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82335. */
  82336. blurKernel: number;
  82337. /**
  82338. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82339. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82340. */
  82341. blurKernelX: number;
  82342. /**
  82343. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82344. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82345. */
  82346. blurKernelY: number;
  82347. private _autoComputeBlurKernel;
  82348. protected _onRatioRescale(): void;
  82349. private _updateGammaSpace;
  82350. private _imageProcessingConfigChangeObserver;
  82351. private _transformMatrix;
  82352. private _mirrorMatrix;
  82353. private _savedViewMatrix;
  82354. private _blurX;
  82355. private _blurY;
  82356. private _adaptiveBlurKernel;
  82357. private _blurKernelX;
  82358. private _blurKernelY;
  82359. private _blurRatio;
  82360. /**
  82361. * Instantiates a Mirror Texture.
  82362. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82363. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82364. * You can then easily use it as a reflectionTexture on a flat surface.
  82365. * In case the surface is not a plane, please consider relying on reflection probes.
  82366. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82367. * @param name
  82368. * @param size
  82369. * @param scene
  82370. * @param generateMipMaps
  82371. * @param type
  82372. * @param samplingMode
  82373. * @param generateDepthBuffer
  82374. */
  82375. constructor(name: string, size: number | {
  82376. width: number;
  82377. height: number;
  82378. } | {
  82379. ratio: number;
  82380. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82381. private _preparePostProcesses;
  82382. /**
  82383. * Clone the mirror texture.
  82384. * @returns the cloned texture
  82385. */
  82386. clone(): MirrorTexture;
  82387. /**
  82388. * Serialize the texture to a JSON representation you could use in Parse later on
  82389. * @returns the serialized JSON representation
  82390. */
  82391. serialize(): any;
  82392. /**
  82393. * Dispose the texture and release its associated resources.
  82394. */
  82395. dispose(): void;
  82396. }
  82397. }
  82398. declare module BABYLON {
  82399. /**
  82400. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82401. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82402. */
  82403. export class Texture extends BaseTexture {
  82404. /**
  82405. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82406. */
  82407. static SerializeBuffers: boolean;
  82408. /** @hidden */
  82409. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82410. /** @hidden */
  82411. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82412. /** @hidden */
  82413. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82414. /** nearest is mag = nearest and min = nearest and mip = linear */
  82415. static readonly NEAREST_SAMPLINGMODE: number;
  82416. /** nearest is mag = nearest and min = nearest and mip = linear */
  82417. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82418. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82419. static readonly BILINEAR_SAMPLINGMODE: number;
  82420. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82421. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82422. /** Trilinear is mag = linear and min = linear and mip = linear */
  82423. static readonly TRILINEAR_SAMPLINGMODE: number;
  82424. /** Trilinear is mag = linear and min = linear and mip = linear */
  82425. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82426. /** mag = nearest and min = nearest and mip = nearest */
  82427. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82428. /** mag = nearest and min = linear and mip = nearest */
  82429. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82430. /** mag = nearest and min = linear and mip = linear */
  82431. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82432. /** mag = nearest and min = linear and mip = none */
  82433. static readonly NEAREST_LINEAR: number;
  82434. /** mag = nearest and min = nearest and mip = none */
  82435. static readonly NEAREST_NEAREST: number;
  82436. /** mag = linear and min = nearest and mip = nearest */
  82437. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82438. /** mag = linear and min = nearest and mip = linear */
  82439. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82440. /** mag = linear and min = linear and mip = none */
  82441. static readonly LINEAR_LINEAR: number;
  82442. /** mag = linear and min = nearest and mip = none */
  82443. static readonly LINEAR_NEAREST: number;
  82444. /** Explicit coordinates mode */
  82445. static readonly EXPLICIT_MODE: number;
  82446. /** Spherical coordinates mode */
  82447. static readonly SPHERICAL_MODE: number;
  82448. /** Planar coordinates mode */
  82449. static readonly PLANAR_MODE: number;
  82450. /** Cubic coordinates mode */
  82451. static readonly CUBIC_MODE: number;
  82452. /** Projection coordinates mode */
  82453. static readonly PROJECTION_MODE: number;
  82454. /** Inverse Cubic coordinates mode */
  82455. static readonly SKYBOX_MODE: number;
  82456. /** Inverse Cubic coordinates mode */
  82457. static readonly INVCUBIC_MODE: number;
  82458. /** Equirectangular coordinates mode */
  82459. static readonly EQUIRECTANGULAR_MODE: number;
  82460. /** Equirectangular Fixed coordinates mode */
  82461. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82462. /** Equirectangular Fixed Mirrored coordinates mode */
  82463. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82464. /** Texture is not repeating outside of 0..1 UVs */
  82465. static readonly CLAMP_ADDRESSMODE: number;
  82466. /** Texture is repeating outside of 0..1 UVs */
  82467. static readonly WRAP_ADDRESSMODE: number;
  82468. /** Texture is repeating and mirrored */
  82469. static readonly MIRROR_ADDRESSMODE: number;
  82470. /**
  82471. * 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
  82472. */
  82473. static UseSerializedUrlIfAny: boolean;
  82474. /**
  82475. * Define the url of the texture.
  82476. */
  82477. url: Nullable<string>;
  82478. /**
  82479. * Define an offset on the texture to offset the u coordinates of the UVs
  82480. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82481. */
  82482. uOffset: number;
  82483. /**
  82484. * Define an offset on the texture to offset the v coordinates of the UVs
  82485. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82486. */
  82487. vOffset: number;
  82488. /**
  82489. * Define an offset on the texture to scale the u coordinates of the UVs
  82490. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82491. */
  82492. uScale: number;
  82493. /**
  82494. * Define an offset on the texture to scale the v coordinates of the UVs
  82495. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82496. */
  82497. vScale: number;
  82498. /**
  82499. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82500. * @see http://doc.babylonjs.com/how_to/more_materials
  82501. */
  82502. uAng: number;
  82503. /**
  82504. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82505. * @see http://doc.babylonjs.com/how_to/more_materials
  82506. */
  82507. vAng: number;
  82508. /**
  82509. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82510. * @see http://doc.babylonjs.com/how_to/more_materials
  82511. */
  82512. wAng: number;
  82513. /**
  82514. * Defines the center of rotation (U)
  82515. */
  82516. uRotationCenter: number;
  82517. /**
  82518. * Defines the center of rotation (V)
  82519. */
  82520. vRotationCenter: number;
  82521. /**
  82522. * Defines the center of rotation (W)
  82523. */
  82524. wRotationCenter: number;
  82525. /**
  82526. * Are mip maps generated for this texture or not.
  82527. */
  82528. readonly noMipmap: boolean;
  82529. /**
  82530. * List of inspectable custom properties (used by the Inspector)
  82531. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82532. */
  82533. inspectableCustomProperties: Nullable<IInspectable[]>;
  82534. private _noMipmap;
  82535. /** @hidden */
  82536. _invertY: boolean;
  82537. private _rowGenerationMatrix;
  82538. private _cachedTextureMatrix;
  82539. private _projectionModeMatrix;
  82540. private _t0;
  82541. private _t1;
  82542. private _t2;
  82543. private _cachedUOffset;
  82544. private _cachedVOffset;
  82545. private _cachedUScale;
  82546. private _cachedVScale;
  82547. private _cachedUAng;
  82548. private _cachedVAng;
  82549. private _cachedWAng;
  82550. private _cachedProjectionMatrixId;
  82551. private _cachedCoordinatesMode;
  82552. /** @hidden */
  82553. protected _initialSamplingMode: number;
  82554. /** @hidden */
  82555. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82556. private _deleteBuffer;
  82557. protected _format: Nullable<number>;
  82558. private _delayedOnLoad;
  82559. private _delayedOnError;
  82560. /**
  82561. * Observable triggered once the texture has been loaded.
  82562. */
  82563. onLoadObservable: Observable<Texture>;
  82564. protected _isBlocking: boolean;
  82565. /**
  82566. * Is the texture preventing material to render while loading.
  82567. * If false, a default texture will be used instead of the loading one during the preparation step.
  82568. */
  82569. isBlocking: boolean;
  82570. /**
  82571. * Get the current sampling mode associated with the texture.
  82572. */
  82573. readonly samplingMode: number;
  82574. /**
  82575. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82576. */
  82577. readonly invertY: boolean;
  82578. /**
  82579. * Instantiates a new texture.
  82580. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82581. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82582. * @param url define the url of the picture to load as a texture
  82583. * @param scene define the scene or engine the texture will belong to
  82584. * @param noMipmap define if the texture will require mip maps or not
  82585. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82586. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82587. * @param onLoad define a callback triggered when the texture has been loaded
  82588. * @param onError define a callback triggered when an error occurred during the loading session
  82589. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82590. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82591. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82592. */
  82593. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  82594. /**
  82595. * Update the url (and optional buffer) of this texture if url was null during construction.
  82596. * @param url the url of the texture
  82597. * @param buffer the buffer of the texture (defaults to null)
  82598. * @param onLoad callback called when the texture is loaded (defaults to null)
  82599. */
  82600. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82601. /**
  82602. * Finish the loading sequence of a texture flagged as delayed load.
  82603. * @hidden
  82604. */
  82605. delayLoad(): void;
  82606. private _prepareRowForTextureGeneration;
  82607. /**
  82608. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82609. * @returns the transform matrix of the texture.
  82610. */
  82611. getTextureMatrix(): Matrix;
  82612. /**
  82613. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82614. * @returns The reflection texture transform
  82615. */
  82616. getReflectionTextureMatrix(): Matrix;
  82617. /**
  82618. * Clones the texture.
  82619. * @returns the cloned texture
  82620. */
  82621. clone(): Texture;
  82622. /**
  82623. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82624. * @returns The JSON representation of the texture
  82625. */
  82626. serialize(): any;
  82627. /**
  82628. * Get the current class name of the texture useful for serialization or dynamic coding.
  82629. * @returns "Texture"
  82630. */
  82631. getClassName(): string;
  82632. /**
  82633. * Dispose the texture and release its associated resources.
  82634. */
  82635. dispose(): void;
  82636. /**
  82637. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82638. * @param parsedTexture Define the JSON representation of the texture
  82639. * @param scene Define the scene the parsed texture should be instantiated in
  82640. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82641. * @returns The parsed texture if successful
  82642. */
  82643. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82644. /**
  82645. * Creates a texture from its base 64 representation.
  82646. * @param data Define the base64 payload without the data: prefix
  82647. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82648. * @param scene Define the scene the texture should belong to
  82649. * @param noMipmap Forces the texture to not create mip map information if true
  82650. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82651. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82652. * @param onLoad define a callback triggered when the texture has been loaded
  82653. * @param onError define a callback triggered when an error occurred during the loading session
  82654. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82655. * @returns the created texture
  82656. */
  82657. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82658. /**
  82659. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82660. * @param data Define the base64 payload without the data: prefix
  82661. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82662. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82663. * @param scene Define the scene the texture should belong to
  82664. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82665. * @param noMipmap Forces the texture to not create mip map information if true
  82666. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82667. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82668. * @param onLoad define a callback triggered when the texture has been loaded
  82669. * @param onError define a callback triggered when an error occurred during the loading session
  82670. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82671. * @returns the created texture
  82672. */
  82673. 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;
  82674. }
  82675. }
  82676. declare module BABYLON {
  82677. /**
  82678. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82679. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82680. */
  82681. export class PostProcessManager {
  82682. private _scene;
  82683. private _indexBuffer;
  82684. private _vertexBuffers;
  82685. /**
  82686. * Creates a new instance PostProcess
  82687. * @param scene The scene that the post process is associated with.
  82688. */
  82689. constructor(scene: Scene);
  82690. private _prepareBuffers;
  82691. private _buildIndexBuffer;
  82692. /**
  82693. * Rebuilds the vertex buffers of the manager.
  82694. * @hidden
  82695. */
  82696. _rebuild(): void;
  82697. /**
  82698. * Prepares a frame to be run through a post process.
  82699. * @param sourceTexture The input texture to the post procesess. (default: null)
  82700. * @param postProcesses An array of post processes to be run. (default: null)
  82701. * @returns True if the post processes were able to be run.
  82702. * @hidden
  82703. */
  82704. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82705. /**
  82706. * Manually render a set of post processes to a texture.
  82707. * @param postProcesses An array of post processes to be run.
  82708. * @param targetTexture The target texture to render to.
  82709. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82710. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82711. * @param lodLevel defines which lod of the texture to render to
  82712. */
  82713. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82714. /**
  82715. * Finalize the result of the output of the postprocesses.
  82716. * @param doNotPresent If true the result will not be displayed to the screen.
  82717. * @param targetTexture The target texture to render to.
  82718. * @param faceIndex The index of the face to bind the target texture to.
  82719. * @param postProcesses The array of post processes to render.
  82720. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82721. * @hidden
  82722. */
  82723. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82724. /**
  82725. * Disposes of the post process manager.
  82726. */
  82727. dispose(): void;
  82728. }
  82729. }
  82730. declare module BABYLON {
  82731. /** Interface used by value gradients (color, factor, ...) */
  82732. export interface IValueGradient {
  82733. /**
  82734. * Gets or sets the gradient value (between 0 and 1)
  82735. */
  82736. gradient: number;
  82737. }
  82738. /** Class used to store color4 gradient */
  82739. export class ColorGradient implements IValueGradient {
  82740. /**
  82741. * Gets or sets the gradient value (between 0 and 1)
  82742. */
  82743. gradient: number;
  82744. /**
  82745. * Gets or sets first associated color
  82746. */
  82747. color1: Color4;
  82748. /**
  82749. * Gets or sets second associated color
  82750. */
  82751. color2?: Color4;
  82752. /**
  82753. * Will get a color picked randomly between color1 and color2.
  82754. * If color2 is undefined then color1 will be used
  82755. * @param result defines the target Color4 to store the result in
  82756. */
  82757. getColorToRef(result: Color4): void;
  82758. }
  82759. /** Class used to store color 3 gradient */
  82760. export class Color3Gradient implements IValueGradient {
  82761. /**
  82762. * Gets or sets the gradient value (between 0 and 1)
  82763. */
  82764. gradient: number;
  82765. /**
  82766. * Gets or sets the associated color
  82767. */
  82768. color: Color3;
  82769. }
  82770. /** Class used to store factor gradient */
  82771. export class FactorGradient implements IValueGradient {
  82772. /**
  82773. * Gets or sets the gradient value (between 0 and 1)
  82774. */
  82775. gradient: number;
  82776. /**
  82777. * Gets or sets first associated factor
  82778. */
  82779. factor1: number;
  82780. /**
  82781. * Gets or sets second associated factor
  82782. */
  82783. factor2?: number;
  82784. /**
  82785. * Will get a number picked randomly between factor1 and factor2.
  82786. * If factor2 is undefined then factor1 will be used
  82787. * @returns the picked number
  82788. */
  82789. getFactor(): number;
  82790. }
  82791. /**
  82792. * Helper used to simplify some generic gradient tasks
  82793. */
  82794. export class GradientHelper {
  82795. /**
  82796. * Gets the current gradient from an array of IValueGradient
  82797. * @param ratio defines the current ratio to get
  82798. * @param gradients defines the array of IValueGradient
  82799. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82800. */
  82801. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82802. }
  82803. }
  82804. declare module BABYLON {
  82805. interface ThinEngine {
  82806. /**
  82807. * Creates a dynamic texture
  82808. * @param width defines the width of the texture
  82809. * @param height defines the height of the texture
  82810. * @param generateMipMaps defines if the engine should generate the mip levels
  82811. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82812. * @returns the dynamic texture inside an InternalTexture
  82813. */
  82814. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82815. /**
  82816. * Update the content of a dynamic texture
  82817. * @param texture defines the texture to update
  82818. * @param canvas defines the canvas containing the source
  82819. * @param invertY defines if data must be stored with Y axis inverted
  82820. * @param premulAlpha defines if alpha is stored as premultiplied
  82821. * @param format defines the format of the data
  82822. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82823. */
  82824. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82825. }
  82826. }
  82827. declare module BABYLON {
  82828. /**
  82829. * A class extending Texture allowing drawing on a texture
  82830. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82831. */
  82832. export class DynamicTexture extends Texture {
  82833. private _generateMipMaps;
  82834. private _canvas;
  82835. private _context;
  82836. private _engine;
  82837. /**
  82838. * Creates a DynamicTexture
  82839. * @param name defines the name of the texture
  82840. * @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
  82841. * @param scene defines the scene where you want the texture
  82842. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82843. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82844. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82845. */
  82846. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82847. /**
  82848. * Get the current class name of the texture useful for serialization or dynamic coding.
  82849. * @returns "DynamicTexture"
  82850. */
  82851. getClassName(): string;
  82852. /**
  82853. * Gets the current state of canRescale
  82854. */
  82855. readonly canRescale: boolean;
  82856. private _recreate;
  82857. /**
  82858. * Scales the texture
  82859. * @param ratio the scale factor to apply to both width and height
  82860. */
  82861. scale(ratio: number): void;
  82862. /**
  82863. * Resizes the texture
  82864. * @param width the new width
  82865. * @param height the new height
  82866. */
  82867. scaleTo(width: number, height: number): void;
  82868. /**
  82869. * Gets the context of the canvas used by the texture
  82870. * @returns the canvas context of the dynamic texture
  82871. */
  82872. getContext(): CanvasRenderingContext2D;
  82873. /**
  82874. * Clears the texture
  82875. */
  82876. clear(): void;
  82877. /**
  82878. * Updates the texture
  82879. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82880. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82881. */
  82882. update(invertY?: boolean, premulAlpha?: boolean): void;
  82883. /**
  82884. * Draws text onto the texture
  82885. * @param text defines the text to be drawn
  82886. * @param x defines the placement of the text from the left
  82887. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82888. * @param font defines the font to be used with font-style, font-size, font-name
  82889. * @param color defines the color used for the text
  82890. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82891. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82892. * @param update defines whether texture is immediately update (default is true)
  82893. */
  82894. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82895. /**
  82896. * Clones the texture
  82897. * @returns the clone of the texture.
  82898. */
  82899. clone(): DynamicTexture;
  82900. /**
  82901. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82902. * @returns a serialized dynamic texture object
  82903. */
  82904. serialize(): any;
  82905. /** @hidden */
  82906. _rebuild(): void;
  82907. }
  82908. }
  82909. declare module BABYLON {
  82910. interface AbstractScene {
  82911. /**
  82912. * The list of procedural textures added to the scene
  82913. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82914. */
  82915. proceduralTextures: Array<ProceduralTexture>;
  82916. }
  82917. /**
  82918. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82919. * in a given scene.
  82920. */
  82921. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82922. /**
  82923. * The component name helpfull to identify the component in the list of scene components.
  82924. */
  82925. readonly name: string;
  82926. /**
  82927. * The scene the component belongs to.
  82928. */
  82929. scene: Scene;
  82930. /**
  82931. * Creates a new instance of the component for the given scene
  82932. * @param scene Defines the scene to register the component in
  82933. */
  82934. constructor(scene: Scene);
  82935. /**
  82936. * Registers the component in a given scene
  82937. */
  82938. register(): void;
  82939. /**
  82940. * Rebuilds the elements related to this component in case of
  82941. * context lost for instance.
  82942. */
  82943. rebuild(): void;
  82944. /**
  82945. * Disposes the component and the associated ressources.
  82946. */
  82947. dispose(): void;
  82948. private _beforeClear;
  82949. }
  82950. }
  82951. declare module BABYLON {
  82952. interface ThinEngine {
  82953. /**
  82954. * Creates a new render target cube texture
  82955. * @param size defines the size of the texture
  82956. * @param options defines the options used to create the texture
  82957. * @returns a new render target cube texture stored in an InternalTexture
  82958. */
  82959. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82960. }
  82961. }
  82962. declare module BABYLON {
  82963. /** @hidden */
  82964. export var proceduralVertexShader: {
  82965. name: string;
  82966. shader: string;
  82967. };
  82968. }
  82969. declare module BABYLON {
  82970. /**
  82971. * 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.
  82972. * This is the base class of any Procedural texture and contains most of the shareable code.
  82973. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82974. */
  82975. export class ProceduralTexture extends Texture {
  82976. isCube: boolean;
  82977. /**
  82978. * Define if the texture is enabled or not (disabled texture will not render)
  82979. */
  82980. isEnabled: boolean;
  82981. /**
  82982. * Define if the texture must be cleared before rendering (default is true)
  82983. */
  82984. autoClear: boolean;
  82985. /**
  82986. * Callback called when the texture is generated
  82987. */
  82988. onGenerated: () => void;
  82989. /**
  82990. * Event raised when the texture is generated
  82991. */
  82992. onGeneratedObservable: Observable<ProceduralTexture>;
  82993. /** @hidden */
  82994. _generateMipMaps: boolean;
  82995. /** @hidden **/
  82996. _effect: Effect;
  82997. /** @hidden */
  82998. _textures: {
  82999. [key: string]: Texture;
  83000. };
  83001. private _size;
  83002. private _currentRefreshId;
  83003. private _refreshRate;
  83004. private _vertexBuffers;
  83005. private _indexBuffer;
  83006. private _uniforms;
  83007. private _samplers;
  83008. private _fragment;
  83009. private _floats;
  83010. private _ints;
  83011. private _floatsArrays;
  83012. private _colors3;
  83013. private _colors4;
  83014. private _vectors2;
  83015. private _vectors3;
  83016. private _matrices;
  83017. private _fallbackTexture;
  83018. private _fallbackTextureUsed;
  83019. private _engine;
  83020. private _cachedDefines;
  83021. private _contentUpdateId;
  83022. private _contentData;
  83023. /**
  83024. * Instantiates a new procedural texture.
  83025. * 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.
  83026. * This is the base class of any Procedural texture and contains most of the shareable code.
  83027. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83028. * @param name Define the name of the texture
  83029. * @param size Define the size of the texture to create
  83030. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83031. * @param scene Define the scene the texture belongs to
  83032. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83033. * @param generateMipMaps Define if the texture should creates mip maps or not
  83034. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83035. */
  83036. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83037. /**
  83038. * The effect that is created when initializing the post process.
  83039. * @returns The created effect corresponding the the postprocess.
  83040. */
  83041. getEffect(): Effect;
  83042. /**
  83043. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83044. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83045. */
  83046. getContent(): Nullable<ArrayBufferView>;
  83047. private _createIndexBuffer;
  83048. /** @hidden */
  83049. _rebuild(): void;
  83050. /**
  83051. * Resets the texture in order to recreate its associated resources.
  83052. * This can be called in case of context loss
  83053. */
  83054. reset(): void;
  83055. protected _getDefines(): string;
  83056. /**
  83057. * Is the texture ready to be used ? (rendered at least once)
  83058. * @returns true if ready, otherwise, false.
  83059. */
  83060. isReady(): boolean;
  83061. /**
  83062. * Resets the refresh counter of the texture and start bak from scratch.
  83063. * Could be useful to regenerate the texture if it is setup to render only once.
  83064. */
  83065. resetRefreshCounter(): void;
  83066. /**
  83067. * Set the fragment shader to use in order to render the texture.
  83068. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83069. */
  83070. setFragment(fragment: any): void;
  83071. /**
  83072. * Define the refresh rate of the texture or the rendering frequency.
  83073. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83074. */
  83075. refreshRate: number;
  83076. /** @hidden */
  83077. _shouldRender(): boolean;
  83078. /**
  83079. * Get the size the texture is rendering at.
  83080. * @returns the size (texture is always squared)
  83081. */
  83082. getRenderSize(): number;
  83083. /**
  83084. * Resize the texture to new value.
  83085. * @param size Define the new size the texture should have
  83086. * @param generateMipMaps Define whether the new texture should create mip maps
  83087. */
  83088. resize(size: number, generateMipMaps: boolean): void;
  83089. private _checkUniform;
  83090. /**
  83091. * Set a texture in the shader program used to render.
  83092. * @param name Define the name of the uniform samplers as defined in the shader
  83093. * @param texture Define the texture to bind to this sampler
  83094. * @return the texture itself allowing "fluent" like uniform updates
  83095. */
  83096. setTexture(name: string, texture: Texture): ProceduralTexture;
  83097. /**
  83098. * Set a float in the shader.
  83099. * @param name Define the name of the uniform as defined in the shader
  83100. * @param value Define the value to give to the uniform
  83101. * @return the texture itself allowing "fluent" like uniform updates
  83102. */
  83103. setFloat(name: string, value: number): ProceduralTexture;
  83104. /**
  83105. * Set a int in the shader.
  83106. * @param name Define the name of the uniform as defined in the shader
  83107. * @param value Define the value to give to the uniform
  83108. * @return the texture itself allowing "fluent" like uniform updates
  83109. */
  83110. setInt(name: string, value: number): ProceduralTexture;
  83111. /**
  83112. * Set an array of floats in the shader.
  83113. * @param name Define the name of the uniform as defined in the shader
  83114. * @param value Define the value to give to the uniform
  83115. * @return the texture itself allowing "fluent" like uniform updates
  83116. */
  83117. setFloats(name: string, value: number[]): ProceduralTexture;
  83118. /**
  83119. * Set a vec3 in the shader from a Color3.
  83120. * @param name Define the name of the uniform as defined in the shader
  83121. * @param value Define the value to give to the uniform
  83122. * @return the texture itself allowing "fluent" like uniform updates
  83123. */
  83124. setColor3(name: string, value: Color3): ProceduralTexture;
  83125. /**
  83126. * Set a vec4 in the shader from a Color4.
  83127. * @param name Define the name of the uniform as defined in the shader
  83128. * @param value Define the value to give to the uniform
  83129. * @return the texture itself allowing "fluent" like uniform updates
  83130. */
  83131. setColor4(name: string, value: Color4): ProceduralTexture;
  83132. /**
  83133. * Set a vec2 in the shader from a Vector2.
  83134. * @param name Define the name of the uniform as defined in the shader
  83135. * @param value Define the value to give to the uniform
  83136. * @return the texture itself allowing "fluent" like uniform updates
  83137. */
  83138. setVector2(name: string, value: Vector2): ProceduralTexture;
  83139. /**
  83140. * Set a vec3 in the shader from a Vector3.
  83141. * @param name Define the name of the uniform as defined in the shader
  83142. * @param value Define the value to give to the uniform
  83143. * @return the texture itself allowing "fluent" like uniform updates
  83144. */
  83145. setVector3(name: string, value: Vector3): ProceduralTexture;
  83146. /**
  83147. * Set a mat4 in the shader from a MAtrix.
  83148. * @param name Define the name of the uniform as defined in the shader
  83149. * @param value Define the value to give to the uniform
  83150. * @return the texture itself allowing "fluent" like uniform updates
  83151. */
  83152. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83153. /**
  83154. * Render the texture to its associated render target.
  83155. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83156. */
  83157. render(useCameraPostProcess?: boolean): void;
  83158. /**
  83159. * Clone the texture.
  83160. * @returns the cloned texture
  83161. */
  83162. clone(): ProceduralTexture;
  83163. /**
  83164. * Dispose the texture and release its asoociated resources.
  83165. */
  83166. dispose(): void;
  83167. }
  83168. }
  83169. declare module BABYLON {
  83170. /**
  83171. * This represents the base class for particle system in Babylon.
  83172. * 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.
  83173. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83174. * @example https://doc.babylonjs.com/babylon101/particles
  83175. */
  83176. export class BaseParticleSystem {
  83177. /**
  83178. * Source color is added to the destination color without alpha affecting the result
  83179. */
  83180. static BLENDMODE_ONEONE: number;
  83181. /**
  83182. * Blend current color and particle color using particle’s alpha
  83183. */
  83184. static BLENDMODE_STANDARD: number;
  83185. /**
  83186. * Add current color and particle color multiplied by particle’s alpha
  83187. */
  83188. static BLENDMODE_ADD: number;
  83189. /**
  83190. * Multiply current color with particle color
  83191. */
  83192. static BLENDMODE_MULTIPLY: number;
  83193. /**
  83194. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83195. */
  83196. static BLENDMODE_MULTIPLYADD: number;
  83197. /**
  83198. * List of animations used by the particle system.
  83199. */
  83200. animations: Animation[];
  83201. /**
  83202. * The id of the Particle system.
  83203. */
  83204. id: string;
  83205. /**
  83206. * The friendly name of the Particle system.
  83207. */
  83208. name: string;
  83209. /**
  83210. * The rendering group used by the Particle system to chose when to render.
  83211. */
  83212. renderingGroupId: number;
  83213. /**
  83214. * The emitter represents the Mesh or position we are attaching the particle system to.
  83215. */
  83216. emitter: Nullable<AbstractMesh | Vector3>;
  83217. /**
  83218. * The maximum number of particles to emit per frame
  83219. */
  83220. emitRate: number;
  83221. /**
  83222. * If you want to launch only a few particles at once, that can be done, as well.
  83223. */
  83224. manualEmitCount: number;
  83225. /**
  83226. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83227. */
  83228. updateSpeed: number;
  83229. /**
  83230. * The amount of time the particle system is running (depends of the overall update speed).
  83231. */
  83232. targetStopDuration: number;
  83233. /**
  83234. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83235. */
  83236. disposeOnStop: boolean;
  83237. /**
  83238. * Minimum power of emitting particles.
  83239. */
  83240. minEmitPower: number;
  83241. /**
  83242. * Maximum power of emitting particles.
  83243. */
  83244. maxEmitPower: number;
  83245. /**
  83246. * Minimum life time of emitting particles.
  83247. */
  83248. minLifeTime: number;
  83249. /**
  83250. * Maximum life time of emitting particles.
  83251. */
  83252. maxLifeTime: number;
  83253. /**
  83254. * Minimum Size of emitting particles.
  83255. */
  83256. minSize: number;
  83257. /**
  83258. * Maximum Size of emitting particles.
  83259. */
  83260. maxSize: number;
  83261. /**
  83262. * Minimum scale of emitting particles on X axis.
  83263. */
  83264. minScaleX: number;
  83265. /**
  83266. * Maximum scale of emitting particles on X axis.
  83267. */
  83268. maxScaleX: number;
  83269. /**
  83270. * Minimum scale of emitting particles on Y axis.
  83271. */
  83272. minScaleY: number;
  83273. /**
  83274. * Maximum scale of emitting particles on Y axis.
  83275. */
  83276. maxScaleY: number;
  83277. /**
  83278. * Gets or sets the minimal initial rotation in radians.
  83279. */
  83280. minInitialRotation: number;
  83281. /**
  83282. * Gets or sets the maximal initial rotation in radians.
  83283. */
  83284. maxInitialRotation: number;
  83285. /**
  83286. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83287. */
  83288. minAngularSpeed: number;
  83289. /**
  83290. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83291. */
  83292. maxAngularSpeed: number;
  83293. /**
  83294. * The texture used to render each particle. (this can be a spritesheet)
  83295. */
  83296. particleTexture: Nullable<Texture>;
  83297. /**
  83298. * The layer mask we are rendering the particles through.
  83299. */
  83300. layerMask: number;
  83301. /**
  83302. * This can help using your own shader to render the particle system.
  83303. * The according effect will be created
  83304. */
  83305. customShader: any;
  83306. /**
  83307. * By default particle system starts as soon as they are created. This prevents the
  83308. * automatic start to happen and let you decide when to start emitting particles.
  83309. */
  83310. preventAutoStart: boolean;
  83311. private _noiseTexture;
  83312. /**
  83313. * Gets or sets a texture used to add random noise to particle positions
  83314. */
  83315. noiseTexture: Nullable<ProceduralTexture>;
  83316. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83317. noiseStrength: Vector3;
  83318. /**
  83319. * Callback triggered when the particle animation is ending.
  83320. */
  83321. onAnimationEnd: Nullable<() => void>;
  83322. /**
  83323. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83324. */
  83325. blendMode: number;
  83326. /**
  83327. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83328. * to override the particles.
  83329. */
  83330. forceDepthWrite: boolean;
  83331. /** 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 */
  83332. preWarmCycles: number;
  83333. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83334. preWarmStepOffset: number;
  83335. /**
  83336. * 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)
  83337. */
  83338. spriteCellChangeSpeed: number;
  83339. /**
  83340. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83341. */
  83342. startSpriteCellID: number;
  83343. /**
  83344. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83345. */
  83346. endSpriteCellID: number;
  83347. /**
  83348. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83349. */
  83350. spriteCellWidth: number;
  83351. /**
  83352. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83353. */
  83354. spriteCellHeight: number;
  83355. /**
  83356. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83357. */
  83358. spriteRandomStartCell: boolean;
  83359. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83360. translationPivot: Vector2;
  83361. /** @hidden */
  83362. protected _isAnimationSheetEnabled: boolean;
  83363. /**
  83364. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83365. */
  83366. beginAnimationOnStart: boolean;
  83367. /**
  83368. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83369. */
  83370. beginAnimationFrom: number;
  83371. /**
  83372. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83373. */
  83374. beginAnimationTo: number;
  83375. /**
  83376. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83377. */
  83378. beginAnimationLoop: boolean;
  83379. /**
  83380. * Gets or sets a world offset applied to all particles
  83381. */
  83382. worldOffset: Vector3;
  83383. /**
  83384. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83385. */
  83386. isAnimationSheetEnabled: boolean;
  83387. /**
  83388. * Get hosting scene
  83389. * @returns the scene
  83390. */
  83391. getScene(): Scene;
  83392. /**
  83393. * You can use gravity if you want to give an orientation to your particles.
  83394. */
  83395. gravity: Vector3;
  83396. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83397. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83398. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83399. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83400. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83401. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83402. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83403. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83404. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83405. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83406. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83407. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83408. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83409. /**
  83410. * Defines the delay in milliseconds before starting the system (0 by default)
  83411. */
  83412. startDelay: number;
  83413. /**
  83414. * Gets the current list of drag gradients.
  83415. * You must use addDragGradient and removeDragGradient to udpate this list
  83416. * @returns the list of drag gradients
  83417. */
  83418. getDragGradients(): Nullable<Array<FactorGradient>>;
  83419. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83420. limitVelocityDamping: number;
  83421. /**
  83422. * Gets the current list of limit velocity gradients.
  83423. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83424. * @returns the list of limit velocity gradients
  83425. */
  83426. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83427. /**
  83428. * Gets the current list of color gradients.
  83429. * You must use addColorGradient and removeColorGradient to udpate this list
  83430. * @returns the list of color gradients
  83431. */
  83432. getColorGradients(): Nullable<Array<ColorGradient>>;
  83433. /**
  83434. * Gets the current list of size gradients.
  83435. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83436. * @returns the list of size gradients
  83437. */
  83438. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83439. /**
  83440. * Gets the current list of color remap gradients.
  83441. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83442. * @returns the list of color remap gradients
  83443. */
  83444. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83445. /**
  83446. * Gets the current list of alpha remap gradients.
  83447. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83448. * @returns the list of alpha remap gradients
  83449. */
  83450. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83451. /**
  83452. * Gets the current list of life time gradients.
  83453. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83454. * @returns the list of life time gradients
  83455. */
  83456. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83457. /**
  83458. * Gets the current list of angular speed gradients.
  83459. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83460. * @returns the list of angular speed gradients
  83461. */
  83462. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83463. /**
  83464. * Gets the current list of velocity gradients.
  83465. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83466. * @returns the list of velocity gradients
  83467. */
  83468. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83469. /**
  83470. * Gets the current list of start size gradients.
  83471. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83472. * @returns the list of start size gradients
  83473. */
  83474. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83475. /**
  83476. * Gets the current list of emit rate gradients.
  83477. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83478. * @returns the list of emit rate gradients
  83479. */
  83480. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83481. /**
  83482. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83483. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83484. */
  83485. direction1: Vector3;
  83486. /**
  83487. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83489. */
  83490. direction2: Vector3;
  83491. /**
  83492. * 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.
  83493. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83494. */
  83495. minEmitBox: Vector3;
  83496. /**
  83497. * 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.
  83498. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83499. */
  83500. maxEmitBox: Vector3;
  83501. /**
  83502. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83503. */
  83504. color1: Color4;
  83505. /**
  83506. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83507. */
  83508. color2: Color4;
  83509. /**
  83510. * Color the particle will have at the end of its lifetime
  83511. */
  83512. colorDead: Color4;
  83513. /**
  83514. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83515. */
  83516. textureMask: Color4;
  83517. /**
  83518. * The particle emitter type defines the emitter used by the particle system.
  83519. * It can be for example box, sphere, or cone...
  83520. */
  83521. particleEmitterType: IParticleEmitterType;
  83522. /** @hidden */
  83523. _isSubEmitter: boolean;
  83524. /**
  83525. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83526. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83527. */
  83528. billboardMode: number;
  83529. protected _isBillboardBased: boolean;
  83530. /**
  83531. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83532. */
  83533. isBillboardBased: boolean;
  83534. /**
  83535. * The scene the particle system belongs to.
  83536. */
  83537. protected _scene: Scene;
  83538. /**
  83539. * Local cache of defines for image processing.
  83540. */
  83541. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83542. /**
  83543. * Default configuration related to image processing available in the standard Material.
  83544. */
  83545. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83546. /**
  83547. * Gets the image processing configuration used either in this material.
  83548. */
  83549. /**
  83550. * Sets the Default image processing configuration used either in the this material.
  83551. *
  83552. * If sets to null, the scene one is in use.
  83553. */
  83554. imageProcessingConfiguration: ImageProcessingConfiguration;
  83555. /**
  83556. * Attaches a new image processing configuration to the Standard Material.
  83557. * @param configuration
  83558. */
  83559. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83560. /** @hidden */
  83561. protected _reset(): void;
  83562. /** @hidden */
  83563. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83564. /**
  83565. * Instantiates a particle system.
  83566. * 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.
  83567. * @param name The name of the particle system
  83568. */
  83569. constructor(name: string);
  83570. /**
  83571. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83572. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83573. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83574. * @returns the emitter
  83575. */
  83576. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83577. /**
  83578. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83579. * @param radius The radius of the hemisphere to emit from
  83580. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83581. * @returns the emitter
  83582. */
  83583. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83584. /**
  83585. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83586. * @param radius The radius of the sphere to emit from
  83587. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83588. * @returns the emitter
  83589. */
  83590. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83591. /**
  83592. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83593. * @param radius The radius of the sphere to emit from
  83594. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83595. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83596. * @returns the emitter
  83597. */
  83598. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83599. /**
  83600. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83601. * @param radius The radius of the emission cylinder
  83602. * @param height The height of the emission cylinder
  83603. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83604. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83605. * @returns the emitter
  83606. */
  83607. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83608. /**
  83609. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83610. * @param radius The radius of the cylinder to emit from
  83611. * @param height The height of the emission cylinder
  83612. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83615. * @returns the emitter
  83616. */
  83617. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83618. /**
  83619. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83620. * @param radius The radius of the cone to emit from
  83621. * @param angle The base angle of the cone
  83622. * @returns the emitter
  83623. */
  83624. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83625. /**
  83626. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83629. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83630. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83631. * @returns the emitter
  83632. */
  83633. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83634. }
  83635. }
  83636. declare module BABYLON {
  83637. /**
  83638. * Type of sub emitter
  83639. */
  83640. export enum SubEmitterType {
  83641. /**
  83642. * Attached to the particle over it's lifetime
  83643. */
  83644. ATTACHED = 0,
  83645. /**
  83646. * Created when the particle dies
  83647. */
  83648. END = 1
  83649. }
  83650. /**
  83651. * Sub emitter class used to emit particles from an existing particle
  83652. */
  83653. export class SubEmitter {
  83654. /**
  83655. * the particle system to be used by the sub emitter
  83656. */
  83657. particleSystem: ParticleSystem;
  83658. /**
  83659. * Type of the submitter (Default: END)
  83660. */
  83661. type: SubEmitterType;
  83662. /**
  83663. * 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)
  83664. * Note: This only is supported when using an emitter of type Mesh
  83665. */
  83666. inheritDirection: boolean;
  83667. /**
  83668. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83669. */
  83670. inheritedVelocityAmount: number;
  83671. /**
  83672. * Creates a sub emitter
  83673. * @param particleSystem the particle system to be used by the sub emitter
  83674. */
  83675. constructor(
  83676. /**
  83677. * the particle system to be used by the sub emitter
  83678. */
  83679. particleSystem: ParticleSystem);
  83680. /**
  83681. * Clones the sub emitter
  83682. * @returns the cloned sub emitter
  83683. */
  83684. clone(): SubEmitter;
  83685. /**
  83686. * Serialize current object to a JSON object
  83687. * @returns the serialized object
  83688. */
  83689. serialize(): any;
  83690. /** @hidden */
  83691. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83692. /**
  83693. * Creates a new SubEmitter from a serialized JSON version
  83694. * @param serializationObject defines the JSON object to read from
  83695. * @param scene defines the hosting scene
  83696. * @param rootUrl defines the rootUrl for data loading
  83697. * @returns a new SubEmitter
  83698. */
  83699. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83700. /** Release associated resources */
  83701. dispose(): void;
  83702. }
  83703. }
  83704. declare module BABYLON {
  83705. /** @hidden */
  83706. export var clipPlaneFragmentDeclaration: {
  83707. name: string;
  83708. shader: string;
  83709. };
  83710. }
  83711. declare module BABYLON {
  83712. /** @hidden */
  83713. export var imageProcessingDeclaration: {
  83714. name: string;
  83715. shader: string;
  83716. };
  83717. }
  83718. declare module BABYLON {
  83719. /** @hidden */
  83720. export var imageProcessingFunctions: {
  83721. name: string;
  83722. shader: string;
  83723. };
  83724. }
  83725. declare module BABYLON {
  83726. /** @hidden */
  83727. export var clipPlaneFragment: {
  83728. name: string;
  83729. shader: string;
  83730. };
  83731. }
  83732. declare module BABYLON {
  83733. /** @hidden */
  83734. export var particlesPixelShader: {
  83735. name: string;
  83736. shader: string;
  83737. };
  83738. }
  83739. declare module BABYLON {
  83740. /** @hidden */
  83741. export var clipPlaneVertexDeclaration: {
  83742. name: string;
  83743. shader: string;
  83744. };
  83745. }
  83746. declare module BABYLON {
  83747. /** @hidden */
  83748. export var clipPlaneVertex: {
  83749. name: string;
  83750. shader: string;
  83751. };
  83752. }
  83753. declare module BABYLON {
  83754. /** @hidden */
  83755. export var particlesVertexShader: {
  83756. name: string;
  83757. shader: string;
  83758. };
  83759. }
  83760. declare module BABYLON {
  83761. /**
  83762. * This represents a particle system in Babylon.
  83763. * 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.
  83764. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83765. * @example https://doc.babylonjs.com/babylon101/particles
  83766. */
  83767. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83768. /**
  83769. * Billboard mode will only apply to Y axis
  83770. */
  83771. static readonly BILLBOARDMODE_Y: number;
  83772. /**
  83773. * Billboard mode will apply to all axes
  83774. */
  83775. static readonly BILLBOARDMODE_ALL: number;
  83776. /**
  83777. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83778. */
  83779. static readonly BILLBOARDMODE_STRETCHED: number;
  83780. /**
  83781. * This function can be defined to provide custom update for active particles.
  83782. * This function will be called instead of regular update (age, position, color, etc.).
  83783. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83784. */
  83785. updateFunction: (particles: Particle[]) => void;
  83786. private _emitterWorldMatrix;
  83787. /**
  83788. * This function can be defined to specify initial direction for every new particle.
  83789. * It by default use the emitterType defined function
  83790. */
  83791. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83792. /**
  83793. * This function can be defined to specify initial position for every new particle.
  83794. * It by default use the emitterType defined function
  83795. */
  83796. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83797. /**
  83798. * @hidden
  83799. */
  83800. _inheritedVelocityOffset: Vector3;
  83801. /**
  83802. * An event triggered when the system is disposed
  83803. */
  83804. onDisposeObservable: Observable<ParticleSystem>;
  83805. private _onDisposeObserver;
  83806. /**
  83807. * Sets a callback that will be triggered when the system is disposed
  83808. */
  83809. onDispose: () => void;
  83810. private _particles;
  83811. private _epsilon;
  83812. private _capacity;
  83813. private _stockParticles;
  83814. private _newPartsExcess;
  83815. private _vertexData;
  83816. private _vertexBuffer;
  83817. private _vertexBuffers;
  83818. private _spriteBuffer;
  83819. private _indexBuffer;
  83820. private _effect;
  83821. private _customEffect;
  83822. private _cachedDefines;
  83823. private _scaledColorStep;
  83824. private _colorDiff;
  83825. private _scaledDirection;
  83826. private _scaledGravity;
  83827. private _currentRenderId;
  83828. private _alive;
  83829. private _useInstancing;
  83830. private _started;
  83831. private _stopped;
  83832. private _actualFrame;
  83833. private _scaledUpdateSpeed;
  83834. private _vertexBufferSize;
  83835. /** @hidden */
  83836. _currentEmitRateGradient: Nullable<FactorGradient>;
  83837. /** @hidden */
  83838. _currentEmitRate1: number;
  83839. /** @hidden */
  83840. _currentEmitRate2: number;
  83841. /** @hidden */
  83842. _currentStartSizeGradient: Nullable<FactorGradient>;
  83843. /** @hidden */
  83844. _currentStartSize1: number;
  83845. /** @hidden */
  83846. _currentStartSize2: number;
  83847. private readonly _rawTextureWidth;
  83848. private _rampGradientsTexture;
  83849. private _useRampGradients;
  83850. /** Gets or sets a boolean indicating that ramp gradients must be used
  83851. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83852. */
  83853. useRampGradients: boolean;
  83854. /**
  83855. * 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.
  83856. * 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: [])
  83857. */
  83858. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83859. private _subEmitters;
  83860. /**
  83861. * @hidden
  83862. * If the particle systems emitter should be disposed when the particle system is disposed
  83863. */
  83864. _disposeEmitterOnDispose: boolean;
  83865. /**
  83866. * The current active Sub-systems, this property is used by the root particle system only.
  83867. */
  83868. activeSubSystems: Array<ParticleSystem>;
  83869. private _rootParticleSystem;
  83870. /**
  83871. * Gets the current list of active particles
  83872. */
  83873. readonly particles: Particle[];
  83874. /**
  83875. * Returns the string "ParticleSystem"
  83876. * @returns a string containing the class name
  83877. */
  83878. getClassName(): string;
  83879. /**
  83880. * Instantiates a particle system.
  83881. * 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.
  83882. * @param name The name of the particle system
  83883. * @param capacity The max number of particles alive at the same time
  83884. * @param scene The scene the particle system belongs to
  83885. * @param customEffect a custom effect used to change the way particles are rendered by default
  83886. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83887. * @param epsilon Offset used to render the particles
  83888. */
  83889. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83890. private _addFactorGradient;
  83891. private _removeFactorGradient;
  83892. /**
  83893. * Adds a new life time gradient
  83894. * @param gradient defines the gradient to use (between 0 and 1)
  83895. * @param factor defines the life time factor to affect to the specified gradient
  83896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83897. * @returns the current particle system
  83898. */
  83899. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83900. /**
  83901. * Remove a specific life time gradient
  83902. * @param gradient defines the gradient to remove
  83903. * @returns the current particle system
  83904. */
  83905. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83906. /**
  83907. * Adds a new size gradient
  83908. * @param gradient defines the gradient to use (between 0 and 1)
  83909. * @param factor defines the size factor to affect to the specified gradient
  83910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83911. * @returns the current particle system
  83912. */
  83913. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83914. /**
  83915. * Remove a specific size gradient
  83916. * @param gradient defines the gradient to remove
  83917. * @returns the current particle system
  83918. */
  83919. removeSizeGradient(gradient: number): IParticleSystem;
  83920. /**
  83921. * Adds a new color remap gradient
  83922. * @param gradient defines the gradient to use (between 0 and 1)
  83923. * @param min defines the color remap minimal range
  83924. * @param max defines the color remap maximal range
  83925. * @returns the current particle system
  83926. */
  83927. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83928. /**
  83929. * Remove a specific color remap gradient
  83930. * @param gradient defines the gradient to remove
  83931. * @returns the current particle system
  83932. */
  83933. removeColorRemapGradient(gradient: number): IParticleSystem;
  83934. /**
  83935. * Adds a new alpha remap gradient
  83936. * @param gradient defines the gradient to use (between 0 and 1)
  83937. * @param min defines the alpha remap minimal range
  83938. * @param max defines the alpha remap maximal range
  83939. * @returns the current particle system
  83940. */
  83941. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83942. /**
  83943. * Remove a specific alpha remap gradient
  83944. * @param gradient defines the gradient to remove
  83945. * @returns the current particle system
  83946. */
  83947. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83948. /**
  83949. * Adds a new angular speed gradient
  83950. * @param gradient defines the gradient to use (between 0 and 1)
  83951. * @param factor defines the angular speed to affect to the specified gradient
  83952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83953. * @returns the current particle system
  83954. */
  83955. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83956. /**
  83957. * Remove a specific angular speed gradient
  83958. * @param gradient defines the gradient to remove
  83959. * @returns the current particle system
  83960. */
  83961. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83962. /**
  83963. * Adds a new velocity gradient
  83964. * @param gradient defines the gradient to use (between 0 and 1)
  83965. * @param factor defines the velocity to affect to the specified gradient
  83966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83967. * @returns the current particle system
  83968. */
  83969. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83970. /**
  83971. * Remove a specific velocity gradient
  83972. * @param gradient defines the gradient to remove
  83973. * @returns the current particle system
  83974. */
  83975. removeVelocityGradient(gradient: number): IParticleSystem;
  83976. /**
  83977. * Adds a new limit velocity gradient
  83978. * @param gradient defines the gradient to use (between 0 and 1)
  83979. * @param factor defines the limit velocity value to affect to the specified gradient
  83980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83981. * @returns the current particle system
  83982. */
  83983. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83984. /**
  83985. * Remove a specific limit velocity gradient
  83986. * @param gradient defines the gradient to remove
  83987. * @returns the current particle system
  83988. */
  83989. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83990. /**
  83991. * Adds a new drag gradient
  83992. * @param gradient defines the gradient to use (between 0 and 1)
  83993. * @param factor defines the drag value to affect to the specified gradient
  83994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83995. * @returns the current particle system
  83996. */
  83997. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83998. /**
  83999. * Remove a specific drag gradient
  84000. * @param gradient defines the gradient to remove
  84001. * @returns the current particle system
  84002. */
  84003. removeDragGradient(gradient: number): IParticleSystem;
  84004. /**
  84005. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84006. * @param gradient defines the gradient to use (between 0 and 1)
  84007. * @param factor defines the emit rate value to affect to the specified gradient
  84008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84009. * @returns the current particle system
  84010. */
  84011. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84012. /**
  84013. * Remove a specific emit rate gradient
  84014. * @param gradient defines the gradient to remove
  84015. * @returns the current particle system
  84016. */
  84017. removeEmitRateGradient(gradient: number): IParticleSystem;
  84018. /**
  84019. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84020. * @param gradient defines the gradient to use (between 0 and 1)
  84021. * @param factor defines the start size value to affect to the specified gradient
  84022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84023. * @returns the current particle system
  84024. */
  84025. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84026. /**
  84027. * Remove a specific start size gradient
  84028. * @param gradient defines the gradient to remove
  84029. * @returns the current particle system
  84030. */
  84031. removeStartSizeGradient(gradient: number): IParticleSystem;
  84032. private _createRampGradientTexture;
  84033. /**
  84034. * Gets the current list of ramp gradients.
  84035. * You must use addRampGradient and removeRampGradient to udpate this list
  84036. * @returns the list of ramp gradients
  84037. */
  84038. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84039. /**
  84040. * Adds a new ramp gradient used to remap particle colors
  84041. * @param gradient defines the gradient to use (between 0 and 1)
  84042. * @param color defines the color to affect to the specified gradient
  84043. * @returns the current particle system
  84044. */
  84045. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84046. /**
  84047. * Remove a specific ramp gradient
  84048. * @param gradient defines the gradient to remove
  84049. * @returns the current particle system
  84050. */
  84051. removeRampGradient(gradient: number): ParticleSystem;
  84052. /**
  84053. * Adds a new color gradient
  84054. * @param gradient defines the gradient to use (between 0 and 1)
  84055. * @param color1 defines the color to affect to the specified gradient
  84056. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84057. * @returns this particle system
  84058. */
  84059. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84060. /**
  84061. * Remove a specific color gradient
  84062. * @param gradient defines the gradient to remove
  84063. * @returns this particle system
  84064. */
  84065. removeColorGradient(gradient: number): IParticleSystem;
  84066. private _fetchR;
  84067. protected _reset(): void;
  84068. private _resetEffect;
  84069. private _createVertexBuffers;
  84070. private _createIndexBuffer;
  84071. /**
  84072. * Gets the maximum number of particles active at the same time.
  84073. * @returns The max number of active particles.
  84074. */
  84075. getCapacity(): number;
  84076. /**
  84077. * Gets whether there are still active particles in the system.
  84078. * @returns True if it is alive, otherwise false.
  84079. */
  84080. isAlive(): boolean;
  84081. /**
  84082. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84083. * @returns True if it has been started, otherwise false.
  84084. */
  84085. isStarted(): boolean;
  84086. private _prepareSubEmitterInternalArray;
  84087. /**
  84088. * Starts the particle system and begins to emit
  84089. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84090. */
  84091. start(delay?: number): void;
  84092. /**
  84093. * Stops the particle system.
  84094. * @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.
  84095. */
  84096. stop(stopSubEmitters?: boolean): void;
  84097. /**
  84098. * Remove all active particles
  84099. */
  84100. reset(): void;
  84101. /**
  84102. * @hidden (for internal use only)
  84103. */
  84104. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84105. /**
  84106. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84107. * Its lifetime will start back at 0.
  84108. */
  84109. recycleParticle: (particle: Particle) => void;
  84110. private _stopSubEmitters;
  84111. private _createParticle;
  84112. private _removeFromRoot;
  84113. private _emitFromParticle;
  84114. private _update;
  84115. /** @hidden */
  84116. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84117. /** @hidden */
  84118. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84119. /** @hidden */
  84120. private _getEffect;
  84121. /**
  84122. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84123. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84124. */
  84125. animate(preWarmOnly?: boolean): void;
  84126. private _appendParticleVertices;
  84127. /**
  84128. * Rebuilds the particle system.
  84129. */
  84130. rebuild(): void;
  84131. /**
  84132. * Is this system ready to be used/rendered
  84133. * @return true if the system is ready
  84134. */
  84135. isReady(): boolean;
  84136. private _render;
  84137. /**
  84138. * Renders the particle system in its current state.
  84139. * @returns the current number of particles
  84140. */
  84141. render(): number;
  84142. /**
  84143. * Disposes the particle system and free the associated resources
  84144. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84145. */
  84146. dispose(disposeTexture?: boolean): void;
  84147. /**
  84148. * Clones the particle system.
  84149. * @param name The name of the cloned object
  84150. * @param newEmitter The new emitter to use
  84151. * @returns the cloned particle system
  84152. */
  84153. clone(name: string, newEmitter: any): ParticleSystem;
  84154. /**
  84155. * Serializes the particle system to a JSON object.
  84156. * @returns the JSON object
  84157. */
  84158. serialize(): any;
  84159. /** @hidden */
  84160. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84161. /** @hidden */
  84162. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84163. /**
  84164. * Parses a JSON object to create a particle system.
  84165. * @param parsedParticleSystem The JSON object to parse
  84166. * @param scene The scene to create the particle system in
  84167. * @param rootUrl The root url to use to load external dependencies like texture
  84168. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84169. * @returns the Parsed particle system
  84170. */
  84171. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84172. }
  84173. }
  84174. declare module BABYLON {
  84175. /**
  84176. * A particle represents one of the element emitted by a particle system.
  84177. * This is mainly define by its coordinates, direction, velocity and age.
  84178. */
  84179. export class Particle {
  84180. /**
  84181. * The particle system the particle belongs to.
  84182. */
  84183. particleSystem: ParticleSystem;
  84184. private static _Count;
  84185. /**
  84186. * Unique ID of the particle
  84187. */
  84188. id: number;
  84189. /**
  84190. * The world position of the particle in the scene.
  84191. */
  84192. position: Vector3;
  84193. /**
  84194. * The world direction of the particle in the scene.
  84195. */
  84196. direction: Vector3;
  84197. /**
  84198. * The color of the particle.
  84199. */
  84200. color: Color4;
  84201. /**
  84202. * The color change of the particle per step.
  84203. */
  84204. colorStep: Color4;
  84205. /**
  84206. * Defines how long will the life of the particle be.
  84207. */
  84208. lifeTime: number;
  84209. /**
  84210. * The current age of the particle.
  84211. */
  84212. age: number;
  84213. /**
  84214. * The current size of the particle.
  84215. */
  84216. size: number;
  84217. /**
  84218. * The current scale of the particle.
  84219. */
  84220. scale: Vector2;
  84221. /**
  84222. * The current angle of the particle.
  84223. */
  84224. angle: number;
  84225. /**
  84226. * Defines how fast is the angle changing.
  84227. */
  84228. angularSpeed: number;
  84229. /**
  84230. * Defines the cell index used by the particle to be rendered from a sprite.
  84231. */
  84232. cellIndex: number;
  84233. /**
  84234. * The information required to support color remapping
  84235. */
  84236. remapData: Vector4;
  84237. /** @hidden */
  84238. _randomCellOffset?: number;
  84239. /** @hidden */
  84240. _initialDirection: Nullable<Vector3>;
  84241. /** @hidden */
  84242. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84243. /** @hidden */
  84244. _initialStartSpriteCellID: number;
  84245. /** @hidden */
  84246. _initialEndSpriteCellID: number;
  84247. /** @hidden */
  84248. _currentColorGradient: Nullable<ColorGradient>;
  84249. /** @hidden */
  84250. _currentColor1: Color4;
  84251. /** @hidden */
  84252. _currentColor2: Color4;
  84253. /** @hidden */
  84254. _currentSizeGradient: Nullable<FactorGradient>;
  84255. /** @hidden */
  84256. _currentSize1: number;
  84257. /** @hidden */
  84258. _currentSize2: number;
  84259. /** @hidden */
  84260. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84261. /** @hidden */
  84262. _currentAngularSpeed1: number;
  84263. /** @hidden */
  84264. _currentAngularSpeed2: number;
  84265. /** @hidden */
  84266. _currentVelocityGradient: Nullable<FactorGradient>;
  84267. /** @hidden */
  84268. _currentVelocity1: number;
  84269. /** @hidden */
  84270. _currentVelocity2: number;
  84271. /** @hidden */
  84272. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84273. /** @hidden */
  84274. _currentLimitVelocity1: number;
  84275. /** @hidden */
  84276. _currentLimitVelocity2: number;
  84277. /** @hidden */
  84278. _currentDragGradient: Nullable<FactorGradient>;
  84279. /** @hidden */
  84280. _currentDrag1: number;
  84281. /** @hidden */
  84282. _currentDrag2: number;
  84283. /** @hidden */
  84284. _randomNoiseCoordinates1: Vector3;
  84285. /** @hidden */
  84286. _randomNoiseCoordinates2: Vector3;
  84287. /**
  84288. * Creates a new instance Particle
  84289. * @param particleSystem the particle system the particle belongs to
  84290. */
  84291. constructor(
  84292. /**
  84293. * The particle system the particle belongs to.
  84294. */
  84295. particleSystem: ParticleSystem);
  84296. private updateCellInfoFromSystem;
  84297. /**
  84298. * Defines how the sprite cell index is updated for the particle
  84299. */
  84300. updateCellIndex(): void;
  84301. /** @hidden */
  84302. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84303. /** @hidden */
  84304. _inheritParticleInfoToSubEmitters(): void;
  84305. /** @hidden */
  84306. _reset(): void;
  84307. /**
  84308. * Copy the properties of particle to another one.
  84309. * @param other the particle to copy the information to.
  84310. */
  84311. copyTo(other: Particle): void;
  84312. }
  84313. }
  84314. declare module BABYLON {
  84315. /**
  84316. * Particle emitter represents a volume emitting particles.
  84317. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84318. */
  84319. export interface IParticleEmitterType {
  84320. /**
  84321. * Called by the particle System when the direction is computed for the created particle.
  84322. * @param worldMatrix is the world matrix of the particle system
  84323. * @param directionToUpdate is the direction vector to update with the result
  84324. * @param particle is the particle we are computed the direction for
  84325. */
  84326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84327. /**
  84328. * Called by the particle System when the position is computed for the created particle.
  84329. * @param worldMatrix is the world matrix of the particle system
  84330. * @param positionToUpdate is the position vector to update with the result
  84331. * @param particle is the particle we are computed the position for
  84332. */
  84333. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84334. /**
  84335. * Clones the current emitter and returns a copy of it
  84336. * @returns the new emitter
  84337. */
  84338. clone(): IParticleEmitterType;
  84339. /**
  84340. * Called by the GPUParticleSystem to setup the update shader
  84341. * @param effect defines the update shader
  84342. */
  84343. applyToShader(effect: Effect): void;
  84344. /**
  84345. * Returns a string to use to update the GPU particles update shader
  84346. * @returns the effect defines string
  84347. */
  84348. getEffectDefines(): string;
  84349. /**
  84350. * Returns a string representing the class name
  84351. * @returns a string containing the class name
  84352. */
  84353. getClassName(): string;
  84354. /**
  84355. * Serializes the particle system to a JSON object.
  84356. * @returns the JSON object
  84357. */
  84358. serialize(): any;
  84359. /**
  84360. * Parse properties from a JSON object
  84361. * @param serializationObject defines the JSON object
  84362. */
  84363. parse(serializationObject: any): void;
  84364. }
  84365. }
  84366. declare module BABYLON {
  84367. /**
  84368. * Particle emitter emitting particles from the inside of a box.
  84369. * It emits the particles randomly between 2 given directions.
  84370. */
  84371. export class BoxParticleEmitter implements IParticleEmitterType {
  84372. /**
  84373. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84374. */
  84375. direction1: Vector3;
  84376. /**
  84377. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84378. */
  84379. direction2: Vector3;
  84380. /**
  84381. * 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.
  84382. */
  84383. minEmitBox: Vector3;
  84384. /**
  84385. * 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.
  84386. */
  84387. maxEmitBox: Vector3;
  84388. /**
  84389. * Creates a new instance BoxParticleEmitter
  84390. */
  84391. constructor();
  84392. /**
  84393. * Called by the particle System when the direction is computed for the created particle.
  84394. * @param worldMatrix is the world matrix of the particle system
  84395. * @param directionToUpdate is the direction vector to update with the result
  84396. * @param particle is the particle we are computed the direction for
  84397. */
  84398. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84399. /**
  84400. * Called by the particle System when the position is computed for the created particle.
  84401. * @param worldMatrix is the world matrix of the particle system
  84402. * @param positionToUpdate is the position vector to update with the result
  84403. * @param particle is the particle we are computed the position for
  84404. */
  84405. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84406. /**
  84407. * Clones the current emitter and returns a copy of it
  84408. * @returns the new emitter
  84409. */
  84410. clone(): BoxParticleEmitter;
  84411. /**
  84412. * Called by the GPUParticleSystem to setup the update shader
  84413. * @param effect defines the update shader
  84414. */
  84415. applyToShader(effect: Effect): void;
  84416. /**
  84417. * Returns a string to use to update the GPU particles update shader
  84418. * @returns a string containng the defines string
  84419. */
  84420. getEffectDefines(): string;
  84421. /**
  84422. * Returns the string "BoxParticleEmitter"
  84423. * @returns a string containing the class name
  84424. */
  84425. getClassName(): string;
  84426. /**
  84427. * Serializes the particle system to a JSON object.
  84428. * @returns the JSON object
  84429. */
  84430. serialize(): any;
  84431. /**
  84432. * Parse properties from a JSON object
  84433. * @param serializationObject defines the JSON object
  84434. */
  84435. parse(serializationObject: any): void;
  84436. }
  84437. }
  84438. declare module BABYLON {
  84439. /**
  84440. * Particle emitter emitting particles from the inside of a cone.
  84441. * It emits the particles alongside the cone volume from the base to the particle.
  84442. * The emission direction might be randomized.
  84443. */
  84444. export class ConeParticleEmitter implements IParticleEmitterType {
  84445. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84446. directionRandomizer: number;
  84447. private _radius;
  84448. private _angle;
  84449. private _height;
  84450. /**
  84451. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84452. */
  84453. radiusRange: number;
  84454. /**
  84455. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84456. */
  84457. heightRange: number;
  84458. /**
  84459. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84460. */
  84461. emitFromSpawnPointOnly: boolean;
  84462. /**
  84463. * Gets or sets the radius of the emission cone
  84464. */
  84465. radius: number;
  84466. /**
  84467. * Gets or sets the angle of the emission cone
  84468. */
  84469. angle: number;
  84470. private _buildHeight;
  84471. /**
  84472. * Creates a new instance ConeParticleEmitter
  84473. * @param radius the radius of the emission cone (1 by default)
  84474. * @param angle the cone base angle (PI by default)
  84475. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84476. */
  84477. constructor(radius?: number, angle?: number,
  84478. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84479. directionRandomizer?: number);
  84480. /**
  84481. * Called by the particle System when the direction is computed for the created particle.
  84482. * @param worldMatrix is the world matrix of the particle system
  84483. * @param directionToUpdate is the direction vector to update with the result
  84484. * @param particle is the particle we are computed the direction for
  84485. */
  84486. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84487. /**
  84488. * Called by the particle System when the position is computed for the created particle.
  84489. * @param worldMatrix is the world matrix of the particle system
  84490. * @param positionToUpdate is the position vector to update with the result
  84491. * @param particle is the particle we are computed the position for
  84492. */
  84493. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84494. /**
  84495. * Clones the current emitter and returns a copy of it
  84496. * @returns the new emitter
  84497. */
  84498. clone(): ConeParticleEmitter;
  84499. /**
  84500. * Called by the GPUParticleSystem to setup the update shader
  84501. * @param effect defines the update shader
  84502. */
  84503. applyToShader(effect: Effect): void;
  84504. /**
  84505. * Returns a string to use to update the GPU particles update shader
  84506. * @returns a string containng the defines string
  84507. */
  84508. getEffectDefines(): string;
  84509. /**
  84510. * Returns the string "ConeParticleEmitter"
  84511. * @returns a string containing the class name
  84512. */
  84513. getClassName(): string;
  84514. /**
  84515. * Serializes the particle system to a JSON object.
  84516. * @returns the JSON object
  84517. */
  84518. serialize(): any;
  84519. /**
  84520. * Parse properties from a JSON object
  84521. * @param serializationObject defines the JSON object
  84522. */
  84523. parse(serializationObject: any): void;
  84524. }
  84525. }
  84526. declare module BABYLON {
  84527. /**
  84528. * Particle emitter emitting particles from the inside of a cylinder.
  84529. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84530. */
  84531. export class CylinderParticleEmitter implements IParticleEmitterType {
  84532. /**
  84533. * The radius of the emission cylinder.
  84534. */
  84535. radius: number;
  84536. /**
  84537. * The height of the emission cylinder.
  84538. */
  84539. height: number;
  84540. /**
  84541. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84542. */
  84543. radiusRange: number;
  84544. /**
  84545. * How much to randomize the particle direction [0-1].
  84546. */
  84547. directionRandomizer: number;
  84548. /**
  84549. * Creates a new instance CylinderParticleEmitter
  84550. * @param radius the radius of the emission cylinder (1 by default)
  84551. * @param height the height of the emission cylinder (1 by default)
  84552. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84553. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84554. */
  84555. constructor(
  84556. /**
  84557. * The radius of the emission cylinder.
  84558. */
  84559. radius?: number,
  84560. /**
  84561. * The height of the emission cylinder.
  84562. */
  84563. height?: number,
  84564. /**
  84565. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84566. */
  84567. radiusRange?: number,
  84568. /**
  84569. * How much to randomize the particle direction [0-1].
  84570. */
  84571. directionRandomizer?: number);
  84572. /**
  84573. * Called by the particle System when the direction is computed for the created particle.
  84574. * @param worldMatrix is the world matrix of the particle system
  84575. * @param directionToUpdate is the direction vector to update with the result
  84576. * @param particle is the particle we are computed the direction for
  84577. */
  84578. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84579. /**
  84580. * Called by the particle System when the position is computed for the created particle.
  84581. * @param worldMatrix is the world matrix of the particle system
  84582. * @param positionToUpdate is the position vector to update with the result
  84583. * @param particle is the particle we are computed the position for
  84584. */
  84585. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84586. /**
  84587. * Clones the current emitter and returns a copy of it
  84588. * @returns the new emitter
  84589. */
  84590. clone(): CylinderParticleEmitter;
  84591. /**
  84592. * Called by the GPUParticleSystem to setup the update shader
  84593. * @param effect defines the update shader
  84594. */
  84595. applyToShader(effect: Effect): void;
  84596. /**
  84597. * Returns a string to use to update the GPU particles update shader
  84598. * @returns a string containng the defines string
  84599. */
  84600. getEffectDefines(): string;
  84601. /**
  84602. * Returns the string "CylinderParticleEmitter"
  84603. * @returns a string containing the class name
  84604. */
  84605. getClassName(): string;
  84606. /**
  84607. * Serializes the particle system to a JSON object.
  84608. * @returns the JSON object
  84609. */
  84610. serialize(): any;
  84611. /**
  84612. * Parse properties from a JSON object
  84613. * @param serializationObject defines the JSON object
  84614. */
  84615. parse(serializationObject: any): void;
  84616. }
  84617. /**
  84618. * Particle emitter emitting particles from the inside of a cylinder.
  84619. * It emits the particles randomly between two vectors.
  84620. */
  84621. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84622. /**
  84623. * The min limit of the emission direction.
  84624. */
  84625. direction1: Vector3;
  84626. /**
  84627. * The max limit of the emission direction.
  84628. */
  84629. direction2: Vector3;
  84630. /**
  84631. * Creates a new instance CylinderDirectedParticleEmitter
  84632. * @param radius the radius of the emission cylinder (1 by default)
  84633. * @param height the height of the emission cylinder (1 by default)
  84634. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84635. * @param direction1 the min limit of the emission direction (up vector by default)
  84636. * @param direction2 the max limit of the emission direction (up vector by default)
  84637. */
  84638. constructor(radius?: number, height?: number, radiusRange?: number,
  84639. /**
  84640. * The min limit of the emission direction.
  84641. */
  84642. direction1?: Vector3,
  84643. /**
  84644. * The max limit of the emission direction.
  84645. */
  84646. direction2?: Vector3);
  84647. /**
  84648. * Called by the particle System when the direction is computed for the created particle.
  84649. * @param worldMatrix is the world matrix of the particle system
  84650. * @param directionToUpdate is the direction vector to update with the result
  84651. * @param particle is the particle we are computed the direction for
  84652. */
  84653. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84654. /**
  84655. * Clones the current emitter and returns a copy of it
  84656. * @returns the new emitter
  84657. */
  84658. clone(): CylinderDirectedParticleEmitter;
  84659. /**
  84660. * Called by the GPUParticleSystem to setup the update shader
  84661. * @param effect defines the update shader
  84662. */
  84663. applyToShader(effect: Effect): void;
  84664. /**
  84665. * Returns a string to use to update the GPU particles update shader
  84666. * @returns a string containng the defines string
  84667. */
  84668. getEffectDefines(): string;
  84669. /**
  84670. * Returns the string "CylinderDirectedParticleEmitter"
  84671. * @returns a string containing the class name
  84672. */
  84673. getClassName(): string;
  84674. /**
  84675. * Serializes the particle system to a JSON object.
  84676. * @returns the JSON object
  84677. */
  84678. serialize(): any;
  84679. /**
  84680. * Parse properties from a JSON object
  84681. * @param serializationObject defines the JSON object
  84682. */
  84683. parse(serializationObject: any): void;
  84684. }
  84685. }
  84686. declare module BABYLON {
  84687. /**
  84688. * Particle emitter emitting particles from the inside of a hemisphere.
  84689. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84690. */
  84691. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84692. /**
  84693. * The radius of the emission hemisphere.
  84694. */
  84695. radius: number;
  84696. /**
  84697. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84698. */
  84699. radiusRange: number;
  84700. /**
  84701. * How much to randomize the particle direction [0-1].
  84702. */
  84703. directionRandomizer: number;
  84704. /**
  84705. * Creates a new instance HemisphericParticleEmitter
  84706. * @param radius the radius of the emission hemisphere (1 by default)
  84707. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84708. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84709. */
  84710. constructor(
  84711. /**
  84712. * The radius of the emission hemisphere.
  84713. */
  84714. radius?: number,
  84715. /**
  84716. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84717. */
  84718. radiusRange?: number,
  84719. /**
  84720. * How much to randomize the particle direction [0-1].
  84721. */
  84722. directionRandomizer?: number);
  84723. /**
  84724. * Called by the particle System when the direction is computed for the created particle.
  84725. * @param worldMatrix is the world matrix of the particle system
  84726. * @param directionToUpdate is the direction vector to update with the result
  84727. * @param particle is the particle we are computed the direction for
  84728. */
  84729. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84730. /**
  84731. * Called by the particle System when the position is computed for the created particle.
  84732. * @param worldMatrix is the world matrix of the particle system
  84733. * @param positionToUpdate is the position vector to update with the result
  84734. * @param particle is the particle we are computed the position for
  84735. */
  84736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84737. /**
  84738. * Clones the current emitter and returns a copy of it
  84739. * @returns the new emitter
  84740. */
  84741. clone(): HemisphericParticleEmitter;
  84742. /**
  84743. * Called by the GPUParticleSystem to setup the update shader
  84744. * @param effect defines the update shader
  84745. */
  84746. applyToShader(effect: Effect): void;
  84747. /**
  84748. * Returns a string to use to update the GPU particles update shader
  84749. * @returns a string containng the defines string
  84750. */
  84751. getEffectDefines(): string;
  84752. /**
  84753. * Returns the string "HemisphericParticleEmitter"
  84754. * @returns a string containing the class name
  84755. */
  84756. getClassName(): string;
  84757. /**
  84758. * Serializes the particle system to a JSON object.
  84759. * @returns the JSON object
  84760. */
  84761. serialize(): any;
  84762. /**
  84763. * Parse properties from a JSON object
  84764. * @param serializationObject defines the JSON object
  84765. */
  84766. parse(serializationObject: any): void;
  84767. }
  84768. }
  84769. declare module BABYLON {
  84770. /**
  84771. * Particle emitter emitting particles from a point.
  84772. * It emits the particles randomly between 2 given directions.
  84773. */
  84774. export class PointParticleEmitter implements IParticleEmitterType {
  84775. /**
  84776. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84777. */
  84778. direction1: Vector3;
  84779. /**
  84780. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84781. */
  84782. direction2: Vector3;
  84783. /**
  84784. * Creates a new instance PointParticleEmitter
  84785. */
  84786. constructor();
  84787. /**
  84788. * Called by the particle System when the direction is computed for the created particle.
  84789. * @param worldMatrix is the world matrix of the particle system
  84790. * @param directionToUpdate is the direction vector to update with the result
  84791. * @param particle is the particle we are computed the direction for
  84792. */
  84793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84794. /**
  84795. * Called by the particle System when the position is computed for the created particle.
  84796. * @param worldMatrix is the world matrix of the particle system
  84797. * @param positionToUpdate is the position vector to update with the result
  84798. * @param particle is the particle we are computed the position for
  84799. */
  84800. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84801. /**
  84802. * Clones the current emitter and returns a copy of it
  84803. * @returns the new emitter
  84804. */
  84805. clone(): PointParticleEmitter;
  84806. /**
  84807. * Called by the GPUParticleSystem to setup the update shader
  84808. * @param effect defines the update shader
  84809. */
  84810. applyToShader(effect: Effect): void;
  84811. /**
  84812. * Returns a string to use to update the GPU particles update shader
  84813. * @returns a string containng the defines string
  84814. */
  84815. getEffectDefines(): string;
  84816. /**
  84817. * Returns the string "PointParticleEmitter"
  84818. * @returns a string containing the class name
  84819. */
  84820. getClassName(): string;
  84821. /**
  84822. * Serializes the particle system to a JSON object.
  84823. * @returns the JSON object
  84824. */
  84825. serialize(): any;
  84826. /**
  84827. * Parse properties from a JSON object
  84828. * @param serializationObject defines the JSON object
  84829. */
  84830. parse(serializationObject: any): void;
  84831. }
  84832. }
  84833. declare module BABYLON {
  84834. /**
  84835. * Particle emitter emitting particles from the inside of a sphere.
  84836. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84837. */
  84838. export class SphereParticleEmitter implements IParticleEmitterType {
  84839. /**
  84840. * The radius of the emission sphere.
  84841. */
  84842. radius: number;
  84843. /**
  84844. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84845. */
  84846. radiusRange: number;
  84847. /**
  84848. * How much to randomize the particle direction [0-1].
  84849. */
  84850. directionRandomizer: number;
  84851. /**
  84852. * Creates a new instance SphereParticleEmitter
  84853. * @param radius the radius of the emission sphere (1 by default)
  84854. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84855. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84856. */
  84857. constructor(
  84858. /**
  84859. * The radius of the emission sphere.
  84860. */
  84861. radius?: number,
  84862. /**
  84863. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84864. */
  84865. radiusRange?: number,
  84866. /**
  84867. * How much to randomize the particle direction [0-1].
  84868. */
  84869. directionRandomizer?: number);
  84870. /**
  84871. * Called by the particle System when the direction is computed for the created particle.
  84872. * @param worldMatrix is the world matrix of the particle system
  84873. * @param directionToUpdate is the direction vector to update with the result
  84874. * @param particle is the particle we are computed the direction for
  84875. */
  84876. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84877. /**
  84878. * Called by the particle System when the position is computed for the created particle.
  84879. * @param worldMatrix is the world matrix of the particle system
  84880. * @param positionToUpdate is the position vector to update with the result
  84881. * @param particle is the particle we are computed the position for
  84882. */
  84883. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84884. /**
  84885. * Clones the current emitter and returns a copy of it
  84886. * @returns the new emitter
  84887. */
  84888. clone(): SphereParticleEmitter;
  84889. /**
  84890. * Called by the GPUParticleSystem to setup the update shader
  84891. * @param effect defines the update shader
  84892. */
  84893. applyToShader(effect: Effect): void;
  84894. /**
  84895. * Returns a string to use to update the GPU particles update shader
  84896. * @returns a string containng the defines string
  84897. */
  84898. getEffectDefines(): string;
  84899. /**
  84900. * Returns the string "SphereParticleEmitter"
  84901. * @returns a string containing the class name
  84902. */
  84903. getClassName(): string;
  84904. /**
  84905. * Serializes the particle system to a JSON object.
  84906. * @returns the JSON object
  84907. */
  84908. serialize(): any;
  84909. /**
  84910. * Parse properties from a JSON object
  84911. * @param serializationObject defines the JSON object
  84912. */
  84913. parse(serializationObject: any): void;
  84914. }
  84915. /**
  84916. * Particle emitter emitting particles from the inside of a sphere.
  84917. * It emits the particles randomly between two vectors.
  84918. */
  84919. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84920. /**
  84921. * The min limit of the emission direction.
  84922. */
  84923. direction1: Vector3;
  84924. /**
  84925. * The max limit of the emission direction.
  84926. */
  84927. direction2: Vector3;
  84928. /**
  84929. * Creates a new instance SphereDirectedParticleEmitter
  84930. * @param radius the radius of the emission sphere (1 by default)
  84931. * @param direction1 the min limit of the emission direction (up vector by default)
  84932. * @param direction2 the max limit of the emission direction (up vector by default)
  84933. */
  84934. constructor(radius?: number,
  84935. /**
  84936. * The min limit of the emission direction.
  84937. */
  84938. direction1?: Vector3,
  84939. /**
  84940. * The max limit of the emission direction.
  84941. */
  84942. direction2?: Vector3);
  84943. /**
  84944. * Called by the particle System when the direction is computed for the created particle.
  84945. * @param worldMatrix is the world matrix of the particle system
  84946. * @param directionToUpdate is the direction vector to update with the result
  84947. * @param particle is the particle we are computed the direction for
  84948. */
  84949. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84950. /**
  84951. * Clones the current emitter and returns a copy of it
  84952. * @returns the new emitter
  84953. */
  84954. clone(): SphereDirectedParticleEmitter;
  84955. /**
  84956. * Called by the GPUParticleSystem to setup the update shader
  84957. * @param effect defines the update shader
  84958. */
  84959. applyToShader(effect: Effect): void;
  84960. /**
  84961. * Returns a string to use to update the GPU particles update shader
  84962. * @returns a string containng the defines string
  84963. */
  84964. getEffectDefines(): string;
  84965. /**
  84966. * Returns the string "SphereDirectedParticleEmitter"
  84967. * @returns a string containing the class name
  84968. */
  84969. getClassName(): string;
  84970. /**
  84971. * Serializes the particle system to a JSON object.
  84972. * @returns the JSON object
  84973. */
  84974. serialize(): any;
  84975. /**
  84976. * Parse properties from a JSON object
  84977. * @param serializationObject defines the JSON object
  84978. */
  84979. parse(serializationObject: any): void;
  84980. }
  84981. }
  84982. declare module BABYLON {
  84983. /**
  84984. * Interface representing a particle system in Babylon.js.
  84985. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84986. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84987. */
  84988. export interface IParticleSystem {
  84989. /**
  84990. * List of animations used by the particle system.
  84991. */
  84992. animations: Animation[];
  84993. /**
  84994. * The id of the Particle system.
  84995. */
  84996. id: string;
  84997. /**
  84998. * The name of the Particle system.
  84999. */
  85000. name: string;
  85001. /**
  85002. * The emitter represents the Mesh or position we are attaching the particle system to.
  85003. */
  85004. emitter: Nullable<AbstractMesh | Vector3>;
  85005. /**
  85006. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85007. */
  85008. isBillboardBased: boolean;
  85009. /**
  85010. * The rendering group used by the Particle system to chose when to render.
  85011. */
  85012. renderingGroupId: number;
  85013. /**
  85014. * The layer mask we are rendering the particles through.
  85015. */
  85016. layerMask: number;
  85017. /**
  85018. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85019. */
  85020. updateSpeed: number;
  85021. /**
  85022. * The amount of time the particle system is running (depends of the overall update speed).
  85023. */
  85024. targetStopDuration: number;
  85025. /**
  85026. * The texture used to render each particle. (this can be a spritesheet)
  85027. */
  85028. particleTexture: Nullable<Texture>;
  85029. /**
  85030. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85031. */
  85032. blendMode: number;
  85033. /**
  85034. * Minimum life time of emitting particles.
  85035. */
  85036. minLifeTime: number;
  85037. /**
  85038. * Maximum life time of emitting particles.
  85039. */
  85040. maxLifeTime: number;
  85041. /**
  85042. * Minimum Size of emitting particles.
  85043. */
  85044. minSize: number;
  85045. /**
  85046. * Maximum Size of emitting particles.
  85047. */
  85048. maxSize: number;
  85049. /**
  85050. * Minimum scale of emitting particles on X axis.
  85051. */
  85052. minScaleX: number;
  85053. /**
  85054. * Maximum scale of emitting particles on X axis.
  85055. */
  85056. maxScaleX: number;
  85057. /**
  85058. * Minimum scale of emitting particles on Y axis.
  85059. */
  85060. minScaleY: number;
  85061. /**
  85062. * Maximum scale of emitting particles on Y axis.
  85063. */
  85064. maxScaleY: number;
  85065. /**
  85066. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85067. */
  85068. color1: Color4;
  85069. /**
  85070. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85071. */
  85072. color2: Color4;
  85073. /**
  85074. * Color the particle will have at the end of its lifetime.
  85075. */
  85076. colorDead: Color4;
  85077. /**
  85078. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85079. */
  85080. emitRate: number;
  85081. /**
  85082. * You can use gravity if you want to give an orientation to your particles.
  85083. */
  85084. gravity: Vector3;
  85085. /**
  85086. * Minimum power of emitting particles.
  85087. */
  85088. minEmitPower: number;
  85089. /**
  85090. * Maximum power of emitting particles.
  85091. */
  85092. maxEmitPower: number;
  85093. /**
  85094. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85095. */
  85096. minAngularSpeed: number;
  85097. /**
  85098. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85099. */
  85100. maxAngularSpeed: number;
  85101. /**
  85102. * Gets or sets the minimal initial rotation in radians.
  85103. */
  85104. minInitialRotation: number;
  85105. /**
  85106. * Gets or sets the maximal initial rotation in radians.
  85107. */
  85108. maxInitialRotation: number;
  85109. /**
  85110. * The particle emitter type defines the emitter used by the particle system.
  85111. * It can be for example box, sphere, or cone...
  85112. */
  85113. particleEmitterType: Nullable<IParticleEmitterType>;
  85114. /**
  85115. * Defines the delay in milliseconds before starting the system (0 by default)
  85116. */
  85117. startDelay: number;
  85118. /**
  85119. * 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
  85120. */
  85121. preWarmCycles: number;
  85122. /**
  85123. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85124. */
  85125. preWarmStepOffset: number;
  85126. /**
  85127. * 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)
  85128. */
  85129. spriteCellChangeSpeed: number;
  85130. /**
  85131. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85132. */
  85133. startSpriteCellID: number;
  85134. /**
  85135. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85136. */
  85137. endSpriteCellID: number;
  85138. /**
  85139. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85140. */
  85141. spriteCellWidth: number;
  85142. /**
  85143. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85144. */
  85145. spriteCellHeight: number;
  85146. /**
  85147. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85148. */
  85149. spriteRandomStartCell: boolean;
  85150. /**
  85151. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85152. */
  85153. isAnimationSheetEnabled: boolean;
  85154. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85155. translationPivot: Vector2;
  85156. /**
  85157. * Gets or sets a texture used to add random noise to particle positions
  85158. */
  85159. noiseTexture: Nullable<BaseTexture>;
  85160. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85161. noiseStrength: Vector3;
  85162. /**
  85163. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85164. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85165. */
  85166. billboardMode: number;
  85167. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85168. limitVelocityDamping: number;
  85169. /**
  85170. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85171. */
  85172. beginAnimationOnStart: boolean;
  85173. /**
  85174. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85175. */
  85176. beginAnimationFrom: number;
  85177. /**
  85178. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85179. */
  85180. beginAnimationTo: number;
  85181. /**
  85182. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85183. */
  85184. beginAnimationLoop: boolean;
  85185. /**
  85186. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85187. */
  85188. disposeOnStop: boolean;
  85189. /**
  85190. * Gets the maximum number of particles active at the same time.
  85191. * @returns The max number of active particles.
  85192. */
  85193. getCapacity(): number;
  85194. /**
  85195. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85196. * @returns True if it has been started, otherwise false.
  85197. */
  85198. isStarted(): boolean;
  85199. /**
  85200. * Animates the particle system for this frame.
  85201. */
  85202. animate(): void;
  85203. /**
  85204. * Renders the particle system in its current state.
  85205. * @returns the current number of particles
  85206. */
  85207. render(): number;
  85208. /**
  85209. * Dispose the particle system and frees its associated resources.
  85210. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85211. */
  85212. dispose(disposeTexture?: boolean): void;
  85213. /**
  85214. * Clones the particle system.
  85215. * @param name The name of the cloned object
  85216. * @param newEmitter The new emitter to use
  85217. * @returns the cloned particle system
  85218. */
  85219. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85220. /**
  85221. * Serializes the particle system to a JSON object.
  85222. * @returns the JSON object
  85223. */
  85224. serialize(): any;
  85225. /**
  85226. * Rebuild the particle system
  85227. */
  85228. rebuild(): void;
  85229. /**
  85230. * Starts the particle system and begins to emit
  85231. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85232. */
  85233. start(delay?: number): void;
  85234. /**
  85235. * Stops the particle system.
  85236. */
  85237. stop(): void;
  85238. /**
  85239. * Remove all active particles
  85240. */
  85241. reset(): void;
  85242. /**
  85243. * Is this system ready to be used/rendered
  85244. * @return true if the system is ready
  85245. */
  85246. isReady(): boolean;
  85247. /**
  85248. * Adds a new color gradient
  85249. * @param gradient defines the gradient to use (between 0 and 1)
  85250. * @param color1 defines the color to affect to the specified gradient
  85251. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85252. * @returns the current particle system
  85253. */
  85254. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85255. /**
  85256. * Remove a specific color gradient
  85257. * @param gradient defines the gradient to remove
  85258. * @returns the current particle system
  85259. */
  85260. removeColorGradient(gradient: number): IParticleSystem;
  85261. /**
  85262. * Adds a new size gradient
  85263. * @param gradient defines the gradient to use (between 0 and 1)
  85264. * @param factor defines the size factor to affect to the specified gradient
  85265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85266. * @returns the current particle system
  85267. */
  85268. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85269. /**
  85270. * Remove a specific size gradient
  85271. * @param gradient defines the gradient to remove
  85272. * @returns the current particle system
  85273. */
  85274. removeSizeGradient(gradient: number): IParticleSystem;
  85275. /**
  85276. * Gets the current list of color gradients.
  85277. * You must use addColorGradient and removeColorGradient to udpate this list
  85278. * @returns the list of color gradients
  85279. */
  85280. getColorGradients(): Nullable<Array<ColorGradient>>;
  85281. /**
  85282. * Gets the current list of size gradients.
  85283. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85284. * @returns the list of size gradients
  85285. */
  85286. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85287. /**
  85288. * Gets the current list of angular speed gradients.
  85289. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85290. * @returns the list of angular speed gradients
  85291. */
  85292. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85293. /**
  85294. * Adds a new angular speed gradient
  85295. * @param gradient defines the gradient to use (between 0 and 1)
  85296. * @param factor defines the angular speed to affect to the specified gradient
  85297. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85298. * @returns the current particle system
  85299. */
  85300. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85301. /**
  85302. * Remove a specific angular speed gradient
  85303. * @param gradient defines the gradient to remove
  85304. * @returns the current particle system
  85305. */
  85306. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85307. /**
  85308. * Gets the current list of velocity gradients.
  85309. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85310. * @returns the list of velocity gradients
  85311. */
  85312. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85313. /**
  85314. * Adds a new velocity gradient
  85315. * @param gradient defines the gradient to use (between 0 and 1)
  85316. * @param factor defines the velocity to affect to the specified gradient
  85317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85318. * @returns the current particle system
  85319. */
  85320. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85321. /**
  85322. * Remove a specific velocity gradient
  85323. * @param gradient defines the gradient to remove
  85324. * @returns the current particle system
  85325. */
  85326. removeVelocityGradient(gradient: number): IParticleSystem;
  85327. /**
  85328. * Gets the current list of limit velocity gradients.
  85329. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85330. * @returns the list of limit velocity gradients
  85331. */
  85332. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85333. /**
  85334. * Adds a new limit velocity gradient
  85335. * @param gradient defines the gradient to use (between 0 and 1)
  85336. * @param factor defines the limit velocity to affect to the specified gradient
  85337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85338. * @returns the current particle system
  85339. */
  85340. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85341. /**
  85342. * Remove a specific limit velocity gradient
  85343. * @param gradient defines the gradient to remove
  85344. * @returns the current particle system
  85345. */
  85346. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85347. /**
  85348. * Adds a new drag gradient
  85349. * @param gradient defines the gradient to use (between 0 and 1)
  85350. * @param factor defines the drag to affect to the specified gradient
  85351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85352. * @returns the current particle system
  85353. */
  85354. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85355. /**
  85356. * Remove a specific drag gradient
  85357. * @param gradient defines the gradient to remove
  85358. * @returns the current particle system
  85359. */
  85360. removeDragGradient(gradient: number): IParticleSystem;
  85361. /**
  85362. * Gets the current list of drag gradients.
  85363. * You must use addDragGradient and removeDragGradient to udpate this list
  85364. * @returns the list of drag gradients
  85365. */
  85366. getDragGradients(): Nullable<Array<FactorGradient>>;
  85367. /**
  85368. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85369. * @param gradient defines the gradient to use (between 0 and 1)
  85370. * @param factor defines the emit rate to affect to the specified gradient
  85371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85372. * @returns the current particle system
  85373. */
  85374. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85375. /**
  85376. * Remove a specific emit rate gradient
  85377. * @param gradient defines the gradient to remove
  85378. * @returns the current particle system
  85379. */
  85380. removeEmitRateGradient(gradient: number): IParticleSystem;
  85381. /**
  85382. * Gets the current list of emit rate gradients.
  85383. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85384. * @returns the list of emit rate gradients
  85385. */
  85386. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85387. /**
  85388. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85389. * @param gradient defines the gradient to use (between 0 and 1)
  85390. * @param factor defines the start size to affect to the specified gradient
  85391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85392. * @returns the current particle system
  85393. */
  85394. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85395. /**
  85396. * Remove a specific start size gradient
  85397. * @param gradient defines the gradient to remove
  85398. * @returns the current particle system
  85399. */
  85400. removeStartSizeGradient(gradient: number): IParticleSystem;
  85401. /**
  85402. * Gets the current list of start size gradients.
  85403. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85404. * @returns the list of start size gradients
  85405. */
  85406. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85407. /**
  85408. * Adds a new life time gradient
  85409. * @param gradient defines the gradient to use (between 0 and 1)
  85410. * @param factor defines the life time factor to affect to the specified gradient
  85411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85412. * @returns the current particle system
  85413. */
  85414. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85415. /**
  85416. * Remove a specific life time gradient
  85417. * @param gradient defines the gradient to remove
  85418. * @returns the current particle system
  85419. */
  85420. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85421. /**
  85422. * Gets the current list of life time gradients.
  85423. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85424. * @returns the list of life time gradients
  85425. */
  85426. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85427. /**
  85428. * Gets the current list of color gradients.
  85429. * You must use addColorGradient and removeColorGradient to udpate this list
  85430. * @returns the list of color gradients
  85431. */
  85432. getColorGradients(): Nullable<Array<ColorGradient>>;
  85433. /**
  85434. * Adds a new ramp gradient used to remap particle colors
  85435. * @param gradient defines the gradient to use (between 0 and 1)
  85436. * @param color defines the color to affect to the specified gradient
  85437. * @returns the current particle system
  85438. */
  85439. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85440. /**
  85441. * Gets the current list of ramp gradients.
  85442. * You must use addRampGradient and removeRampGradient to udpate this list
  85443. * @returns the list of ramp gradients
  85444. */
  85445. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85446. /** Gets or sets a boolean indicating that ramp gradients must be used
  85447. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85448. */
  85449. useRampGradients: boolean;
  85450. /**
  85451. * Adds a new color remap gradient
  85452. * @param gradient defines the gradient to use (between 0 and 1)
  85453. * @param min defines the color remap minimal range
  85454. * @param max defines the color remap maximal range
  85455. * @returns the current particle system
  85456. */
  85457. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85458. /**
  85459. * Gets the current list of color remap gradients.
  85460. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85461. * @returns the list of color remap gradients
  85462. */
  85463. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85464. /**
  85465. * Adds a new alpha remap gradient
  85466. * @param gradient defines the gradient to use (between 0 and 1)
  85467. * @param min defines the alpha remap minimal range
  85468. * @param max defines the alpha remap maximal range
  85469. * @returns the current particle system
  85470. */
  85471. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85472. /**
  85473. * Gets the current list of alpha remap gradients.
  85474. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85475. * @returns the list of alpha remap gradients
  85476. */
  85477. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85478. /**
  85479. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85480. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85481. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85482. * @returns the emitter
  85483. */
  85484. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85485. /**
  85486. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85487. * @param radius The radius of the hemisphere to emit from
  85488. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85489. * @returns the emitter
  85490. */
  85491. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85492. /**
  85493. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85494. * @param radius The radius of the sphere to emit from
  85495. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85496. * @returns the emitter
  85497. */
  85498. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85499. /**
  85500. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85501. * @param radius The radius of the sphere to emit from
  85502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85504. * @returns the emitter
  85505. */
  85506. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85507. /**
  85508. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85509. * @param radius The radius of the emission cylinder
  85510. * @param height The height of the emission cylinder
  85511. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85512. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85513. * @returns the emitter
  85514. */
  85515. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85516. /**
  85517. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85518. * @param radius The radius of the cylinder to emit from
  85519. * @param height The height of the emission cylinder
  85520. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85523. * @returns the emitter
  85524. */
  85525. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85526. /**
  85527. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85528. * @param radius The radius of the cone to emit from
  85529. * @param angle The base angle of the cone
  85530. * @returns the emitter
  85531. */
  85532. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85533. /**
  85534. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85537. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85538. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85539. * @returns the emitter
  85540. */
  85541. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85542. /**
  85543. * Get hosting scene
  85544. * @returns the scene
  85545. */
  85546. getScene(): Scene;
  85547. }
  85548. }
  85549. declare module BABYLON {
  85550. /**
  85551. * Creates an instance based on a source mesh.
  85552. */
  85553. export class InstancedMesh extends AbstractMesh {
  85554. private _sourceMesh;
  85555. private _currentLOD;
  85556. /** @hidden */
  85557. _indexInSourceMeshInstanceArray: number;
  85558. constructor(name: string, source: Mesh);
  85559. /**
  85560. * Returns the string "InstancedMesh".
  85561. */
  85562. getClassName(): string;
  85563. /** Gets the list of lights affecting that mesh */
  85564. readonly lightSources: Light[];
  85565. _resyncLightSources(): void;
  85566. _resyncLighSource(light: Light): void;
  85567. _removeLightSource(light: Light, dispose: boolean): void;
  85568. /**
  85569. * If the source mesh receives shadows
  85570. */
  85571. readonly receiveShadows: boolean;
  85572. /**
  85573. * The material of the source mesh
  85574. */
  85575. readonly material: Nullable<Material>;
  85576. /**
  85577. * Visibility of the source mesh
  85578. */
  85579. readonly visibility: number;
  85580. /**
  85581. * Skeleton of the source mesh
  85582. */
  85583. readonly skeleton: Nullable<Skeleton>;
  85584. /**
  85585. * Rendering ground id of the source mesh
  85586. */
  85587. renderingGroupId: number;
  85588. /**
  85589. * Returns the total number of vertices (integer).
  85590. */
  85591. getTotalVertices(): number;
  85592. /**
  85593. * Returns a positive integer : the total number of indices in this mesh geometry.
  85594. * @returns the numner of indices or zero if the mesh has no geometry.
  85595. */
  85596. getTotalIndices(): number;
  85597. /**
  85598. * The source mesh of the instance
  85599. */
  85600. readonly sourceMesh: Mesh;
  85601. /**
  85602. * Is this node ready to be used/rendered
  85603. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85604. * @return {boolean} is it ready
  85605. */
  85606. isReady(completeCheck?: boolean): boolean;
  85607. /**
  85608. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85609. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85610. * @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.
  85611. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85612. */
  85613. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85614. /**
  85615. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85616. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85617. * The `data` are either a numeric array either a Float32Array.
  85618. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85619. * 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).
  85620. * Note that a new underlying VertexBuffer object is created each call.
  85621. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85622. *
  85623. * Possible `kind` values :
  85624. * - VertexBuffer.PositionKind
  85625. * - VertexBuffer.UVKind
  85626. * - VertexBuffer.UV2Kind
  85627. * - VertexBuffer.UV3Kind
  85628. * - VertexBuffer.UV4Kind
  85629. * - VertexBuffer.UV5Kind
  85630. * - VertexBuffer.UV6Kind
  85631. * - VertexBuffer.ColorKind
  85632. * - VertexBuffer.MatricesIndicesKind
  85633. * - VertexBuffer.MatricesIndicesExtraKind
  85634. * - VertexBuffer.MatricesWeightsKind
  85635. * - VertexBuffer.MatricesWeightsExtraKind
  85636. *
  85637. * Returns the Mesh.
  85638. */
  85639. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85640. /**
  85641. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85642. * If the mesh has no geometry, it is simply returned as it is.
  85643. * The `data` are either a numeric array either a Float32Array.
  85644. * No new underlying VertexBuffer object is created.
  85645. * 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.
  85646. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85647. *
  85648. * Possible `kind` values :
  85649. * - VertexBuffer.PositionKind
  85650. * - VertexBuffer.UVKind
  85651. * - VertexBuffer.UV2Kind
  85652. * - VertexBuffer.UV3Kind
  85653. * - VertexBuffer.UV4Kind
  85654. * - VertexBuffer.UV5Kind
  85655. * - VertexBuffer.UV6Kind
  85656. * - VertexBuffer.ColorKind
  85657. * - VertexBuffer.MatricesIndicesKind
  85658. * - VertexBuffer.MatricesIndicesExtraKind
  85659. * - VertexBuffer.MatricesWeightsKind
  85660. * - VertexBuffer.MatricesWeightsExtraKind
  85661. *
  85662. * Returns the Mesh.
  85663. */
  85664. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85665. /**
  85666. * Sets the mesh indices.
  85667. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85668. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85669. * This method creates a new index buffer each call.
  85670. * Returns the Mesh.
  85671. */
  85672. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85673. /**
  85674. * Boolean : True if the mesh owns the requested kind of data.
  85675. */
  85676. isVerticesDataPresent(kind: string): boolean;
  85677. /**
  85678. * Returns an array of indices (IndicesArray).
  85679. */
  85680. getIndices(): Nullable<IndicesArray>;
  85681. readonly _positions: Nullable<Vector3[]>;
  85682. /**
  85683. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85684. * This means the mesh underlying bounding box and sphere are recomputed.
  85685. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85686. * @returns the current mesh
  85687. */
  85688. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85689. /** @hidden */
  85690. _preActivate(): InstancedMesh;
  85691. /** @hidden */
  85692. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85693. /** @hidden */
  85694. _postActivate(): void;
  85695. getWorldMatrix(): Matrix;
  85696. readonly isAnInstance: boolean;
  85697. /**
  85698. * Returns the current associated LOD AbstractMesh.
  85699. */
  85700. getLOD(camera: Camera): AbstractMesh;
  85701. /** @hidden */
  85702. _syncSubMeshes(): InstancedMesh;
  85703. /** @hidden */
  85704. _generatePointsArray(): boolean;
  85705. /**
  85706. * Creates a new InstancedMesh from the current mesh.
  85707. * - name (string) : the cloned mesh name
  85708. * - newParent (optional Node) : the optional Node to parent the clone to.
  85709. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85710. *
  85711. * Returns the clone.
  85712. */
  85713. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85714. /**
  85715. * Disposes the InstancedMesh.
  85716. * Returns nothing.
  85717. */
  85718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85719. }
  85720. }
  85721. declare module BABYLON {
  85722. /**
  85723. * Defines the options associated with the creation of a shader material.
  85724. */
  85725. export interface IShaderMaterialOptions {
  85726. /**
  85727. * Does the material work in alpha blend mode
  85728. */
  85729. needAlphaBlending: boolean;
  85730. /**
  85731. * Does the material work in alpha test mode
  85732. */
  85733. needAlphaTesting: boolean;
  85734. /**
  85735. * The list of attribute names used in the shader
  85736. */
  85737. attributes: string[];
  85738. /**
  85739. * The list of unifrom names used in the shader
  85740. */
  85741. uniforms: string[];
  85742. /**
  85743. * The list of UBO names used in the shader
  85744. */
  85745. uniformBuffers: string[];
  85746. /**
  85747. * The list of sampler names used in the shader
  85748. */
  85749. samplers: string[];
  85750. /**
  85751. * The list of defines used in the shader
  85752. */
  85753. defines: string[];
  85754. }
  85755. /**
  85756. * 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.
  85757. *
  85758. * This returned material effects how the mesh will look based on the code in the shaders.
  85759. *
  85760. * @see http://doc.babylonjs.com/how_to/shader_material
  85761. */
  85762. export class ShaderMaterial extends Material {
  85763. private _shaderPath;
  85764. private _options;
  85765. private _textures;
  85766. private _textureArrays;
  85767. private _floats;
  85768. private _ints;
  85769. private _floatsArrays;
  85770. private _colors3;
  85771. private _colors3Arrays;
  85772. private _colors4;
  85773. private _colors4Arrays;
  85774. private _vectors2;
  85775. private _vectors3;
  85776. private _vectors4;
  85777. private _matrices;
  85778. private _matrices3x3;
  85779. private _matrices2x2;
  85780. private _vectors2Arrays;
  85781. private _vectors3Arrays;
  85782. private _vectors4Arrays;
  85783. private _cachedWorldViewMatrix;
  85784. private _cachedWorldViewProjectionMatrix;
  85785. private _renderId;
  85786. /**
  85787. * Instantiate a new shader material.
  85788. * 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.
  85789. * This returned material effects how the mesh will look based on the code in the shaders.
  85790. * @see http://doc.babylonjs.com/how_to/shader_material
  85791. * @param name Define the name of the material in the scene
  85792. * @param scene Define the scene the material belongs to
  85793. * @param shaderPath Defines the route to the shader code in one of three ways:
  85794. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85795. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85796. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85797. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85798. * @param options Define the options used to create the shader
  85799. */
  85800. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85801. /**
  85802. * Gets the options used to compile the shader.
  85803. * They can be modified to trigger a new compilation
  85804. */
  85805. readonly options: IShaderMaterialOptions;
  85806. /**
  85807. * Gets the current class name of the material e.g. "ShaderMaterial"
  85808. * Mainly use in serialization.
  85809. * @returns the class name
  85810. */
  85811. getClassName(): string;
  85812. /**
  85813. * Specifies if the material will require alpha blending
  85814. * @returns a boolean specifying if alpha blending is needed
  85815. */
  85816. needAlphaBlending(): boolean;
  85817. /**
  85818. * Specifies if this material should be rendered in alpha test mode
  85819. * @returns a boolean specifying if an alpha test is needed.
  85820. */
  85821. needAlphaTesting(): boolean;
  85822. private _checkUniform;
  85823. /**
  85824. * Set a texture in the shader.
  85825. * @param name Define the name of the uniform samplers as defined in the shader
  85826. * @param texture Define the texture to bind to this sampler
  85827. * @return the material itself allowing "fluent" like uniform updates
  85828. */
  85829. setTexture(name: string, texture: Texture): ShaderMaterial;
  85830. /**
  85831. * Set a texture array in the shader.
  85832. * @param name Define the name of the uniform sampler array as defined in the shader
  85833. * @param textures Define the list of textures to bind to this sampler
  85834. * @return the material itself allowing "fluent" like uniform updates
  85835. */
  85836. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85837. /**
  85838. * Set a float in the shader.
  85839. * @param name Define the name of the uniform as defined in the shader
  85840. * @param value Define the value to give to the uniform
  85841. * @return the material itself allowing "fluent" like uniform updates
  85842. */
  85843. setFloat(name: string, value: number): ShaderMaterial;
  85844. /**
  85845. * Set a int in the shader.
  85846. * @param name Define the name of the uniform as defined in the shader
  85847. * @param value Define the value to give to the uniform
  85848. * @return the material itself allowing "fluent" like uniform updates
  85849. */
  85850. setInt(name: string, value: number): ShaderMaterial;
  85851. /**
  85852. * Set an array of floats in the shader.
  85853. * @param name Define the name of the uniform as defined in the shader
  85854. * @param value Define the value to give to the uniform
  85855. * @return the material itself allowing "fluent" like uniform updates
  85856. */
  85857. setFloats(name: string, value: number[]): ShaderMaterial;
  85858. /**
  85859. * Set a vec3 in the shader from a Color3.
  85860. * @param name Define the name of the uniform as defined in the shader
  85861. * @param value Define the value to give to the uniform
  85862. * @return the material itself allowing "fluent" like uniform updates
  85863. */
  85864. setColor3(name: string, value: Color3): ShaderMaterial;
  85865. /**
  85866. * Set a vec3 array in the shader from a Color3 array.
  85867. * @param name Define the name of the uniform as defined in the shader
  85868. * @param value Define the value to give to the uniform
  85869. * @return the material itself allowing "fluent" like uniform updates
  85870. */
  85871. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85872. /**
  85873. * Set a vec4 in the shader from a Color4.
  85874. * @param name Define the name of the uniform as defined in the shader
  85875. * @param value Define the value to give to the uniform
  85876. * @return the material itself allowing "fluent" like uniform updates
  85877. */
  85878. setColor4(name: string, value: Color4): ShaderMaterial;
  85879. /**
  85880. * Set a vec4 array in the shader from a Color4 array.
  85881. * @param name Define the name of the uniform as defined in the shader
  85882. * @param value Define the value to give to the uniform
  85883. * @return the material itself allowing "fluent" like uniform updates
  85884. */
  85885. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85886. /**
  85887. * Set a vec2 in the shader from a Vector2.
  85888. * @param name Define the name of the uniform as defined in the shader
  85889. * @param value Define the value to give to the uniform
  85890. * @return the material itself allowing "fluent" like uniform updates
  85891. */
  85892. setVector2(name: string, value: Vector2): ShaderMaterial;
  85893. /**
  85894. * Set a vec3 in the shader from a Vector3.
  85895. * @param name Define the name of the uniform as defined in the shader
  85896. * @param value Define the value to give to the uniform
  85897. * @return the material itself allowing "fluent" like uniform updates
  85898. */
  85899. setVector3(name: string, value: Vector3): ShaderMaterial;
  85900. /**
  85901. * Set a vec4 in the shader from a Vector4.
  85902. * @param name Define the name of the uniform as defined in the shader
  85903. * @param value Define the value to give to the uniform
  85904. * @return the material itself allowing "fluent" like uniform updates
  85905. */
  85906. setVector4(name: string, value: Vector4): ShaderMaterial;
  85907. /**
  85908. * Set a mat4 in the shader from a Matrix.
  85909. * @param name Define the name of the uniform as defined in the shader
  85910. * @param value Define the value to give to the uniform
  85911. * @return the material itself allowing "fluent" like uniform updates
  85912. */
  85913. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85914. /**
  85915. * Set a mat3 in the shader from a Float32Array.
  85916. * @param name Define the name of the uniform as defined in the shader
  85917. * @param value Define the value to give to the uniform
  85918. * @return the material itself allowing "fluent" like uniform updates
  85919. */
  85920. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85921. /**
  85922. * Set a mat2 in the shader from a Float32Array.
  85923. * @param name Define the name of the uniform as defined in the shader
  85924. * @param value Define the value to give to the uniform
  85925. * @return the material itself allowing "fluent" like uniform updates
  85926. */
  85927. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85928. /**
  85929. * Set a vec2 array in the shader from a number array.
  85930. * @param name Define the name of the uniform as defined in the shader
  85931. * @param value Define the value to give to the uniform
  85932. * @return the material itself allowing "fluent" like uniform updates
  85933. */
  85934. setArray2(name: string, value: number[]): ShaderMaterial;
  85935. /**
  85936. * Set a vec3 array in the shader from a number array.
  85937. * @param name Define the name of the uniform as defined in the shader
  85938. * @param value Define the value to give to the uniform
  85939. * @return the material itself allowing "fluent" like uniform updates
  85940. */
  85941. setArray3(name: string, value: number[]): ShaderMaterial;
  85942. /**
  85943. * Set a vec4 array in the shader from a number array.
  85944. * @param name Define the name of the uniform as defined in the shader
  85945. * @param value Define the value to give to the uniform
  85946. * @return the material itself allowing "fluent" like uniform updates
  85947. */
  85948. setArray4(name: string, value: number[]): ShaderMaterial;
  85949. private _checkCache;
  85950. /**
  85951. * Specifies that the submesh is ready to be used
  85952. * @param mesh defines the mesh to check
  85953. * @param subMesh defines which submesh to check
  85954. * @param useInstances specifies that instances should be used
  85955. * @returns a boolean indicating that the submesh is ready or not
  85956. */
  85957. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85958. /**
  85959. * Checks if the material is ready to render the requested mesh
  85960. * @param mesh Define the mesh to render
  85961. * @param useInstances Define whether or not the material is used with instances
  85962. * @returns true if ready, otherwise false
  85963. */
  85964. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85965. /**
  85966. * Binds the world matrix to the material
  85967. * @param world defines the world transformation matrix
  85968. */
  85969. bindOnlyWorldMatrix(world: Matrix): void;
  85970. /**
  85971. * Binds the material to the mesh
  85972. * @param world defines the world transformation matrix
  85973. * @param mesh defines the mesh to bind the material to
  85974. */
  85975. bind(world: Matrix, mesh?: Mesh): void;
  85976. /**
  85977. * Gets the active textures from the material
  85978. * @returns an array of textures
  85979. */
  85980. getActiveTextures(): BaseTexture[];
  85981. /**
  85982. * Specifies if the material uses a texture
  85983. * @param texture defines the texture to check against the material
  85984. * @returns a boolean specifying if the material uses the texture
  85985. */
  85986. hasTexture(texture: BaseTexture): boolean;
  85987. /**
  85988. * Makes a duplicate of the material, and gives it a new name
  85989. * @param name defines the new name for the duplicated material
  85990. * @returns the cloned material
  85991. */
  85992. clone(name: string): ShaderMaterial;
  85993. /**
  85994. * Disposes the material
  85995. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85996. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85997. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85998. */
  85999. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86000. /**
  86001. * Serializes this material in a JSON representation
  86002. * @returns the serialized material object
  86003. */
  86004. serialize(): any;
  86005. /**
  86006. * Creates a shader material from parsed shader material data
  86007. * @param source defines the JSON represnetation of the material
  86008. * @param scene defines the hosting scene
  86009. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86010. * @returns a new material
  86011. */
  86012. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86013. }
  86014. }
  86015. declare module BABYLON {
  86016. /** @hidden */
  86017. export var colorPixelShader: {
  86018. name: string;
  86019. shader: string;
  86020. };
  86021. }
  86022. declare module BABYLON {
  86023. /** @hidden */
  86024. export var colorVertexShader: {
  86025. name: string;
  86026. shader: string;
  86027. };
  86028. }
  86029. declare module BABYLON {
  86030. /**
  86031. * Line mesh
  86032. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86033. */
  86034. export class LinesMesh extends Mesh {
  86035. /**
  86036. * If vertex color should be applied to the mesh
  86037. */
  86038. readonly useVertexColor?: boolean | undefined;
  86039. /**
  86040. * If vertex alpha should be applied to the mesh
  86041. */
  86042. readonly useVertexAlpha?: boolean | undefined;
  86043. /**
  86044. * Color of the line (Default: White)
  86045. */
  86046. color: Color3;
  86047. /**
  86048. * Alpha of the line (Default: 1)
  86049. */
  86050. alpha: number;
  86051. /**
  86052. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86053. * This margin is expressed in world space coordinates, so its value may vary.
  86054. * Default value is 0.1
  86055. */
  86056. intersectionThreshold: number;
  86057. private _colorShader;
  86058. private color4;
  86059. /**
  86060. * Creates a new LinesMesh
  86061. * @param name defines the name
  86062. * @param scene defines the hosting scene
  86063. * @param parent defines the parent mesh if any
  86064. * @param source defines the optional source LinesMesh used to clone data from
  86065. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86066. * When false, achieved by calling a clone(), also passing False.
  86067. * This will make creation of children, recursive.
  86068. * @param useVertexColor defines if this LinesMesh supports vertex color
  86069. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86070. */
  86071. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86072. /**
  86073. * If vertex color should be applied to the mesh
  86074. */
  86075. useVertexColor?: boolean | undefined,
  86076. /**
  86077. * If vertex alpha should be applied to the mesh
  86078. */
  86079. useVertexAlpha?: boolean | undefined);
  86080. private _addClipPlaneDefine;
  86081. private _removeClipPlaneDefine;
  86082. isReady(): boolean;
  86083. /**
  86084. * Returns the string "LineMesh"
  86085. */
  86086. getClassName(): string;
  86087. /**
  86088. * @hidden
  86089. */
  86090. /**
  86091. * @hidden
  86092. */
  86093. material: Material;
  86094. /**
  86095. * @hidden
  86096. */
  86097. readonly checkCollisions: boolean;
  86098. /** @hidden */
  86099. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86100. /** @hidden */
  86101. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86102. /**
  86103. * Disposes of the line mesh
  86104. * @param doNotRecurse If children should be disposed
  86105. */
  86106. dispose(doNotRecurse?: boolean): void;
  86107. /**
  86108. * Returns a new LineMesh object cloned from the current one.
  86109. */
  86110. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86111. /**
  86112. * Creates a new InstancedLinesMesh object from the mesh model.
  86113. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86114. * @param name defines the name of the new instance
  86115. * @returns a new InstancedLinesMesh
  86116. */
  86117. createInstance(name: string): InstancedLinesMesh;
  86118. }
  86119. /**
  86120. * Creates an instance based on a source LinesMesh
  86121. */
  86122. export class InstancedLinesMesh extends InstancedMesh {
  86123. /**
  86124. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86125. * This margin is expressed in world space coordinates, so its value may vary.
  86126. * Initilized with the intersectionThreshold value of the source LinesMesh
  86127. */
  86128. intersectionThreshold: number;
  86129. constructor(name: string, source: LinesMesh);
  86130. /**
  86131. * Returns the string "InstancedLinesMesh".
  86132. */
  86133. getClassName(): string;
  86134. }
  86135. }
  86136. declare module BABYLON {
  86137. /** @hidden */
  86138. export var linePixelShader: {
  86139. name: string;
  86140. shader: string;
  86141. };
  86142. }
  86143. declare module BABYLON {
  86144. /** @hidden */
  86145. export var lineVertexShader: {
  86146. name: string;
  86147. shader: string;
  86148. };
  86149. }
  86150. declare module BABYLON {
  86151. interface AbstractMesh {
  86152. /**
  86153. * Gets the edgesRenderer associated with the mesh
  86154. */
  86155. edgesRenderer: Nullable<EdgesRenderer>;
  86156. }
  86157. interface LinesMesh {
  86158. /**
  86159. * Enables the edge rendering mode on the mesh.
  86160. * This mode makes the mesh edges visible
  86161. * @param epsilon defines the maximal distance between two angles to detect a face
  86162. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86163. * @returns the currentAbstractMesh
  86164. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86165. */
  86166. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86167. }
  86168. interface InstancedLinesMesh {
  86169. /**
  86170. * Enables the edge rendering mode on the mesh.
  86171. * This mode makes the mesh edges visible
  86172. * @param epsilon defines the maximal distance between two angles to detect a face
  86173. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86174. * @returns the current InstancedLinesMesh
  86175. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86176. */
  86177. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86178. }
  86179. /**
  86180. * Defines the minimum contract an Edges renderer should follow.
  86181. */
  86182. export interface IEdgesRenderer extends IDisposable {
  86183. /**
  86184. * Gets or sets a boolean indicating if the edgesRenderer is active
  86185. */
  86186. isEnabled: boolean;
  86187. /**
  86188. * Renders the edges of the attached mesh,
  86189. */
  86190. render(): void;
  86191. /**
  86192. * Checks wether or not the edges renderer is ready to render.
  86193. * @return true if ready, otherwise false.
  86194. */
  86195. isReady(): boolean;
  86196. }
  86197. /**
  86198. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86199. */
  86200. export class EdgesRenderer implements IEdgesRenderer {
  86201. /**
  86202. * Define the size of the edges with an orthographic camera
  86203. */
  86204. edgesWidthScalerForOrthographic: number;
  86205. /**
  86206. * Define the size of the edges with a perspective camera
  86207. */
  86208. edgesWidthScalerForPerspective: number;
  86209. protected _source: AbstractMesh;
  86210. protected _linesPositions: number[];
  86211. protected _linesNormals: number[];
  86212. protected _linesIndices: number[];
  86213. protected _epsilon: number;
  86214. protected _indicesCount: number;
  86215. protected _lineShader: ShaderMaterial;
  86216. protected _ib: DataBuffer;
  86217. protected _buffers: {
  86218. [key: string]: Nullable<VertexBuffer>;
  86219. };
  86220. protected _checkVerticesInsteadOfIndices: boolean;
  86221. private _meshRebuildObserver;
  86222. private _meshDisposeObserver;
  86223. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86224. isEnabled: boolean;
  86225. /**
  86226. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86227. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86228. * @param source Mesh used to create edges
  86229. * @param epsilon sum of angles in adjacency to check for edge
  86230. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86231. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86232. */
  86233. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86234. protected _prepareRessources(): void;
  86235. /** @hidden */
  86236. _rebuild(): void;
  86237. /**
  86238. * Releases the required resources for the edges renderer
  86239. */
  86240. dispose(): void;
  86241. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86242. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86243. /**
  86244. * Checks if the pair of p0 and p1 is en edge
  86245. * @param faceIndex
  86246. * @param edge
  86247. * @param faceNormals
  86248. * @param p0
  86249. * @param p1
  86250. * @private
  86251. */
  86252. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86253. /**
  86254. * push line into the position, normal and index buffer
  86255. * @protected
  86256. */
  86257. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86258. /**
  86259. * Generates lines edges from adjacencjes
  86260. * @private
  86261. */
  86262. _generateEdgesLines(): void;
  86263. /**
  86264. * Checks wether or not the edges renderer is ready to render.
  86265. * @return true if ready, otherwise false.
  86266. */
  86267. isReady(): boolean;
  86268. /**
  86269. * Renders the edges of the attached mesh,
  86270. */
  86271. render(): void;
  86272. }
  86273. /**
  86274. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86275. */
  86276. export class LineEdgesRenderer extends EdgesRenderer {
  86277. /**
  86278. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86279. * @param source LineMesh used to generate edges
  86280. * @param epsilon not important (specified angle for edge detection)
  86281. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86282. */
  86283. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86284. /**
  86285. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86286. */
  86287. _generateEdgesLines(): void;
  86288. }
  86289. }
  86290. declare module BABYLON {
  86291. /**
  86292. * This represents the object necessary to create a rendering group.
  86293. * This is exclusively used and created by the rendering manager.
  86294. * To modify the behavior, you use the available helpers in your scene or meshes.
  86295. * @hidden
  86296. */
  86297. export class RenderingGroup {
  86298. index: number;
  86299. private static _zeroVector;
  86300. private _scene;
  86301. private _opaqueSubMeshes;
  86302. private _transparentSubMeshes;
  86303. private _alphaTestSubMeshes;
  86304. private _depthOnlySubMeshes;
  86305. private _particleSystems;
  86306. private _spriteManagers;
  86307. private _opaqueSortCompareFn;
  86308. private _alphaTestSortCompareFn;
  86309. private _transparentSortCompareFn;
  86310. private _renderOpaque;
  86311. private _renderAlphaTest;
  86312. private _renderTransparent;
  86313. /** @hidden */
  86314. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86315. onBeforeTransparentRendering: () => void;
  86316. /**
  86317. * Set the opaque sort comparison function.
  86318. * If null the sub meshes will be render in the order they were created
  86319. */
  86320. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86321. /**
  86322. * Set the alpha test sort comparison function.
  86323. * If null the sub meshes will be render in the order they were created
  86324. */
  86325. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86326. /**
  86327. * Set the transparent sort comparison function.
  86328. * If null the sub meshes will be render in the order they were created
  86329. */
  86330. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86331. /**
  86332. * Creates a new rendering group.
  86333. * @param index The rendering group index
  86334. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86335. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86336. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86337. */
  86338. 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>);
  86339. /**
  86340. * Render all the sub meshes contained in the group.
  86341. * @param customRenderFunction Used to override the default render behaviour of the group.
  86342. * @returns true if rendered some submeshes.
  86343. */
  86344. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86345. /**
  86346. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86347. * @param subMeshes The submeshes to render
  86348. */
  86349. private renderOpaqueSorted;
  86350. /**
  86351. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86352. * @param subMeshes The submeshes to render
  86353. */
  86354. private renderAlphaTestSorted;
  86355. /**
  86356. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86357. * @param subMeshes The submeshes to render
  86358. */
  86359. private renderTransparentSorted;
  86360. /**
  86361. * Renders the submeshes in a specified order.
  86362. * @param subMeshes The submeshes to sort before render
  86363. * @param sortCompareFn The comparison function use to sort
  86364. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86365. * @param transparent Specifies to activate blending if true
  86366. */
  86367. private static renderSorted;
  86368. /**
  86369. * Renders the submeshes in the order they were dispatched (no sort applied).
  86370. * @param subMeshes The submeshes to render
  86371. */
  86372. private static renderUnsorted;
  86373. /**
  86374. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86375. * are rendered back to front if in the same alpha index.
  86376. *
  86377. * @param a The first submesh
  86378. * @param b The second submesh
  86379. * @returns The result of the comparison
  86380. */
  86381. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86382. /**
  86383. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86384. * are rendered back to front.
  86385. *
  86386. * @param a The first submesh
  86387. * @param b The second submesh
  86388. * @returns The result of the comparison
  86389. */
  86390. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86391. /**
  86392. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86393. * are rendered front to back (prevent overdraw).
  86394. *
  86395. * @param a The first submesh
  86396. * @param b The second submesh
  86397. * @returns The result of the comparison
  86398. */
  86399. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86400. /**
  86401. * Resets the different lists of submeshes to prepare a new frame.
  86402. */
  86403. prepare(): void;
  86404. dispose(): void;
  86405. /**
  86406. * Inserts the submesh in its correct queue depending on its material.
  86407. * @param subMesh The submesh to dispatch
  86408. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86409. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86410. */
  86411. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86412. dispatchSprites(spriteManager: ISpriteManager): void;
  86413. dispatchParticles(particleSystem: IParticleSystem): void;
  86414. private _renderParticles;
  86415. private _renderSprites;
  86416. }
  86417. }
  86418. declare module BABYLON {
  86419. /**
  86420. * Interface describing the different options available in the rendering manager
  86421. * regarding Auto Clear between groups.
  86422. */
  86423. export interface IRenderingManagerAutoClearSetup {
  86424. /**
  86425. * Defines whether or not autoclear is enable.
  86426. */
  86427. autoClear: boolean;
  86428. /**
  86429. * Defines whether or not to autoclear the depth buffer.
  86430. */
  86431. depth: boolean;
  86432. /**
  86433. * Defines whether or not to autoclear the stencil buffer.
  86434. */
  86435. stencil: boolean;
  86436. }
  86437. /**
  86438. * This class is used by the onRenderingGroupObservable
  86439. */
  86440. export class RenderingGroupInfo {
  86441. /**
  86442. * The Scene that being rendered
  86443. */
  86444. scene: Scene;
  86445. /**
  86446. * The camera currently used for the rendering pass
  86447. */
  86448. camera: Nullable<Camera>;
  86449. /**
  86450. * The ID of the renderingGroup being processed
  86451. */
  86452. renderingGroupId: number;
  86453. }
  86454. /**
  86455. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86456. * It is enable to manage the different groups as well as the different necessary sort functions.
  86457. * This should not be used directly aside of the few static configurations
  86458. */
  86459. export class RenderingManager {
  86460. /**
  86461. * The max id used for rendering groups (not included)
  86462. */
  86463. static MAX_RENDERINGGROUPS: number;
  86464. /**
  86465. * The min id used for rendering groups (included)
  86466. */
  86467. static MIN_RENDERINGGROUPS: number;
  86468. /**
  86469. * Used to globally prevent autoclearing scenes.
  86470. */
  86471. static AUTOCLEAR: boolean;
  86472. /**
  86473. * @hidden
  86474. */
  86475. _useSceneAutoClearSetup: boolean;
  86476. private _scene;
  86477. private _renderingGroups;
  86478. private _depthStencilBufferAlreadyCleaned;
  86479. private _autoClearDepthStencil;
  86480. private _customOpaqueSortCompareFn;
  86481. private _customAlphaTestSortCompareFn;
  86482. private _customTransparentSortCompareFn;
  86483. private _renderingGroupInfo;
  86484. /**
  86485. * Instantiates a new rendering group for a particular scene
  86486. * @param scene Defines the scene the groups belongs to
  86487. */
  86488. constructor(scene: Scene);
  86489. private _clearDepthStencilBuffer;
  86490. /**
  86491. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86492. * @hidden
  86493. */
  86494. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86495. /**
  86496. * Resets the different information of the group to prepare a new frame
  86497. * @hidden
  86498. */
  86499. reset(): void;
  86500. /**
  86501. * Dispose and release the group and its associated resources.
  86502. * @hidden
  86503. */
  86504. dispose(): void;
  86505. /**
  86506. * Clear the info related to rendering groups preventing retention points during dispose.
  86507. */
  86508. freeRenderingGroups(): void;
  86509. private _prepareRenderingGroup;
  86510. /**
  86511. * Add a sprite manager to the rendering manager in order to render it this frame.
  86512. * @param spriteManager Define the sprite manager to render
  86513. */
  86514. dispatchSprites(spriteManager: ISpriteManager): void;
  86515. /**
  86516. * Add a particle system to the rendering manager in order to render it this frame.
  86517. * @param particleSystem Define the particle system to render
  86518. */
  86519. dispatchParticles(particleSystem: IParticleSystem): void;
  86520. /**
  86521. * Add a submesh to the manager in order to render it this frame
  86522. * @param subMesh The submesh to dispatch
  86523. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86524. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86525. */
  86526. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86527. /**
  86528. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86529. * This allowed control for front to back rendering or reversly depending of the special needs.
  86530. *
  86531. * @param renderingGroupId The rendering group id corresponding to its index
  86532. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86533. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86534. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86535. */
  86536. 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;
  86537. /**
  86538. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86539. *
  86540. * @param renderingGroupId The rendering group id corresponding to its index
  86541. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86542. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86543. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86544. */
  86545. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86546. /**
  86547. * Gets the current auto clear configuration for one rendering group of the rendering
  86548. * manager.
  86549. * @param index the rendering group index to get the information for
  86550. * @returns The auto clear setup for the requested rendering group
  86551. */
  86552. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86553. }
  86554. }
  86555. declare module BABYLON {
  86556. /**
  86557. * This Helps creating a texture that will be created from a camera in your scene.
  86558. * It is basically a dynamic texture that could be used to create special effects for instance.
  86559. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86560. */
  86561. export class RenderTargetTexture extends Texture {
  86562. isCube: boolean;
  86563. /**
  86564. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86565. */
  86566. static readonly REFRESHRATE_RENDER_ONCE: number;
  86567. /**
  86568. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86569. */
  86570. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86571. /**
  86572. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86573. * the central point of your effect and can save a lot of performances.
  86574. */
  86575. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86576. /**
  86577. * Use this predicate to dynamically define the list of mesh you want to render.
  86578. * If set, the renderList property will be overwritten.
  86579. */
  86580. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86581. private _renderList;
  86582. /**
  86583. * Use this list to define the list of mesh you want to render.
  86584. */
  86585. renderList: Nullable<Array<AbstractMesh>>;
  86586. private _hookArray;
  86587. /**
  86588. * Define if particles should be rendered in your texture.
  86589. */
  86590. renderParticles: boolean;
  86591. /**
  86592. * Define if sprites should be rendered in your texture.
  86593. */
  86594. renderSprites: boolean;
  86595. /**
  86596. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86597. */
  86598. coordinatesMode: number;
  86599. /**
  86600. * Define the camera used to render the texture.
  86601. */
  86602. activeCamera: Nullable<Camera>;
  86603. /**
  86604. * Override the render function of the texture with your own one.
  86605. */
  86606. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86607. /**
  86608. * Define if camera post processes should be use while rendering the texture.
  86609. */
  86610. useCameraPostProcesses: boolean;
  86611. /**
  86612. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86613. */
  86614. ignoreCameraViewport: boolean;
  86615. private _postProcessManager;
  86616. private _postProcesses;
  86617. private _resizeObserver;
  86618. /**
  86619. * An event triggered when the texture is unbind.
  86620. */
  86621. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86622. /**
  86623. * An event triggered when the texture is unbind.
  86624. */
  86625. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86626. private _onAfterUnbindObserver;
  86627. /**
  86628. * Set a after unbind callback in the texture.
  86629. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86630. */
  86631. onAfterUnbind: () => void;
  86632. /**
  86633. * An event triggered before rendering the texture
  86634. */
  86635. onBeforeRenderObservable: Observable<number>;
  86636. private _onBeforeRenderObserver;
  86637. /**
  86638. * Set a before render callback in the texture.
  86639. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86640. */
  86641. onBeforeRender: (faceIndex: number) => void;
  86642. /**
  86643. * An event triggered after rendering the texture
  86644. */
  86645. onAfterRenderObservable: Observable<number>;
  86646. private _onAfterRenderObserver;
  86647. /**
  86648. * Set a after render callback in the texture.
  86649. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86650. */
  86651. onAfterRender: (faceIndex: number) => void;
  86652. /**
  86653. * An event triggered after the texture clear
  86654. */
  86655. onClearObservable: Observable<Engine>;
  86656. private _onClearObserver;
  86657. /**
  86658. * Set a clear callback in the texture.
  86659. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86660. */
  86661. onClear: (Engine: Engine) => void;
  86662. /**
  86663. * An event triggered when the texture is resized.
  86664. */
  86665. onResizeObservable: Observable<RenderTargetTexture>;
  86666. /**
  86667. * Define the clear color of the Render Target if it should be different from the scene.
  86668. */
  86669. clearColor: Color4;
  86670. protected _size: number | {
  86671. width: number;
  86672. height: number;
  86673. };
  86674. protected _initialSizeParameter: number | {
  86675. width: number;
  86676. height: number;
  86677. } | {
  86678. ratio: number;
  86679. };
  86680. protected _sizeRatio: Nullable<number>;
  86681. /** @hidden */
  86682. _generateMipMaps: boolean;
  86683. protected _renderingManager: RenderingManager;
  86684. /** @hidden */
  86685. _waitingRenderList: string[];
  86686. protected _doNotChangeAspectRatio: boolean;
  86687. protected _currentRefreshId: number;
  86688. protected _refreshRate: number;
  86689. protected _textureMatrix: Matrix;
  86690. protected _samples: number;
  86691. protected _renderTargetOptions: RenderTargetCreationOptions;
  86692. /**
  86693. * Gets render target creation options that were used.
  86694. */
  86695. readonly renderTargetOptions: RenderTargetCreationOptions;
  86696. protected _engine: Engine;
  86697. protected _onRatioRescale(): void;
  86698. /**
  86699. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86700. * It must define where the camera used to render the texture is set
  86701. */
  86702. boundingBoxPosition: Vector3;
  86703. private _boundingBoxSize;
  86704. /**
  86705. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86706. * When defined, the cubemap will switch to local mode
  86707. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86708. * @example https://www.babylonjs-playground.com/#RNASML
  86709. */
  86710. boundingBoxSize: Vector3;
  86711. /**
  86712. * In case the RTT has been created with a depth texture, get the associated
  86713. * depth texture.
  86714. * Otherwise, return null.
  86715. */
  86716. depthStencilTexture: Nullable<InternalTexture>;
  86717. /**
  86718. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86719. * or used a shadow, depth texture...
  86720. * @param name The friendly name of the texture
  86721. * @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)
  86722. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86723. * @param generateMipMaps True if mip maps need to be generated after render.
  86724. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86725. * @param type The type of the buffer in the RTT (int, half float, float...)
  86726. * @param isCube True if a cube texture needs to be created
  86727. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86728. * @param generateDepthBuffer True to generate a depth buffer
  86729. * @param generateStencilBuffer True to generate a stencil buffer
  86730. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86731. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86732. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86733. */
  86734. constructor(name: string, size: number | {
  86735. width: number;
  86736. height: number;
  86737. } | {
  86738. ratio: number;
  86739. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86740. /**
  86741. * Creates a depth stencil texture.
  86742. * This is only available in WebGL 2 or with the depth texture extension available.
  86743. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86744. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86745. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86746. */
  86747. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86748. private _processSizeParameter;
  86749. /**
  86750. * Define the number of samples to use in case of MSAA.
  86751. * It defaults to one meaning no MSAA has been enabled.
  86752. */
  86753. samples: number;
  86754. /**
  86755. * Resets the refresh counter of the texture and start bak from scratch.
  86756. * Could be useful to regenerate the texture if it is setup to render only once.
  86757. */
  86758. resetRefreshCounter(): void;
  86759. /**
  86760. * Define the refresh rate of the texture or the rendering frequency.
  86761. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86762. */
  86763. refreshRate: number;
  86764. /**
  86765. * Adds a post process to the render target rendering passes.
  86766. * @param postProcess define the post process to add
  86767. */
  86768. addPostProcess(postProcess: PostProcess): void;
  86769. /**
  86770. * Clear all the post processes attached to the render target
  86771. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86772. */
  86773. clearPostProcesses(dispose?: boolean): void;
  86774. /**
  86775. * Remove one of the post process from the list of attached post processes to the texture
  86776. * @param postProcess define the post process to remove from the list
  86777. */
  86778. removePostProcess(postProcess: PostProcess): void;
  86779. /** @hidden */
  86780. _shouldRender(): boolean;
  86781. /**
  86782. * Gets the actual render size of the texture.
  86783. * @returns the width of the render size
  86784. */
  86785. getRenderSize(): number;
  86786. /**
  86787. * Gets the actual render width of the texture.
  86788. * @returns the width of the render size
  86789. */
  86790. getRenderWidth(): number;
  86791. /**
  86792. * Gets the actual render height of the texture.
  86793. * @returns the height of the render size
  86794. */
  86795. getRenderHeight(): number;
  86796. /**
  86797. * Get if the texture can be rescaled or not.
  86798. */
  86799. readonly canRescale: boolean;
  86800. /**
  86801. * Resize the texture using a ratio.
  86802. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86803. */
  86804. scale(ratio: number): void;
  86805. /**
  86806. * Get the texture reflection matrix used to rotate/transform the reflection.
  86807. * @returns the reflection matrix
  86808. */
  86809. getReflectionTextureMatrix(): Matrix;
  86810. /**
  86811. * Resize the texture to a new desired size.
  86812. * Be carrefull as it will recreate all the data in the new texture.
  86813. * @param size Define the new size. It can be:
  86814. * - a number for squared texture,
  86815. * - an object containing { width: number, height: number }
  86816. * - or an object containing a ratio { ratio: number }
  86817. */
  86818. resize(size: number | {
  86819. width: number;
  86820. height: number;
  86821. } | {
  86822. ratio: number;
  86823. }): void;
  86824. /**
  86825. * Renders all the objects from the render list into the texture.
  86826. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86827. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86828. */
  86829. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86830. private _bestReflectionRenderTargetDimension;
  86831. /**
  86832. * @hidden
  86833. * @param faceIndex face index to bind to if this is a cubetexture
  86834. */
  86835. _bindFrameBuffer(faceIndex?: number): void;
  86836. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86837. private renderToTarget;
  86838. /**
  86839. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86840. * This allowed control for front to back rendering or reversly depending of the special needs.
  86841. *
  86842. * @param renderingGroupId The rendering group id corresponding to its index
  86843. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86844. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86845. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86846. */
  86847. 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;
  86848. /**
  86849. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86850. *
  86851. * @param renderingGroupId The rendering group id corresponding to its index
  86852. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86853. */
  86854. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86855. /**
  86856. * Clones the texture.
  86857. * @returns the cloned texture
  86858. */
  86859. clone(): RenderTargetTexture;
  86860. /**
  86861. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86862. * @returns The JSON representation of the texture
  86863. */
  86864. serialize(): any;
  86865. /**
  86866. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86867. */
  86868. disposeFramebufferObjects(): void;
  86869. /**
  86870. * Dispose the texture and release its associated resources.
  86871. */
  86872. dispose(): void;
  86873. /** @hidden */
  86874. _rebuild(): void;
  86875. /**
  86876. * Clear the info related to rendering groups preventing retention point in material dispose.
  86877. */
  86878. freeRenderingGroups(): void;
  86879. /**
  86880. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86881. * @returns the view count
  86882. */
  86883. getViewCount(): number;
  86884. }
  86885. }
  86886. declare module BABYLON {
  86887. /**
  86888. * Base class for the main features of a material in Babylon.js
  86889. */
  86890. export class Material implements IAnimatable {
  86891. /**
  86892. * Returns the triangle fill mode
  86893. */
  86894. static readonly TriangleFillMode: number;
  86895. /**
  86896. * Returns the wireframe mode
  86897. */
  86898. static readonly WireFrameFillMode: number;
  86899. /**
  86900. * Returns the point fill mode
  86901. */
  86902. static readonly PointFillMode: number;
  86903. /**
  86904. * Returns the point list draw mode
  86905. */
  86906. static readonly PointListDrawMode: number;
  86907. /**
  86908. * Returns the line list draw mode
  86909. */
  86910. static readonly LineListDrawMode: number;
  86911. /**
  86912. * Returns the line loop draw mode
  86913. */
  86914. static readonly LineLoopDrawMode: number;
  86915. /**
  86916. * Returns the line strip draw mode
  86917. */
  86918. static readonly LineStripDrawMode: number;
  86919. /**
  86920. * Returns the triangle strip draw mode
  86921. */
  86922. static readonly TriangleStripDrawMode: number;
  86923. /**
  86924. * Returns the triangle fan draw mode
  86925. */
  86926. static readonly TriangleFanDrawMode: number;
  86927. /**
  86928. * Stores the clock-wise side orientation
  86929. */
  86930. static readonly ClockWiseSideOrientation: number;
  86931. /**
  86932. * Stores the counter clock-wise side orientation
  86933. */
  86934. static readonly CounterClockWiseSideOrientation: number;
  86935. /**
  86936. * The dirty texture flag value
  86937. */
  86938. static readonly TextureDirtyFlag: number;
  86939. /**
  86940. * The dirty light flag value
  86941. */
  86942. static readonly LightDirtyFlag: number;
  86943. /**
  86944. * The dirty fresnel flag value
  86945. */
  86946. static readonly FresnelDirtyFlag: number;
  86947. /**
  86948. * The dirty attribute flag value
  86949. */
  86950. static readonly AttributesDirtyFlag: number;
  86951. /**
  86952. * The dirty misc flag value
  86953. */
  86954. static readonly MiscDirtyFlag: number;
  86955. /**
  86956. * The all dirty flag value
  86957. */
  86958. static readonly AllDirtyFlag: number;
  86959. /**
  86960. * The ID of the material
  86961. */
  86962. id: string;
  86963. /**
  86964. * Gets or sets the unique id of the material
  86965. */
  86966. uniqueId: number;
  86967. /**
  86968. * The name of the material
  86969. */
  86970. name: string;
  86971. /**
  86972. * Gets or sets user defined metadata
  86973. */
  86974. metadata: any;
  86975. /**
  86976. * For internal use only. Please do not use.
  86977. */
  86978. reservedDataStore: any;
  86979. /**
  86980. * Specifies if the ready state should be checked on each call
  86981. */
  86982. checkReadyOnEveryCall: boolean;
  86983. /**
  86984. * Specifies if the ready state should be checked once
  86985. */
  86986. checkReadyOnlyOnce: boolean;
  86987. /**
  86988. * The state of the material
  86989. */
  86990. state: string;
  86991. /**
  86992. * The alpha value of the material
  86993. */
  86994. protected _alpha: number;
  86995. /**
  86996. * List of inspectable custom properties (used by the Inspector)
  86997. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86998. */
  86999. inspectableCustomProperties: IInspectable[];
  87000. /**
  87001. * Sets the alpha value of the material
  87002. */
  87003. /**
  87004. * Gets the alpha value of the material
  87005. */
  87006. alpha: number;
  87007. /**
  87008. * Specifies if back face culling is enabled
  87009. */
  87010. protected _backFaceCulling: boolean;
  87011. /**
  87012. * Sets the back-face culling state
  87013. */
  87014. /**
  87015. * Gets the back-face culling state
  87016. */
  87017. backFaceCulling: boolean;
  87018. /**
  87019. * Stores the value for side orientation
  87020. */
  87021. sideOrientation: number;
  87022. /**
  87023. * Callback triggered when the material is compiled
  87024. */
  87025. onCompiled: Nullable<(effect: Effect) => void>;
  87026. /**
  87027. * Callback triggered when an error occurs
  87028. */
  87029. onError: Nullable<(effect: Effect, errors: string) => void>;
  87030. /**
  87031. * Callback triggered to get the render target textures
  87032. */
  87033. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87034. /**
  87035. * Gets a boolean indicating that current material needs to register RTT
  87036. */
  87037. readonly hasRenderTargetTextures: boolean;
  87038. /**
  87039. * Specifies if the material should be serialized
  87040. */
  87041. doNotSerialize: boolean;
  87042. /**
  87043. * @hidden
  87044. */
  87045. _storeEffectOnSubMeshes: boolean;
  87046. /**
  87047. * Stores the animations for the material
  87048. */
  87049. animations: Nullable<Array<Animation>>;
  87050. /**
  87051. * An event triggered when the material is disposed
  87052. */
  87053. onDisposeObservable: Observable<Material>;
  87054. /**
  87055. * An observer which watches for dispose events
  87056. */
  87057. private _onDisposeObserver;
  87058. private _onUnBindObservable;
  87059. /**
  87060. * Called during a dispose event
  87061. */
  87062. onDispose: () => void;
  87063. private _onBindObservable;
  87064. /**
  87065. * An event triggered when the material is bound
  87066. */
  87067. readonly onBindObservable: Observable<AbstractMesh>;
  87068. /**
  87069. * An observer which watches for bind events
  87070. */
  87071. private _onBindObserver;
  87072. /**
  87073. * Called during a bind event
  87074. */
  87075. onBind: (Mesh: AbstractMesh) => void;
  87076. /**
  87077. * An event triggered when the material is unbound
  87078. */
  87079. readonly onUnBindObservable: Observable<Material>;
  87080. /**
  87081. * Stores the value of the alpha mode
  87082. */
  87083. private _alphaMode;
  87084. /**
  87085. * Sets the value of the alpha mode.
  87086. *
  87087. * | Value | Type | Description |
  87088. * | --- | --- | --- |
  87089. * | 0 | ALPHA_DISABLE | |
  87090. * | 1 | ALPHA_ADD | |
  87091. * | 2 | ALPHA_COMBINE | |
  87092. * | 3 | ALPHA_SUBTRACT | |
  87093. * | 4 | ALPHA_MULTIPLY | |
  87094. * | 5 | ALPHA_MAXIMIZED | |
  87095. * | 6 | ALPHA_ONEONE | |
  87096. * | 7 | ALPHA_PREMULTIPLIED | |
  87097. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87098. * | 9 | ALPHA_INTERPOLATE | |
  87099. * | 10 | ALPHA_SCREENMODE | |
  87100. *
  87101. */
  87102. /**
  87103. * Gets the value of the alpha mode
  87104. */
  87105. alphaMode: number;
  87106. /**
  87107. * Stores the state of the need depth pre-pass value
  87108. */
  87109. private _needDepthPrePass;
  87110. /**
  87111. * Sets the need depth pre-pass value
  87112. */
  87113. /**
  87114. * Gets the depth pre-pass value
  87115. */
  87116. needDepthPrePass: boolean;
  87117. /**
  87118. * Specifies if depth writing should be disabled
  87119. */
  87120. disableDepthWrite: boolean;
  87121. /**
  87122. * Specifies if depth writing should be forced
  87123. */
  87124. forceDepthWrite: boolean;
  87125. /**
  87126. * Specifies if there should be a separate pass for culling
  87127. */
  87128. separateCullingPass: boolean;
  87129. /**
  87130. * Stores the state specifing if fog should be enabled
  87131. */
  87132. private _fogEnabled;
  87133. /**
  87134. * Sets the state for enabling fog
  87135. */
  87136. /**
  87137. * Gets the value of the fog enabled state
  87138. */
  87139. fogEnabled: boolean;
  87140. /**
  87141. * Stores the size of points
  87142. */
  87143. pointSize: number;
  87144. /**
  87145. * Stores the z offset value
  87146. */
  87147. zOffset: number;
  87148. /**
  87149. * Gets a value specifying if wireframe mode is enabled
  87150. */
  87151. /**
  87152. * Sets the state of wireframe mode
  87153. */
  87154. wireframe: boolean;
  87155. /**
  87156. * Gets the value specifying if point clouds are enabled
  87157. */
  87158. /**
  87159. * Sets the state of point cloud mode
  87160. */
  87161. pointsCloud: boolean;
  87162. /**
  87163. * Gets the material fill mode
  87164. */
  87165. /**
  87166. * Sets the material fill mode
  87167. */
  87168. fillMode: number;
  87169. /**
  87170. * @hidden
  87171. * Stores the effects for the material
  87172. */
  87173. _effect: Nullable<Effect>;
  87174. /**
  87175. * @hidden
  87176. * Specifies if the material was previously ready
  87177. */
  87178. _wasPreviouslyReady: boolean;
  87179. /**
  87180. * Specifies if uniform buffers should be used
  87181. */
  87182. private _useUBO;
  87183. /**
  87184. * Stores a reference to the scene
  87185. */
  87186. private _scene;
  87187. /**
  87188. * Stores the fill mode state
  87189. */
  87190. private _fillMode;
  87191. /**
  87192. * Specifies if the depth write state should be cached
  87193. */
  87194. private _cachedDepthWriteState;
  87195. /**
  87196. * Stores the uniform buffer
  87197. */
  87198. protected _uniformBuffer: UniformBuffer;
  87199. /** @hidden */
  87200. _indexInSceneMaterialArray: number;
  87201. /** @hidden */
  87202. meshMap: Nullable<{
  87203. [id: string]: AbstractMesh | undefined;
  87204. }>;
  87205. /**
  87206. * Creates a material instance
  87207. * @param name defines the name of the material
  87208. * @param scene defines the scene to reference
  87209. * @param doNotAdd specifies if the material should be added to the scene
  87210. */
  87211. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87212. /**
  87213. * Returns a string representation of the current material
  87214. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87215. * @returns a string with material information
  87216. */
  87217. toString(fullDetails?: boolean): string;
  87218. /**
  87219. * Gets the class name of the material
  87220. * @returns a string with the class name of the material
  87221. */
  87222. getClassName(): string;
  87223. /**
  87224. * Specifies if updates for the material been locked
  87225. */
  87226. readonly isFrozen: boolean;
  87227. /**
  87228. * Locks updates for the material
  87229. */
  87230. freeze(): void;
  87231. /**
  87232. * Unlocks updates for the material
  87233. */
  87234. unfreeze(): void;
  87235. /**
  87236. * Specifies if the material is ready to be used
  87237. * @param mesh defines the mesh to check
  87238. * @param useInstances specifies if instances should be used
  87239. * @returns a boolean indicating if the material is ready to be used
  87240. */
  87241. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87242. /**
  87243. * Specifies that the submesh is ready to be used
  87244. * @param mesh defines the mesh to check
  87245. * @param subMesh defines which submesh to check
  87246. * @param useInstances specifies that instances should be used
  87247. * @returns a boolean indicating that the submesh is ready or not
  87248. */
  87249. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87250. /**
  87251. * Returns the material effect
  87252. * @returns the effect associated with the material
  87253. */
  87254. getEffect(): Nullable<Effect>;
  87255. /**
  87256. * Returns the current scene
  87257. * @returns a Scene
  87258. */
  87259. getScene(): Scene;
  87260. /**
  87261. * Specifies if the material will require alpha blending
  87262. * @returns a boolean specifying if alpha blending is needed
  87263. */
  87264. needAlphaBlending(): boolean;
  87265. /**
  87266. * Specifies if the mesh will require alpha blending
  87267. * @param mesh defines the mesh to check
  87268. * @returns a boolean specifying if alpha blending is needed for the mesh
  87269. */
  87270. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87271. /**
  87272. * Specifies if this material should be rendered in alpha test mode
  87273. * @returns a boolean specifying if an alpha test is needed.
  87274. */
  87275. needAlphaTesting(): boolean;
  87276. /**
  87277. * Gets the texture used for the alpha test
  87278. * @returns the texture to use for alpha testing
  87279. */
  87280. getAlphaTestTexture(): Nullable<BaseTexture>;
  87281. /**
  87282. * Marks the material to indicate that it needs to be re-calculated
  87283. */
  87284. markDirty(): void;
  87285. /** @hidden */
  87286. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87287. /**
  87288. * Binds the material to the mesh
  87289. * @param world defines the world transformation matrix
  87290. * @param mesh defines the mesh to bind the material to
  87291. */
  87292. bind(world: Matrix, mesh?: Mesh): void;
  87293. /**
  87294. * Binds the submesh to the material
  87295. * @param world defines the world transformation matrix
  87296. * @param mesh defines the mesh containing the submesh
  87297. * @param subMesh defines the submesh to bind the material to
  87298. */
  87299. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87300. /**
  87301. * Binds the world matrix to the material
  87302. * @param world defines the world transformation matrix
  87303. */
  87304. bindOnlyWorldMatrix(world: Matrix): void;
  87305. /**
  87306. * Binds the scene's uniform buffer to the effect.
  87307. * @param effect defines the effect to bind to the scene uniform buffer
  87308. * @param sceneUbo defines the uniform buffer storing scene data
  87309. */
  87310. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87311. /**
  87312. * Binds the view matrix to the effect
  87313. * @param effect defines the effect to bind the view matrix to
  87314. */
  87315. bindView(effect: Effect): void;
  87316. /**
  87317. * Binds the view projection matrix to the effect
  87318. * @param effect defines the effect to bind the view projection matrix to
  87319. */
  87320. bindViewProjection(effect: Effect): void;
  87321. /**
  87322. * Specifies if material alpha testing should be turned on for the mesh
  87323. * @param mesh defines the mesh to check
  87324. */
  87325. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87326. /**
  87327. * Processes to execute after binding the material to a mesh
  87328. * @param mesh defines the rendered mesh
  87329. */
  87330. protected _afterBind(mesh?: Mesh): void;
  87331. /**
  87332. * Unbinds the material from the mesh
  87333. */
  87334. unbind(): void;
  87335. /**
  87336. * Gets the active textures from the material
  87337. * @returns an array of textures
  87338. */
  87339. getActiveTextures(): BaseTexture[];
  87340. /**
  87341. * Specifies if the material uses a texture
  87342. * @param texture defines the texture to check against the material
  87343. * @returns a boolean specifying if the material uses the texture
  87344. */
  87345. hasTexture(texture: BaseTexture): boolean;
  87346. /**
  87347. * Makes a duplicate of the material, and gives it a new name
  87348. * @param name defines the new name for the duplicated material
  87349. * @returns the cloned material
  87350. */
  87351. clone(name: string): Nullable<Material>;
  87352. /**
  87353. * Gets the meshes bound to the material
  87354. * @returns an array of meshes bound to the material
  87355. */
  87356. getBindedMeshes(): AbstractMesh[];
  87357. /**
  87358. * Force shader compilation
  87359. * @param mesh defines the mesh associated with this material
  87360. * @param onCompiled defines a function to execute once the material is compiled
  87361. * @param options defines the options to configure the compilation
  87362. * @param onError defines a function to execute if the material fails compiling
  87363. */
  87364. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87365. clipPlane: boolean;
  87366. }>, onError?: (reason: string) => void): void;
  87367. /**
  87368. * Force shader compilation
  87369. * @param mesh defines the mesh that will use this material
  87370. * @param options defines additional options for compiling the shaders
  87371. * @returns a promise that resolves when the compilation completes
  87372. */
  87373. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87374. clipPlane: boolean;
  87375. }>): Promise<void>;
  87376. private static readonly _AllDirtyCallBack;
  87377. private static readonly _ImageProcessingDirtyCallBack;
  87378. private static readonly _TextureDirtyCallBack;
  87379. private static readonly _FresnelDirtyCallBack;
  87380. private static readonly _MiscDirtyCallBack;
  87381. private static readonly _LightsDirtyCallBack;
  87382. private static readonly _AttributeDirtyCallBack;
  87383. private static _FresnelAndMiscDirtyCallBack;
  87384. private static _TextureAndMiscDirtyCallBack;
  87385. private static readonly _DirtyCallbackArray;
  87386. private static readonly _RunDirtyCallBacks;
  87387. /**
  87388. * Marks a define in the material to indicate that it needs to be re-computed
  87389. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87390. */
  87391. markAsDirty(flag: number): void;
  87392. /**
  87393. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87394. * @param func defines a function which checks material defines against the submeshes
  87395. */
  87396. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87397. /**
  87398. * Indicates that we need to re-calculated for all submeshes
  87399. */
  87400. protected _markAllSubMeshesAsAllDirty(): void;
  87401. /**
  87402. * Indicates that image processing needs to be re-calculated for all submeshes
  87403. */
  87404. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87405. /**
  87406. * Indicates that textures need to be re-calculated for all submeshes
  87407. */
  87408. protected _markAllSubMeshesAsTexturesDirty(): void;
  87409. /**
  87410. * Indicates that fresnel needs to be re-calculated for all submeshes
  87411. */
  87412. protected _markAllSubMeshesAsFresnelDirty(): void;
  87413. /**
  87414. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87415. */
  87416. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87417. /**
  87418. * Indicates that lights need to be re-calculated for all submeshes
  87419. */
  87420. protected _markAllSubMeshesAsLightsDirty(): void;
  87421. /**
  87422. * Indicates that attributes need to be re-calculated for all submeshes
  87423. */
  87424. protected _markAllSubMeshesAsAttributesDirty(): void;
  87425. /**
  87426. * Indicates that misc needs to be re-calculated for all submeshes
  87427. */
  87428. protected _markAllSubMeshesAsMiscDirty(): void;
  87429. /**
  87430. * Indicates that textures and misc need to be re-calculated for all submeshes
  87431. */
  87432. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87433. /**
  87434. * Disposes the material
  87435. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87436. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87437. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87438. */
  87439. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87440. /** @hidden */
  87441. private releaseVertexArrayObject;
  87442. /**
  87443. * Serializes this material
  87444. * @returns the serialized material object
  87445. */
  87446. serialize(): any;
  87447. /**
  87448. * Creates a material from parsed material data
  87449. * @param parsedMaterial defines parsed material data
  87450. * @param scene defines the hosting scene
  87451. * @param rootUrl defines the root URL to use to load textures
  87452. * @returns a new material
  87453. */
  87454. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87455. }
  87456. }
  87457. declare module BABYLON {
  87458. /**
  87459. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87460. * separate meshes. This can be use to improve performances.
  87461. * @see http://doc.babylonjs.com/how_to/multi_materials
  87462. */
  87463. export class MultiMaterial extends Material {
  87464. private _subMaterials;
  87465. /**
  87466. * Gets or Sets the list of Materials used within the multi material.
  87467. * They need to be ordered according to the submeshes order in the associated mesh
  87468. */
  87469. subMaterials: Nullable<Material>[];
  87470. /**
  87471. * Function used to align with Node.getChildren()
  87472. * @returns the list of Materials used within the multi material
  87473. */
  87474. getChildren(): Nullable<Material>[];
  87475. /**
  87476. * Instantiates a new Multi Material
  87477. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87478. * separate meshes. This can be use to improve performances.
  87479. * @see http://doc.babylonjs.com/how_to/multi_materials
  87480. * @param name Define the name in the scene
  87481. * @param scene Define the scene the material belongs to
  87482. */
  87483. constructor(name: string, scene: Scene);
  87484. private _hookArray;
  87485. /**
  87486. * Get one of the submaterial by its index in the submaterials array
  87487. * @param index The index to look the sub material at
  87488. * @returns The Material if the index has been defined
  87489. */
  87490. getSubMaterial(index: number): Nullable<Material>;
  87491. /**
  87492. * Get the list of active textures for the whole sub materials list.
  87493. * @returns All the textures that will be used during the rendering
  87494. */
  87495. getActiveTextures(): BaseTexture[];
  87496. /**
  87497. * Gets the current class name of the material e.g. "MultiMaterial"
  87498. * Mainly use in serialization.
  87499. * @returns the class name
  87500. */
  87501. getClassName(): string;
  87502. /**
  87503. * Checks if the material is ready to render the requested sub mesh
  87504. * @param mesh Define the mesh the submesh belongs to
  87505. * @param subMesh Define the sub mesh to look readyness for
  87506. * @param useInstances Define whether or not the material is used with instances
  87507. * @returns true if ready, otherwise false
  87508. */
  87509. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87510. /**
  87511. * Clones the current material and its related sub materials
  87512. * @param name Define the name of the newly cloned material
  87513. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87514. * @returns the cloned material
  87515. */
  87516. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87517. /**
  87518. * Serializes the materials into a JSON representation.
  87519. * @returns the JSON representation
  87520. */
  87521. serialize(): any;
  87522. /**
  87523. * Dispose the material and release its associated resources
  87524. * @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)
  87525. * @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)
  87526. * @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)
  87527. */
  87528. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87529. /**
  87530. * Creates a MultiMaterial from parsed MultiMaterial data.
  87531. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87532. * @param scene defines the hosting scene
  87533. * @returns a new MultiMaterial
  87534. */
  87535. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87536. }
  87537. }
  87538. declare module BABYLON {
  87539. /**
  87540. * Base class for submeshes
  87541. */
  87542. export class BaseSubMesh {
  87543. /** @hidden */
  87544. _materialDefines: Nullable<MaterialDefines>;
  87545. /** @hidden */
  87546. _materialEffect: Nullable<Effect>;
  87547. /**
  87548. * Gets associated effect
  87549. */
  87550. readonly effect: Nullable<Effect>;
  87551. /**
  87552. * Sets associated effect (effect used to render this submesh)
  87553. * @param effect defines the effect to associate with
  87554. * @param defines defines the set of defines used to compile this effect
  87555. */
  87556. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87557. }
  87558. /**
  87559. * Defines a subdivision inside a mesh
  87560. */
  87561. export class SubMesh extends BaseSubMesh implements ICullable {
  87562. /** the material index to use */
  87563. materialIndex: number;
  87564. /** vertex index start */
  87565. verticesStart: number;
  87566. /** vertices count */
  87567. verticesCount: number;
  87568. /** index start */
  87569. indexStart: number;
  87570. /** indices count */
  87571. indexCount: number;
  87572. /** @hidden */
  87573. _linesIndexCount: number;
  87574. private _mesh;
  87575. private _renderingMesh;
  87576. private _boundingInfo;
  87577. private _linesIndexBuffer;
  87578. /** @hidden */
  87579. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87580. /** @hidden */
  87581. _trianglePlanes: Plane[];
  87582. /** @hidden */
  87583. _lastColliderTransformMatrix: Nullable<Matrix>;
  87584. /** @hidden */
  87585. _renderId: number;
  87586. /** @hidden */
  87587. _alphaIndex: number;
  87588. /** @hidden */
  87589. _distanceToCamera: number;
  87590. /** @hidden */
  87591. _id: number;
  87592. private _currentMaterial;
  87593. /**
  87594. * Add a new submesh to a mesh
  87595. * @param materialIndex defines the material index to use
  87596. * @param verticesStart defines vertex index start
  87597. * @param verticesCount defines vertices count
  87598. * @param indexStart defines index start
  87599. * @param indexCount defines indices count
  87600. * @param mesh defines the parent mesh
  87601. * @param renderingMesh defines an optional rendering mesh
  87602. * @param createBoundingBox defines if bounding box should be created for this submesh
  87603. * @returns the new submesh
  87604. */
  87605. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87606. /**
  87607. * Creates a new submesh
  87608. * @param materialIndex defines the material index to use
  87609. * @param verticesStart defines vertex index start
  87610. * @param verticesCount defines vertices count
  87611. * @param indexStart defines index start
  87612. * @param indexCount defines indices count
  87613. * @param mesh defines the parent mesh
  87614. * @param renderingMesh defines an optional rendering mesh
  87615. * @param createBoundingBox defines if bounding box should be created for this submesh
  87616. */
  87617. constructor(
  87618. /** the material index to use */
  87619. materialIndex: number,
  87620. /** vertex index start */
  87621. verticesStart: number,
  87622. /** vertices count */
  87623. verticesCount: number,
  87624. /** index start */
  87625. indexStart: number,
  87626. /** indices count */
  87627. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87628. /**
  87629. * Returns true if this submesh covers the entire parent mesh
  87630. * @ignorenaming
  87631. */
  87632. readonly IsGlobal: boolean;
  87633. /**
  87634. * Returns the submesh BoudingInfo object
  87635. * @returns current bounding info (or mesh's one if the submesh is global)
  87636. */
  87637. getBoundingInfo(): BoundingInfo;
  87638. /**
  87639. * Sets the submesh BoundingInfo
  87640. * @param boundingInfo defines the new bounding info to use
  87641. * @returns the SubMesh
  87642. */
  87643. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87644. /**
  87645. * Returns the mesh of the current submesh
  87646. * @return the parent mesh
  87647. */
  87648. getMesh(): AbstractMesh;
  87649. /**
  87650. * Returns the rendering mesh of the submesh
  87651. * @returns the rendering mesh (could be different from parent mesh)
  87652. */
  87653. getRenderingMesh(): Mesh;
  87654. /**
  87655. * Returns the submesh material
  87656. * @returns null or the current material
  87657. */
  87658. getMaterial(): Nullable<Material>;
  87659. /**
  87660. * Sets a new updated BoundingInfo object to the submesh
  87661. * @param data defines an optional position array to use to determine the bounding info
  87662. * @returns the SubMesh
  87663. */
  87664. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87665. /** @hidden */
  87666. _checkCollision(collider: Collider): boolean;
  87667. /**
  87668. * Updates the submesh BoundingInfo
  87669. * @param world defines the world matrix to use to update the bounding info
  87670. * @returns the submesh
  87671. */
  87672. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87673. /**
  87674. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87675. * @param frustumPlanes defines the frustum planes
  87676. * @returns true if the submesh is intersecting with the frustum
  87677. */
  87678. isInFrustum(frustumPlanes: Plane[]): boolean;
  87679. /**
  87680. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87681. * @param frustumPlanes defines the frustum planes
  87682. * @returns true if the submesh is inside the frustum
  87683. */
  87684. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87685. /**
  87686. * Renders the submesh
  87687. * @param enableAlphaMode defines if alpha needs to be used
  87688. * @returns the submesh
  87689. */
  87690. render(enableAlphaMode: boolean): SubMesh;
  87691. /**
  87692. * @hidden
  87693. */
  87694. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87695. /**
  87696. * Checks if the submesh intersects with a ray
  87697. * @param ray defines the ray to test
  87698. * @returns true is the passed ray intersects the submesh bounding box
  87699. */
  87700. canIntersects(ray: Ray): boolean;
  87701. /**
  87702. * Intersects current submesh with a ray
  87703. * @param ray defines the ray to test
  87704. * @param positions defines mesh's positions array
  87705. * @param indices defines mesh's indices array
  87706. * @param fastCheck defines if only bounding info should be used
  87707. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87708. * @returns intersection info or null if no intersection
  87709. */
  87710. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87711. /** @hidden */
  87712. private _intersectLines;
  87713. /** @hidden */
  87714. private _intersectUnIndexedLines;
  87715. /** @hidden */
  87716. private _intersectTriangles;
  87717. /** @hidden */
  87718. private _intersectUnIndexedTriangles;
  87719. /** @hidden */
  87720. _rebuild(): void;
  87721. /**
  87722. * Creates a new submesh from the passed mesh
  87723. * @param newMesh defines the new hosting mesh
  87724. * @param newRenderingMesh defines an optional rendering mesh
  87725. * @returns the new submesh
  87726. */
  87727. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87728. /**
  87729. * Release associated resources
  87730. */
  87731. dispose(): void;
  87732. /**
  87733. * Gets the class name
  87734. * @returns the string "SubMesh".
  87735. */
  87736. getClassName(): string;
  87737. /**
  87738. * Creates a new submesh from indices data
  87739. * @param materialIndex the index of the main mesh material
  87740. * @param startIndex the index where to start the copy in the mesh indices array
  87741. * @param indexCount the number of indices to copy then from the startIndex
  87742. * @param mesh the main mesh to create the submesh from
  87743. * @param renderingMesh the optional rendering mesh
  87744. * @returns a new submesh
  87745. */
  87746. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87747. }
  87748. }
  87749. declare module BABYLON {
  87750. /**
  87751. * Class used to represent data loading progression
  87752. */
  87753. export class SceneLoaderFlags {
  87754. private static _ForceFullSceneLoadingForIncremental;
  87755. private static _ShowLoadingScreen;
  87756. private static _CleanBoneMatrixWeights;
  87757. private static _loggingLevel;
  87758. /**
  87759. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87760. */
  87761. static ForceFullSceneLoadingForIncremental: boolean;
  87762. /**
  87763. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87764. */
  87765. static ShowLoadingScreen: boolean;
  87766. /**
  87767. * Defines the current logging level (while loading the scene)
  87768. * @ignorenaming
  87769. */
  87770. static loggingLevel: number;
  87771. /**
  87772. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87773. */
  87774. static CleanBoneMatrixWeights: boolean;
  87775. }
  87776. }
  87777. declare module BABYLON {
  87778. /**
  87779. * Class used to store geometry data (vertex buffers + index buffer)
  87780. */
  87781. export class Geometry implements IGetSetVerticesData {
  87782. /**
  87783. * Gets or sets the ID of the geometry
  87784. */
  87785. id: string;
  87786. /**
  87787. * Gets or sets the unique ID of the geometry
  87788. */
  87789. uniqueId: number;
  87790. /**
  87791. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87792. */
  87793. delayLoadState: number;
  87794. /**
  87795. * Gets the file containing the data to load when running in delay load state
  87796. */
  87797. delayLoadingFile: Nullable<string>;
  87798. /**
  87799. * Callback called when the geometry is updated
  87800. */
  87801. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87802. private _scene;
  87803. private _engine;
  87804. private _meshes;
  87805. private _totalVertices;
  87806. /** @hidden */
  87807. _indices: IndicesArray;
  87808. /** @hidden */
  87809. _vertexBuffers: {
  87810. [key: string]: VertexBuffer;
  87811. };
  87812. private _isDisposed;
  87813. private _extend;
  87814. private _boundingBias;
  87815. /** @hidden */
  87816. _delayInfo: Array<string>;
  87817. private _indexBuffer;
  87818. private _indexBufferIsUpdatable;
  87819. /** @hidden */
  87820. _boundingInfo: Nullable<BoundingInfo>;
  87821. /** @hidden */
  87822. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87823. /** @hidden */
  87824. _softwareSkinningFrameId: number;
  87825. private _vertexArrayObjects;
  87826. private _updatable;
  87827. /** @hidden */
  87828. _positions: Nullable<Vector3[]>;
  87829. /**
  87830. * 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
  87831. */
  87832. /**
  87833. * 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
  87834. */
  87835. boundingBias: Vector2;
  87836. /**
  87837. * Static function used to attach a new empty geometry to a mesh
  87838. * @param mesh defines the mesh to attach the geometry to
  87839. * @returns the new Geometry
  87840. */
  87841. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87842. /**
  87843. * Creates a new geometry
  87844. * @param id defines the unique ID
  87845. * @param scene defines the hosting scene
  87846. * @param vertexData defines the VertexData used to get geometry data
  87847. * @param updatable defines if geometry must be updatable (false by default)
  87848. * @param mesh defines the mesh that will be associated with the geometry
  87849. */
  87850. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87851. /**
  87852. * Gets the current extend of the geometry
  87853. */
  87854. readonly extend: {
  87855. minimum: Vector3;
  87856. maximum: Vector3;
  87857. };
  87858. /**
  87859. * Gets the hosting scene
  87860. * @returns the hosting Scene
  87861. */
  87862. getScene(): Scene;
  87863. /**
  87864. * Gets the hosting engine
  87865. * @returns the hosting Engine
  87866. */
  87867. getEngine(): Engine;
  87868. /**
  87869. * Defines if the geometry is ready to use
  87870. * @returns true if the geometry is ready to be used
  87871. */
  87872. isReady(): boolean;
  87873. /**
  87874. * Gets a value indicating that the geometry should not be serialized
  87875. */
  87876. readonly doNotSerialize: boolean;
  87877. /** @hidden */
  87878. _rebuild(): void;
  87879. /**
  87880. * Affects all geometry data in one call
  87881. * @param vertexData defines the geometry data
  87882. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87883. */
  87884. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87885. /**
  87886. * Set specific vertex data
  87887. * @param kind defines the data kind (Position, normal, etc...)
  87888. * @param data defines the vertex data to use
  87889. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87890. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87891. */
  87892. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87893. /**
  87894. * Removes a specific vertex data
  87895. * @param kind defines the data kind (Position, normal, etc...)
  87896. */
  87897. removeVerticesData(kind: string): void;
  87898. /**
  87899. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87900. * @param buffer defines the vertex buffer to use
  87901. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87902. */
  87903. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87904. /**
  87905. * Update a specific vertex buffer
  87906. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87907. * It will do nothing if the buffer is not updatable
  87908. * @param kind defines the data kind (Position, normal, etc...)
  87909. * @param data defines the data to use
  87910. * @param offset defines the offset in the target buffer where to store the data
  87911. * @param useBytes set to true if the offset is in bytes
  87912. */
  87913. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87914. /**
  87915. * Update a specific vertex buffer
  87916. * This function will create a new buffer if the current one is not updatable
  87917. * @param kind defines the data kind (Position, normal, etc...)
  87918. * @param data defines the data to use
  87919. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87920. */
  87921. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87922. private _updateBoundingInfo;
  87923. /** @hidden */
  87924. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87925. /**
  87926. * Gets total number of vertices
  87927. * @returns the total number of vertices
  87928. */
  87929. getTotalVertices(): number;
  87930. /**
  87931. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87932. * @param kind defines the data kind (Position, normal, etc...)
  87933. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87934. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87935. * @returns a float array containing vertex data
  87936. */
  87937. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87938. /**
  87939. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87940. * @param kind defines the data kind (Position, normal, etc...)
  87941. * @returns true if the vertex buffer with the specified kind is updatable
  87942. */
  87943. isVertexBufferUpdatable(kind: string): boolean;
  87944. /**
  87945. * Gets a specific vertex buffer
  87946. * @param kind defines the data kind (Position, normal, etc...)
  87947. * @returns a VertexBuffer
  87948. */
  87949. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87950. /**
  87951. * Returns all vertex buffers
  87952. * @return an object holding all vertex buffers indexed by kind
  87953. */
  87954. getVertexBuffers(): Nullable<{
  87955. [key: string]: VertexBuffer;
  87956. }>;
  87957. /**
  87958. * Gets a boolean indicating if specific vertex buffer is present
  87959. * @param kind defines the data kind (Position, normal, etc...)
  87960. * @returns true if data is present
  87961. */
  87962. isVerticesDataPresent(kind: string): boolean;
  87963. /**
  87964. * Gets a list of all attached data kinds (Position, normal, etc...)
  87965. * @returns a list of string containing all kinds
  87966. */
  87967. getVerticesDataKinds(): string[];
  87968. /**
  87969. * Update index buffer
  87970. * @param indices defines the indices to store in the index buffer
  87971. * @param offset defines the offset in the target buffer where to store the data
  87972. * @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)
  87973. */
  87974. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87975. /**
  87976. * Creates a new index buffer
  87977. * @param indices defines the indices to store in the index buffer
  87978. * @param totalVertices defines the total number of vertices (could be null)
  87979. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87980. */
  87981. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87982. /**
  87983. * Return the total number of indices
  87984. * @returns the total number of indices
  87985. */
  87986. getTotalIndices(): number;
  87987. /**
  87988. * Gets the index buffer array
  87989. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87990. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87991. * @returns the index buffer array
  87992. */
  87993. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87994. /**
  87995. * Gets the index buffer
  87996. * @return the index buffer
  87997. */
  87998. getIndexBuffer(): Nullable<DataBuffer>;
  87999. /** @hidden */
  88000. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88001. /**
  88002. * Release the associated resources for a specific mesh
  88003. * @param mesh defines the source mesh
  88004. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88005. */
  88006. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88007. /**
  88008. * Apply current geometry to a given mesh
  88009. * @param mesh defines the mesh to apply geometry to
  88010. */
  88011. applyToMesh(mesh: Mesh): void;
  88012. private _updateExtend;
  88013. private _applyToMesh;
  88014. private notifyUpdate;
  88015. /**
  88016. * Load the geometry if it was flagged as delay loaded
  88017. * @param scene defines the hosting scene
  88018. * @param onLoaded defines a callback called when the geometry is loaded
  88019. */
  88020. load(scene: Scene, onLoaded?: () => void): void;
  88021. private _queueLoad;
  88022. /**
  88023. * Invert the geometry to move from a right handed system to a left handed one.
  88024. */
  88025. toLeftHanded(): void;
  88026. /** @hidden */
  88027. _resetPointsArrayCache(): void;
  88028. /** @hidden */
  88029. _generatePointsArray(): boolean;
  88030. /**
  88031. * Gets a value indicating if the geometry is disposed
  88032. * @returns true if the geometry was disposed
  88033. */
  88034. isDisposed(): boolean;
  88035. private _disposeVertexArrayObjects;
  88036. /**
  88037. * Free all associated resources
  88038. */
  88039. dispose(): void;
  88040. /**
  88041. * Clone the current geometry into a new geometry
  88042. * @param id defines the unique ID of the new geometry
  88043. * @returns a new geometry object
  88044. */
  88045. copy(id: string): Geometry;
  88046. /**
  88047. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88048. * @return a JSON representation of the current geometry data (without the vertices data)
  88049. */
  88050. serialize(): any;
  88051. private toNumberArray;
  88052. /**
  88053. * Serialize all vertices data into a JSON oject
  88054. * @returns a JSON representation of the current geometry data
  88055. */
  88056. serializeVerticeData(): any;
  88057. /**
  88058. * Extracts a clone of a mesh geometry
  88059. * @param mesh defines the source mesh
  88060. * @param id defines the unique ID of the new geometry object
  88061. * @returns the new geometry object
  88062. */
  88063. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88064. /**
  88065. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88066. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88067. * Be aware Math.random() could cause collisions, but:
  88068. * "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"
  88069. * @returns a string containing a new GUID
  88070. */
  88071. static RandomId(): string;
  88072. /** @hidden */
  88073. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88074. private static _CleanMatricesWeights;
  88075. /**
  88076. * Create a new geometry from persisted data (Using .babylon file format)
  88077. * @param parsedVertexData defines the persisted data
  88078. * @param scene defines the hosting scene
  88079. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88080. * @returns the new geometry object
  88081. */
  88082. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88083. }
  88084. }
  88085. declare module BABYLON {
  88086. /**
  88087. * Define an interface for all classes that will get and set the data on vertices
  88088. */
  88089. export interface IGetSetVerticesData {
  88090. /**
  88091. * Gets a boolean indicating if specific vertex data is present
  88092. * @param kind defines the vertex data kind to use
  88093. * @returns true is data kind is present
  88094. */
  88095. isVerticesDataPresent(kind: string): boolean;
  88096. /**
  88097. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88098. * @param kind defines the data kind (Position, normal, etc...)
  88099. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88100. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88101. * @returns a float array containing vertex data
  88102. */
  88103. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88104. /**
  88105. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88106. * @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.
  88107. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88108. * @returns the indices array or an empty array if the mesh has no geometry
  88109. */
  88110. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88111. /**
  88112. * Set specific vertex data
  88113. * @param kind defines the data kind (Position, normal, etc...)
  88114. * @param data defines the vertex data to use
  88115. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88116. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88117. */
  88118. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88119. /**
  88120. * Update a specific associated vertex buffer
  88121. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88122. * - VertexBuffer.PositionKind
  88123. * - VertexBuffer.UVKind
  88124. * - VertexBuffer.UV2Kind
  88125. * - VertexBuffer.UV3Kind
  88126. * - VertexBuffer.UV4Kind
  88127. * - VertexBuffer.UV5Kind
  88128. * - VertexBuffer.UV6Kind
  88129. * - VertexBuffer.ColorKind
  88130. * - VertexBuffer.MatricesIndicesKind
  88131. * - VertexBuffer.MatricesIndicesExtraKind
  88132. * - VertexBuffer.MatricesWeightsKind
  88133. * - VertexBuffer.MatricesWeightsExtraKind
  88134. * @param data defines the data source
  88135. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88136. * @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)
  88137. */
  88138. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88139. /**
  88140. * Creates a new index buffer
  88141. * @param indices defines the indices to store in the index buffer
  88142. * @param totalVertices defines the total number of vertices (could be null)
  88143. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88144. */
  88145. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88146. }
  88147. /**
  88148. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88149. */
  88150. export class VertexData {
  88151. /**
  88152. * Mesh side orientation : usually the external or front surface
  88153. */
  88154. static readonly FRONTSIDE: number;
  88155. /**
  88156. * Mesh side orientation : usually the internal or back surface
  88157. */
  88158. static readonly BACKSIDE: number;
  88159. /**
  88160. * Mesh side orientation : both internal and external or front and back surfaces
  88161. */
  88162. static readonly DOUBLESIDE: number;
  88163. /**
  88164. * Mesh side orientation : by default, `FRONTSIDE`
  88165. */
  88166. static readonly DEFAULTSIDE: number;
  88167. /**
  88168. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88169. */
  88170. positions: Nullable<FloatArray>;
  88171. /**
  88172. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88173. */
  88174. normals: Nullable<FloatArray>;
  88175. /**
  88176. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88177. */
  88178. tangents: Nullable<FloatArray>;
  88179. /**
  88180. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88181. */
  88182. uvs: Nullable<FloatArray>;
  88183. /**
  88184. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88185. */
  88186. uvs2: Nullable<FloatArray>;
  88187. /**
  88188. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88189. */
  88190. uvs3: Nullable<FloatArray>;
  88191. /**
  88192. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88193. */
  88194. uvs4: Nullable<FloatArray>;
  88195. /**
  88196. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88197. */
  88198. uvs5: Nullable<FloatArray>;
  88199. /**
  88200. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88201. */
  88202. uvs6: Nullable<FloatArray>;
  88203. /**
  88204. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88205. */
  88206. colors: Nullable<FloatArray>;
  88207. /**
  88208. * 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).
  88209. */
  88210. matricesIndices: Nullable<FloatArray>;
  88211. /**
  88212. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88213. */
  88214. matricesWeights: Nullable<FloatArray>;
  88215. /**
  88216. * An array extending the number of possible indices
  88217. */
  88218. matricesIndicesExtra: Nullable<FloatArray>;
  88219. /**
  88220. * An array extending the number of possible weights when the number of indices is extended
  88221. */
  88222. matricesWeightsExtra: Nullable<FloatArray>;
  88223. /**
  88224. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88225. */
  88226. indices: Nullable<IndicesArray>;
  88227. /**
  88228. * Uses the passed data array to set the set the values for the specified kind of data
  88229. * @param data a linear array of floating numbers
  88230. * @param kind the type of data that is being set, eg positions, colors etc
  88231. */
  88232. set(data: FloatArray, kind: string): void;
  88233. /**
  88234. * Associates the vertexData to the passed Mesh.
  88235. * Sets it as updatable or not (default `false`)
  88236. * @param mesh the mesh the vertexData is applied to
  88237. * @param updatable when used and having the value true allows new data to update the vertexData
  88238. * @returns the VertexData
  88239. */
  88240. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88241. /**
  88242. * Associates the vertexData to the passed Geometry.
  88243. * Sets it as updatable or not (default `false`)
  88244. * @param geometry the geometry the vertexData is applied to
  88245. * @param updatable when used and having the value true allows new data to update the vertexData
  88246. * @returns VertexData
  88247. */
  88248. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88249. /**
  88250. * Updates the associated mesh
  88251. * @param mesh the mesh to be updated
  88252. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88253. * @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
  88254. * @returns VertexData
  88255. */
  88256. updateMesh(mesh: Mesh): VertexData;
  88257. /**
  88258. * Updates the associated geometry
  88259. * @param geometry the geometry to be updated
  88260. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88261. * @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
  88262. * @returns VertexData.
  88263. */
  88264. updateGeometry(geometry: Geometry): VertexData;
  88265. private _applyTo;
  88266. private _update;
  88267. /**
  88268. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88269. * @param matrix the transforming matrix
  88270. * @returns the VertexData
  88271. */
  88272. transform(matrix: Matrix): VertexData;
  88273. /**
  88274. * Merges the passed VertexData into the current one
  88275. * @param other the VertexData to be merged into the current one
  88276. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88277. * @returns the modified VertexData
  88278. */
  88279. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88280. private _mergeElement;
  88281. private _validate;
  88282. /**
  88283. * Serializes the VertexData
  88284. * @returns a serialized object
  88285. */
  88286. serialize(): any;
  88287. /**
  88288. * Extracts the vertexData from a mesh
  88289. * @param mesh the mesh from which to extract the VertexData
  88290. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88291. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88292. * @returns the object VertexData associated to the passed mesh
  88293. */
  88294. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88295. /**
  88296. * Extracts the vertexData from the geometry
  88297. * @param geometry the geometry from which to extract the VertexData
  88298. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88299. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88300. * @returns the object VertexData associated to the passed mesh
  88301. */
  88302. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88303. private static _ExtractFrom;
  88304. /**
  88305. * Creates the VertexData for a Ribbon
  88306. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88307. * * pathArray array of paths, each of which an array of successive Vector3
  88308. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88309. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88310. * * 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
  88311. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88312. * * 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)
  88313. * * 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)
  88314. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88315. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88316. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88317. * @returns the VertexData of the ribbon
  88318. */
  88319. static CreateRibbon(options: {
  88320. pathArray: Vector3[][];
  88321. closeArray?: boolean;
  88322. closePath?: boolean;
  88323. offset?: number;
  88324. sideOrientation?: number;
  88325. frontUVs?: Vector4;
  88326. backUVs?: Vector4;
  88327. invertUV?: boolean;
  88328. uvs?: Vector2[];
  88329. colors?: Color4[];
  88330. }): VertexData;
  88331. /**
  88332. * Creates the VertexData for a box
  88333. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88334. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88335. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88336. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88337. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88338. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88339. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88340. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88341. * * 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)
  88342. * * 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)
  88343. * @returns the VertexData of the box
  88344. */
  88345. static CreateBox(options: {
  88346. size?: number;
  88347. width?: number;
  88348. height?: number;
  88349. depth?: number;
  88350. faceUV?: Vector4[];
  88351. faceColors?: Color4[];
  88352. sideOrientation?: number;
  88353. frontUVs?: Vector4;
  88354. backUVs?: Vector4;
  88355. }): VertexData;
  88356. /**
  88357. * Creates the VertexData for a tiled box
  88358. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88359. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88360. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88361. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88362. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88363. * @returns the VertexData of the box
  88364. */
  88365. static CreateTiledBox(options: {
  88366. pattern?: number;
  88367. width?: number;
  88368. height?: number;
  88369. depth?: number;
  88370. tileSize?: number;
  88371. tileWidth?: number;
  88372. tileHeight?: number;
  88373. alignHorizontal?: number;
  88374. alignVertical?: number;
  88375. faceUV?: Vector4[];
  88376. faceColors?: Color4[];
  88377. sideOrientation?: number;
  88378. }): VertexData;
  88379. /**
  88380. * Creates the VertexData for a tiled plane
  88381. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88382. * * pattern a limited pattern arrangement depending on the number
  88383. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88384. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88385. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88386. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88387. * * 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)
  88388. * * 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)
  88389. * @returns the VertexData of the tiled plane
  88390. */
  88391. static CreateTiledPlane(options: {
  88392. pattern?: number;
  88393. tileSize?: number;
  88394. tileWidth?: number;
  88395. tileHeight?: number;
  88396. size?: number;
  88397. width?: number;
  88398. height?: number;
  88399. alignHorizontal?: number;
  88400. alignVertical?: number;
  88401. sideOrientation?: number;
  88402. frontUVs?: Vector4;
  88403. backUVs?: Vector4;
  88404. }): VertexData;
  88405. /**
  88406. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88407. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88408. * * segments sets the number of horizontal strips optional, default 32
  88409. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88410. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88411. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88412. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88413. * * 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
  88414. * * 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
  88415. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88416. * * 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)
  88417. * * 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)
  88418. * @returns the VertexData of the ellipsoid
  88419. */
  88420. static CreateSphere(options: {
  88421. segments?: number;
  88422. diameter?: number;
  88423. diameterX?: number;
  88424. diameterY?: number;
  88425. diameterZ?: number;
  88426. arc?: number;
  88427. slice?: number;
  88428. sideOrientation?: number;
  88429. frontUVs?: Vector4;
  88430. backUVs?: Vector4;
  88431. }): VertexData;
  88432. /**
  88433. * Creates the VertexData for a cylinder, cone or prism
  88434. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88435. * * height sets the height (y direction) of the cylinder, optional, default 2
  88436. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88437. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88438. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88439. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88440. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88441. * * 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
  88442. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88443. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88444. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88445. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88446. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88447. * * 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)
  88448. * * 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)
  88449. * @returns the VertexData of the cylinder, cone or prism
  88450. */
  88451. static CreateCylinder(options: {
  88452. height?: number;
  88453. diameterTop?: number;
  88454. diameterBottom?: number;
  88455. diameter?: number;
  88456. tessellation?: number;
  88457. subdivisions?: number;
  88458. arc?: number;
  88459. faceColors?: Color4[];
  88460. faceUV?: Vector4[];
  88461. hasRings?: boolean;
  88462. enclose?: boolean;
  88463. sideOrientation?: number;
  88464. frontUVs?: Vector4;
  88465. backUVs?: Vector4;
  88466. }): VertexData;
  88467. /**
  88468. * Creates the VertexData for a torus
  88469. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88470. * * diameter the diameter of the torus, optional default 1
  88471. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88472. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88474. * * 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)
  88475. * * 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)
  88476. * @returns the VertexData of the torus
  88477. */
  88478. static CreateTorus(options: {
  88479. diameter?: number;
  88480. thickness?: number;
  88481. tessellation?: number;
  88482. sideOrientation?: number;
  88483. frontUVs?: Vector4;
  88484. backUVs?: Vector4;
  88485. }): VertexData;
  88486. /**
  88487. * Creates the VertexData of the LineSystem
  88488. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88489. * - lines an array of lines, each line being an array of successive Vector3
  88490. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88491. * @returns the VertexData of the LineSystem
  88492. */
  88493. static CreateLineSystem(options: {
  88494. lines: Vector3[][];
  88495. colors?: Nullable<Color4[][]>;
  88496. }): VertexData;
  88497. /**
  88498. * Create the VertexData for a DashedLines
  88499. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88500. * - points an array successive Vector3
  88501. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88502. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88503. * - dashNb the intended total number of dashes, optional, default 200
  88504. * @returns the VertexData for the DashedLines
  88505. */
  88506. static CreateDashedLines(options: {
  88507. points: Vector3[];
  88508. dashSize?: number;
  88509. gapSize?: number;
  88510. dashNb?: number;
  88511. }): VertexData;
  88512. /**
  88513. * Creates the VertexData for a Ground
  88514. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88515. * - width the width (x direction) of the ground, optional, default 1
  88516. * - height the height (z direction) of the ground, optional, default 1
  88517. * - subdivisions the number of subdivisions per side, optional, default 1
  88518. * @returns the VertexData of the Ground
  88519. */
  88520. static CreateGround(options: {
  88521. width?: number;
  88522. height?: number;
  88523. subdivisions?: number;
  88524. subdivisionsX?: number;
  88525. subdivisionsY?: number;
  88526. }): VertexData;
  88527. /**
  88528. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88529. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88530. * * xmin the ground minimum X coordinate, optional, default -1
  88531. * * zmin the ground minimum Z coordinate, optional, default -1
  88532. * * xmax the ground maximum X coordinate, optional, default 1
  88533. * * zmax the ground maximum Z coordinate, optional, default 1
  88534. * * 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}
  88535. * * 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}
  88536. * @returns the VertexData of the TiledGround
  88537. */
  88538. static CreateTiledGround(options: {
  88539. xmin: number;
  88540. zmin: number;
  88541. xmax: number;
  88542. zmax: number;
  88543. subdivisions?: {
  88544. w: number;
  88545. h: number;
  88546. };
  88547. precision?: {
  88548. w: number;
  88549. h: number;
  88550. };
  88551. }): VertexData;
  88552. /**
  88553. * Creates the VertexData of the Ground designed from a heightmap
  88554. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88555. * * width the width (x direction) of the ground
  88556. * * height the height (z direction) of the ground
  88557. * * subdivisions the number of subdivisions per side
  88558. * * minHeight the minimum altitude on the ground, optional, default 0
  88559. * * maxHeight the maximum altitude on the ground, optional default 1
  88560. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88561. * * buffer the array holding the image color data
  88562. * * bufferWidth the width of image
  88563. * * bufferHeight the height of image
  88564. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88565. * @returns the VertexData of the Ground designed from a heightmap
  88566. */
  88567. static CreateGroundFromHeightMap(options: {
  88568. width: number;
  88569. height: number;
  88570. subdivisions: number;
  88571. minHeight: number;
  88572. maxHeight: number;
  88573. colorFilter: Color3;
  88574. buffer: Uint8Array;
  88575. bufferWidth: number;
  88576. bufferHeight: number;
  88577. alphaFilter: number;
  88578. }): VertexData;
  88579. /**
  88580. * Creates the VertexData for a Plane
  88581. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88582. * * size sets the width and height of the plane to the value of size, optional default 1
  88583. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88584. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88585. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88586. * * 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)
  88587. * * 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)
  88588. * @returns the VertexData of the box
  88589. */
  88590. static CreatePlane(options: {
  88591. size?: number;
  88592. width?: number;
  88593. height?: number;
  88594. sideOrientation?: number;
  88595. frontUVs?: Vector4;
  88596. backUVs?: Vector4;
  88597. }): VertexData;
  88598. /**
  88599. * Creates the VertexData of the Disc or regular Polygon
  88600. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88601. * * radius the radius of the disc, optional default 0.5
  88602. * * tessellation the number of polygon sides, optional, default 64
  88603. * * 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
  88604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88605. * * 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)
  88606. * * 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)
  88607. * @returns the VertexData of the box
  88608. */
  88609. static CreateDisc(options: {
  88610. radius?: number;
  88611. tessellation?: number;
  88612. arc?: number;
  88613. sideOrientation?: number;
  88614. frontUVs?: Vector4;
  88615. backUVs?: Vector4;
  88616. }): VertexData;
  88617. /**
  88618. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88619. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88620. * @param polygon a mesh built from polygonTriangulation.build()
  88621. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88622. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88623. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88624. * @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)
  88625. * @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)
  88626. * @returns the VertexData of the Polygon
  88627. */
  88628. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88629. /**
  88630. * Creates the VertexData of the IcoSphere
  88631. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88632. * * radius the radius of the IcoSphere, optional default 1
  88633. * * radiusX allows stretching in the x direction, optional, default radius
  88634. * * radiusY allows stretching in the y direction, optional, default radius
  88635. * * radiusZ allows stretching in the z direction, optional, default radius
  88636. * * flat when true creates a flat shaded mesh, optional, default true
  88637. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88638. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88639. * * 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)
  88640. * * 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)
  88641. * @returns the VertexData of the IcoSphere
  88642. */
  88643. static CreateIcoSphere(options: {
  88644. radius?: number;
  88645. radiusX?: number;
  88646. radiusY?: number;
  88647. radiusZ?: number;
  88648. flat?: boolean;
  88649. subdivisions?: number;
  88650. sideOrientation?: number;
  88651. frontUVs?: Vector4;
  88652. backUVs?: Vector4;
  88653. }): VertexData;
  88654. /**
  88655. * Creates the VertexData for a Polyhedron
  88656. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88657. * * type provided types are:
  88658. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88659. * * 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)
  88660. * * size the size of the IcoSphere, optional default 1
  88661. * * sizeX allows stretching in the x direction, optional, default size
  88662. * * sizeY allows stretching in the y direction, optional, default size
  88663. * * sizeZ allows stretching in the z direction, optional, default size
  88664. * * 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
  88665. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88666. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88667. * * flat when true creates a flat shaded mesh, optional, default true
  88668. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88669. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88670. * * 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)
  88671. * * 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)
  88672. * @returns the VertexData of the Polyhedron
  88673. */
  88674. static CreatePolyhedron(options: {
  88675. type?: number;
  88676. size?: number;
  88677. sizeX?: number;
  88678. sizeY?: number;
  88679. sizeZ?: number;
  88680. custom?: any;
  88681. faceUV?: Vector4[];
  88682. faceColors?: Color4[];
  88683. flat?: boolean;
  88684. sideOrientation?: number;
  88685. frontUVs?: Vector4;
  88686. backUVs?: Vector4;
  88687. }): VertexData;
  88688. /**
  88689. * Creates the VertexData for a TorusKnot
  88690. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88691. * * radius the radius of the torus knot, optional, default 2
  88692. * * tube the thickness of the tube, optional, default 0.5
  88693. * * radialSegments the number of sides on each tube segments, optional, default 32
  88694. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88695. * * p the number of windings around the z axis, optional, default 2
  88696. * * q the number of windings around the x axis, optional, default 3
  88697. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88698. * * 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)
  88699. * * 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)
  88700. * @returns the VertexData of the Torus Knot
  88701. */
  88702. static CreateTorusKnot(options: {
  88703. radius?: number;
  88704. tube?: number;
  88705. radialSegments?: number;
  88706. tubularSegments?: number;
  88707. p?: number;
  88708. q?: number;
  88709. sideOrientation?: number;
  88710. frontUVs?: Vector4;
  88711. backUVs?: Vector4;
  88712. }): VertexData;
  88713. /**
  88714. * Compute normals for given positions and indices
  88715. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88716. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88717. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88718. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88719. * * facetNormals : optional array of facet normals (vector3)
  88720. * * facetPositions : optional array of facet positions (vector3)
  88721. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88722. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88723. * * bInfo : optional bounding info, required for facetPartitioning computation
  88724. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88725. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88726. * * useRightHandedSystem: optional boolean to for right handed system computation
  88727. * * depthSort : optional boolean to enable the facet depth sort computation
  88728. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88729. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88730. */
  88731. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88732. facetNormals?: any;
  88733. facetPositions?: any;
  88734. facetPartitioning?: any;
  88735. ratio?: number;
  88736. bInfo?: any;
  88737. bbSize?: Vector3;
  88738. subDiv?: any;
  88739. useRightHandedSystem?: boolean;
  88740. depthSort?: boolean;
  88741. distanceTo?: Vector3;
  88742. depthSortedFacets?: any;
  88743. }): void;
  88744. /** @hidden */
  88745. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88746. /**
  88747. * Applies VertexData created from the imported parameters to the geometry
  88748. * @param parsedVertexData the parsed data from an imported file
  88749. * @param geometry the geometry to apply the VertexData to
  88750. */
  88751. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88752. }
  88753. }
  88754. declare module BABYLON {
  88755. /**
  88756. * Defines a target to use with MorphTargetManager
  88757. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88758. */
  88759. export class MorphTarget implements IAnimatable {
  88760. /** defines the name of the target */
  88761. name: string;
  88762. /**
  88763. * Gets or sets the list of animations
  88764. */
  88765. animations: Animation[];
  88766. private _scene;
  88767. private _positions;
  88768. private _normals;
  88769. private _tangents;
  88770. private _uvs;
  88771. private _influence;
  88772. /**
  88773. * Observable raised when the influence changes
  88774. */
  88775. onInfluenceChanged: Observable<boolean>;
  88776. /** @hidden */
  88777. _onDataLayoutChanged: Observable<void>;
  88778. /**
  88779. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88780. */
  88781. influence: number;
  88782. /**
  88783. * Gets or sets the id of the morph Target
  88784. */
  88785. id: string;
  88786. private _animationPropertiesOverride;
  88787. /**
  88788. * Gets or sets the animation properties override
  88789. */
  88790. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88791. /**
  88792. * Creates a new MorphTarget
  88793. * @param name defines the name of the target
  88794. * @param influence defines the influence to use
  88795. * @param scene defines the scene the morphtarget belongs to
  88796. */
  88797. constructor(
  88798. /** defines the name of the target */
  88799. name: string, influence?: number, scene?: Nullable<Scene>);
  88800. /**
  88801. * Gets a boolean defining if the target contains position data
  88802. */
  88803. readonly hasPositions: boolean;
  88804. /**
  88805. * Gets a boolean defining if the target contains normal data
  88806. */
  88807. readonly hasNormals: boolean;
  88808. /**
  88809. * Gets a boolean defining if the target contains tangent data
  88810. */
  88811. readonly hasTangents: boolean;
  88812. /**
  88813. * Gets a boolean defining if the target contains texture coordinates data
  88814. */
  88815. readonly hasUVs: boolean;
  88816. /**
  88817. * Affects position data to this target
  88818. * @param data defines the position data to use
  88819. */
  88820. setPositions(data: Nullable<FloatArray>): void;
  88821. /**
  88822. * Gets the position data stored in this target
  88823. * @returns a FloatArray containing the position data (or null if not present)
  88824. */
  88825. getPositions(): Nullable<FloatArray>;
  88826. /**
  88827. * Affects normal data to this target
  88828. * @param data defines the normal data to use
  88829. */
  88830. setNormals(data: Nullable<FloatArray>): void;
  88831. /**
  88832. * Gets the normal data stored in this target
  88833. * @returns a FloatArray containing the normal data (or null if not present)
  88834. */
  88835. getNormals(): Nullable<FloatArray>;
  88836. /**
  88837. * Affects tangent data to this target
  88838. * @param data defines the tangent data to use
  88839. */
  88840. setTangents(data: Nullable<FloatArray>): void;
  88841. /**
  88842. * Gets the tangent data stored in this target
  88843. * @returns a FloatArray containing the tangent data (or null if not present)
  88844. */
  88845. getTangents(): Nullable<FloatArray>;
  88846. /**
  88847. * Affects texture coordinates data to this target
  88848. * @param data defines the texture coordinates data to use
  88849. */
  88850. setUVs(data: Nullable<FloatArray>): void;
  88851. /**
  88852. * Gets the texture coordinates data stored in this target
  88853. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88854. */
  88855. getUVs(): Nullable<FloatArray>;
  88856. /**
  88857. * Serializes the current target into a Serialization object
  88858. * @returns the serialized object
  88859. */
  88860. serialize(): any;
  88861. /**
  88862. * Returns the string "MorphTarget"
  88863. * @returns "MorphTarget"
  88864. */
  88865. getClassName(): string;
  88866. /**
  88867. * Creates a new target from serialized data
  88868. * @param serializationObject defines the serialized data to use
  88869. * @returns a new MorphTarget
  88870. */
  88871. static Parse(serializationObject: any): MorphTarget;
  88872. /**
  88873. * Creates a MorphTarget from mesh data
  88874. * @param mesh defines the source mesh
  88875. * @param name defines the name to use for the new target
  88876. * @param influence defines the influence to attach to the target
  88877. * @returns a new MorphTarget
  88878. */
  88879. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88880. }
  88881. }
  88882. declare module BABYLON {
  88883. /**
  88884. * This class is used to deform meshes using morphing between different targets
  88885. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88886. */
  88887. export class MorphTargetManager {
  88888. private _targets;
  88889. private _targetInfluenceChangedObservers;
  88890. private _targetDataLayoutChangedObservers;
  88891. private _activeTargets;
  88892. private _scene;
  88893. private _influences;
  88894. private _supportsNormals;
  88895. private _supportsTangents;
  88896. private _supportsUVs;
  88897. private _vertexCount;
  88898. private _uniqueId;
  88899. private _tempInfluences;
  88900. /**
  88901. * Gets or sets a boolean indicating if normals must be morphed
  88902. */
  88903. enableNormalMorphing: boolean;
  88904. /**
  88905. * Gets or sets a boolean indicating if tangents must be morphed
  88906. */
  88907. enableTangentMorphing: boolean;
  88908. /**
  88909. * Gets or sets a boolean indicating if UV must be morphed
  88910. */
  88911. enableUVMorphing: boolean;
  88912. /**
  88913. * Creates a new MorphTargetManager
  88914. * @param scene defines the current scene
  88915. */
  88916. constructor(scene?: Nullable<Scene>);
  88917. /**
  88918. * Gets the unique ID of this manager
  88919. */
  88920. readonly uniqueId: number;
  88921. /**
  88922. * Gets the number of vertices handled by this manager
  88923. */
  88924. readonly vertexCount: number;
  88925. /**
  88926. * Gets a boolean indicating if this manager supports morphing of normals
  88927. */
  88928. readonly supportsNormals: boolean;
  88929. /**
  88930. * Gets a boolean indicating if this manager supports morphing of tangents
  88931. */
  88932. readonly supportsTangents: boolean;
  88933. /**
  88934. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88935. */
  88936. readonly supportsUVs: boolean;
  88937. /**
  88938. * Gets the number of targets stored in this manager
  88939. */
  88940. readonly numTargets: number;
  88941. /**
  88942. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88943. */
  88944. readonly numInfluencers: number;
  88945. /**
  88946. * Gets the list of influences (one per target)
  88947. */
  88948. readonly influences: Float32Array;
  88949. /**
  88950. * Gets the active target at specified index. An active target is a target with an influence > 0
  88951. * @param index defines the index to check
  88952. * @returns the requested target
  88953. */
  88954. getActiveTarget(index: number): MorphTarget;
  88955. /**
  88956. * Gets the target at specified index
  88957. * @param index defines the index to check
  88958. * @returns the requested target
  88959. */
  88960. getTarget(index: number): MorphTarget;
  88961. /**
  88962. * Add a new target to this manager
  88963. * @param target defines the target to add
  88964. */
  88965. addTarget(target: MorphTarget): void;
  88966. /**
  88967. * Removes a target from the manager
  88968. * @param target defines the target to remove
  88969. */
  88970. removeTarget(target: MorphTarget): void;
  88971. /**
  88972. * Serializes the current manager into a Serialization object
  88973. * @returns the serialized object
  88974. */
  88975. serialize(): any;
  88976. private _syncActiveTargets;
  88977. /**
  88978. * Syncrhonize the targets with all the meshes using this morph target manager
  88979. */
  88980. synchronize(): void;
  88981. /**
  88982. * Creates a new MorphTargetManager from serialized data
  88983. * @param serializationObject defines the serialized data
  88984. * @param scene defines the hosting scene
  88985. * @returns the new MorphTargetManager
  88986. */
  88987. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88988. }
  88989. }
  88990. declare module BABYLON {
  88991. /**
  88992. * Class used to represent a specific level of detail of a mesh
  88993. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88994. */
  88995. export class MeshLODLevel {
  88996. /** Defines the distance where this level should start being displayed */
  88997. distance: number;
  88998. /** Defines the mesh to use to render this level */
  88999. mesh: Nullable<Mesh>;
  89000. /**
  89001. * Creates a new LOD level
  89002. * @param distance defines the distance where this level should star being displayed
  89003. * @param mesh defines the mesh to use to render this level
  89004. */
  89005. constructor(
  89006. /** Defines the distance where this level should start being displayed */
  89007. distance: number,
  89008. /** Defines the mesh to use to render this level */
  89009. mesh: Nullable<Mesh>);
  89010. }
  89011. }
  89012. declare module BABYLON {
  89013. /**
  89014. * Mesh representing the gorund
  89015. */
  89016. export class GroundMesh extends Mesh {
  89017. /** If octree should be generated */
  89018. generateOctree: boolean;
  89019. private _heightQuads;
  89020. /** @hidden */
  89021. _subdivisionsX: number;
  89022. /** @hidden */
  89023. _subdivisionsY: number;
  89024. /** @hidden */
  89025. _width: number;
  89026. /** @hidden */
  89027. _height: number;
  89028. /** @hidden */
  89029. _minX: number;
  89030. /** @hidden */
  89031. _maxX: number;
  89032. /** @hidden */
  89033. _minZ: number;
  89034. /** @hidden */
  89035. _maxZ: number;
  89036. constructor(name: string, scene: Scene);
  89037. /**
  89038. * "GroundMesh"
  89039. * @returns "GroundMesh"
  89040. */
  89041. getClassName(): string;
  89042. /**
  89043. * The minimum of x and y subdivisions
  89044. */
  89045. readonly subdivisions: number;
  89046. /**
  89047. * X subdivisions
  89048. */
  89049. readonly subdivisionsX: number;
  89050. /**
  89051. * Y subdivisions
  89052. */
  89053. readonly subdivisionsY: number;
  89054. /**
  89055. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89056. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89057. * @param chunksCount the number of subdivisions for x and y
  89058. * @param octreeBlocksSize (Default: 32)
  89059. */
  89060. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89061. /**
  89062. * Returns a height (y) value in the Worl system :
  89063. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89064. * @param x x coordinate
  89065. * @param z z coordinate
  89066. * @returns the ground y position if (x, z) are outside the ground surface.
  89067. */
  89068. getHeightAtCoordinates(x: number, z: number): number;
  89069. /**
  89070. * Returns a normalized vector (Vector3) orthogonal to the ground
  89071. * at the ground coordinates (x, z) expressed in the World system.
  89072. * @param x x coordinate
  89073. * @param z z coordinate
  89074. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89075. */
  89076. getNormalAtCoordinates(x: number, z: number): Vector3;
  89077. /**
  89078. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89079. * at the ground coordinates (x, z) expressed in the World system.
  89080. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89081. * @param x x coordinate
  89082. * @param z z coordinate
  89083. * @param ref vector to store the result
  89084. * @returns the GroundMesh.
  89085. */
  89086. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89087. /**
  89088. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89089. * if the ground has been updated.
  89090. * This can be used in the render loop.
  89091. * @returns the GroundMesh.
  89092. */
  89093. updateCoordinateHeights(): GroundMesh;
  89094. private _getFacetAt;
  89095. private _initHeightQuads;
  89096. private _computeHeightQuads;
  89097. /**
  89098. * Serializes this ground mesh
  89099. * @param serializationObject object to write serialization to
  89100. */
  89101. serialize(serializationObject: any): void;
  89102. /**
  89103. * Parses a serialized ground mesh
  89104. * @param parsedMesh the serialized mesh
  89105. * @param scene the scene to create the ground mesh in
  89106. * @returns the created ground mesh
  89107. */
  89108. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89109. }
  89110. }
  89111. declare module BABYLON {
  89112. /**
  89113. * Interface for Physics-Joint data
  89114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89115. */
  89116. export interface PhysicsJointData {
  89117. /**
  89118. * The main pivot of the joint
  89119. */
  89120. mainPivot?: Vector3;
  89121. /**
  89122. * The connected pivot of the joint
  89123. */
  89124. connectedPivot?: Vector3;
  89125. /**
  89126. * The main axis of the joint
  89127. */
  89128. mainAxis?: Vector3;
  89129. /**
  89130. * The connected axis of the joint
  89131. */
  89132. connectedAxis?: Vector3;
  89133. /**
  89134. * The collision of the joint
  89135. */
  89136. collision?: boolean;
  89137. /**
  89138. * Native Oimo/Cannon/Energy data
  89139. */
  89140. nativeParams?: any;
  89141. }
  89142. /**
  89143. * This is a holder class for the physics joint created by the physics plugin
  89144. * It holds a set of functions to control the underlying joint
  89145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89146. */
  89147. export class PhysicsJoint {
  89148. /**
  89149. * The type of the physics joint
  89150. */
  89151. type: number;
  89152. /**
  89153. * The data for the physics joint
  89154. */
  89155. jointData: PhysicsJointData;
  89156. private _physicsJoint;
  89157. protected _physicsPlugin: IPhysicsEnginePlugin;
  89158. /**
  89159. * Initializes the physics joint
  89160. * @param type The type of the physics joint
  89161. * @param jointData The data for the physics joint
  89162. */
  89163. constructor(
  89164. /**
  89165. * The type of the physics joint
  89166. */
  89167. type: number,
  89168. /**
  89169. * The data for the physics joint
  89170. */
  89171. jointData: PhysicsJointData);
  89172. /**
  89173. * Gets the physics joint
  89174. */
  89175. /**
  89176. * Sets the physics joint
  89177. */
  89178. physicsJoint: any;
  89179. /**
  89180. * Sets the physics plugin
  89181. */
  89182. physicsPlugin: IPhysicsEnginePlugin;
  89183. /**
  89184. * Execute a function that is physics-plugin specific.
  89185. * @param {Function} func the function that will be executed.
  89186. * It accepts two parameters: the physics world and the physics joint
  89187. */
  89188. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89189. /**
  89190. * Distance-Joint type
  89191. */
  89192. static DistanceJoint: number;
  89193. /**
  89194. * Hinge-Joint type
  89195. */
  89196. static HingeJoint: number;
  89197. /**
  89198. * Ball-and-Socket joint type
  89199. */
  89200. static BallAndSocketJoint: number;
  89201. /**
  89202. * Wheel-Joint type
  89203. */
  89204. static WheelJoint: number;
  89205. /**
  89206. * Slider-Joint type
  89207. */
  89208. static SliderJoint: number;
  89209. /**
  89210. * Prismatic-Joint type
  89211. */
  89212. static PrismaticJoint: number;
  89213. /**
  89214. * Universal-Joint type
  89215. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89216. */
  89217. static UniversalJoint: number;
  89218. /**
  89219. * Hinge-Joint 2 type
  89220. */
  89221. static Hinge2Joint: number;
  89222. /**
  89223. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89224. */
  89225. static PointToPointJoint: number;
  89226. /**
  89227. * Spring-Joint type
  89228. */
  89229. static SpringJoint: number;
  89230. /**
  89231. * Lock-Joint type
  89232. */
  89233. static LockJoint: number;
  89234. }
  89235. /**
  89236. * A class representing a physics distance joint
  89237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89238. */
  89239. export class DistanceJoint extends PhysicsJoint {
  89240. /**
  89241. *
  89242. * @param jointData The data for the Distance-Joint
  89243. */
  89244. constructor(jointData: DistanceJointData);
  89245. /**
  89246. * Update the predefined distance.
  89247. * @param maxDistance The maximum preferred distance
  89248. * @param minDistance The minimum preferred distance
  89249. */
  89250. updateDistance(maxDistance: number, minDistance?: number): void;
  89251. }
  89252. /**
  89253. * Represents a Motor-Enabled Joint
  89254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89255. */
  89256. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89257. /**
  89258. * Initializes the Motor-Enabled Joint
  89259. * @param type The type of the joint
  89260. * @param jointData The physica joint data for the joint
  89261. */
  89262. constructor(type: number, jointData: PhysicsJointData);
  89263. /**
  89264. * Set the motor values.
  89265. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89266. * @param force the force to apply
  89267. * @param maxForce max force for this motor.
  89268. */
  89269. setMotor(force?: number, maxForce?: number): void;
  89270. /**
  89271. * Set the motor's limits.
  89272. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89273. * @param upperLimit The upper limit of the motor
  89274. * @param lowerLimit The lower limit of the motor
  89275. */
  89276. setLimit(upperLimit: number, lowerLimit?: number): void;
  89277. }
  89278. /**
  89279. * This class represents a single physics Hinge-Joint
  89280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89281. */
  89282. export class HingeJoint extends MotorEnabledJoint {
  89283. /**
  89284. * Initializes the Hinge-Joint
  89285. * @param jointData The joint data for the Hinge-Joint
  89286. */
  89287. constructor(jointData: PhysicsJointData);
  89288. /**
  89289. * Set the motor values.
  89290. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89291. * @param {number} force the force to apply
  89292. * @param {number} maxForce max force for this motor.
  89293. */
  89294. setMotor(force?: number, maxForce?: number): void;
  89295. /**
  89296. * Set the motor's limits.
  89297. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89298. * @param upperLimit The upper limit of the motor
  89299. * @param lowerLimit The lower limit of the motor
  89300. */
  89301. setLimit(upperLimit: number, lowerLimit?: number): void;
  89302. }
  89303. /**
  89304. * This class represents a dual hinge physics joint (same as wheel joint)
  89305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89306. */
  89307. export class Hinge2Joint extends MotorEnabledJoint {
  89308. /**
  89309. * Initializes the Hinge2-Joint
  89310. * @param jointData The joint data for the Hinge2-Joint
  89311. */
  89312. constructor(jointData: PhysicsJointData);
  89313. /**
  89314. * Set the motor values.
  89315. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89316. * @param {number} targetSpeed the speed the motor is to reach
  89317. * @param {number} maxForce max force for this motor.
  89318. * @param {motorIndex} the motor's index, 0 or 1.
  89319. */
  89320. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89321. /**
  89322. * Set the motor limits.
  89323. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89324. * @param {number} upperLimit the upper limit
  89325. * @param {number} lowerLimit lower limit
  89326. * @param {motorIndex} the motor's index, 0 or 1.
  89327. */
  89328. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89329. }
  89330. /**
  89331. * Interface for a motor enabled joint
  89332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89333. */
  89334. export interface IMotorEnabledJoint {
  89335. /**
  89336. * Physics joint
  89337. */
  89338. physicsJoint: any;
  89339. /**
  89340. * Sets the motor of the motor-enabled joint
  89341. * @param force The force of the motor
  89342. * @param maxForce The maximum force of the motor
  89343. * @param motorIndex The index of the motor
  89344. */
  89345. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89346. /**
  89347. * Sets the limit of the motor
  89348. * @param upperLimit The upper limit of the motor
  89349. * @param lowerLimit The lower limit of the motor
  89350. * @param motorIndex The index of the motor
  89351. */
  89352. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89353. }
  89354. /**
  89355. * Joint data for a Distance-Joint
  89356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89357. */
  89358. export interface DistanceJointData extends PhysicsJointData {
  89359. /**
  89360. * Max distance the 2 joint objects can be apart
  89361. */
  89362. maxDistance: number;
  89363. }
  89364. /**
  89365. * Joint data from a spring joint
  89366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89367. */
  89368. export interface SpringJointData extends PhysicsJointData {
  89369. /**
  89370. * Length of the spring
  89371. */
  89372. length: number;
  89373. /**
  89374. * Stiffness of the spring
  89375. */
  89376. stiffness: number;
  89377. /**
  89378. * Damping of the spring
  89379. */
  89380. damping: number;
  89381. /** this callback will be called when applying the force to the impostors. */
  89382. forceApplicationCallback: () => void;
  89383. }
  89384. }
  89385. declare module BABYLON {
  89386. /**
  89387. * Holds the data for the raycast result
  89388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89389. */
  89390. export class PhysicsRaycastResult {
  89391. private _hasHit;
  89392. private _hitDistance;
  89393. private _hitNormalWorld;
  89394. private _hitPointWorld;
  89395. private _rayFromWorld;
  89396. private _rayToWorld;
  89397. /**
  89398. * Gets if there was a hit
  89399. */
  89400. readonly hasHit: boolean;
  89401. /**
  89402. * Gets the distance from the hit
  89403. */
  89404. readonly hitDistance: number;
  89405. /**
  89406. * Gets the hit normal/direction in the world
  89407. */
  89408. readonly hitNormalWorld: Vector3;
  89409. /**
  89410. * Gets the hit point in the world
  89411. */
  89412. readonly hitPointWorld: Vector3;
  89413. /**
  89414. * Gets the ray "start point" of the ray in the world
  89415. */
  89416. readonly rayFromWorld: Vector3;
  89417. /**
  89418. * Gets the ray "end point" of the ray in the world
  89419. */
  89420. readonly rayToWorld: Vector3;
  89421. /**
  89422. * Sets the hit data (normal & point in world space)
  89423. * @param hitNormalWorld defines the normal in world space
  89424. * @param hitPointWorld defines the point in world space
  89425. */
  89426. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89427. /**
  89428. * Sets the distance from the start point to the hit point
  89429. * @param distance
  89430. */
  89431. setHitDistance(distance: number): void;
  89432. /**
  89433. * Calculates the distance manually
  89434. */
  89435. calculateHitDistance(): void;
  89436. /**
  89437. * Resets all the values to default
  89438. * @param from The from point on world space
  89439. * @param to The to point on world space
  89440. */
  89441. reset(from?: Vector3, to?: Vector3): void;
  89442. }
  89443. /**
  89444. * Interface for the size containing width and height
  89445. */
  89446. interface IXYZ {
  89447. /**
  89448. * X
  89449. */
  89450. x: number;
  89451. /**
  89452. * Y
  89453. */
  89454. y: number;
  89455. /**
  89456. * Z
  89457. */
  89458. z: number;
  89459. }
  89460. }
  89461. declare module BABYLON {
  89462. /**
  89463. * Interface used to describe a physics joint
  89464. */
  89465. export interface PhysicsImpostorJoint {
  89466. /** Defines the main impostor to which the joint is linked */
  89467. mainImpostor: PhysicsImpostor;
  89468. /** Defines the impostor that is connected to the main impostor using this joint */
  89469. connectedImpostor: PhysicsImpostor;
  89470. /** Defines the joint itself */
  89471. joint: PhysicsJoint;
  89472. }
  89473. /** @hidden */
  89474. export interface IPhysicsEnginePlugin {
  89475. world: any;
  89476. name: string;
  89477. setGravity(gravity: Vector3): void;
  89478. setTimeStep(timeStep: number): void;
  89479. getTimeStep(): number;
  89480. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89481. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89482. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89483. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89484. removePhysicsBody(impostor: PhysicsImpostor): void;
  89485. generateJoint(joint: PhysicsImpostorJoint): void;
  89486. removeJoint(joint: PhysicsImpostorJoint): void;
  89487. isSupported(): boolean;
  89488. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89489. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89491. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89492. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89493. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89494. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89495. getBodyMass(impostor: PhysicsImpostor): number;
  89496. getBodyFriction(impostor: PhysicsImpostor): number;
  89497. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89498. getBodyRestitution(impostor: PhysicsImpostor): number;
  89499. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89500. getBodyPressure?(impostor: PhysicsImpostor): number;
  89501. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89502. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89503. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89504. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89505. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89506. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89507. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89508. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89509. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89510. sleepBody(impostor: PhysicsImpostor): void;
  89511. wakeUpBody(impostor: PhysicsImpostor): void;
  89512. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89513. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89514. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89515. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89516. getRadius(impostor: PhysicsImpostor): number;
  89517. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89518. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89519. dispose(): void;
  89520. }
  89521. /**
  89522. * Interface used to define a physics engine
  89523. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89524. */
  89525. export interface IPhysicsEngine {
  89526. /**
  89527. * Gets the gravity vector used by the simulation
  89528. */
  89529. gravity: Vector3;
  89530. /**
  89531. * Sets the gravity vector used by the simulation
  89532. * @param gravity defines the gravity vector to use
  89533. */
  89534. setGravity(gravity: Vector3): void;
  89535. /**
  89536. * Set the time step of the physics engine.
  89537. * Default is 1/60.
  89538. * To slow it down, enter 1/600 for example.
  89539. * To speed it up, 1/30
  89540. * @param newTimeStep the new timestep to apply to this world.
  89541. */
  89542. setTimeStep(newTimeStep: number): void;
  89543. /**
  89544. * Get the time step of the physics engine.
  89545. * @returns the current time step
  89546. */
  89547. getTimeStep(): number;
  89548. /**
  89549. * Release all resources
  89550. */
  89551. dispose(): void;
  89552. /**
  89553. * Gets the name of the current physics plugin
  89554. * @returns the name of the plugin
  89555. */
  89556. getPhysicsPluginName(): string;
  89557. /**
  89558. * Adding a new impostor for the impostor tracking.
  89559. * This will be done by the impostor itself.
  89560. * @param impostor the impostor to add
  89561. */
  89562. addImpostor(impostor: PhysicsImpostor): void;
  89563. /**
  89564. * Remove an impostor from the engine.
  89565. * This impostor and its mesh will not longer be updated by the physics engine.
  89566. * @param impostor the impostor to remove
  89567. */
  89568. removeImpostor(impostor: PhysicsImpostor): void;
  89569. /**
  89570. * Add a joint to the physics engine
  89571. * @param mainImpostor defines the main impostor to which the joint is added.
  89572. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89573. * @param joint defines the joint that will connect both impostors.
  89574. */
  89575. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89576. /**
  89577. * Removes a joint from the simulation
  89578. * @param mainImpostor defines the impostor used with the joint
  89579. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89580. * @param joint defines the joint to remove
  89581. */
  89582. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89583. /**
  89584. * Gets the current plugin used to run the simulation
  89585. * @returns current plugin
  89586. */
  89587. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89588. /**
  89589. * Gets the list of physic impostors
  89590. * @returns an array of PhysicsImpostor
  89591. */
  89592. getImpostors(): Array<PhysicsImpostor>;
  89593. /**
  89594. * Gets the impostor for a physics enabled object
  89595. * @param object defines the object impersonated by the impostor
  89596. * @returns the PhysicsImpostor or null if not found
  89597. */
  89598. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89599. /**
  89600. * Gets the impostor for a physics body object
  89601. * @param body defines physics body used by the impostor
  89602. * @returns the PhysicsImpostor or null if not found
  89603. */
  89604. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89605. /**
  89606. * Does a raycast in the physics world
  89607. * @param from when should the ray start?
  89608. * @param to when should the ray end?
  89609. * @returns PhysicsRaycastResult
  89610. */
  89611. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89612. /**
  89613. * Called by the scene. No need to call it.
  89614. * @param delta defines the timespam between frames
  89615. */
  89616. _step(delta: number): void;
  89617. }
  89618. }
  89619. declare module BABYLON {
  89620. /**
  89621. * The interface for the physics imposter parameters
  89622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89623. */
  89624. export interface PhysicsImpostorParameters {
  89625. /**
  89626. * The mass of the physics imposter
  89627. */
  89628. mass: number;
  89629. /**
  89630. * The friction of the physics imposter
  89631. */
  89632. friction?: number;
  89633. /**
  89634. * The coefficient of restitution of the physics imposter
  89635. */
  89636. restitution?: number;
  89637. /**
  89638. * The native options of the physics imposter
  89639. */
  89640. nativeOptions?: any;
  89641. /**
  89642. * Specifies if the parent should be ignored
  89643. */
  89644. ignoreParent?: boolean;
  89645. /**
  89646. * Specifies if bi-directional transformations should be disabled
  89647. */
  89648. disableBidirectionalTransformation?: boolean;
  89649. /**
  89650. * The pressure inside the physics imposter, soft object only
  89651. */
  89652. pressure?: number;
  89653. /**
  89654. * The stiffness the physics imposter, soft object only
  89655. */
  89656. stiffness?: number;
  89657. /**
  89658. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89659. */
  89660. velocityIterations?: number;
  89661. /**
  89662. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89663. */
  89664. positionIterations?: number;
  89665. /**
  89666. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89667. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89668. * Add to fix multiple points
  89669. */
  89670. fixedPoints?: number;
  89671. /**
  89672. * The collision margin around a soft object
  89673. */
  89674. margin?: number;
  89675. /**
  89676. * The collision margin around a soft object
  89677. */
  89678. damping?: number;
  89679. /**
  89680. * The path for a rope based on an extrusion
  89681. */
  89682. path?: any;
  89683. /**
  89684. * The shape of an extrusion used for a rope based on an extrusion
  89685. */
  89686. shape?: any;
  89687. }
  89688. /**
  89689. * Interface for a physics-enabled object
  89690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89691. */
  89692. export interface IPhysicsEnabledObject {
  89693. /**
  89694. * The position of the physics-enabled object
  89695. */
  89696. position: Vector3;
  89697. /**
  89698. * The rotation of the physics-enabled object
  89699. */
  89700. rotationQuaternion: Nullable<Quaternion>;
  89701. /**
  89702. * The scale of the physics-enabled object
  89703. */
  89704. scaling: Vector3;
  89705. /**
  89706. * The rotation of the physics-enabled object
  89707. */
  89708. rotation?: Vector3;
  89709. /**
  89710. * The parent of the physics-enabled object
  89711. */
  89712. parent?: any;
  89713. /**
  89714. * The bounding info of the physics-enabled object
  89715. * @returns The bounding info of the physics-enabled object
  89716. */
  89717. getBoundingInfo(): BoundingInfo;
  89718. /**
  89719. * Computes the world matrix
  89720. * @param force Specifies if the world matrix should be computed by force
  89721. * @returns A world matrix
  89722. */
  89723. computeWorldMatrix(force: boolean): Matrix;
  89724. /**
  89725. * Gets the world matrix
  89726. * @returns A world matrix
  89727. */
  89728. getWorldMatrix?(): Matrix;
  89729. /**
  89730. * Gets the child meshes
  89731. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89732. * @returns An array of abstract meshes
  89733. */
  89734. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89735. /**
  89736. * Gets the vertex data
  89737. * @param kind The type of vertex data
  89738. * @returns A nullable array of numbers, or a float32 array
  89739. */
  89740. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89741. /**
  89742. * Gets the indices from the mesh
  89743. * @returns A nullable array of index arrays
  89744. */
  89745. getIndices?(): Nullable<IndicesArray>;
  89746. /**
  89747. * Gets the scene from the mesh
  89748. * @returns the indices array or null
  89749. */
  89750. getScene?(): Scene;
  89751. /**
  89752. * Gets the absolute position from the mesh
  89753. * @returns the absolute position
  89754. */
  89755. getAbsolutePosition(): Vector3;
  89756. /**
  89757. * Gets the absolute pivot point from the mesh
  89758. * @returns the absolute pivot point
  89759. */
  89760. getAbsolutePivotPoint(): Vector3;
  89761. /**
  89762. * Rotates the mesh
  89763. * @param axis The axis of rotation
  89764. * @param amount The amount of rotation
  89765. * @param space The space of the rotation
  89766. * @returns The rotation transform node
  89767. */
  89768. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89769. /**
  89770. * Translates the mesh
  89771. * @param axis The axis of translation
  89772. * @param distance The distance of translation
  89773. * @param space The space of the translation
  89774. * @returns The transform node
  89775. */
  89776. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89777. /**
  89778. * Sets the absolute position of the mesh
  89779. * @param absolutePosition The absolute position of the mesh
  89780. * @returns The transform node
  89781. */
  89782. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89783. /**
  89784. * Gets the class name of the mesh
  89785. * @returns The class name
  89786. */
  89787. getClassName(): string;
  89788. }
  89789. /**
  89790. * Represents a physics imposter
  89791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89792. */
  89793. export class PhysicsImpostor {
  89794. /**
  89795. * The physics-enabled object used as the physics imposter
  89796. */
  89797. object: IPhysicsEnabledObject;
  89798. /**
  89799. * The type of the physics imposter
  89800. */
  89801. type: number;
  89802. private _options;
  89803. private _scene?;
  89804. /**
  89805. * The default object size of the imposter
  89806. */
  89807. static DEFAULT_OBJECT_SIZE: Vector3;
  89808. /**
  89809. * The identity quaternion of the imposter
  89810. */
  89811. static IDENTITY_QUATERNION: Quaternion;
  89812. /** @hidden */
  89813. _pluginData: any;
  89814. private _physicsEngine;
  89815. private _physicsBody;
  89816. private _bodyUpdateRequired;
  89817. private _onBeforePhysicsStepCallbacks;
  89818. private _onAfterPhysicsStepCallbacks;
  89819. /** @hidden */
  89820. _onPhysicsCollideCallbacks: Array<{
  89821. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89822. otherImpostors: Array<PhysicsImpostor>;
  89823. }>;
  89824. private _deltaPosition;
  89825. private _deltaRotation;
  89826. private _deltaRotationConjugated;
  89827. /** @hidden */
  89828. _isFromLine: boolean;
  89829. private _parent;
  89830. private _isDisposed;
  89831. private static _tmpVecs;
  89832. private static _tmpQuat;
  89833. /**
  89834. * Specifies if the physics imposter is disposed
  89835. */
  89836. readonly isDisposed: boolean;
  89837. /**
  89838. * Gets the mass of the physics imposter
  89839. */
  89840. mass: number;
  89841. /**
  89842. * Gets the coefficient of friction
  89843. */
  89844. /**
  89845. * Sets the coefficient of friction
  89846. */
  89847. friction: number;
  89848. /**
  89849. * Gets the coefficient of restitution
  89850. */
  89851. /**
  89852. * Sets the coefficient of restitution
  89853. */
  89854. restitution: number;
  89855. /**
  89856. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89857. */
  89858. /**
  89859. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89860. */
  89861. pressure: number;
  89862. /**
  89863. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89864. */
  89865. /**
  89866. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89867. */
  89868. stiffness: number;
  89869. /**
  89870. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89871. */
  89872. /**
  89873. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89874. */
  89875. velocityIterations: number;
  89876. /**
  89877. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89878. */
  89879. /**
  89880. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89881. */
  89882. positionIterations: number;
  89883. /**
  89884. * The unique id of the physics imposter
  89885. * set by the physics engine when adding this impostor to the array
  89886. */
  89887. uniqueId: number;
  89888. /**
  89889. * @hidden
  89890. */
  89891. soft: boolean;
  89892. /**
  89893. * @hidden
  89894. */
  89895. segments: number;
  89896. private _joints;
  89897. /**
  89898. * Initializes the physics imposter
  89899. * @param object The physics-enabled object used as the physics imposter
  89900. * @param type The type of the physics imposter
  89901. * @param _options The options for the physics imposter
  89902. * @param _scene The Babylon scene
  89903. */
  89904. constructor(
  89905. /**
  89906. * The physics-enabled object used as the physics imposter
  89907. */
  89908. object: IPhysicsEnabledObject,
  89909. /**
  89910. * The type of the physics imposter
  89911. */
  89912. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89913. /**
  89914. * This function will completly initialize this impostor.
  89915. * It will create a new body - but only if this mesh has no parent.
  89916. * If it has, this impostor will not be used other than to define the impostor
  89917. * of the child mesh.
  89918. * @hidden
  89919. */
  89920. _init(): void;
  89921. private _getPhysicsParent;
  89922. /**
  89923. * Should a new body be generated.
  89924. * @returns boolean specifying if body initialization is required
  89925. */
  89926. isBodyInitRequired(): boolean;
  89927. /**
  89928. * Sets the updated scaling
  89929. * @param updated Specifies if the scaling is updated
  89930. */
  89931. setScalingUpdated(): void;
  89932. /**
  89933. * Force a regeneration of this or the parent's impostor's body.
  89934. * Use under cautious - This will remove all joints already implemented.
  89935. */
  89936. forceUpdate(): void;
  89937. /**
  89938. * Gets the body that holds this impostor. Either its own, or its parent.
  89939. */
  89940. /**
  89941. * Set the physics body. Used mainly by the physics engine/plugin
  89942. */
  89943. physicsBody: any;
  89944. /**
  89945. * Get the parent of the physics imposter
  89946. * @returns Physics imposter or null
  89947. */
  89948. /**
  89949. * Sets the parent of the physics imposter
  89950. */
  89951. parent: Nullable<PhysicsImpostor>;
  89952. /**
  89953. * Resets the update flags
  89954. */
  89955. resetUpdateFlags(): void;
  89956. /**
  89957. * Gets the object extend size
  89958. * @returns the object extend size
  89959. */
  89960. getObjectExtendSize(): Vector3;
  89961. /**
  89962. * Gets the object center
  89963. * @returns The object center
  89964. */
  89965. getObjectCenter(): Vector3;
  89966. /**
  89967. * Get a specific parametes from the options parameter
  89968. * @param paramName The object parameter name
  89969. * @returns The object parameter
  89970. */
  89971. getParam(paramName: string): any;
  89972. /**
  89973. * Sets a specific parameter in the options given to the physics plugin
  89974. * @param paramName The parameter name
  89975. * @param value The value of the parameter
  89976. */
  89977. setParam(paramName: string, value: number): void;
  89978. /**
  89979. * Specifically change the body's mass option. Won't recreate the physics body object
  89980. * @param mass The mass of the physics imposter
  89981. */
  89982. setMass(mass: number): void;
  89983. /**
  89984. * Gets the linear velocity
  89985. * @returns linear velocity or null
  89986. */
  89987. getLinearVelocity(): Nullable<Vector3>;
  89988. /**
  89989. * Sets the linear velocity
  89990. * @param velocity linear velocity or null
  89991. */
  89992. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89993. /**
  89994. * Gets the angular velocity
  89995. * @returns angular velocity or null
  89996. */
  89997. getAngularVelocity(): Nullable<Vector3>;
  89998. /**
  89999. * Sets the angular velocity
  90000. * @param velocity The velocity or null
  90001. */
  90002. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90003. /**
  90004. * Execute a function with the physics plugin native code
  90005. * Provide a function the will have two variables - the world object and the physics body object
  90006. * @param func The function to execute with the physics plugin native code
  90007. */
  90008. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90009. /**
  90010. * Register a function that will be executed before the physics world is stepping forward
  90011. * @param func The function to execute before the physics world is stepped forward
  90012. */
  90013. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90014. /**
  90015. * Unregister a function that will be executed before the physics world is stepping forward
  90016. * @param func The function to execute before the physics world is stepped forward
  90017. */
  90018. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90019. /**
  90020. * Register a function that will be executed after the physics step
  90021. * @param func The function to execute after physics step
  90022. */
  90023. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90024. /**
  90025. * Unregisters a function that will be executed after the physics step
  90026. * @param func The function to execute after physics step
  90027. */
  90028. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90029. /**
  90030. * register a function that will be executed when this impostor collides against a different body
  90031. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90032. * @param func Callback that is executed on collision
  90033. */
  90034. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90035. /**
  90036. * Unregisters the physics imposter on contact
  90037. * @param collideAgainst The physics object to collide against
  90038. * @param func Callback to execute on collision
  90039. */
  90040. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90041. private _tmpQuat;
  90042. private _tmpQuat2;
  90043. /**
  90044. * Get the parent rotation
  90045. * @returns The parent rotation
  90046. */
  90047. getParentsRotation(): Quaternion;
  90048. /**
  90049. * this function is executed by the physics engine.
  90050. */
  90051. beforeStep: () => void;
  90052. /**
  90053. * this function is executed by the physics engine
  90054. */
  90055. afterStep: () => void;
  90056. /**
  90057. * Legacy collision detection event support
  90058. */
  90059. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90060. /**
  90061. * event and body object due to cannon's event-based architecture.
  90062. */
  90063. onCollide: (e: {
  90064. body: any;
  90065. }) => void;
  90066. /**
  90067. * Apply a force
  90068. * @param force The force to apply
  90069. * @param contactPoint The contact point for the force
  90070. * @returns The physics imposter
  90071. */
  90072. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90073. /**
  90074. * Apply an impulse
  90075. * @param force The impulse force
  90076. * @param contactPoint The contact point for the impulse force
  90077. * @returns The physics imposter
  90078. */
  90079. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90080. /**
  90081. * A help function to create a joint
  90082. * @param otherImpostor A physics imposter used to create a joint
  90083. * @param jointType The type of joint
  90084. * @param jointData The data for the joint
  90085. * @returns The physics imposter
  90086. */
  90087. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90088. /**
  90089. * Add a joint to this impostor with a different impostor
  90090. * @param otherImpostor A physics imposter used to add a joint
  90091. * @param joint The joint to add
  90092. * @returns The physics imposter
  90093. */
  90094. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90095. /**
  90096. * Add an anchor to a cloth impostor
  90097. * @param otherImpostor rigid impostor to anchor to
  90098. * @param width ratio across width from 0 to 1
  90099. * @param height ratio up height from 0 to 1
  90100. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90101. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90102. * @returns impostor the soft imposter
  90103. */
  90104. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90105. /**
  90106. * Add a hook to a rope impostor
  90107. * @param otherImpostor rigid impostor to anchor to
  90108. * @param length ratio across rope from 0 to 1
  90109. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90110. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90111. * @returns impostor the rope imposter
  90112. */
  90113. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90114. /**
  90115. * Will keep this body still, in a sleep mode.
  90116. * @returns the physics imposter
  90117. */
  90118. sleep(): PhysicsImpostor;
  90119. /**
  90120. * Wake the body up.
  90121. * @returns The physics imposter
  90122. */
  90123. wakeUp(): PhysicsImpostor;
  90124. /**
  90125. * Clones the physics imposter
  90126. * @param newObject The physics imposter clones to this physics-enabled object
  90127. * @returns A nullable physics imposter
  90128. */
  90129. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90130. /**
  90131. * Disposes the physics imposter
  90132. */
  90133. dispose(): void;
  90134. /**
  90135. * Sets the delta position
  90136. * @param position The delta position amount
  90137. */
  90138. setDeltaPosition(position: Vector3): void;
  90139. /**
  90140. * Sets the delta rotation
  90141. * @param rotation The delta rotation amount
  90142. */
  90143. setDeltaRotation(rotation: Quaternion): void;
  90144. /**
  90145. * Gets the box size of the physics imposter and stores the result in the input parameter
  90146. * @param result Stores the box size
  90147. * @returns The physics imposter
  90148. */
  90149. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90150. /**
  90151. * Gets the radius of the physics imposter
  90152. * @returns Radius of the physics imposter
  90153. */
  90154. getRadius(): number;
  90155. /**
  90156. * Sync a bone with this impostor
  90157. * @param bone The bone to sync to the impostor.
  90158. * @param boneMesh The mesh that the bone is influencing.
  90159. * @param jointPivot The pivot of the joint / bone in local space.
  90160. * @param distToJoint Optional distance from the impostor to the joint.
  90161. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90162. */
  90163. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90164. /**
  90165. * Sync impostor to a bone
  90166. * @param bone The bone that the impostor will be synced to.
  90167. * @param boneMesh The mesh that the bone is influencing.
  90168. * @param jointPivot The pivot of the joint / bone in local space.
  90169. * @param distToJoint Optional distance from the impostor to the joint.
  90170. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90171. * @param boneAxis Optional vector3 axis the bone is aligned with
  90172. */
  90173. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90174. /**
  90175. * No-Imposter type
  90176. */
  90177. static NoImpostor: number;
  90178. /**
  90179. * Sphere-Imposter type
  90180. */
  90181. static SphereImpostor: number;
  90182. /**
  90183. * Box-Imposter type
  90184. */
  90185. static BoxImpostor: number;
  90186. /**
  90187. * Plane-Imposter type
  90188. */
  90189. static PlaneImpostor: number;
  90190. /**
  90191. * Mesh-imposter type
  90192. */
  90193. static MeshImpostor: number;
  90194. /**
  90195. * Capsule-Impostor type (Ammo.js plugin only)
  90196. */
  90197. static CapsuleImpostor: number;
  90198. /**
  90199. * Cylinder-Imposter type
  90200. */
  90201. static CylinderImpostor: number;
  90202. /**
  90203. * Particle-Imposter type
  90204. */
  90205. static ParticleImpostor: number;
  90206. /**
  90207. * Heightmap-Imposter type
  90208. */
  90209. static HeightmapImpostor: number;
  90210. /**
  90211. * ConvexHull-Impostor type (Ammo.js plugin only)
  90212. */
  90213. static ConvexHullImpostor: number;
  90214. /**
  90215. * Rope-Imposter type
  90216. */
  90217. static RopeImpostor: number;
  90218. /**
  90219. * Cloth-Imposter type
  90220. */
  90221. static ClothImpostor: number;
  90222. /**
  90223. * Softbody-Imposter type
  90224. */
  90225. static SoftbodyImpostor: number;
  90226. }
  90227. }
  90228. declare module BABYLON {
  90229. /**
  90230. * @hidden
  90231. **/
  90232. export class _CreationDataStorage {
  90233. closePath?: boolean;
  90234. closeArray?: boolean;
  90235. idx: number[];
  90236. dashSize: number;
  90237. gapSize: number;
  90238. path3D: Path3D;
  90239. pathArray: Vector3[][];
  90240. arc: number;
  90241. radius: number;
  90242. cap: number;
  90243. tessellation: number;
  90244. }
  90245. /**
  90246. * @hidden
  90247. **/
  90248. class _InstanceDataStorage {
  90249. visibleInstances: any;
  90250. batchCache: _InstancesBatch;
  90251. instancesBufferSize: number;
  90252. instancesBuffer: Nullable<Buffer>;
  90253. instancesData: Float32Array;
  90254. overridenInstanceCount: number;
  90255. isFrozen: boolean;
  90256. previousBatch: Nullable<_InstancesBatch>;
  90257. hardwareInstancedRendering: boolean;
  90258. sideOrientation: number;
  90259. }
  90260. /**
  90261. * @hidden
  90262. **/
  90263. export class _InstancesBatch {
  90264. mustReturn: boolean;
  90265. visibleInstances: Nullable<InstancedMesh[]>[];
  90266. renderSelf: boolean[];
  90267. hardwareInstancedRendering: boolean[];
  90268. }
  90269. /**
  90270. * Class used to represent renderable models
  90271. */
  90272. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90273. /**
  90274. * Mesh side orientation : usually the external or front surface
  90275. */
  90276. static readonly FRONTSIDE: number;
  90277. /**
  90278. * Mesh side orientation : usually the internal or back surface
  90279. */
  90280. static readonly BACKSIDE: number;
  90281. /**
  90282. * Mesh side orientation : both internal and external or front and back surfaces
  90283. */
  90284. static readonly DOUBLESIDE: number;
  90285. /**
  90286. * Mesh side orientation : by default, `FRONTSIDE`
  90287. */
  90288. static readonly DEFAULTSIDE: number;
  90289. /**
  90290. * Mesh cap setting : no cap
  90291. */
  90292. static readonly NO_CAP: number;
  90293. /**
  90294. * Mesh cap setting : one cap at the beginning of the mesh
  90295. */
  90296. static readonly CAP_START: number;
  90297. /**
  90298. * Mesh cap setting : one cap at the end of the mesh
  90299. */
  90300. static readonly CAP_END: number;
  90301. /**
  90302. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90303. */
  90304. static readonly CAP_ALL: number;
  90305. /**
  90306. * Mesh pattern setting : no flip or rotate
  90307. */
  90308. static readonly NO_FLIP: number;
  90309. /**
  90310. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90311. */
  90312. static readonly FLIP_TILE: number;
  90313. /**
  90314. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90315. */
  90316. static readonly ROTATE_TILE: number;
  90317. /**
  90318. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90319. */
  90320. static readonly FLIP_ROW: number;
  90321. /**
  90322. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90323. */
  90324. static readonly ROTATE_ROW: number;
  90325. /**
  90326. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90327. */
  90328. static readonly FLIP_N_ROTATE_TILE: number;
  90329. /**
  90330. * Mesh pattern setting : rotate pattern and rotate
  90331. */
  90332. static readonly FLIP_N_ROTATE_ROW: number;
  90333. /**
  90334. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90335. */
  90336. static readonly CENTER: number;
  90337. /**
  90338. * Mesh tile positioning : part tiles on left
  90339. */
  90340. static readonly LEFT: number;
  90341. /**
  90342. * Mesh tile positioning : part tiles on right
  90343. */
  90344. static readonly RIGHT: number;
  90345. /**
  90346. * Mesh tile positioning : part tiles on top
  90347. */
  90348. static readonly TOP: number;
  90349. /**
  90350. * Mesh tile positioning : part tiles on bottom
  90351. */
  90352. static readonly BOTTOM: number;
  90353. /**
  90354. * Gets the default side orientation.
  90355. * @param orientation the orientation to value to attempt to get
  90356. * @returns the default orientation
  90357. * @hidden
  90358. */
  90359. static _GetDefaultSideOrientation(orientation?: number): number;
  90360. private _internalMeshDataInfo;
  90361. /**
  90362. * An event triggered before rendering the mesh
  90363. */
  90364. readonly onBeforeRenderObservable: Observable<Mesh>;
  90365. /**
  90366. * An event triggered before binding the mesh
  90367. */
  90368. readonly onBeforeBindObservable: Observable<Mesh>;
  90369. /**
  90370. * An event triggered after rendering the mesh
  90371. */
  90372. readonly onAfterRenderObservable: Observable<Mesh>;
  90373. /**
  90374. * An event triggered before drawing the mesh
  90375. */
  90376. readonly onBeforeDrawObservable: Observable<Mesh>;
  90377. private _onBeforeDrawObserver;
  90378. /**
  90379. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90380. */
  90381. onBeforeDraw: () => void;
  90382. readonly hasInstances: boolean;
  90383. /**
  90384. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90385. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90386. */
  90387. delayLoadState: number;
  90388. /**
  90389. * Gets the list of instances created from this mesh
  90390. * it is not supposed to be modified manually.
  90391. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90392. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90393. */
  90394. instances: InstancedMesh[];
  90395. /**
  90396. * Gets the file containing delay loading data for this mesh
  90397. */
  90398. delayLoadingFile: string;
  90399. /** @hidden */
  90400. _binaryInfo: any;
  90401. /**
  90402. * User defined function used to change how LOD level selection is done
  90403. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90404. */
  90405. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90406. /**
  90407. * Gets or sets the morph target manager
  90408. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90409. */
  90410. morphTargetManager: Nullable<MorphTargetManager>;
  90411. /** @hidden */
  90412. _creationDataStorage: Nullable<_CreationDataStorage>;
  90413. /** @hidden */
  90414. _geometry: Nullable<Geometry>;
  90415. /** @hidden */
  90416. _delayInfo: Array<string>;
  90417. /** @hidden */
  90418. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90419. /** @hidden */
  90420. _instanceDataStorage: _InstanceDataStorage;
  90421. private _effectiveMaterial;
  90422. /** @hidden */
  90423. _shouldGenerateFlatShading: boolean;
  90424. /** @hidden */
  90425. _originalBuilderSideOrientation: number;
  90426. /**
  90427. * Use this property to change the original side orientation defined at construction time
  90428. */
  90429. overrideMaterialSideOrientation: Nullable<number>;
  90430. /**
  90431. * Gets the source mesh (the one used to clone this one from)
  90432. */
  90433. readonly source: Nullable<Mesh>;
  90434. /**
  90435. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90436. */
  90437. isUnIndexed: boolean;
  90438. /**
  90439. * @constructor
  90440. * @param name The value used by scene.getMeshByName() to do a lookup.
  90441. * @param scene The scene to add this mesh to.
  90442. * @param parent The parent of this mesh, if it has one
  90443. * @param source An optional Mesh from which geometry is shared, cloned.
  90444. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90445. * When false, achieved by calling a clone(), also passing False.
  90446. * This will make creation of children, recursive.
  90447. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90448. */
  90449. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90450. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90451. /**
  90452. * Gets the class name
  90453. * @returns the string "Mesh".
  90454. */
  90455. getClassName(): string;
  90456. /** @hidden */
  90457. readonly _isMesh: boolean;
  90458. /**
  90459. * Returns a description of this mesh
  90460. * @param fullDetails define if full details about this mesh must be used
  90461. * @returns a descriptive string representing this mesh
  90462. */
  90463. toString(fullDetails?: boolean): string;
  90464. /** @hidden */
  90465. _unBindEffect(): void;
  90466. /**
  90467. * Gets a boolean indicating if this mesh has LOD
  90468. */
  90469. readonly hasLODLevels: boolean;
  90470. /**
  90471. * Gets the list of MeshLODLevel associated with the current mesh
  90472. * @returns an array of MeshLODLevel
  90473. */
  90474. getLODLevels(): MeshLODLevel[];
  90475. private _sortLODLevels;
  90476. /**
  90477. * Add a mesh as LOD level triggered at the given distance.
  90478. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90479. * @param distance The distance from the center of the object to show this level
  90480. * @param mesh The mesh to be added as LOD level (can be null)
  90481. * @return This mesh (for chaining)
  90482. */
  90483. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90484. /**
  90485. * Returns the LOD level mesh at the passed distance or null if not found.
  90486. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90487. * @param distance The distance from the center of the object to show this level
  90488. * @returns a Mesh or `null`
  90489. */
  90490. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90491. /**
  90492. * Remove a mesh from the LOD array
  90493. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90494. * @param mesh defines the mesh to be removed
  90495. * @return This mesh (for chaining)
  90496. */
  90497. removeLODLevel(mesh: Mesh): Mesh;
  90498. /**
  90499. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90500. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90501. * @param camera defines the camera to use to compute distance
  90502. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90503. * @return This mesh (for chaining)
  90504. */
  90505. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90506. /**
  90507. * Gets the mesh internal Geometry object
  90508. */
  90509. readonly geometry: Nullable<Geometry>;
  90510. /**
  90511. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90512. * @returns the total number of vertices
  90513. */
  90514. getTotalVertices(): number;
  90515. /**
  90516. * Returns the content of an associated vertex buffer
  90517. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90518. * - VertexBuffer.PositionKind
  90519. * - VertexBuffer.UVKind
  90520. * - VertexBuffer.UV2Kind
  90521. * - VertexBuffer.UV3Kind
  90522. * - VertexBuffer.UV4Kind
  90523. * - VertexBuffer.UV5Kind
  90524. * - VertexBuffer.UV6Kind
  90525. * - VertexBuffer.ColorKind
  90526. * - VertexBuffer.MatricesIndicesKind
  90527. * - VertexBuffer.MatricesIndicesExtraKind
  90528. * - VertexBuffer.MatricesWeightsKind
  90529. * - VertexBuffer.MatricesWeightsExtraKind
  90530. * @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
  90531. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90532. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90533. */
  90534. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90535. /**
  90536. * Returns the mesh VertexBuffer object from the requested `kind`
  90537. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90538. * - VertexBuffer.PositionKind
  90539. * - VertexBuffer.NormalKind
  90540. * - VertexBuffer.UVKind
  90541. * - VertexBuffer.UV2Kind
  90542. * - VertexBuffer.UV3Kind
  90543. * - VertexBuffer.UV4Kind
  90544. * - VertexBuffer.UV5Kind
  90545. * - VertexBuffer.UV6Kind
  90546. * - VertexBuffer.ColorKind
  90547. * - VertexBuffer.MatricesIndicesKind
  90548. * - VertexBuffer.MatricesIndicesExtraKind
  90549. * - VertexBuffer.MatricesWeightsKind
  90550. * - VertexBuffer.MatricesWeightsExtraKind
  90551. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90552. */
  90553. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90554. /**
  90555. * Tests if a specific vertex buffer is associated with this mesh
  90556. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90557. * - VertexBuffer.PositionKind
  90558. * - VertexBuffer.NormalKind
  90559. * - VertexBuffer.UVKind
  90560. * - VertexBuffer.UV2Kind
  90561. * - VertexBuffer.UV3Kind
  90562. * - VertexBuffer.UV4Kind
  90563. * - VertexBuffer.UV5Kind
  90564. * - VertexBuffer.UV6Kind
  90565. * - VertexBuffer.ColorKind
  90566. * - VertexBuffer.MatricesIndicesKind
  90567. * - VertexBuffer.MatricesIndicesExtraKind
  90568. * - VertexBuffer.MatricesWeightsKind
  90569. * - VertexBuffer.MatricesWeightsExtraKind
  90570. * @returns a boolean
  90571. */
  90572. isVerticesDataPresent(kind: string): boolean;
  90573. /**
  90574. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90575. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90576. * - VertexBuffer.PositionKind
  90577. * - VertexBuffer.UVKind
  90578. * - VertexBuffer.UV2Kind
  90579. * - VertexBuffer.UV3Kind
  90580. * - VertexBuffer.UV4Kind
  90581. * - VertexBuffer.UV5Kind
  90582. * - VertexBuffer.UV6Kind
  90583. * - VertexBuffer.ColorKind
  90584. * - VertexBuffer.MatricesIndicesKind
  90585. * - VertexBuffer.MatricesIndicesExtraKind
  90586. * - VertexBuffer.MatricesWeightsKind
  90587. * - VertexBuffer.MatricesWeightsExtraKind
  90588. * @returns a boolean
  90589. */
  90590. isVertexBufferUpdatable(kind: string): boolean;
  90591. /**
  90592. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90593. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90594. * - VertexBuffer.PositionKind
  90595. * - VertexBuffer.NormalKind
  90596. * - VertexBuffer.UVKind
  90597. * - VertexBuffer.UV2Kind
  90598. * - VertexBuffer.UV3Kind
  90599. * - VertexBuffer.UV4Kind
  90600. * - VertexBuffer.UV5Kind
  90601. * - VertexBuffer.UV6Kind
  90602. * - VertexBuffer.ColorKind
  90603. * - VertexBuffer.MatricesIndicesKind
  90604. * - VertexBuffer.MatricesIndicesExtraKind
  90605. * - VertexBuffer.MatricesWeightsKind
  90606. * - VertexBuffer.MatricesWeightsExtraKind
  90607. * @returns an array of strings
  90608. */
  90609. getVerticesDataKinds(): string[];
  90610. /**
  90611. * Returns a positive integer : the total number of indices in this mesh geometry.
  90612. * @returns the numner of indices or zero if the mesh has no geometry.
  90613. */
  90614. getTotalIndices(): number;
  90615. /**
  90616. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90617. * @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.
  90618. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90619. * @returns the indices array or an empty array if the mesh has no geometry
  90620. */
  90621. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90622. readonly isBlocked: boolean;
  90623. /**
  90624. * Determine if the current mesh is ready to be rendered
  90625. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90626. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90627. * @returns true if all associated assets are ready (material, textures, shaders)
  90628. */
  90629. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90630. /**
  90631. * 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.
  90632. */
  90633. readonly areNormalsFrozen: boolean;
  90634. /**
  90635. * 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.
  90636. * @returns the current mesh
  90637. */
  90638. freezeNormals(): Mesh;
  90639. /**
  90640. * 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
  90641. * @returns the current mesh
  90642. */
  90643. unfreezeNormals(): Mesh;
  90644. /**
  90645. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90646. */
  90647. overridenInstanceCount: number;
  90648. /** @hidden */
  90649. _preActivate(): Mesh;
  90650. /** @hidden */
  90651. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90652. /** @hidden */
  90653. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90654. /**
  90655. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90656. * This means the mesh underlying bounding box and sphere are recomputed.
  90657. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90658. * @returns the current mesh
  90659. */
  90660. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90661. /** @hidden */
  90662. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90663. /**
  90664. * This function will subdivide the mesh into multiple submeshes
  90665. * @param count defines the expected number of submeshes
  90666. */
  90667. subdivide(count: number): void;
  90668. /**
  90669. * Copy a FloatArray into a specific associated vertex buffer
  90670. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90671. * - VertexBuffer.PositionKind
  90672. * - VertexBuffer.UVKind
  90673. * - VertexBuffer.UV2Kind
  90674. * - VertexBuffer.UV3Kind
  90675. * - VertexBuffer.UV4Kind
  90676. * - VertexBuffer.UV5Kind
  90677. * - VertexBuffer.UV6Kind
  90678. * - VertexBuffer.ColorKind
  90679. * - VertexBuffer.MatricesIndicesKind
  90680. * - VertexBuffer.MatricesIndicesExtraKind
  90681. * - VertexBuffer.MatricesWeightsKind
  90682. * - VertexBuffer.MatricesWeightsExtraKind
  90683. * @param data defines the data source
  90684. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90685. * @param stride defines the data stride size (can be null)
  90686. * @returns the current mesh
  90687. */
  90688. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90689. /**
  90690. * Flags an associated vertex buffer as updatable
  90691. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90692. * - VertexBuffer.PositionKind
  90693. * - VertexBuffer.UVKind
  90694. * - VertexBuffer.UV2Kind
  90695. * - VertexBuffer.UV3Kind
  90696. * - VertexBuffer.UV4Kind
  90697. * - VertexBuffer.UV5Kind
  90698. * - VertexBuffer.UV6Kind
  90699. * - VertexBuffer.ColorKind
  90700. * - VertexBuffer.MatricesIndicesKind
  90701. * - VertexBuffer.MatricesIndicesExtraKind
  90702. * - VertexBuffer.MatricesWeightsKind
  90703. * - VertexBuffer.MatricesWeightsExtraKind
  90704. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90705. */
  90706. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90707. /**
  90708. * Sets the mesh global Vertex Buffer
  90709. * @param buffer defines the buffer to use
  90710. * @returns the current mesh
  90711. */
  90712. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90713. /**
  90714. * Update a specific associated vertex buffer
  90715. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90716. * - VertexBuffer.PositionKind
  90717. * - VertexBuffer.UVKind
  90718. * - VertexBuffer.UV2Kind
  90719. * - VertexBuffer.UV3Kind
  90720. * - VertexBuffer.UV4Kind
  90721. * - VertexBuffer.UV5Kind
  90722. * - VertexBuffer.UV6Kind
  90723. * - VertexBuffer.ColorKind
  90724. * - VertexBuffer.MatricesIndicesKind
  90725. * - VertexBuffer.MatricesIndicesExtraKind
  90726. * - VertexBuffer.MatricesWeightsKind
  90727. * - VertexBuffer.MatricesWeightsExtraKind
  90728. * @param data defines the data source
  90729. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90730. * @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)
  90731. * @returns the current mesh
  90732. */
  90733. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90734. /**
  90735. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90736. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90737. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90738. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90739. * @returns the current mesh
  90740. */
  90741. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90742. /**
  90743. * Creates a un-shared specific occurence of the geometry for the mesh.
  90744. * @returns the current mesh
  90745. */
  90746. makeGeometryUnique(): Mesh;
  90747. /**
  90748. * Set the index buffer of this mesh
  90749. * @param indices defines the source data
  90750. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90751. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90752. * @returns the current mesh
  90753. */
  90754. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90755. /**
  90756. * Update the current index buffer
  90757. * @param indices defines the source data
  90758. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90759. * @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)
  90760. * @returns the current mesh
  90761. */
  90762. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90763. /**
  90764. * Invert the geometry to move from a right handed system to a left handed one.
  90765. * @returns the current mesh
  90766. */
  90767. toLeftHanded(): Mesh;
  90768. /** @hidden */
  90769. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90770. /** @hidden */
  90771. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90772. /**
  90773. * Registers for this mesh a javascript function called just before the rendering process
  90774. * @param func defines the function to call before rendering this mesh
  90775. * @returns the current mesh
  90776. */
  90777. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90778. /**
  90779. * Disposes a previously registered javascript function called before the rendering
  90780. * @param func defines the function to remove
  90781. * @returns the current mesh
  90782. */
  90783. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90784. /**
  90785. * Registers for this mesh a javascript function called just after the rendering is complete
  90786. * @param func defines the function to call after rendering this mesh
  90787. * @returns the current mesh
  90788. */
  90789. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90790. /**
  90791. * Disposes a previously registered javascript function called after the rendering.
  90792. * @param func defines the function to remove
  90793. * @returns the current mesh
  90794. */
  90795. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90796. /** @hidden */
  90797. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90798. /** @hidden */
  90799. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90800. /** @hidden */
  90801. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90802. /** @hidden */
  90803. _rebuild(): void;
  90804. /** @hidden */
  90805. _freeze(): void;
  90806. /** @hidden */
  90807. _unFreeze(): void;
  90808. /**
  90809. * 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
  90810. * @param subMesh defines the subMesh to render
  90811. * @param enableAlphaMode defines if alpha mode can be changed
  90812. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  90813. * @returns the current mesh
  90814. */
  90815. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  90816. private _onBeforeDraw;
  90817. /**
  90818. * Renormalize the mesh and patch it up if there are no weights
  90819. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90820. * However in the case of zero weights then we set just a single influence to 1.
  90821. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90822. */
  90823. cleanMatrixWeights(): void;
  90824. private normalizeSkinFourWeights;
  90825. private normalizeSkinWeightsAndExtra;
  90826. /**
  90827. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90828. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90829. * the user know there was an issue with importing the mesh
  90830. * @returns a validation object with skinned, valid and report string
  90831. */
  90832. validateSkinning(): {
  90833. skinned: boolean;
  90834. valid: boolean;
  90835. report: string;
  90836. };
  90837. /** @hidden */
  90838. _checkDelayState(): Mesh;
  90839. private _queueLoad;
  90840. /**
  90841. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90842. * A mesh is in the frustum if its bounding box intersects the frustum
  90843. * @param frustumPlanes defines the frustum to test
  90844. * @returns true if the mesh is in the frustum planes
  90845. */
  90846. isInFrustum(frustumPlanes: Plane[]): boolean;
  90847. /**
  90848. * Sets the mesh material by the material or multiMaterial `id` property
  90849. * @param id is a string identifying the material or the multiMaterial
  90850. * @returns the current mesh
  90851. */
  90852. setMaterialByID(id: string): Mesh;
  90853. /**
  90854. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90855. * @returns an array of IAnimatable
  90856. */
  90857. getAnimatables(): IAnimatable[];
  90858. /**
  90859. * Modifies the mesh geometry according to the passed transformation matrix.
  90860. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90861. * The mesh normals are modified using the same transformation.
  90862. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90863. * @param transform defines the transform matrix to use
  90864. * @see http://doc.babylonjs.com/resources/baking_transformations
  90865. * @returns the current mesh
  90866. */
  90867. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90868. /**
  90869. * Modifies the mesh geometry according to its own current World Matrix.
  90870. * The mesh World Matrix is then reset.
  90871. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90872. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90873. * @see http://doc.babylonjs.com/resources/baking_transformations
  90874. * @returns the current mesh
  90875. */
  90876. bakeCurrentTransformIntoVertices(): Mesh;
  90877. /** @hidden */
  90878. readonly _positions: Nullable<Vector3[]>;
  90879. /** @hidden */
  90880. _resetPointsArrayCache(): Mesh;
  90881. /** @hidden */
  90882. _generatePointsArray(): boolean;
  90883. /**
  90884. * Returns a new Mesh object generated from the current mesh properties.
  90885. * This method must not get confused with createInstance()
  90886. * @param name is a string, the name given to the new mesh
  90887. * @param newParent can be any Node object (default `null`)
  90888. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90889. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90890. * @returns a new mesh
  90891. */
  90892. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90893. /**
  90894. * Releases resources associated with this mesh.
  90895. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90896. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90897. */
  90898. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90899. /**
  90900. * Modifies the mesh geometry according to a displacement map.
  90901. * 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.
  90902. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90903. * @param url is a string, the URL from the image file is to be downloaded.
  90904. * @param minHeight is the lower limit of the displacement.
  90905. * @param maxHeight is the upper limit of the displacement.
  90906. * @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.
  90907. * @param uvOffset is an optional vector2 used to offset UV.
  90908. * @param uvScale is an optional vector2 used to scale UV.
  90909. * @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.
  90910. * @returns the Mesh.
  90911. */
  90912. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90913. /**
  90914. * Modifies the mesh geometry according to a displacementMap buffer.
  90915. * 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.
  90916. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90917. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90918. * @param heightMapWidth is the width of the buffer image.
  90919. * @param heightMapHeight is the height of the buffer image.
  90920. * @param minHeight is the lower limit of the displacement.
  90921. * @param maxHeight is the upper limit of the displacement.
  90922. * @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.
  90923. * @param uvOffset is an optional vector2 used to offset UV.
  90924. * @param uvScale is an optional vector2 used to scale UV.
  90925. * @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.
  90926. * @returns the Mesh.
  90927. */
  90928. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90929. /**
  90930. * Modify the mesh to get a flat shading rendering.
  90931. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90932. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90933. * @returns current mesh
  90934. */
  90935. convertToFlatShadedMesh(): Mesh;
  90936. /**
  90937. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90938. * In other words, more vertices, no more indices and a single bigger VBO.
  90939. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90940. * @returns current mesh
  90941. */
  90942. convertToUnIndexedMesh(): Mesh;
  90943. /**
  90944. * Inverses facet orientations.
  90945. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90946. * @param flipNormals will also inverts the normals
  90947. * @returns current mesh
  90948. */
  90949. flipFaces(flipNormals?: boolean): Mesh;
  90950. /**
  90951. * Increase the number of facets and hence vertices in a mesh
  90952. * Vertex normals are interpolated from existing vertex normals
  90953. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90954. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90955. */
  90956. increaseVertices(numberPerEdge: number): void;
  90957. /**
  90958. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90959. * This will undo any application of covertToFlatShadedMesh
  90960. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90961. */
  90962. forceSharedVertices(): void;
  90963. /** @hidden */
  90964. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90965. /** @hidden */
  90966. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90967. /**
  90968. * Creates a new InstancedMesh object from the mesh model.
  90969. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90970. * @param name defines the name of the new instance
  90971. * @returns a new InstancedMesh
  90972. */
  90973. createInstance(name: string): InstancedMesh;
  90974. /**
  90975. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90976. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90977. * @returns the current mesh
  90978. */
  90979. synchronizeInstances(): Mesh;
  90980. /**
  90981. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90982. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90983. * This should be used together with the simplification to avoid disappearing triangles.
  90984. * @param successCallback an optional success callback to be called after the optimization finished.
  90985. * @returns the current mesh
  90986. */
  90987. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90988. /**
  90989. * Serialize current mesh
  90990. * @param serializationObject defines the object which will receive the serialization data
  90991. */
  90992. serialize(serializationObject: any): void;
  90993. /** @hidden */
  90994. _syncGeometryWithMorphTargetManager(): void;
  90995. /** @hidden */
  90996. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90997. /**
  90998. * Returns a new Mesh object parsed from the source provided.
  90999. * @param parsedMesh is the source
  91000. * @param scene defines the hosting scene
  91001. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91002. * @returns a new Mesh
  91003. */
  91004. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91005. /**
  91006. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91007. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91008. * @param name defines the name of the mesh to create
  91009. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91010. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91011. * @param closePath creates a seam between the first and the last points of each path of the path array
  91012. * @param offset is taken in account only if the `pathArray` is containing a single path
  91013. * @param scene defines the hosting scene
  91014. * @param updatable defines if the mesh must be flagged as updatable
  91015. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91016. * @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)
  91017. * @returns a new Mesh
  91018. */
  91019. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91020. /**
  91021. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91022. * @param name defines the name of the mesh to create
  91023. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91024. * @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
  91025. * @param scene defines the hosting scene
  91026. * @param updatable defines if the mesh must be flagged as updatable
  91027. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91028. * @returns a new Mesh
  91029. */
  91030. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91031. /**
  91032. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91033. * @param name defines the name of the mesh to create
  91034. * @param size sets the size (float) of each box side (default 1)
  91035. * @param scene defines the hosting scene
  91036. * @param updatable defines if the mesh must be flagged as updatable
  91037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91038. * @returns a new Mesh
  91039. */
  91040. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91041. /**
  91042. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91043. * @param name defines the name of the mesh to create
  91044. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91045. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91046. * @param scene defines the hosting scene
  91047. * @param updatable defines if the mesh must be flagged as updatable
  91048. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91049. * @returns a new Mesh
  91050. */
  91051. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91052. /**
  91053. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91054. * @param name defines the name of the mesh to create
  91055. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91056. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91057. * @param scene defines the hosting scene
  91058. * @returns a new Mesh
  91059. */
  91060. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91061. /**
  91062. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91063. * @param name defines the name of the mesh to create
  91064. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91065. * @param diameterTop set the top cap diameter (floats, default 1)
  91066. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91067. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91068. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91069. * @param scene defines the hosting scene
  91070. * @param updatable defines if the mesh must be flagged as updatable
  91071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91072. * @returns a new Mesh
  91073. */
  91074. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91075. /**
  91076. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91077. * @param name defines the name of the mesh to create
  91078. * @param diameter sets the diameter size (float) of the torus (default 1)
  91079. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91080. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91081. * @param scene defines the hosting scene
  91082. * @param updatable defines if the mesh must be flagged as updatable
  91083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91084. * @returns a new Mesh
  91085. */
  91086. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91087. /**
  91088. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91089. * @param name defines the name of the mesh to create
  91090. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91091. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91092. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91093. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91094. * @param p the number of windings on X axis (positive integers, default 2)
  91095. * @param q the number of windings on Y axis (positive integers, default 3)
  91096. * @param scene defines the hosting scene
  91097. * @param updatable defines if the mesh must be flagged as updatable
  91098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91099. * @returns a new Mesh
  91100. */
  91101. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91102. /**
  91103. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91104. * @param name defines the name of the mesh to create
  91105. * @param points is an array successive Vector3
  91106. * @param scene defines the hosting scene
  91107. * @param updatable defines if the mesh must be flagged as updatable
  91108. * @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).
  91109. * @returns a new Mesh
  91110. */
  91111. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91112. /**
  91113. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91114. * @param name defines the name of the mesh to create
  91115. * @param points is an array successive Vector3
  91116. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91117. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91118. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91119. * @param scene defines the hosting scene
  91120. * @param updatable defines if the mesh must be flagged as updatable
  91121. * @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)
  91122. * @returns a new Mesh
  91123. */
  91124. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91125. /**
  91126. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91127. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91128. * 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.
  91129. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91130. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91131. * Remember you can only change the shape positions, not their number when updating a polygon.
  91132. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91133. * @param name defines the name of the mesh to create
  91134. * @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
  91135. * @param scene defines the hosting scene
  91136. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91137. * @param updatable defines if the mesh must be flagged as updatable
  91138. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91139. * @param earcutInjection can be used to inject your own earcut reference
  91140. * @returns a new Mesh
  91141. */
  91142. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91143. /**
  91144. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91145. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91146. * @param name defines the name of the mesh to create
  91147. * @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
  91148. * @param depth defines the height of extrusion
  91149. * @param scene defines the hosting scene
  91150. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91151. * @param updatable defines if the mesh must be flagged as updatable
  91152. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91153. * @param earcutInjection can be used to inject your own earcut reference
  91154. * @returns a new Mesh
  91155. */
  91156. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91157. /**
  91158. * Creates an extruded shape mesh.
  91159. * 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
  91160. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91161. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91162. * @param name defines the name of the mesh to create
  91163. * @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
  91164. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91165. * @param scale is the value to scale the shape
  91166. * @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
  91167. * @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
  91168. * @param scene defines the hosting scene
  91169. * @param updatable defines if the mesh must be flagged as updatable
  91170. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91171. * @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)
  91172. * @returns a new Mesh
  91173. */
  91174. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91175. /**
  91176. * Creates an custom extruded shape mesh.
  91177. * The custom extrusion is a parametric shape.
  91178. * It has no predefined shape. Its final shape will depend on the input parameters.
  91179. * Please consider using the same method from the MeshBuilder class instead
  91180. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91181. * @param name defines the name of the mesh to create
  91182. * @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
  91183. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91184. * @param scaleFunction is a custom Javascript function called on each path point
  91185. * @param rotationFunction is a custom Javascript function called on each path point
  91186. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91187. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91188. * @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
  91189. * @param scene defines the hosting scene
  91190. * @param updatable defines if the mesh must be flagged as updatable
  91191. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91192. * @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)
  91193. * @returns a new Mesh
  91194. */
  91195. 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;
  91196. /**
  91197. * Creates lathe mesh.
  91198. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91199. * Please consider using the same method from the MeshBuilder class instead
  91200. * @param name defines the name of the mesh to create
  91201. * @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
  91202. * @param radius is the radius value of the lathe
  91203. * @param tessellation is the side number of the lathe.
  91204. * @param scene defines the hosting scene
  91205. * @param updatable defines if the mesh must be flagged as updatable
  91206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91207. * @returns a new Mesh
  91208. */
  91209. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91210. /**
  91211. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91212. * @param name defines the name of the mesh to create
  91213. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91214. * @param scene defines the hosting scene
  91215. * @param updatable defines if the mesh must be flagged as updatable
  91216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91217. * @returns a new Mesh
  91218. */
  91219. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91220. /**
  91221. * Creates a ground mesh.
  91222. * Please consider using the same method from the MeshBuilder class instead
  91223. * @param name defines the name of the mesh to create
  91224. * @param width set the width of the ground
  91225. * @param height set the height of the ground
  91226. * @param subdivisions sets the number of subdivisions per side
  91227. * @param scene defines the hosting scene
  91228. * @param updatable defines if the mesh must be flagged as updatable
  91229. * @returns a new Mesh
  91230. */
  91231. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91232. /**
  91233. * Creates a tiled ground mesh.
  91234. * Please consider using the same method from the MeshBuilder class instead
  91235. * @param name defines the name of the mesh to create
  91236. * @param xmin set the ground minimum X coordinate
  91237. * @param zmin set the ground minimum Y coordinate
  91238. * @param xmax set the ground maximum X coordinate
  91239. * @param zmax set the ground maximum Z coordinate
  91240. * @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
  91241. * @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
  91242. * @param scene defines the hosting scene
  91243. * @param updatable defines if the mesh must be flagged as updatable
  91244. * @returns a new Mesh
  91245. */
  91246. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91247. w: number;
  91248. h: number;
  91249. }, precision: {
  91250. w: number;
  91251. h: number;
  91252. }, scene: Scene, updatable?: boolean): Mesh;
  91253. /**
  91254. * Creates a ground mesh from a height map.
  91255. * Please consider using the same method from the MeshBuilder class instead
  91256. * @see http://doc.babylonjs.com/babylon101/height_map
  91257. * @param name defines the name of the mesh to create
  91258. * @param url sets the URL of the height map image resource
  91259. * @param width set the ground width size
  91260. * @param height set the ground height size
  91261. * @param subdivisions sets the number of subdivision per side
  91262. * @param minHeight is the minimum altitude on the ground
  91263. * @param maxHeight is the maximum altitude on the ground
  91264. * @param scene defines the hosting scene
  91265. * @param updatable defines if the mesh must be flagged as updatable
  91266. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91267. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91268. * @returns a new Mesh
  91269. */
  91270. 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;
  91271. /**
  91272. * Creates a tube mesh.
  91273. * The tube is a parametric shape.
  91274. * It has no predefined shape. Its final shape will depend on the input parameters.
  91275. * Please consider using the same method from the MeshBuilder class instead
  91276. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91277. * @param name defines the name of the mesh to create
  91278. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91279. * @param radius sets the tube radius size
  91280. * @param tessellation is the number of sides on the tubular surface
  91281. * @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
  91282. * @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
  91283. * @param scene defines the hosting scene
  91284. * @param updatable defines if the mesh must be flagged as updatable
  91285. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91286. * @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)
  91287. * @returns a new Mesh
  91288. */
  91289. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91290. (i: number, distance: number): number;
  91291. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91292. /**
  91293. * Creates a polyhedron mesh.
  91294. * Please consider using the same method from the MeshBuilder class instead.
  91295. * * 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
  91296. * * The parameter `size` (positive float, default 1) sets the polygon size
  91297. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91298. * * 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`
  91299. * * 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
  91300. * * 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)`)
  91301. * * 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
  91302. * * 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
  91303. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91304. * * If you create a double-sided mesh, you can choose what parts of 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
  91305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91306. * @param name defines the name of the mesh to create
  91307. * @param options defines the options used to create the mesh
  91308. * @param scene defines the hosting scene
  91309. * @returns a new Mesh
  91310. */
  91311. static CreatePolyhedron(name: string, options: {
  91312. type?: number;
  91313. size?: number;
  91314. sizeX?: number;
  91315. sizeY?: number;
  91316. sizeZ?: number;
  91317. custom?: any;
  91318. faceUV?: Vector4[];
  91319. faceColors?: Color4[];
  91320. updatable?: boolean;
  91321. sideOrientation?: number;
  91322. }, scene: Scene): Mesh;
  91323. /**
  91324. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91325. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91326. * * 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`)
  91327. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91328. * * 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
  91329. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91330. * * If you create a double-sided mesh, you can choose what parts of 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
  91331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91332. * @param name defines the name of the mesh
  91333. * @param options defines the options used to create the mesh
  91334. * @param scene defines the hosting scene
  91335. * @returns a new Mesh
  91336. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91337. */
  91338. static CreateIcoSphere(name: string, options: {
  91339. radius?: number;
  91340. flat?: boolean;
  91341. subdivisions?: number;
  91342. sideOrientation?: number;
  91343. updatable?: boolean;
  91344. }, scene: Scene): Mesh;
  91345. /**
  91346. * Creates a decal mesh.
  91347. * Please consider using the same method from the MeshBuilder class instead.
  91348. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91349. * @param name defines the name of the mesh
  91350. * @param sourceMesh defines the mesh receiving the decal
  91351. * @param position sets the position of the decal in world coordinates
  91352. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91353. * @param size sets the decal scaling
  91354. * @param angle sets the angle to rotate the decal
  91355. * @returns a new Mesh
  91356. */
  91357. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91358. /**
  91359. * Prepare internal position array for software CPU skinning
  91360. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91361. */
  91362. setPositionsForCPUSkinning(): Float32Array;
  91363. /**
  91364. * Prepare internal normal array for software CPU skinning
  91365. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91366. */
  91367. setNormalsForCPUSkinning(): Float32Array;
  91368. /**
  91369. * Updates the vertex buffer by applying transformation from the bones
  91370. * @param skeleton defines the skeleton to apply to current mesh
  91371. * @returns the current mesh
  91372. */
  91373. applySkeleton(skeleton: Skeleton): Mesh;
  91374. /**
  91375. * 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
  91376. * @param meshes defines the list of meshes to scan
  91377. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91378. */
  91379. static MinMax(meshes: AbstractMesh[]): {
  91380. min: Vector3;
  91381. max: Vector3;
  91382. };
  91383. /**
  91384. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91385. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91386. * @returns a vector3
  91387. */
  91388. static Center(meshesOrMinMaxVector: {
  91389. min: Vector3;
  91390. max: Vector3;
  91391. } | AbstractMesh[]): Vector3;
  91392. /**
  91393. * Merge the array of meshes into a single mesh for performance reasons.
  91394. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91395. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91396. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91397. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91398. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91399. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91400. * @returns a new mesh
  91401. */
  91402. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91403. /** @hidden */
  91404. addInstance(instance: InstancedMesh): void;
  91405. /** @hidden */
  91406. removeInstance(instance: InstancedMesh): void;
  91407. }
  91408. }
  91409. declare module BABYLON {
  91410. /**
  91411. * This is the base class of all the camera used in the application.
  91412. * @see http://doc.babylonjs.com/features/cameras
  91413. */
  91414. export class Camera extends Node {
  91415. /** @hidden */
  91416. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91417. /**
  91418. * This is the default projection mode used by the cameras.
  91419. * It helps recreating a feeling of perspective and better appreciate depth.
  91420. * This is the best way to simulate real life cameras.
  91421. */
  91422. static readonly PERSPECTIVE_CAMERA: number;
  91423. /**
  91424. * This helps creating camera with an orthographic mode.
  91425. * 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.
  91426. */
  91427. static readonly ORTHOGRAPHIC_CAMERA: number;
  91428. /**
  91429. * This is the default FOV mode for perspective cameras.
  91430. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91431. */
  91432. static readonly FOVMODE_VERTICAL_FIXED: number;
  91433. /**
  91434. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91435. */
  91436. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91437. /**
  91438. * This specifies ther is no need for a camera rig.
  91439. * Basically only one eye is rendered corresponding to the camera.
  91440. */
  91441. static readonly RIG_MODE_NONE: number;
  91442. /**
  91443. * Simulates a camera Rig with one blue eye and one red eye.
  91444. * This can be use with 3d blue and red glasses.
  91445. */
  91446. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91447. /**
  91448. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91449. */
  91450. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91451. /**
  91452. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91453. */
  91454. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91455. /**
  91456. * Defines that both eyes of the camera will be rendered over under each other.
  91457. */
  91458. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91459. /**
  91460. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91461. */
  91462. static readonly RIG_MODE_VR: number;
  91463. /**
  91464. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91465. */
  91466. static readonly RIG_MODE_WEBVR: number;
  91467. /**
  91468. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91469. */
  91470. static readonly RIG_MODE_CUSTOM: number;
  91471. /**
  91472. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91473. */
  91474. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91475. /**
  91476. * Define the input manager associated with the camera.
  91477. */
  91478. inputs: CameraInputsManager<Camera>;
  91479. /** @hidden */
  91480. _position: Vector3;
  91481. /**
  91482. * Define the current local position of the camera in the scene
  91483. */
  91484. position: Vector3;
  91485. /**
  91486. * The vector the camera should consider as up.
  91487. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91488. */
  91489. upVector: Vector3;
  91490. /**
  91491. * Define the current limit on the left side for an orthographic camera
  91492. * In scene unit
  91493. */
  91494. orthoLeft: Nullable<number>;
  91495. /**
  91496. * Define the current limit on the right side for an orthographic camera
  91497. * In scene unit
  91498. */
  91499. orthoRight: Nullable<number>;
  91500. /**
  91501. * Define the current limit on the bottom side for an orthographic camera
  91502. * In scene unit
  91503. */
  91504. orthoBottom: Nullable<number>;
  91505. /**
  91506. * Define the current limit on the top side for an orthographic camera
  91507. * In scene unit
  91508. */
  91509. orthoTop: Nullable<number>;
  91510. /**
  91511. * Field Of View is set in Radians. (default is 0.8)
  91512. */
  91513. fov: number;
  91514. /**
  91515. * Define the minimum distance the camera can see from.
  91516. * This is important to note that the depth buffer are not infinite and the closer it starts
  91517. * the more your scene might encounter depth fighting issue.
  91518. */
  91519. minZ: number;
  91520. /**
  91521. * Define the maximum distance the camera can see to.
  91522. * This is important to note that the depth buffer are not infinite and the further it end
  91523. * the more your scene might encounter depth fighting issue.
  91524. */
  91525. maxZ: number;
  91526. /**
  91527. * Define the default inertia of the camera.
  91528. * This helps giving a smooth feeling to the camera movement.
  91529. */
  91530. inertia: number;
  91531. /**
  91532. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91533. */
  91534. mode: number;
  91535. /**
  91536. * Define wether the camera is intermediate.
  91537. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91538. */
  91539. isIntermediate: boolean;
  91540. /**
  91541. * Define the viewport of the camera.
  91542. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91543. */
  91544. viewport: Viewport;
  91545. /**
  91546. * Restricts the camera to viewing objects with the same layerMask.
  91547. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91548. */
  91549. layerMask: number;
  91550. /**
  91551. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91552. */
  91553. fovMode: number;
  91554. /**
  91555. * Rig mode of the camera.
  91556. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91557. * This is normally controlled byt the camera themselves as internal use.
  91558. */
  91559. cameraRigMode: number;
  91560. /**
  91561. * Defines the distance between both "eyes" in case of a RIG
  91562. */
  91563. interaxialDistance: number;
  91564. /**
  91565. * Defines if stereoscopic rendering is done side by side or over under.
  91566. */
  91567. isStereoscopicSideBySide: boolean;
  91568. /**
  91569. * 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
  91570. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91571. * else in the scene. (Eg. security camera)
  91572. *
  91573. * 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)
  91574. */
  91575. customRenderTargets: RenderTargetTexture[];
  91576. /**
  91577. * When set, the camera will render to this render target instead of the default canvas
  91578. *
  91579. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91580. */
  91581. outputRenderTarget: Nullable<RenderTargetTexture>;
  91582. /**
  91583. * Observable triggered when the camera view matrix has changed.
  91584. */
  91585. onViewMatrixChangedObservable: Observable<Camera>;
  91586. /**
  91587. * Observable triggered when the camera Projection matrix has changed.
  91588. */
  91589. onProjectionMatrixChangedObservable: Observable<Camera>;
  91590. /**
  91591. * Observable triggered when the inputs have been processed.
  91592. */
  91593. onAfterCheckInputsObservable: Observable<Camera>;
  91594. /**
  91595. * Observable triggered when reset has been called and applied to the camera.
  91596. */
  91597. onRestoreStateObservable: Observable<Camera>;
  91598. /** @hidden */
  91599. _cameraRigParams: any;
  91600. /** @hidden */
  91601. _rigCameras: Camera[];
  91602. /** @hidden */
  91603. _rigPostProcess: Nullable<PostProcess>;
  91604. protected _webvrViewMatrix: Matrix;
  91605. /** @hidden */
  91606. _skipRendering: boolean;
  91607. /** @hidden */
  91608. _projectionMatrix: Matrix;
  91609. /** @hidden */
  91610. _postProcesses: Nullable<PostProcess>[];
  91611. /** @hidden */
  91612. _activeMeshes: SmartArray<AbstractMesh>;
  91613. protected _globalPosition: Vector3;
  91614. /** @hidden */
  91615. _computedViewMatrix: Matrix;
  91616. private _doNotComputeProjectionMatrix;
  91617. private _transformMatrix;
  91618. private _frustumPlanes;
  91619. private _refreshFrustumPlanes;
  91620. private _storedFov;
  91621. private _stateStored;
  91622. /**
  91623. * Instantiates a new camera object.
  91624. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91625. * @see http://doc.babylonjs.com/features/cameras
  91626. * @param name Defines the name of the camera in the scene
  91627. * @param position Defines the position of the camera
  91628. * @param scene Defines the scene the camera belongs too
  91629. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91630. */
  91631. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91632. /**
  91633. * Store current camera state (fov, position, etc..)
  91634. * @returns the camera
  91635. */
  91636. storeState(): Camera;
  91637. /**
  91638. * Restores the camera state values if it has been stored. You must call storeState() first
  91639. */
  91640. protected _restoreStateValues(): boolean;
  91641. /**
  91642. * Restored camera state. You must call storeState() first.
  91643. * @returns true if restored and false otherwise
  91644. */
  91645. restoreState(): boolean;
  91646. /**
  91647. * Gets the class name of the camera.
  91648. * @returns the class name
  91649. */
  91650. getClassName(): string;
  91651. /** @hidden */
  91652. readonly _isCamera: boolean;
  91653. /**
  91654. * Gets a string representation of the camera useful for debug purpose.
  91655. * @param fullDetails Defines that a more verboe level of logging is required
  91656. * @returns the string representation
  91657. */
  91658. toString(fullDetails?: boolean): string;
  91659. /**
  91660. * Gets the current world space position of the camera.
  91661. */
  91662. readonly globalPosition: Vector3;
  91663. /**
  91664. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91665. * @returns the active meshe list
  91666. */
  91667. getActiveMeshes(): SmartArray<AbstractMesh>;
  91668. /**
  91669. * Check wether a mesh is part of the current active mesh list of the camera
  91670. * @param mesh Defines the mesh to check
  91671. * @returns true if active, false otherwise
  91672. */
  91673. isActiveMesh(mesh: Mesh): boolean;
  91674. /**
  91675. * Is this camera ready to be used/rendered
  91676. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91677. * @return true if the camera is ready
  91678. */
  91679. isReady(completeCheck?: boolean): boolean;
  91680. /** @hidden */
  91681. _initCache(): void;
  91682. /** @hidden */
  91683. _updateCache(ignoreParentClass?: boolean): void;
  91684. /** @hidden */
  91685. _isSynchronized(): boolean;
  91686. /** @hidden */
  91687. _isSynchronizedViewMatrix(): boolean;
  91688. /** @hidden */
  91689. _isSynchronizedProjectionMatrix(): boolean;
  91690. /**
  91691. * Attach the input controls to a specific dom element to get the input from.
  91692. * @param element Defines the element the controls should be listened from
  91693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91694. */
  91695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91696. /**
  91697. * Detach the current controls from the specified dom element.
  91698. * @param element Defines the element to stop listening the inputs from
  91699. */
  91700. detachControl(element: HTMLElement): void;
  91701. /**
  91702. * Update the camera state according to the different inputs gathered during the frame.
  91703. */
  91704. update(): void;
  91705. /** @hidden */
  91706. _checkInputs(): void;
  91707. /** @hidden */
  91708. readonly rigCameras: Camera[];
  91709. /**
  91710. * Gets the post process used by the rig cameras
  91711. */
  91712. readonly rigPostProcess: Nullable<PostProcess>;
  91713. /**
  91714. * Internal, gets the first post proces.
  91715. * @returns the first post process to be run on this camera.
  91716. */
  91717. _getFirstPostProcess(): Nullable<PostProcess>;
  91718. private _cascadePostProcessesToRigCams;
  91719. /**
  91720. * Attach a post process to the camera.
  91721. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91722. * @param postProcess The post process to attach to the camera
  91723. * @param insertAt The position of the post process in case several of them are in use in the scene
  91724. * @returns the position the post process has been inserted at
  91725. */
  91726. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91727. /**
  91728. * Detach a post process to the camera.
  91729. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91730. * @param postProcess The post process to detach from the camera
  91731. */
  91732. detachPostProcess(postProcess: PostProcess): void;
  91733. /**
  91734. * Gets the current world matrix of the camera
  91735. */
  91736. getWorldMatrix(): Matrix;
  91737. /** @hidden */
  91738. _getViewMatrix(): Matrix;
  91739. /**
  91740. * Gets the current view matrix of the camera.
  91741. * @param force forces the camera to recompute the matrix without looking at the cached state
  91742. * @returns the view matrix
  91743. */
  91744. getViewMatrix(force?: boolean): Matrix;
  91745. /**
  91746. * Freeze the projection matrix.
  91747. * It will prevent the cache check of the camera projection compute and can speed up perf
  91748. * if no parameter of the camera are meant to change
  91749. * @param projection Defines manually a projection if necessary
  91750. */
  91751. freezeProjectionMatrix(projection?: Matrix): void;
  91752. /**
  91753. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91754. */
  91755. unfreezeProjectionMatrix(): void;
  91756. /**
  91757. * Gets the current projection matrix of the camera.
  91758. * @param force forces the camera to recompute the matrix without looking at the cached state
  91759. * @returns the projection matrix
  91760. */
  91761. getProjectionMatrix(force?: boolean): Matrix;
  91762. /**
  91763. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91764. * @returns a Matrix
  91765. */
  91766. getTransformationMatrix(): Matrix;
  91767. private _updateFrustumPlanes;
  91768. /**
  91769. * Checks if a cullable object (mesh...) is in the camera frustum
  91770. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91771. * @param target The object to check
  91772. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91773. * @returns true if the object is in frustum otherwise false
  91774. */
  91775. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91776. /**
  91777. * Checks if a cullable object (mesh...) is in the camera frustum
  91778. * Unlike isInFrustum this cheks the full bounding box
  91779. * @param target The object to check
  91780. * @returns true if the object is in frustum otherwise false
  91781. */
  91782. isCompletelyInFrustum(target: ICullable): boolean;
  91783. /**
  91784. * Gets a ray in the forward direction from the camera.
  91785. * @param length Defines the length of the ray to create
  91786. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91787. * @param origin Defines the start point of the ray which defaults to the camera position
  91788. * @returns the forward ray
  91789. */
  91790. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91791. /**
  91792. * Releases resources associated with this node.
  91793. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91794. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91795. */
  91796. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91797. /** @hidden */
  91798. _isLeftCamera: boolean;
  91799. /**
  91800. * Gets the left camera of a rig setup in case of Rigged Camera
  91801. */
  91802. readonly isLeftCamera: boolean;
  91803. /** @hidden */
  91804. _isRightCamera: boolean;
  91805. /**
  91806. * Gets the right camera of a rig setup in case of Rigged Camera
  91807. */
  91808. readonly isRightCamera: boolean;
  91809. /**
  91810. * Gets the left camera of a rig setup in case of Rigged Camera
  91811. */
  91812. readonly leftCamera: Nullable<FreeCamera>;
  91813. /**
  91814. * Gets the right camera of a rig setup in case of Rigged Camera
  91815. */
  91816. readonly rightCamera: Nullable<FreeCamera>;
  91817. /**
  91818. * Gets the left camera target of a rig setup in case of Rigged Camera
  91819. * @returns the target position
  91820. */
  91821. getLeftTarget(): Nullable<Vector3>;
  91822. /**
  91823. * Gets the right camera target of a rig setup in case of Rigged Camera
  91824. * @returns the target position
  91825. */
  91826. getRightTarget(): Nullable<Vector3>;
  91827. /**
  91828. * @hidden
  91829. */
  91830. setCameraRigMode(mode: number, rigParams: any): void;
  91831. /** @hidden */
  91832. static _setStereoscopicRigMode(camera: Camera): void;
  91833. /** @hidden */
  91834. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91835. /** @hidden */
  91836. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91837. /** @hidden */
  91838. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91839. /** @hidden */
  91840. _getVRProjectionMatrix(): Matrix;
  91841. protected _updateCameraRotationMatrix(): void;
  91842. protected _updateWebVRCameraRotationMatrix(): void;
  91843. /**
  91844. * This function MUST be overwritten by the different WebVR cameras available.
  91845. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91846. * @hidden
  91847. */
  91848. _getWebVRProjectionMatrix(): Matrix;
  91849. /**
  91850. * This function MUST be overwritten by the different WebVR cameras available.
  91851. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91852. * @hidden
  91853. */
  91854. _getWebVRViewMatrix(): Matrix;
  91855. /** @hidden */
  91856. setCameraRigParameter(name: string, value: any): void;
  91857. /**
  91858. * needs to be overridden by children so sub has required properties to be copied
  91859. * @hidden
  91860. */
  91861. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91862. /**
  91863. * May need to be overridden by children
  91864. * @hidden
  91865. */
  91866. _updateRigCameras(): void;
  91867. /** @hidden */
  91868. _setupInputs(): void;
  91869. /**
  91870. * Serialiaze the camera setup to a json represention
  91871. * @returns the JSON representation
  91872. */
  91873. serialize(): any;
  91874. /**
  91875. * Clones the current camera.
  91876. * @param name The cloned camera name
  91877. * @returns the cloned camera
  91878. */
  91879. clone(name: string): Camera;
  91880. /**
  91881. * Gets the direction of the camera relative to a given local axis.
  91882. * @param localAxis Defines the reference axis to provide a relative direction.
  91883. * @return the direction
  91884. */
  91885. getDirection(localAxis: Vector3): Vector3;
  91886. /**
  91887. * Returns the current camera absolute rotation
  91888. */
  91889. readonly absoluteRotation: Quaternion;
  91890. /**
  91891. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91892. * @param localAxis Defines the reference axis to provide a relative direction.
  91893. * @param result Defines the vector to store the result in
  91894. */
  91895. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91896. /**
  91897. * Gets a camera constructor for a given camera type
  91898. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91899. * @param name The name of the camera the result will be able to instantiate
  91900. * @param scene The scene the result will construct the camera in
  91901. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91902. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91903. * @returns a factory method to construc the camera
  91904. */
  91905. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91906. /**
  91907. * Compute the world matrix of the camera.
  91908. * @returns the camera workd matrix
  91909. */
  91910. computeWorldMatrix(): Matrix;
  91911. /**
  91912. * Parse a JSON and creates the camera from the parsed information
  91913. * @param parsedCamera The JSON to parse
  91914. * @param scene The scene to instantiate the camera in
  91915. * @returns the newly constructed camera
  91916. */
  91917. static Parse(parsedCamera: any, scene: Scene): Camera;
  91918. }
  91919. }
  91920. declare module BABYLON {
  91921. /**
  91922. * Class containing static functions to help procedurally build meshes
  91923. */
  91924. export class DiscBuilder {
  91925. /**
  91926. * Creates a plane polygonal mesh. By default, this is a disc
  91927. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91928. * * 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
  91929. * * 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
  91930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91933. * @param name defines the name of the mesh
  91934. * @param options defines the options used to create the mesh
  91935. * @param scene defines the hosting scene
  91936. * @returns the plane polygonal mesh
  91937. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91938. */
  91939. static CreateDisc(name: string, options: {
  91940. radius?: number;
  91941. tessellation?: number;
  91942. arc?: number;
  91943. updatable?: boolean;
  91944. sideOrientation?: number;
  91945. frontUVs?: Vector4;
  91946. backUVs?: Vector4;
  91947. }, scene?: Nullable<Scene>): Mesh;
  91948. }
  91949. }
  91950. declare module BABYLON {
  91951. /**
  91952. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91953. *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.
  91954. * The SPS is also a particle system. It provides some methods to manage the particles.
  91955. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91956. *
  91957. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91958. */
  91959. export class SolidParticleSystem implements IDisposable {
  91960. /**
  91961. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91962. * Example : var p = SPS.particles[i];
  91963. */
  91964. particles: SolidParticle[];
  91965. /**
  91966. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91967. */
  91968. nbParticles: number;
  91969. /**
  91970. * If the particles must ever face the camera (default false). Useful for planar particles.
  91971. */
  91972. billboard: boolean;
  91973. /**
  91974. * Recompute normals when adding a shape
  91975. */
  91976. recomputeNormals: boolean;
  91977. /**
  91978. * This a counter ofr your own usage. It's not set by any SPS functions.
  91979. */
  91980. counter: number;
  91981. /**
  91982. * The SPS name. This name is also given to the underlying mesh.
  91983. */
  91984. name: string;
  91985. /**
  91986. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91987. */
  91988. mesh: Mesh;
  91989. /**
  91990. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91991. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91992. */
  91993. vars: any;
  91994. /**
  91995. * This array is populated when the SPS is set as 'pickable'.
  91996. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91997. * Each element of this array is an object `{idx: int, faceId: int}`.
  91998. * `idx` is the picked particle index in the `SPS.particles` array
  91999. * `faceId` is the picked face index counted within this particle.
  92000. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92001. */
  92002. pickedParticles: {
  92003. idx: number;
  92004. faceId: number;
  92005. }[];
  92006. /**
  92007. * This array is populated when `enableDepthSort` is set to true.
  92008. * Each element of this array is an instance of the class DepthSortedParticle.
  92009. */
  92010. depthSortedParticles: DepthSortedParticle[];
  92011. /**
  92012. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92013. * @hidden
  92014. */
  92015. _bSphereOnly: boolean;
  92016. /**
  92017. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92018. * @hidden
  92019. */
  92020. _bSphereRadiusFactor: number;
  92021. private _scene;
  92022. private _positions;
  92023. private _indices;
  92024. private _normals;
  92025. private _colors;
  92026. private _uvs;
  92027. private _indices32;
  92028. private _positions32;
  92029. private _normals32;
  92030. private _fixedNormal32;
  92031. private _colors32;
  92032. private _uvs32;
  92033. private _index;
  92034. private _updatable;
  92035. private _pickable;
  92036. private _isVisibilityBoxLocked;
  92037. private _alwaysVisible;
  92038. private _depthSort;
  92039. private _expandable;
  92040. private _shapeCounter;
  92041. private _copy;
  92042. private _color;
  92043. private _computeParticleColor;
  92044. private _computeParticleTexture;
  92045. private _computeParticleRotation;
  92046. private _computeParticleVertex;
  92047. private _computeBoundingBox;
  92048. private _depthSortParticles;
  92049. private _camera;
  92050. private _mustUnrotateFixedNormals;
  92051. private _particlesIntersect;
  92052. private _needs32Bits;
  92053. /**
  92054. * Creates a SPS (Solid Particle System) object.
  92055. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92056. * @param scene (Scene) is the scene in which the SPS is added.
  92057. * @param options defines the options of the sps e.g.
  92058. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92059. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92060. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92061. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92062. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92063. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92064. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92065. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92066. */
  92067. constructor(name: string, scene: Scene, options?: {
  92068. updatable?: boolean;
  92069. isPickable?: boolean;
  92070. enableDepthSort?: boolean;
  92071. particleIntersection?: boolean;
  92072. boundingSphereOnly?: boolean;
  92073. bSphereRadiusFactor?: number;
  92074. expandable?: boolean;
  92075. });
  92076. /**
  92077. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92078. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92079. * @returns the created mesh
  92080. */
  92081. buildMesh(): Mesh;
  92082. /**
  92083. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92084. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92085. * Thus the particles generated from `digest()` have their property `position` set yet.
  92086. * @param mesh ( Mesh ) is the mesh to be digested
  92087. * @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
  92088. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92089. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92090. * @returns the current SPS
  92091. */
  92092. digest(mesh: Mesh, options?: {
  92093. facetNb?: number;
  92094. number?: number;
  92095. delta?: number;
  92096. }): SolidParticleSystem;
  92097. private _unrotateFixedNormals;
  92098. private _resetCopy;
  92099. private _meshBuilder;
  92100. private _posToShape;
  92101. private _uvsToShapeUV;
  92102. private _addParticle;
  92103. /**
  92104. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92105. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92106. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92107. * @param nb (positive integer) the number of particles to be created from this model
  92108. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92109. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92110. * @returns the number of shapes in the system
  92111. */
  92112. addShape(mesh: Mesh, nb: number, options?: {
  92113. positionFunction?: any;
  92114. vertexFunction?: any;
  92115. }): number;
  92116. private _rebuildParticle;
  92117. /**
  92118. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92119. * @returns the SPS.
  92120. */
  92121. rebuildMesh(): SolidParticleSystem;
  92122. /**
  92123. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92124. * This method calls `updateParticle()` for each particle of the SPS.
  92125. * For an animated SPS, it is usually called within the render loop.
  92126. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92127. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92128. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92129. * @returns the SPS.
  92130. */
  92131. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92132. /**
  92133. * Disposes the SPS.
  92134. */
  92135. dispose(): void;
  92136. /**
  92137. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92138. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92139. * @returns the SPS.
  92140. */
  92141. refreshVisibleSize(): SolidParticleSystem;
  92142. /**
  92143. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92144. * @param size the size (float) of the visibility box
  92145. * note : this doesn't lock the SPS mesh bounding box.
  92146. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92147. */
  92148. setVisibilityBox(size: number): void;
  92149. /**
  92150. * Gets whether the SPS as always visible or not
  92151. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92152. */
  92153. /**
  92154. * Sets the SPS as always visible or not
  92155. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92156. */
  92157. isAlwaysVisible: boolean;
  92158. /**
  92159. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92160. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92161. */
  92162. /**
  92163. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92164. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92165. */
  92166. isVisibilityBoxLocked: boolean;
  92167. /**
  92168. * Tells to `setParticles()` to compute the particle rotations or not.
  92169. * Default value : true. The SPS is faster when it's set to false.
  92170. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92171. */
  92172. /**
  92173. * Gets if `setParticles()` computes the particle rotations or not.
  92174. * Default value : true. The SPS is faster when it's set to false.
  92175. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92176. */
  92177. computeParticleRotation: boolean;
  92178. /**
  92179. * Tells to `setParticles()` to compute the particle colors or not.
  92180. * Default value : true. The SPS is faster when it's set to false.
  92181. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92182. */
  92183. /**
  92184. * Gets if `setParticles()` computes the particle colors or not.
  92185. * Default value : true. The SPS is faster when it's set to false.
  92186. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92187. */
  92188. computeParticleColor: boolean;
  92189. /**
  92190. * Gets if `setParticles()` computes the particle textures or not.
  92191. * Default value : true. The SPS is faster when it's set to false.
  92192. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92193. */
  92194. computeParticleTexture: boolean;
  92195. /**
  92196. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92197. * Default value : false. The SPS is faster when it's set to false.
  92198. * Note : the particle custom vertex positions aren't stored values.
  92199. */
  92200. /**
  92201. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92202. * Default value : false. The SPS is faster when it's set to false.
  92203. * Note : the particle custom vertex positions aren't stored values.
  92204. */
  92205. computeParticleVertex: boolean;
  92206. /**
  92207. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92208. */
  92209. /**
  92210. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92211. */
  92212. computeBoundingBox: boolean;
  92213. /**
  92214. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92215. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92216. * Default : `true`
  92217. */
  92218. /**
  92219. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92220. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92221. * Default : `true`
  92222. */
  92223. depthSortParticles: boolean;
  92224. /**
  92225. * Gets if the SPS is created as expandable at construction time.
  92226. * Default : `false`
  92227. */
  92228. readonly expandable: boolean;
  92229. /**
  92230. * This function does nothing. It may be overwritten to set all the particle first values.
  92231. * The SPS doesn't call this function, you may have to call it by your own.
  92232. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92233. */
  92234. initParticles(): void;
  92235. /**
  92236. * This function does nothing. It may be overwritten to recycle a particle.
  92237. * The SPS doesn't call this function, you may have to call it by your own.
  92238. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92239. * @param particle The particle to recycle
  92240. * @returns the recycled particle
  92241. */
  92242. recycleParticle(particle: SolidParticle): SolidParticle;
  92243. /**
  92244. * Updates a particle : this function should be overwritten by the user.
  92245. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92247. * @example : just set a particle position or velocity and recycle conditions
  92248. * @param particle The particle to update
  92249. * @returns the updated particle
  92250. */
  92251. updateParticle(particle: SolidParticle): SolidParticle;
  92252. /**
  92253. * Updates a vertex of a particle : it can be overwritten by the user.
  92254. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92255. * @param particle the current particle
  92256. * @param vertex the current index of the current particle
  92257. * @param pt the index of the current vertex in the particle shape
  92258. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92259. * @example : just set a vertex particle position
  92260. * @returns the updated vertex
  92261. */
  92262. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92263. /**
  92264. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92265. * This does nothing and may be overwritten by the user.
  92266. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92267. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92268. * @param update the boolean update value actually passed to setParticles()
  92269. */
  92270. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92271. /**
  92272. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92273. * This will be passed three parameters.
  92274. * This does nothing and may be overwritten by the user.
  92275. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92276. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92277. * @param update the boolean update value actually passed to setParticles()
  92278. */
  92279. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92280. }
  92281. }
  92282. declare module BABYLON {
  92283. /**
  92284. * Represents one particle of a solid particle system.
  92285. */
  92286. export class SolidParticle {
  92287. /**
  92288. * particle global index
  92289. */
  92290. idx: number;
  92291. /**
  92292. * The color of the particle
  92293. */
  92294. color: Nullable<Color4>;
  92295. /**
  92296. * The world space position of the particle.
  92297. */
  92298. position: Vector3;
  92299. /**
  92300. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92301. */
  92302. rotation: Vector3;
  92303. /**
  92304. * The world space rotation quaternion of the particle.
  92305. */
  92306. rotationQuaternion: Nullable<Quaternion>;
  92307. /**
  92308. * The scaling of the particle.
  92309. */
  92310. scaling: Vector3;
  92311. /**
  92312. * The uvs of the particle.
  92313. */
  92314. uvs: Vector4;
  92315. /**
  92316. * The current speed of the particle.
  92317. */
  92318. velocity: Vector3;
  92319. /**
  92320. * The pivot point in the particle local space.
  92321. */
  92322. pivot: Vector3;
  92323. /**
  92324. * Must the particle be translated from its pivot point in its local space ?
  92325. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92326. * Default : false
  92327. */
  92328. translateFromPivot: boolean;
  92329. /**
  92330. * Is the particle active or not ?
  92331. */
  92332. alive: boolean;
  92333. /**
  92334. * Is the particle visible or not ?
  92335. */
  92336. isVisible: boolean;
  92337. /**
  92338. * Index of this particle in the global "positions" array (Internal use)
  92339. * @hidden
  92340. */
  92341. _pos: number;
  92342. /**
  92343. * @hidden Index of this particle in the global "indices" array (Internal use)
  92344. */
  92345. _ind: number;
  92346. /**
  92347. * @hidden ModelShape of this particle (Internal use)
  92348. */
  92349. _model: ModelShape;
  92350. /**
  92351. * ModelShape id of this particle
  92352. */
  92353. shapeId: number;
  92354. /**
  92355. * Index of the particle in its shape id
  92356. */
  92357. idxInShape: number;
  92358. /**
  92359. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92360. */
  92361. _modelBoundingInfo: BoundingInfo;
  92362. /**
  92363. * @hidden Particle BoundingInfo object (Internal use)
  92364. */
  92365. _boundingInfo: BoundingInfo;
  92366. /**
  92367. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92368. */
  92369. _sps: SolidParticleSystem;
  92370. /**
  92371. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92372. */
  92373. _stillInvisible: boolean;
  92374. /**
  92375. * @hidden Last computed particle rotation matrix
  92376. */
  92377. _rotationMatrix: number[];
  92378. /**
  92379. * Parent particle Id, if any.
  92380. * Default null.
  92381. */
  92382. parentId: Nullable<number>;
  92383. /**
  92384. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92385. * The possible values are :
  92386. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92387. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92388. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92389. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92390. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92391. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92392. * */
  92393. cullingStrategy: number;
  92394. /**
  92395. * @hidden Internal global position in the SPS.
  92396. */
  92397. _globalPosition: Vector3;
  92398. /**
  92399. * Creates a Solid Particle object.
  92400. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92401. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92402. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92403. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92404. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92405. * @param shapeId (integer) is the model shape identifier in the SPS.
  92406. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92407. * @param sps defines the sps it is associated to
  92408. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92409. */
  92410. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92411. /**
  92412. * Legacy support, changed scale to scaling
  92413. */
  92414. /**
  92415. * Legacy support, changed scale to scaling
  92416. */
  92417. scale: Vector3;
  92418. /**
  92419. * Legacy support, changed quaternion to rotationQuaternion
  92420. */
  92421. /**
  92422. * Legacy support, changed quaternion to rotationQuaternion
  92423. */
  92424. quaternion: Nullable<Quaternion>;
  92425. /**
  92426. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92427. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92428. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92429. * @returns true if it intersects
  92430. */
  92431. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92432. /**
  92433. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92434. * A particle is in the frustum if its bounding box intersects the frustum
  92435. * @param frustumPlanes defines the frustum to test
  92436. * @returns true if the particle is in the frustum planes
  92437. */
  92438. isInFrustum(frustumPlanes: Plane[]): boolean;
  92439. /**
  92440. * get the rotation matrix of the particle
  92441. * @hidden
  92442. */
  92443. getRotationMatrix(m: Matrix): void;
  92444. }
  92445. /**
  92446. * Represents the shape of the model used by one particle of a solid particle system.
  92447. * SPS internal tool, don't use it manually.
  92448. */
  92449. export class ModelShape {
  92450. /**
  92451. * The shape id
  92452. * @hidden
  92453. */
  92454. shapeID: number;
  92455. /**
  92456. * flat array of model positions (internal use)
  92457. * @hidden
  92458. */
  92459. _shape: Vector3[];
  92460. /**
  92461. * flat array of model UVs (internal use)
  92462. * @hidden
  92463. */
  92464. _shapeUV: number[];
  92465. /**
  92466. * length of the shape in the model indices array (internal use)
  92467. * @hidden
  92468. */
  92469. _indicesLength: number;
  92470. /**
  92471. * Custom position function (internal use)
  92472. * @hidden
  92473. */
  92474. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92475. /**
  92476. * Custom vertex function (internal use)
  92477. * @hidden
  92478. */
  92479. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92480. /**
  92481. * 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.
  92482. * SPS internal tool, don't use it manually.
  92483. * @hidden
  92484. */
  92485. 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>);
  92486. }
  92487. /**
  92488. * Represents a Depth Sorted Particle in the solid particle system.
  92489. */
  92490. export class DepthSortedParticle {
  92491. /**
  92492. * Index of the particle in the "indices" array
  92493. */
  92494. ind: number;
  92495. /**
  92496. * Length of the particle shape in the "indices" array
  92497. */
  92498. indicesLength: number;
  92499. /**
  92500. * Squared distance from the particle to the camera
  92501. */
  92502. sqDistance: number;
  92503. }
  92504. }
  92505. declare module BABYLON {
  92506. /**
  92507. * @hidden
  92508. */
  92509. export class _MeshCollisionData {
  92510. _checkCollisions: boolean;
  92511. _collisionMask: number;
  92512. _collisionGroup: number;
  92513. _collider: Nullable<Collider>;
  92514. _oldPositionForCollisions: Vector3;
  92515. _diffPositionForCollisions: Vector3;
  92516. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92517. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92518. }
  92519. }
  92520. declare module BABYLON {
  92521. /** @hidden */
  92522. class _FacetDataStorage {
  92523. facetPositions: Vector3[];
  92524. facetNormals: Vector3[];
  92525. facetPartitioning: number[][];
  92526. facetNb: number;
  92527. partitioningSubdivisions: number;
  92528. partitioningBBoxRatio: number;
  92529. facetDataEnabled: boolean;
  92530. facetParameters: any;
  92531. bbSize: Vector3;
  92532. subDiv: {
  92533. max: number;
  92534. X: number;
  92535. Y: number;
  92536. Z: number;
  92537. };
  92538. facetDepthSort: boolean;
  92539. facetDepthSortEnabled: boolean;
  92540. depthSortedIndices: IndicesArray;
  92541. depthSortedFacets: {
  92542. ind: number;
  92543. sqDistance: number;
  92544. }[];
  92545. facetDepthSortFunction: (f1: {
  92546. ind: number;
  92547. sqDistance: number;
  92548. }, f2: {
  92549. ind: number;
  92550. sqDistance: number;
  92551. }) => number;
  92552. facetDepthSortFrom: Vector3;
  92553. facetDepthSortOrigin: Vector3;
  92554. invertedMatrix: Matrix;
  92555. }
  92556. /**
  92557. * @hidden
  92558. **/
  92559. class _InternalAbstractMeshDataInfo {
  92560. _hasVertexAlpha: boolean;
  92561. _useVertexColors: boolean;
  92562. _numBoneInfluencers: number;
  92563. _applyFog: boolean;
  92564. _receiveShadows: boolean;
  92565. _facetData: _FacetDataStorage;
  92566. _visibility: number;
  92567. _skeleton: Nullable<Skeleton>;
  92568. _layerMask: number;
  92569. _computeBonesUsingShaders: boolean;
  92570. _isActive: boolean;
  92571. _onlyForInstances: boolean;
  92572. _isActiveIntermediate: boolean;
  92573. _onlyForInstancesIntermediate: boolean;
  92574. _actAsRegularMesh: boolean;
  92575. }
  92576. /**
  92577. * Class used to store all common mesh properties
  92578. */
  92579. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92580. /** No occlusion */
  92581. static OCCLUSION_TYPE_NONE: number;
  92582. /** Occlusion set to optimisitic */
  92583. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92584. /** Occlusion set to strict */
  92585. static OCCLUSION_TYPE_STRICT: number;
  92586. /** Use an accurante occlusion algorithm */
  92587. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92588. /** Use a conservative occlusion algorithm */
  92589. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92590. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92591. * Test order :
  92592. * Is the bounding sphere outside the frustum ?
  92593. * If not, are the bounding box vertices outside the frustum ?
  92594. * It not, then the cullable object is in the frustum.
  92595. */
  92596. static readonly CULLINGSTRATEGY_STANDARD: number;
  92597. /** Culling strategy : Bounding Sphere Only.
  92598. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92599. * It's also less accurate than the standard because some not visible objects can still be selected.
  92600. * Test : is the bounding sphere outside the frustum ?
  92601. * If not, then the cullable object is in the frustum.
  92602. */
  92603. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92604. /** Culling strategy : Optimistic Inclusion.
  92605. * This in an inclusion test first, then the standard exclusion test.
  92606. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92607. * 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.
  92608. * Anyway, it's as accurate as the standard strategy.
  92609. * Test :
  92610. * Is the cullable object bounding sphere center in the frustum ?
  92611. * If not, apply the default culling strategy.
  92612. */
  92613. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92614. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92615. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92616. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92617. * 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.
  92618. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92619. * Test :
  92620. * Is the cullable object bounding sphere center in the frustum ?
  92621. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92622. */
  92623. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92624. /**
  92625. * No billboard
  92626. */
  92627. static readonly BILLBOARDMODE_NONE: number;
  92628. /** Billboard on X axis */
  92629. static readonly BILLBOARDMODE_X: number;
  92630. /** Billboard on Y axis */
  92631. static readonly BILLBOARDMODE_Y: number;
  92632. /** Billboard on Z axis */
  92633. static readonly BILLBOARDMODE_Z: number;
  92634. /** Billboard on all axes */
  92635. static readonly BILLBOARDMODE_ALL: number;
  92636. /** Billboard on using position instead of orientation */
  92637. static readonly BILLBOARDMODE_USE_POSITION: number;
  92638. /** @hidden */
  92639. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92640. /**
  92641. * The culling strategy to use to check whether the mesh must be rendered or not.
  92642. * This value can be changed at any time and will be used on the next render mesh selection.
  92643. * The possible values are :
  92644. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92645. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92646. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92647. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92648. * Please read each static variable documentation to get details about the culling process.
  92649. * */
  92650. cullingStrategy: number;
  92651. /**
  92652. * Gets the number of facets in the mesh
  92653. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92654. */
  92655. readonly facetNb: number;
  92656. /**
  92657. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92658. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92659. */
  92660. partitioningSubdivisions: number;
  92661. /**
  92662. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92663. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92664. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92665. */
  92666. partitioningBBoxRatio: number;
  92667. /**
  92668. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92669. * Works only for updatable meshes.
  92670. * Doesn't work with multi-materials
  92671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92672. */
  92673. mustDepthSortFacets: boolean;
  92674. /**
  92675. * The location (Vector3) where the facet depth sort must be computed from.
  92676. * By default, the active camera position.
  92677. * Used only when facet depth sort is enabled
  92678. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92679. */
  92680. facetDepthSortFrom: Vector3;
  92681. /**
  92682. * gets a boolean indicating if facetData is enabled
  92683. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92684. */
  92685. readonly isFacetDataEnabled: boolean;
  92686. /** @hidden */
  92687. _updateNonUniformScalingState(value: boolean): boolean;
  92688. /**
  92689. * An event triggered when this mesh collides with another one
  92690. */
  92691. onCollideObservable: Observable<AbstractMesh>;
  92692. /** Set a function to call when this mesh collides with another one */
  92693. onCollide: () => void;
  92694. /**
  92695. * An event triggered when the collision's position changes
  92696. */
  92697. onCollisionPositionChangeObservable: Observable<Vector3>;
  92698. /** Set a function to call when the collision's position changes */
  92699. onCollisionPositionChange: () => void;
  92700. /**
  92701. * An event triggered when material is changed
  92702. */
  92703. onMaterialChangedObservable: Observable<AbstractMesh>;
  92704. /**
  92705. * Gets or sets the orientation for POV movement & rotation
  92706. */
  92707. definedFacingForward: boolean;
  92708. /** @hidden */
  92709. _occlusionQuery: Nullable<WebGLQuery>;
  92710. /** @hidden */
  92711. _renderingGroup: Nullable<RenderingGroup>;
  92712. /**
  92713. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92714. */
  92715. /**
  92716. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92717. */
  92718. visibility: number;
  92719. /** Gets or sets the alpha index used to sort transparent meshes
  92720. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92721. */
  92722. alphaIndex: number;
  92723. /**
  92724. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92725. */
  92726. isVisible: boolean;
  92727. /**
  92728. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92729. */
  92730. isPickable: boolean;
  92731. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92732. showSubMeshesBoundingBox: boolean;
  92733. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92734. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92735. */
  92736. isBlocker: boolean;
  92737. /**
  92738. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92739. */
  92740. enablePointerMoveEvents: boolean;
  92741. /**
  92742. * Specifies the rendering group id for this mesh (0 by default)
  92743. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92744. */
  92745. renderingGroupId: number;
  92746. private _material;
  92747. /** Gets or sets current material */
  92748. material: Nullable<Material>;
  92749. /**
  92750. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92751. * @see http://doc.babylonjs.com/babylon101/shadows
  92752. */
  92753. receiveShadows: boolean;
  92754. /** Defines color to use when rendering outline */
  92755. outlineColor: Color3;
  92756. /** Define width to use when rendering outline */
  92757. outlineWidth: number;
  92758. /** Defines color to use when rendering overlay */
  92759. overlayColor: Color3;
  92760. /** Defines alpha to use when rendering overlay */
  92761. overlayAlpha: number;
  92762. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92763. hasVertexAlpha: boolean;
  92764. /** 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) */
  92765. useVertexColors: boolean;
  92766. /**
  92767. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92768. */
  92769. computeBonesUsingShaders: boolean;
  92770. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92771. numBoneInfluencers: number;
  92772. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92773. applyFog: boolean;
  92774. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92775. useOctreeForRenderingSelection: boolean;
  92776. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92777. useOctreeForPicking: boolean;
  92778. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92779. useOctreeForCollisions: boolean;
  92780. /**
  92781. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92782. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92783. */
  92784. layerMask: number;
  92785. /**
  92786. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92787. */
  92788. alwaysSelectAsActiveMesh: boolean;
  92789. /**
  92790. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92791. */
  92792. doNotSyncBoundingInfo: boolean;
  92793. /**
  92794. * Gets or sets the current action manager
  92795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92796. */
  92797. actionManager: Nullable<AbstractActionManager>;
  92798. private _meshCollisionData;
  92799. /**
  92800. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92801. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92802. */
  92803. ellipsoid: Vector3;
  92804. /**
  92805. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92806. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92807. */
  92808. ellipsoidOffset: Vector3;
  92809. /**
  92810. * Gets or sets a collision mask used to mask collisions (default is -1).
  92811. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92812. */
  92813. collisionMask: number;
  92814. /**
  92815. * Gets or sets the current collision group mask (-1 by default).
  92816. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92817. */
  92818. collisionGroup: number;
  92819. /**
  92820. * Defines edge width used when edgesRenderer is enabled
  92821. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92822. */
  92823. edgesWidth: number;
  92824. /**
  92825. * Defines edge color used when edgesRenderer is enabled
  92826. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92827. */
  92828. edgesColor: Color4;
  92829. /** @hidden */
  92830. _edgesRenderer: Nullable<IEdgesRenderer>;
  92831. /** @hidden */
  92832. _masterMesh: Nullable<AbstractMesh>;
  92833. /** @hidden */
  92834. _boundingInfo: Nullable<BoundingInfo>;
  92835. /** @hidden */
  92836. _renderId: number;
  92837. /**
  92838. * Gets or sets the list of subMeshes
  92839. * @see http://doc.babylonjs.com/how_to/multi_materials
  92840. */
  92841. subMeshes: SubMesh[];
  92842. /** @hidden */
  92843. _intersectionsInProgress: AbstractMesh[];
  92844. /** @hidden */
  92845. _unIndexed: boolean;
  92846. /** @hidden */
  92847. _lightSources: Light[];
  92848. /** Gets the list of lights affecting that mesh */
  92849. readonly lightSources: Light[];
  92850. /** @hidden */
  92851. readonly _positions: Nullable<Vector3[]>;
  92852. /** @hidden */
  92853. _waitingData: {
  92854. lods: Nullable<any>;
  92855. actions: Nullable<any>;
  92856. freezeWorldMatrix: Nullable<boolean>;
  92857. };
  92858. /** @hidden */
  92859. _bonesTransformMatrices: Nullable<Float32Array>;
  92860. /** @hidden */
  92861. _transformMatrixTexture: Nullable<RawTexture>;
  92862. /**
  92863. * Gets or sets a skeleton to apply skining transformations
  92864. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92865. */
  92866. skeleton: Nullable<Skeleton>;
  92867. /**
  92868. * An event triggered when the mesh is rebuilt.
  92869. */
  92870. onRebuildObservable: Observable<AbstractMesh>;
  92871. /**
  92872. * Creates a new AbstractMesh
  92873. * @param name defines the name of the mesh
  92874. * @param scene defines the hosting scene
  92875. */
  92876. constructor(name: string, scene?: Nullable<Scene>);
  92877. /**
  92878. * Returns the string "AbstractMesh"
  92879. * @returns "AbstractMesh"
  92880. */
  92881. getClassName(): string;
  92882. /**
  92883. * Gets a string representation of the current mesh
  92884. * @param fullDetails defines a boolean indicating if full details must be included
  92885. * @returns a string representation of the current mesh
  92886. */
  92887. toString(fullDetails?: boolean): string;
  92888. /**
  92889. * @hidden
  92890. */
  92891. protected _getEffectiveParent(): Nullable<Node>;
  92892. /** @hidden */
  92893. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92894. /** @hidden */
  92895. _rebuild(): void;
  92896. /** @hidden */
  92897. _resyncLightSources(): void;
  92898. /** @hidden */
  92899. _resyncLighSource(light: Light): void;
  92900. /** @hidden */
  92901. _unBindEffect(): void;
  92902. /** @hidden */
  92903. _removeLightSource(light: Light, dispose: boolean): void;
  92904. private _markSubMeshesAsDirty;
  92905. /** @hidden */
  92906. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92907. /** @hidden */
  92908. _markSubMeshesAsAttributesDirty(): void;
  92909. /** @hidden */
  92910. _markSubMeshesAsMiscDirty(): void;
  92911. /**
  92912. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92913. */
  92914. scaling: Vector3;
  92915. /**
  92916. * Returns true if the mesh is blocked. Implemented by child classes
  92917. */
  92918. readonly isBlocked: boolean;
  92919. /**
  92920. * Returns the mesh itself by default. Implemented by child classes
  92921. * @param camera defines the camera to use to pick the right LOD level
  92922. * @returns the currentAbstractMesh
  92923. */
  92924. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92925. /**
  92926. * Returns 0 by default. Implemented by child classes
  92927. * @returns an integer
  92928. */
  92929. getTotalVertices(): number;
  92930. /**
  92931. * Returns a positive integer : the total number of indices in this mesh geometry.
  92932. * @returns the numner of indices or zero if the mesh has no geometry.
  92933. */
  92934. getTotalIndices(): number;
  92935. /**
  92936. * Returns null by default. Implemented by child classes
  92937. * @returns null
  92938. */
  92939. getIndices(): Nullable<IndicesArray>;
  92940. /**
  92941. * Returns the array of the requested vertex data kind. Implemented by child classes
  92942. * @param kind defines the vertex data kind to use
  92943. * @returns null
  92944. */
  92945. getVerticesData(kind: string): Nullable<FloatArray>;
  92946. /**
  92947. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92948. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92949. * Note that a new underlying VertexBuffer object is created each call.
  92950. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92951. * @param kind defines vertex data kind:
  92952. * * VertexBuffer.PositionKind
  92953. * * VertexBuffer.UVKind
  92954. * * VertexBuffer.UV2Kind
  92955. * * VertexBuffer.UV3Kind
  92956. * * VertexBuffer.UV4Kind
  92957. * * VertexBuffer.UV5Kind
  92958. * * VertexBuffer.UV6Kind
  92959. * * VertexBuffer.ColorKind
  92960. * * VertexBuffer.MatricesIndicesKind
  92961. * * VertexBuffer.MatricesIndicesExtraKind
  92962. * * VertexBuffer.MatricesWeightsKind
  92963. * * VertexBuffer.MatricesWeightsExtraKind
  92964. * @param data defines the data source
  92965. * @param updatable defines if the data must be flagged as updatable (or static)
  92966. * @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
  92967. * @returns the current mesh
  92968. */
  92969. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92970. /**
  92971. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92972. * If the mesh has no geometry, it is simply returned as it is.
  92973. * @param kind defines vertex data kind:
  92974. * * VertexBuffer.PositionKind
  92975. * * VertexBuffer.UVKind
  92976. * * VertexBuffer.UV2Kind
  92977. * * VertexBuffer.UV3Kind
  92978. * * VertexBuffer.UV4Kind
  92979. * * VertexBuffer.UV5Kind
  92980. * * VertexBuffer.UV6Kind
  92981. * * VertexBuffer.ColorKind
  92982. * * VertexBuffer.MatricesIndicesKind
  92983. * * VertexBuffer.MatricesIndicesExtraKind
  92984. * * VertexBuffer.MatricesWeightsKind
  92985. * * VertexBuffer.MatricesWeightsExtraKind
  92986. * @param data defines the data source
  92987. * @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
  92988. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92989. * @returns the current mesh
  92990. */
  92991. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92992. /**
  92993. * Sets the mesh indices,
  92994. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92995. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92996. * @param totalVertices Defines the total number of vertices
  92997. * @returns the current mesh
  92998. */
  92999. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93000. /**
  93001. * Gets a boolean indicating if specific vertex data is present
  93002. * @param kind defines the vertex data kind to use
  93003. * @returns true is data kind is present
  93004. */
  93005. isVerticesDataPresent(kind: string): boolean;
  93006. /**
  93007. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93008. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93009. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93010. * @returns a BoundingInfo
  93011. */
  93012. getBoundingInfo(): BoundingInfo;
  93013. /**
  93014. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93015. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93016. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93017. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93018. * @returns the current mesh
  93019. */
  93020. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93021. /**
  93022. * Overwrite the current bounding info
  93023. * @param boundingInfo defines the new bounding info
  93024. * @returns the current mesh
  93025. */
  93026. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93027. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93028. readonly useBones: boolean;
  93029. /** @hidden */
  93030. _preActivate(): void;
  93031. /** @hidden */
  93032. _preActivateForIntermediateRendering(renderId: number): void;
  93033. /** @hidden */
  93034. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93035. /** @hidden */
  93036. _postActivate(): void;
  93037. /** @hidden */
  93038. _freeze(): void;
  93039. /** @hidden */
  93040. _unFreeze(): void;
  93041. /**
  93042. * Gets the current world matrix
  93043. * @returns a Matrix
  93044. */
  93045. getWorldMatrix(): Matrix;
  93046. /** @hidden */
  93047. _getWorldMatrixDeterminant(): number;
  93048. /**
  93049. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93050. */
  93051. readonly isAnInstance: boolean;
  93052. /**
  93053. * Gets a boolean indicating if this mesh has instances
  93054. */
  93055. readonly hasInstances: boolean;
  93056. /**
  93057. * Perform relative position change from the point of view of behind the front of the mesh.
  93058. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93059. * Supports definition of mesh facing forward or backward
  93060. * @param amountRight defines the distance on the right axis
  93061. * @param amountUp defines the distance on the up axis
  93062. * @param amountForward defines the distance on the forward axis
  93063. * @returns the current mesh
  93064. */
  93065. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93066. /**
  93067. * Calculate relative position change from the point of view of behind the front of the mesh.
  93068. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93069. * Supports definition of mesh facing forward or backward
  93070. * @param amountRight defines the distance on the right axis
  93071. * @param amountUp defines the distance on the up axis
  93072. * @param amountForward defines the distance on the forward axis
  93073. * @returns the new displacement vector
  93074. */
  93075. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93076. /**
  93077. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93078. * Supports definition of mesh facing forward or backward
  93079. * @param flipBack defines the flip
  93080. * @param twirlClockwise defines the twirl
  93081. * @param tiltRight defines the tilt
  93082. * @returns the current mesh
  93083. */
  93084. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93085. /**
  93086. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93087. * Supports definition of mesh facing forward or backward.
  93088. * @param flipBack defines the flip
  93089. * @param twirlClockwise defines the twirl
  93090. * @param tiltRight defines the tilt
  93091. * @returns the new rotation vector
  93092. */
  93093. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93094. /**
  93095. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93096. * This means the mesh underlying bounding box and sphere are recomputed.
  93097. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93098. * @returns the current mesh
  93099. */
  93100. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93101. /** @hidden */
  93102. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93103. /** @hidden */
  93104. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93105. /** @hidden */
  93106. _updateBoundingInfo(): AbstractMesh;
  93107. /** @hidden */
  93108. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93109. /** @hidden */
  93110. protected _afterComputeWorldMatrix(): void;
  93111. /** @hidden */
  93112. readonly _effectiveMesh: AbstractMesh;
  93113. /**
  93114. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93115. * A mesh is in the frustum if its bounding box intersects the frustum
  93116. * @param frustumPlanes defines the frustum to test
  93117. * @returns true if the mesh is in the frustum planes
  93118. */
  93119. isInFrustum(frustumPlanes: Plane[]): boolean;
  93120. /**
  93121. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93122. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93123. * @param frustumPlanes defines the frustum to test
  93124. * @returns true if the mesh is completely in the frustum planes
  93125. */
  93126. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93127. /**
  93128. * True if the mesh intersects another mesh or a SolidParticle object
  93129. * @param mesh defines a target mesh or SolidParticle to test
  93130. * @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)
  93131. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93132. * @returns true if there is an intersection
  93133. */
  93134. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93135. /**
  93136. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93137. * @param point defines the point to test
  93138. * @returns true if there is an intersection
  93139. */
  93140. intersectsPoint(point: Vector3): boolean;
  93141. /**
  93142. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93144. */
  93145. checkCollisions: boolean;
  93146. /**
  93147. * Gets Collider object used to compute collisions (not physics)
  93148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93149. */
  93150. readonly collider: Nullable<Collider>;
  93151. /**
  93152. * Move the mesh using collision engine
  93153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93154. * @param displacement defines the requested displacement vector
  93155. * @returns the current mesh
  93156. */
  93157. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93158. private _onCollisionPositionChange;
  93159. /** @hidden */
  93160. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93161. /** @hidden */
  93162. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93163. /** @hidden */
  93164. _checkCollision(collider: Collider): AbstractMesh;
  93165. /** @hidden */
  93166. _generatePointsArray(): boolean;
  93167. /**
  93168. * Checks if the passed Ray intersects with the mesh
  93169. * @param ray defines the ray to use
  93170. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93171. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93172. * @returns the picking info
  93173. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93174. */
  93175. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93176. /**
  93177. * Clones the current mesh
  93178. * @param name defines the mesh name
  93179. * @param newParent defines the new mesh parent
  93180. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93181. * @returns the new mesh
  93182. */
  93183. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93184. /**
  93185. * Disposes all the submeshes of the current meshnp
  93186. * @returns the current mesh
  93187. */
  93188. releaseSubMeshes(): AbstractMesh;
  93189. /**
  93190. * Releases resources associated with this abstract mesh.
  93191. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93192. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93193. */
  93194. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93195. /**
  93196. * Adds the passed mesh as a child to the current mesh
  93197. * @param mesh defines the child mesh
  93198. * @returns the current mesh
  93199. */
  93200. addChild(mesh: AbstractMesh): AbstractMesh;
  93201. /**
  93202. * Removes the passed mesh from the current mesh children list
  93203. * @param mesh defines the child mesh
  93204. * @returns the current mesh
  93205. */
  93206. removeChild(mesh: AbstractMesh): AbstractMesh;
  93207. /** @hidden */
  93208. private _initFacetData;
  93209. /**
  93210. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93211. * This method can be called within the render loop.
  93212. * 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
  93213. * @returns the current mesh
  93214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93215. */
  93216. updateFacetData(): AbstractMesh;
  93217. /**
  93218. * Returns the facetLocalNormals array.
  93219. * The normals are expressed in the mesh local spac
  93220. * @returns an array of Vector3
  93221. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93222. */
  93223. getFacetLocalNormals(): Vector3[];
  93224. /**
  93225. * Returns the facetLocalPositions array.
  93226. * The facet positions are expressed in the mesh local space
  93227. * @returns an array of Vector3
  93228. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93229. */
  93230. getFacetLocalPositions(): Vector3[];
  93231. /**
  93232. * Returns the facetLocalPartioning array
  93233. * @returns an array of array of numbers
  93234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93235. */
  93236. getFacetLocalPartitioning(): number[][];
  93237. /**
  93238. * Returns the i-th facet position in the world system.
  93239. * This method allocates a new Vector3 per call
  93240. * @param i defines the facet index
  93241. * @returns a new Vector3
  93242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93243. */
  93244. getFacetPosition(i: number): Vector3;
  93245. /**
  93246. * Sets the reference Vector3 with the i-th facet position in the world system
  93247. * @param i defines the facet index
  93248. * @param ref defines the target vector
  93249. * @returns the current mesh
  93250. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93251. */
  93252. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93253. /**
  93254. * Returns the i-th facet normal in the world system.
  93255. * This method allocates a new Vector3 per call
  93256. * @param i defines the facet index
  93257. * @returns a new Vector3
  93258. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93259. */
  93260. getFacetNormal(i: number): Vector3;
  93261. /**
  93262. * Sets the reference Vector3 with the i-th facet normal in the world system
  93263. * @param i defines the facet index
  93264. * @param ref defines the target vector
  93265. * @returns the current mesh
  93266. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93267. */
  93268. getFacetNormalToRef(i: number, ref: Vector3): this;
  93269. /**
  93270. * 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)
  93271. * @param x defines x coordinate
  93272. * @param y defines y coordinate
  93273. * @param z defines z coordinate
  93274. * @returns the array of facet indexes
  93275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93276. */
  93277. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93278. /**
  93279. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93280. * @param projected sets as the (x,y,z) world projection on the facet
  93281. * @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
  93282. * @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
  93283. * @param x defines x coordinate
  93284. * @param y defines y coordinate
  93285. * @param z defines z coordinate
  93286. * @returns the face index if found (or null instead)
  93287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93288. */
  93289. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93290. /**
  93291. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93292. * @param projected sets as the (x,y,z) local projection on the facet
  93293. * @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
  93294. * @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
  93295. * @param x defines x coordinate
  93296. * @param y defines y coordinate
  93297. * @param z defines z coordinate
  93298. * @returns the face index if found (or null instead)
  93299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93300. */
  93301. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93302. /**
  93303. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93304. * @returns the parameters
  93305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93306. */
  93307. getFacetDataParameters(): any;
  93308. /**
  93309. * Disables the feature FacetData and frees the related memory
  93310. * @returns the current mesh
  93311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93312. */
  93313. disableFacetData(): AbstractMesh;
  93314. /**
  93315. * Updates the AbstractMesh indices array
  93316. * @param indices defines the data source
  93317. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93318. * @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)
  93319. * @returns the current mesh
  93320. */
  93321. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93322. /**
  93323. * Creates new normals data for the mesh
  93324. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93325. * @returns the current mesh
  93326. */
  93327. createNormals(updatable: boolean): AbstractMesh;
  93328. /**
  93329. * Align the mesh with a normal
  93330. * @param normal defines the normal to use
  93331. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93332. * @returns the current mesh
  93333. */
  93334. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93335. /** @hidden */
  93336. _checkOcclusionQuery(): boolean;
  93337. /**
  93338. * Disables the mesh edge rendering mode
  93339. * @returns the currentAbstractMesh
  93340. */
  93341. disableEdgesRendering(): AbstractMesh;
  93342. /**
  93343. * Enables the edge rendering mode on the mesh.
  93344. * This mode makes the mesh edges visible
  93345. * @param epsilon defines the maximal distance between two angles to detect a face
  93346. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93347. * @returns the currentAbstractMesh
  93348. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93349. */
  93350. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93351. }
  93352. }
  93353. declare module BABYLON {
  93354. /**
  93355. * Interface used to define ActionEvent
  93356. */
  93357. export interface IActionEvent {
  93358. /** The mesh or sprite that triggered the action */
  93359. source: any;
  93360. /** The X mouse cursor position at the time of the event */
  93361. pointerX: number;
  93362. /** The Y mouse cursor position at the time of the event */
  93363. pointerY: number;
  93364. /** The mesh that is currently pointed at (can be null) */
  93365. meshUnderPointer: Nullable<AbstractMesh>;
  93366. /** the original (browser) event that triggered the ActionEvent */
  93367. sourceEvent?: any;
  93368. /** additional data for the event */
  93369. additionalData?: any;
  93370. }
  93371. /**
  93372. * ActionEvent is the event being sent when an action is triggered.
  93373. */
  93374. export class ActionEvent implements IActionEvent {
  93375. /** The mesh or sprite that triggered the action */
  93376. source: any;
  93377. /** The X mouse cursor position at the time of the event */
  93378. pointerX: number;
  93379. /** The Y mouse cursor position at the time of the event */
  93380. pointerY: number;
  93381. /** The mesh that is currently pointed at (can be null) */
  93382. meshUnderPointer: Nullable<AbstractMesh>;
  93383. /** the original (browser) event that triggered the ActionEvent */
  93384. sourceEvent?: any;
  93385. /** additional data for the event */
  93386. additionalData?: any;
  93387. /**
  93388. * Creates a new ActionEvent
  93389. * @param source The mesh or sprite that triggered the action
  93390. * @param pointerX The X mouse cursor position at the time of the event
  93391. * @param pointerY The Y mouse cursor position at the time of the event
  93392. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93393. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93394. * @param additionalData additional data for the event
  93395. */
  93396. constructor(
  93397. /** The mesh or sprite that triggered the action */
  93398. source: any,
  93399. /** The X mouse cursor position at the time of the event */
  93400. pointerX: number,
  93401. /** The Y mouse cursor position at the time of the event */
  93402. pointerY: number,
  93403. /** The mesh that is currently pointed at (can be null) */
  93404. meshUnderPointer: Nullable<AbstractMesh>,
  93405. /** the original (browser) event that triggered the ActionEvent */
  93406. sourceEvent?: any,
  93407. /** additional data for the event */
  93408. additionalData?: any);
  93409. /**
  93410. * Helper function to auto-create an ActionEvent from a source mesh.
  93411. * @param source The source mesh that triggered the event
  93412. * @param evt The original (browser) event
  93413. * @param additionalData additional data for the event
  93414. * @returns the new ActionEvent
  93415. */
  93416. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93417. /**
  93418. * Helper function to auto-create an ActionEvent from a source sprite
  93419. * @param source The source sprite that triggered the event
  93420. * @param scene Scene associated with the sprite
  93421. * @param evt The original (browser) event
  93422. * @param additionalData additional data for the event
  93423. * @returns the new ActionEvent
  93424. */
  93425. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93426. /**
  93427. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93428. * @param scene the scene where the event occurred
  93429. * @param evt The original (browser) event
  93430. * @returns the new ActionEvent
  93431. */
  93432. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93433. /**
  93434. * Helper function to auto-create an ActionEvent from a primitive
  93435. * @param prim defines the target primitive
  93436. * @param pointerPos defines the pointer position
  93437. * @param evt The original (browser) event
  93438. * @param additionalData additional data for the event
  93439. * @returns the new ActionEvent
  93440. */
  93441. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93442. }
  93443. }
  93444. declare module BABYLON {
  93445. /**
  93446. * Abstract class used to decouple action Manager from scene and meshes.
  93447. * Do not instantiate.
  93448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93449. */
  93450. export abstract class AbstractActionManager implements IDisposable {
  93451. /** Gets the list of active triggers */
  93452. static Triggers: {
  93453. [key: string]: number;
  93454. };
  93455. /** Gets the cursor to use when hovering items */
  93456. hoverCursor: string;
  93457. /** Gets the list of actions */
  93458. actions: IAction[];
  93459. /**
  93460. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93461. */
  93462. isRecursive: boolean;
  93463. /**
  93464. * Releases all associated resources
  93465. */
  93466. abstract dispose(): void;
  93467. /**
  93468. * Does this action manager has pointer triggers
  93469. */
  93470. abstract readonly hasPointerTriggers: boolean;
  93471. /**
  93472. * Does this action manager has pick triggers
  93473. */
  93474. abstract readonly hasPickTriggers: boolean;
  93475. /**
  93476. * Process a specific trigger
  93477. * @param trigger defines the trigger to process
  93478. * @param evt defines the event details to be processed
  93479. */
  93480. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93481. /**
  93482. * Does this action manager handles actions of any of the given triggers
  93483. * @param triggers defines the triggers to be tested
  93484. * @return a boolean indicating whether one (or more) of the triggers is handled
  93485. */
  93486. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93487. /**
  93488. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93489. * speed.
  93490. * @param triggerA defines the trigger to be tested
  93491. * @param triggerB defines the trigger to be tested
  93492. * @return a boolean indicating whether one (or more) of the triggers is handled
  93493. */
  93494. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93495. /**
  93496. * Does this action manager handles actions of a given trigger
  93497. * @param trigger defines the trigger to be tested
  93498. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93499. * @return whether the trigger is handled
  93500. */
  93501. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93502. /**
  93503. * Serialize this manager to a JSON object
  93504. * @param name defines the property name to store this manager
  93505. * @returns a JSON representation of this manager
  93506. */
  93507. abstract serialize(name: string): any;
  93508. /**
  93509. * Registers an action to this action manager
  93510. * @param action defines the action to be registered
  93511. * @return the action amended (prepared) after registration
  93512. */
  93513. abstract registerAction(action: IAction): Nullable<IAction>;
  93514. /**
  93515. * Unregisters an action to this action manager
  93516. * @param action defines the action to be unregistered
  93517. * @return a boolean indicating whether the action has been unregistered
  93518. */
  93519. abstract unregisterAction(action: IAction): Boolean;
  93520. /**
  93521. * Does exist one action manager with at least one trigger
  93522. **/
  93523. static readonly HasTriggers: boolean;
  93524. /**
  93525. * Does exist one action manager with at least one pick trigger
  93526. **/
  93527. static readonly HasPickTriggers: boolean;
  93528. /**
  93529. * Does exist one action manager that handles actions of a given trigger
  93530. * @param trigger defines the trigger to be tested
  93531. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93532. **/
  93533. static HasSpecificTrigger(trigger: number): boolean;
  93534. }
  93535. }
  93536. declare module BABYLON {
  93537. /**
  93538. * Defines how a node can be built from a string name.
  93539. */
  93540. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93541. /**
  93542. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93543. */
  93544. export class Node implements IBehaviorAware<Node> {
  93545. /** @hidden */
  93546. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93547. private static _NodeConstructors;
  93548. /**
  93549. * Add a new node constructor
  93550. * @param type defines the type name of the node to construct
  93551. * @param constructorFunc defines the constructor function
  93552. */
  93553. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93554. /**
  93555. * Returns a node constructor based on type name
  93556. * @param type defines the type name
  93557. * @param name defines the new node name
  93558. * @param scene defines the hosting scene
  93559. * @param options defines optional options to transmit to constructors
  93560. * @returns the new constructor or null
  93561. */
  93562. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93563. /**
  93564. * Gets or sets the name of the node
  93565. */
  93566. name: string;
  93567. /**
  93568. * Gets or sets the id of the node
  93569. */
  93570. id: string;
  93571. /**
  93572. * Gets or sets the unique id of the node
  93573. */
  93574. uniqueId: number;
  93575. /**
  93576. * Gets or sets a string used to store user defined state for the node
  93577. */
  93578. state: string;
  93579. /**
  93580. * Gets or sets an object used to store user defined information for the node
  93581. */
  93582. metadata: any;
  93583. /**
  93584. * For internal use only. Please do not use.
  93585. */
  93586. reservedDataStore: any;
  93587. /**
  93588. * List of inspectable custom properties (used by the Inspector)
  93589. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93590. */
  93591. inspectableCustomProperties: IInspectable[];
  93592. private _doNotSerialize;
  93593. /**
  93594. * Gets or sets a boolean used to define if the node must be serialized
  93595. */
  93596. doNotSerialize: boolean;
  93597. /** @hidden */
  93598. _isDisposed: boolean;
  93599. /**
  93600. * Gets a list of Animations associated with the node
  93601. */
  93602. animations: Animation[];
  93603. protected _ranges: {
  93604. [name: string]: Nullable<AnimationRange>;
  93605. };
  93606. /**
  93607. * Callback raised when the node is ready to be used
  93608. */
  93609. onReady: Nullable<(node: Node) => void>;
  93610. private _isEnabled;
  93611. private _isParentEnabled;
  93612. private _isReady;
  93613. /** @hidden */
  93614. _currentRenderId: number;
  93615. private _parentUpdateId;
  93616. /** @hidden */
  93617. _childUpdateId: number;
  93618. /** @hidden */
  93619. _waitingParentId: Nullable<string>;
  93620. /** @hidden */
  93621. _scene: Scene;
  93622. /** @hidden */
  93623. _cache: any;
  93624. private _parentNode;
  93625. private _children;
  93626. /** @hidden */
  93627. _worldMatrix: Matrix;
  93628. /** @hidden */
  93629. _worldMatrixDeterminant: number;
  93630. /** @hidden */
  93631. _worldMatrixDeterminantIsDirty: boolean;
  93632. /** @hidden */
  93633. private _sceneRootNodesIndex;
  93634. /**
  93635. * Gets a boolean indicating if the node has been disposed
  93636. * @returns true if the node was disposed
  93637. */
  93638. isDisposed(): boolean;
  93639. /**
  93640. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93641. * @see https://doc.babylonjs.com/how_to/parenting
  93642. */
  93643. parent: Nullable<Node>;
  93644. private addToSceneRootNodes;
  93645. private removeFromSceneRootNodes;
  93646. private _animationPropertiesOverride;
  93647. /**
  93648. * Gets or sets the animation properties override
  93649. */
  93650. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93651. /**
  93652. * Gets a string idenfifying the name of the class
  93653. * @returns "Node" string
  93654. */
  93655. getClassName(): string;
  93656. /** @hidden */
  93657. readonly _isNode: boolean;
  93658. /**
  93659. * An event triggered when the mesh is disposed
  93660. */
  93661. onDisposeObservable: Observable<Node>;
  93662. private _onDisposeObserver;
  93663. /**
  93664. * Sets a callback that will be raised when the node will be disposed
  93665. */
  93666. onDispose: () => void;
  93667. /**
  93668. * Creates a new Node
  93669. * @param name the name and id to be given to this node
  93670. * @param scene the scene this node will be added to
  93671. * @param addToRootNodes the node will be added to scene.rootNodes
  93672. */
  93673. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93674. /**
  93675. * Gets the scene of the node
  93676. * @returns a scene
  93677. */
  93678. getScene(): Scene;
  93679. /**
  93680. * Gets the engine of the node
  93681. * @returns a Engine
  93682. */
  93683. getEngine(): Engine;
  93684. private _behaviors;
  93685. /**
  93686. * Attach a behavior to the node
  93687. * @see http://doc.babylonjs.com/features/behaviour
  93688. * @param behavior defines the behavior to attach
  93689. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93690. * @returns the current Node
  93691. */
  93692. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93693. /**
  93694. * Remove an attached behavior
  93695. * @see http://doc.babylonjs.com/features/behaviour
  93696. * @param behavior defines the behavior to attach
  93697. * @returns the current Node
  93698. */
  93699. removeBehavior(behavior: Behavior<Node>): Node;
  93700. /**
  93701. * Gets the list of attached behaviors
  93702. * @see http://doc.babylonjs.com/features/behaviour
  93703. */
  93704. readonly behaviors: Behavior<Node>[];
  93705. /**
  93706. * Gets an attached behavior by name
  93707. * @param name defines the name of the behavior to look for
  93708. * @see http://doc.babylonjs.com/features/behaviour
  93709. * @returns null if behavior was not found else the requested behavior
  93710. */
  93711. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93712. /**
  93713. * Returns the latest update of the World matrix
  93714. * @returns a Matrix
  93715. */
  93716. getWorldMatrix(): Matrix;
  93717. /** @hidden */
  93718. _getWorldMatrixDeterminant(): number;
  93719. /**
  93720. * Returns directly the latest state of the mesh World matrix.
  93721. * A Matrix is returned.
  93722. */
  93723. readonly worldMatrixFromCache: Matrix;
  93724. /** @hidden */
  93725. _initCache(): void;
  93726. /** @hidden */
  93727. updateCache(force?: boolean): void;
  93728. /** @hidden */
  93729. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93730. /** @hidden */
  93731. _updateCache(ignoreParentClass?: boolean): void;
  93732. /** @hidden */
  93733. _isSynchronized(): boolean;
  93734. /** @hidden */
  93735. _markSyncedWithParent(): void;
  93736. /** @hidden */
  93737. isSynchronizedWithParent(): boolean;
  93738. /** @hidden */
  93739. isSynchronized(): boolean;
  93740. /**
  93741. * Is this node ready to be used/rendered
  93742. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93743. * @return true if the node is ready
  93744. */
  93745. isReady(completeCheck?: boolean): boolean;
  93746. /**
  93747. * Is this node enabled?
  93748. * 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
  93749. * @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
  93750. * @return whether this node (and its parent) is enabled
  93751. */
  93752. isEnabled(checkAncestors?: boolean): boolean;
  93753. /** @hidden */
  93754. protected _syncParentEnabledState(): void;
  93755. /**
  93756. * Set the enabled state of this node
  93757. * @param value defines the new enabled state
  93758. */
  93759. setEnabled(value: boolean): void;
  93760. /**
  93761. * Is this node a descendant of the given node?
  93762. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93763. * @param ancestor defines the parent node to inspect
  93764. * @returns a boolean indicating if this node is a descendant of the given node
  93765. */
  93766. isDescendantOf(ancestor: Node): boolean;
  93767. /** @hidden */
  93768. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93769. /**
  93770. * Will return all nodes that have this node as ascendant
  93771. * @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
  93772. * @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
  93773. * @return all children nodes of all types
  93774. */
  93775. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93776. /**
  93777. * Get all child-meshes of this node
  93778. * @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)
  93779. * @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
  93780. * @returns an array of AbstractMesh
  93781. */
  93782. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93783. /**
  93784. * Get all direct children of this node
  93785. * @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
  93786. * @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)
  93787. * @returns an array of Node
  93788. */
  93789. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93790. /** @hidden */
  93791. _setReady(state: boolean): void;
  93792. /**
  93793. * Get an animation by name
  93794. * @param name defines the name of the animation to look for
  93795. * @returns null if not found else the requested animation
  93796. */
  93797. getAnimationByName(name: string): Nullable<Animation>;
  93798. /**
  93799. * Creates an animation range for this node
  93800. * @param name defines the name of the range
  93801. * @param from defines the starting key
  93802. * @param to defines the end key
  93803. */
  93804. createAnimationRange(name: string, from: number, to: number): void;
  93805. /**
  93806. * Delete a specific animation range
  93807. * @param name defines the name of the range to delete
  93808. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93809. */
  93810. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93811. /**
  93812. * Get an animation range by name
  93813. * @param name defines the name of the animation range to look for
  93814. * @returns null if not found else the requested animation range
  93815. */
  93816. getAnimationRange(name: string): Nullable<AnimationRange>;
  93817. /**
  93818. * Gets the list of all animation ranges defined on this node
  93819. * @returns an array
  93820. */
  93821. getAnimationRanges(): Nullable<AnimationRange>[];
  93822. /**
  93823. * Will start the animation sequence
  93824. * @param name defines the range frames for animation sequence
  93825. * @param loop defines if the animation should loop (false by default)
  93826. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93827. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93828. * @returns the object created for this animation. If range does not exist, it will return null
  93829. */
  93830. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93831. /**
  93832. * Serialize animation ranges into a JSON compatible object
  93833. * @returns serialization object
  93834. */
  93835. serializeAnimationRanges(): any;
  93836. /**
  93837. * Computes the world matrix of the node
  93838. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93839. * @returns the world matrix
  93840. */
  93841. computeWorldMatrix(force?: boolean): Matrix;
  93842. /**
  93843. * Releases resources associated with this node.
  93844. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93845. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93846. */
  93847. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93848. /**
  93849. * Parse animation range data from a serialization object and store them into a given node
  93850. * @param node defines where to store the animation ranges
  93851. * @param parsedNode defines the serialization object to read data from
  93852. * @param scene defines the hosting scene
  93853. */
  93854. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93855. /**
  93856. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93857. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93858. * @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
  93859. * @returns the new bounding vectors
  93860. */
  93861. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93862. min: Vector3;
  93863. max: Vector3;
  93864. };
  93865. }
  93866. }
  93867. declare module BABYLON {
  93868. /**
  93869. * @hidden
  93870. */
  93871. export class _IAnimationState {
  93872. key: number;
  93873. repeatCount: number;
  93874. workValue?: any;
  93875. loopMode?: number;
  93876. offsetValue?: any;
  93877. highLimitValue?: any;
  93878. }
  93879. /**
  93880. * Class used to store any kind of animation
  93881. */
  93882. export class Animation {
  93883. /**Name of the animation */
  93884. name: string;
  93885. /**Property to animate */
  93886. targetProperty: string;
  93887. /**The frames per second of the animation */
  93888. framePerSecond: number;
  93889. /**The data type of the animation */
  93890. dataType: number;
  93891. /**The loop mode of the animation */
  93892. loopMode?: number | undefined;
  93893. /**Specifies if blending should be enabled */
  93894. enableBlending?: boolean | undefined;
  93895. /**
  93896. * Use matrix interpolation instead of using direct key value when animating matrices
  93897. */
  93898. static AllowMatricesInterpolation: boolean;
  93899. /**
  93900. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93901. */
  93902. static AllowMatrixDecomposeForInterpolation: boolean;
  93903. /**
  93904. * Stores the key frames of the animation
  93905. */
  93906. private _keys;
  93907. /**
  93908. * Stores the easing function of the animation
  93909. */
  93910. private _easingFunction;
  93911. /**
  93912. * @hidden Internal use only
  93913. */
  93914. _runtimeAnimations: RuntimeAnimation[];
  93915. /**
  93916. * The set of event that will be linked to this animation
  93917. */
  93918. private _events;
  93919. /**
  93920. * Stores an array of target property paths
  93921. */
  93922. targetPropertyPath: string[];
  93923. /**
  93924. * Stores the blending speed of the animation
  93925. */
  93926. blendingSpeed: number;
  93927. /**
  93928. * Stores the animation ranges for the animation
  93929. */
  93930. private _ranges;
  93931. /**
  93932. * @hidden Internal use
  93933. */
  93934. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93935. /**
  93936. * Sets up an animation
  93937. * @param property The property to animate
  93938. * @param animationType The animation type to apply
  93939. * @param framePerSecond The frames per second of the animation
  93940. * @param easingFunction The easing function used in the animation
  93941. * @returns The created animation
  93942. */
  93943. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93944. /**
  93945. * Create and start an animation on a node
  93946. * @param name defines the name of the global animation that will be run on all nodes
  93947. * @param node defines the root node where the animation will take place
  93948. * @param targetProperty defines property to animate
  93949. * @param framePerSecond defines the number of frame per second yo use
  93950. * @param totalFrame defines the number of frames in total
  93951. * @param from defines the initial value
  93952. * @param to defines the final value
  93953. * @param loopMode defines which loop mode you want to use (off by default)
  93954. * @param easingFunction defines the easing function to use (linear by default)
  93955. * @param onAnimationEnd defines the callback to call when animation end
  93956. * @returns the animatable created for this animation
  93957. */
  93958. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93959. /**
  93960. * Create and start an animation on a node and its descendants
  93961. * @param name defines the name of the global animation that will be run on all nodes
  93962. * @param node defines the root node where the animation will take place
  93963. * @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
  93964. * @param targetProperty defines property to animate
  93965. * @param framePerSecond defines the number of frame per second to use
  93966. * @param totalFrame defines the number of frames in total
  93967. * @param from defines the initial value
  93968. * @param to defines the final value
  93969. * @param loopMode defines which loop mode you want to use (off by default)
  93970. * @param easingFunction defines the easing function to use (linear by default)
  93971. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93972. * @returns the list of animatables created for all nodes
  93973. * @example https://www.babylonjs-playground.com/#MH0VLI
  93974. */
  93975. 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[]>;
  93976. /**
  93977. * Creates a new animation, merges it with the existing animations and starts it
  93978. * @param name Name of the animation
  93979. * @param node Node which contains the scene that begins the animations
  93980. * @param targetProperty Specifies which property to animate
  93981. * @param framePerSecond The frames per second of the animation
  93982. * @param totalFrame The total number of frames
  93983. * @param from The frame at the beginning of the animation
  93984. * @param to The frame at the end of the animation
  93985. * @param loopMode Specifies the loop mode of the animation
  93986. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93987. * @param onAnimationEnd Callback to run once the animation is complete
  93988. * @returns Nullable animation
  93989. */
  93990. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93991. /**
  93992. * Transition property of an host to the target Value
  93993. * @param property The property to transition
  93994. * @param targetValue The target Value of the property
  93995. * @param host The object where the property to animate belongs
  93996. * @param scene Scene used to run the animation
  93997. * @param frameRate Framerate (in frame/s) to use
  93998. * @param transition The transition type we want to use
  93999. * @param duration The duration of the animation, in milliseconds
  94000. * @param onAnimationEnd Callback trigger at the end of the animation
  94001. * @returns Nullable animation
  94002. */
  94003. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94004. /**
  94005. * Return the array of runtime animations currently using this animation
  94006. */
  94007. readonly runtimeAnimations: RuntimeAnimation[];
  94008. /**
  94009. * Specifies if any of the runtime animations are currently running
  94010. */
  94011. readonly hasRunningRuntimeAnimations: boolean;
  94012. /**
  94013. * Initializes the animation
  94014. * @param name Name of the animation
  94015. * @param targetProperty Property to animate
  94016. * @param framePerSecond The frames per second of the animation
  94017. * @param dataType The data type of the animation
  94018. * @param loopMode The loop mode of the animation
  94019. * @param enableBlending Specifies if blending should be enabled
  94020. */
  94021. constructor(
  94022. /**Name of the animation */
  94023. name: string,
  94024. /**Property to animate */
  94025. targetProperty: string,
  94026. /**The frames per second of the animation */
  94027. framePerSecond: number,
  94028. /**The data type of the animation */
  94029. dataType: number,
  94030. /**The loop mode of the animation */
  94031. loopMode?: number | undefined,
  94032. /**Specifies if blending should be enabled */
  94033. enableBlending?: boolean | undefined);
  94034. /**
  94035. * Converts the animation to a string
  94036. * @param fullDetails support for multiple levels of logging within scene loading
  94037. * @returns String form of the animation
  94038. */
  94039. toString(fullDetails?: boolean): string;
  94040. /**
  94041. * Add an event to this animation
  94042. * @param event Event to add
  94043. */
  94044. addEvent(event: AnimationEvent): void;
  94045. /**
  94046. * Remove all events found at the given frame
  94047. * @param frame The frame to remove events from
  94048. */
  94049. removeEvents(frame: number): void;
  94050. /**
  94051. * Retrieves all the events from the animation
  94052. * @returns Events from the animation
  94053. */
  94054. getEvents(): AnimationEvent[];
  94055. /**
  94056. * Creates an animation range
  94057. * @param name Name of the animation range
  94058. * @param from Starting frame of the animation range
  94059. * @param to Ending frame of the animation
  94060. */
  94061. createRange(name: string, from: number, to: number): void;
  94062. /**
  94063. * Deletes an animation range by name
  94064. * @param name Name of the animation range to delete
  94065. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94066. */
  94067. deleteRange(name: string, deleteFrames?: boolean): void;
  94068. /**
  94069. * Gets the animation range by name, or null if not defined
  94070. * @param name Name of the animation range
  94071. * @returns Nullable animation range
  94072. */
  94073. getRange(name: string): Nullable<AnimationRange>;
  94074. /**
  94075. * Gets the key frames from the animation
  94076. * @returns The key frames of the animation
  94077. */
  94078. getKeys(): Array<IAnimationKey>;
  94079. /**
  94080. * Gets the highest frame rate of the animation
  94081. * @returns Highest frame rate of the animation
  94082. */
  94083. getHighestFrame(): number;
  94084. /**
  94085. * Gets the easing function of the animation
  94086. * @returns Easing function of the animation
  94087. */
  94088. getEasingFunction(): IEasingFunction;
  94089. /**
  94090. * Sets the easing function of the animation
  94091. * @param easingFunction A custom mathematical formula for animation
  94092. */
  94093. setEasingFunction(easingFunction: EasingFunction): void;
  94094. /**
  94095. * Interpolates a scalar linearly
  94096. * @param startValue Start value of the animation curve
  94097. * @param endValue End value of the animation curve
  94098. * @param gradient Scalar amount to interpolate
  94099. * @returns Interpolated scalar value
  94100. */
  94101. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94102. /**
  94103. * Interpolates a scalar cubically
  94104. * @param startValue Start value of the animation curve
  94105. * @param outTangent End tangent of the animation
  94106. * @param endValue End value of the animation curve
  94107. * @param inTangent Start tangent of the animation curve
  94108. * @param gradient Scalar amount to interpolate
  94109. * @returns Interpolated scalar value
  94110. */
  94111. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94112. /**
  94113. * Interpolates a quaternion using a spherical linear interpolation
  94114. * @param startValue Start value of the animation curve
  94115. * @param endValue End value of the animation curve
  94116. * @param gradient Scalar amount to interpolate
  94117. * @returns Interpolated quaternion value
  94118. */
  94119. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94120. /**
  94121. * Interpolates a quaternion cubically
  94122. * @param startValue Start value of the animation curve
  94123. * @param outTangent End tangent of the animation curve
  94124. * @param endValue End value of the animation curve
  94125. * @param inTangent Start tangent of the animation curve
  94126. * @param gradient Scalar amount to interpolate
  94127. * @returns Interpolated quaternion value
  94128. */
  94129. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94130. /**
  94131. * Interpolates a Vector3 linearl
  94132. * @param startValue Start value of the animation curve
  94133. * @param endValue End value of the animation curve
  94134. * @param gradient Scalar amount to interpolate
  94135. * @returns Interpolated scalar value
  94136. */
  94137. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94138. /**
  94139. * Interpolates a Vector3 cubically
  94140. * @param startValue Start value of the animation curve
  94141. * @param outTangent End tangent of the animation
  94142. * @param endValue End value of the animation curve
  94143. * @param inTangent Start tangent of the animation curve
  94144. * @param gradient Scalar amount to interpolate
  94145. * @returns InterpolatedVector3 value
  94146. */
  94147. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94148. /**
  94149. * Interpolates a Vector2 linearly
  94150. * @param startValue Start value of the animation curve
  94151. * @param endValue End value of the animation curve
  94152. * @param gradient Scalar amount to interpolate
  94153. * @returns Interpolated Vector2 value
  94154. */
  94155. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94156. /**
  94157. * Interpolates a Vector2 cubically
  94158. * @param startValue Start value of the animation curve
  94159. * @param outTangent End tangent of the animation
  94160. * @param endValue End value of the animation curve
  94161. * @param inTangent Start tangent of the animation curve
  94162. * @param gradient Scalar amount to interpolate
  94163. * @returns Interpolated Vector2 value
  94164. */
  94165. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94166. /**
  94167. * Interpolates a size linearly
  94168. * @param startValue Start value of the animation curve
  94169. * @param endValue End value of the animation curve
  94170. * @param gradient Scalar amount to interpolate
  94171. * @returns Interpolated Size value
  94172. */
  94173. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94174. /**
  94175. * Interpolates a Color3 linearly
  94176. * @param startValue Start value of the animation curve
  94177. * @param endValue End value of the animation curve
  94178. * @param gradient Scalar amount to interpolate
  94179. * @returns Interpolated Color3 value
  94180. */
  94181. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94182. /**
  94183. * @hidden Internal use only
  94184. */
  94185. _getKeyValue(value: any): any;
  94186. /**
  94187. * @hidden Internal use only
  94188. */
  94189. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94190. /**
  94191. * Defines the function to use to interpolate matrices
  94192. * @param startValue defines the start matrix
  94193. * @param endValue defines the end matrix
  94194. * @param gradient defines the gradient between both matrices
  94195. * @param result defines an optional target matrix where to store the interpolation
  94196. * @returns the interpolated matrix
  94197. */
  94198. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94199. /**
  94200. * Makes a copy of the animation
  94201. * @returns Cloned animation
  94202. */
  94203. clone(): Animation;
  94204. /**
  94205. * Sets the key frames of the animation
  94206. * @param values The animation key frames to set
  94207. */
  94208. setKeys(values: Array<IAnimationKey>): void;
  94209. /**
  94210. * Serializes the animation to an object
  94211. * @returns Serialized object
  94212. */
  94213. serialize(): any;
  94214. /**
  94215. * Float animation type
  94216. */
  94217. private static _ANIMATIONTYPE_FLOAT;
  94218. /**
  94219. * Vector3 animation type
  94220. */
  94221. private static _ANIMATIONTYPE_VECTOR3;
  94222. /**
  94223. * Quaternion animation type
  94224. */
  94225. private static _ANIMATIONTYPE_QUATERNION;
  94226. /**
  94227. * Matrix animation type
  94228. */
  94229. private static _ANIMATIONTYPE_MATRIX;
  94230. /**
  94231. * Color3 animation type
  94232. */
  94233. private static _ANIMATIONTYPE_COLOR3;
  94234. /**
  94235. * Vector2 animation type
  94236. */
  94237. private static _ANIMATIONTYPE_VECTOR2;
  94238. /**
  94239. * Size animation type
  94240. */
  94241. private static _ANIMATIONTYPE_SIZE;
  94242. /**
  94243. * Relative Loop Mode
  94244. */
  94245. private static _ANIMATIONLOOPMODE_RELATIVE;
  94246. /**
  94247. * Cycle Loop Mode
  94248. */
  94249. private static _ANIMATIONLOOPMODE_CYCLE;
  94250. /**
  94251. * Constant Loop Mode
  94252. */
  94253. private static _ANIMATIONLOOPMODE_CONSTANT;
  94254. /**
  94255. * Get the float animation type
  94256. */
  94257. static readonly ANIMATIONTYPE_FLOAT: number;
  94258. /**
  94259. * Get the Vector3 animation type
  94260. */
  94261. static readonly ANIMATIONTYPE_VECTOR3: number;
  94262. /**
  94263. * Get the Vector2 animation type
  94264. */
  94265. static readonly ANIMATIONTYPE_VECTOR2: number;
  94266. /**
  94267. * Get the Size animation type
  94268. */
  94269. static readonly ANIMATIONTYPE_SIZE: number;
  94270. /**
  94271. * Get the Quaternion animation type
  94272. */
  94273. static readonly ANIMATIONTYPE_QUATERNION: number;
  94274. /**
  94275. * Get the Matrix animation type
  94276. */
  94277. static readonly ANIMATIONTYPE_MATRIX: number;
  94278. /**
  94279. * Get the Color3 animation type
  94280. */
  94281. static readonly ANIMATIONTYPE_COLOR3: number;
  94282. /**
  94283. * Get the Relative Loop Mode
  94284. */
  94285. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94286. /**
  94287. * Get the Cycle Loop Mode
  94288. */
  94289. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94290. /**
  94291. * Get the Constant Loop Mode
  94292. */
  94293. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94294. /** @hidden */
  94295. static _UniversalLerp(left: any, right: any, amount: number): any;
  94296. /**
  94297. * Parses an animation object and creates an animation
  94298. * @param parsedAnimation Parsed animation object
  94299. * @returns Animation object
  94300. */
  94301. static Parse(parsedAnimation: any): Animation;
  94302. /**
  94303. * Appends the serialized animations from the source animations
  94304. * @param source Source containing the animations
  94305. * @param destination Target to store the animations
  94306. */
  94307. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94308. }
  94309. }
  94310. declare module BABYLON {
  94311. /**
  94312. * Interface containing an array of animations
  94313. */
  94314. export interface IAnimatable {
  94315. /**
  94316. * Array of animations
  94317. */
  94318. animations: Nullable<Array<Animation>>;
  94319. }
  94320. }
  94321. declare module BABYLON {
  94322. /**
  94323. * This represents all the required information to add a fresnel effect on a material:
  94324. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94325. */
  94326. export class FresnelParameters {
  94327. private _isEnabled;
  94328. /**
  94329. * Define if the fresnel effect is enable or not.
  94330. */
  94331. isEnabled: boolean;
  94332. /**
  94333. * Define the color used on edges (grazing angle)
  94334. */
  94335. leftColor: Color3;
  94336. /**
  94337. * Define the color used on center
  94338. */
  94339. rightColor: Color3;
  94340. /**
  94341. * Define bias applied to computed fresnel term
  94342. */
  94343. bias: number;
  94344. /**
  94345. * Defined the power exponent applied to fresnel term
  94346. */
  94347. power: number;
  94348. /**
  94349. * Clones the current fresnel and its valuues
  94350. * @returns a clone fresnel configuration
  94351. */
  94352. clone(): FresnelParameters;
  94353. /**
  94354. * Serializes the current fresnel parameters to a JSON representation.
  94355. * @return the JSON serialization
  94356. */
  94357. serialize(): any;
  94358. /**
  94359. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94360. * @param parsedFresnelParameters Define the JSON representation
  94361. * @returns the parsed parameters
  94362. */
  94363. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94364. }
  94365. }
  94366. declare module BABYLON {
  94367. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94368. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94369. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94370. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94371. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94372. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94373. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94374. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94375. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94376. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94377. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94378. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94379. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94380. /**
  94381. * Decorator used to define property that can be serialized as reference to a camera
  94382. * @param sourceName defines the name of the property to decorate
  94383. */
  94384. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94385. /**
  94386. * Class used to help serialization objects
  94387. */
  94388. export class SerializationHelper {
  94389. /** @hidden */
  94390. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94391. /** @hidden */
  94392. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94393. /** @hidden */
  94394. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94395. /** @hidden */
  94396. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94397. /**
  94398. * Appends the serialized animations from the source animations
  94399. * @param source Source containing the animations
  94400. * @param destination Target to store the animations
  94401. */
  94402. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94403. /**
  94404. * Static function used to serialized a specific entity
  94405. * @param entity defines the entity to serialize
  94406. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94407. * @returns a JSON compatible object representing the serialization of the entity
  94408. */
  94409. static Serialize<T>(entity: T, serializationObject?: any): any;
  94410. /**
  94411. * Creates a new entity from a serialization data object
  94412. * @param creationFunction defines a function used to instanciated the new entity
  94413. * @param source defines the source serialization data
  94414. * @param scene defines the hosting scene
  94415. * @param rootUrl defines the root url for resources
  94416. * @returns a new entity
  94417. */
  94418. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94419. /**
  94420. * Clones an object
  94421. * @param creationFunction defines the function used to instanciate the new object
  94422. * @param source defines the source object
  94423. * @returns the cloned object
  94424. */
  94425. static Clone<T>(creationFunction: () => T, source: T): T;
  94426. /**
  94427. * Instanciates a new object based on a source one (some data will be shared between both object)
  94428. * @param creationFunction defines the function used to instanciate the new object
  94429. * @param source defines the source object
  94430. * @returns the new object
  94431. */
  94432. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94433. }
  94434. }
  94435. declare module BABYLON {
  94436. /**
  94437. * Class used to manipulate GUIDs
  94438. */
  94439. export class GUID {
  94440. /**
  94441. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94442. * Be aware Math.random() could cause collisions, but:
  94443. * "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"
  94444. * @returns a pseudo random id
  94445. */
  94446. static RandomId(): string;
  94447. }
  94448. }
  94449. declare module BABYLON {
  94450. /**
  94451. * Base class of all the textures in babylon.
  94452. * It groups all the common properties the materials, post process, lights... might need
  94453. * in order to make a correct use of the texture.
  94454. */
  94455. export class BaseTexture implements IAnimatable {
  94456. /**
  94457. * Default anisotropic filtering level for the application.
  94458. * It is set to 4 as a good tradeoff between perf and quality.
  94459. */
  94460. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94461. /**
  94462. * Gets or sets the unique id of the texture
  94463. */
  94464. uniqueId: number;
  94465. /**
  94466. * Define the name of the texture.
  94467. */
  94468. name: string;
  94469. /**
  94470. * Gets or sets an object used to store user defined information.
  94471. */
  94472. metadata: any;
  94473. /**
  94474. * For internal use only. Please do not use.
  94475. */
  94476. reservedDataStore: any;
  94477. private _hasAlpha;
  94478. /**
  94479. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94480. */
  94481. hasAlpha: boolean;
  94482. /**
  94483. * Defines if the alpha value should be determined via the rgb values.
  94484. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94485. */
  94486. getAlphaFromRGB: boolean;
  94487. /**
  94488. * Intensity or strength of the texture.
  94489. * It is commonly used by materials to fine tune the intensity of the texture
  94490. */
  94491. level: number;
  94492. /**
  94493. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94494. * This is part of the texture as textures usually maps to one uv set.
  94495. */
  94496. coordinatesIndex: number;
  94497. private _coordinatesMode;
  94498. /**
  94499. * How a texture is mapped.
  94500. *
  94501. * | Value | Type | Description |
  94502. * | ----- | ----------------------------------- | ----------- |
  94503. * | 0 | EXPLICIT_MODE | |
  94504. * | 1 | SPHERICAL_MODE | |
  94505. * | 2 | PLANAR_MODE | |
  94506. * | 3 | CUBIC_MODE | |
  94507. * | 4 | PROJECTION_MODE | |
  94508. * | 5 | SKYBOX_MODE | |
  94509. * | 6 | INVCUBIC_MODE | |
  94510. * | 7 | EQUIRECTANGULAR_MODE | |
  94511. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94512. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94513. */
  94514. coordinatesMode: number;
  94515. /**
  94516. * | Value | Type | Description |
  94517. * | ----- | ------------------ | ----------- |
  94518. * | 0 | CLAMP_ADDRESSMODE | |
  94519. * | 1 | WRAP_ADDRESSMODE | |
  94520. * | 2 | MIRROR_ADDRESSMODE | |
  94521. */
  94522. wrapU: number;
  94523. /**
  94524. * | Value | Type | Description |
  94525. * | ----- | ------------------ | ----------- |
  94526. * | 0 | CLAMP_ADDRESSMODE | |
  94527. * | 1 | WRAP_ADDRESSMODE | |
  94528. * | 2 | MIRROR_ADDRESSMODE | |
  94529. */
  94530. wrapV: number;
  94531. /**
  94532. * | Value | Type | Description |
  94533. * | ----- | ------------------ | ----------- |
  94534. * | 0 | CLAMP_ADDRESSMODE | |
  94535. * | 1 | WRAP_ADDRESSMODE | |
  94536. * | 2 | MIRROR_ADDRESSMODE | |
  94537. */
  94538. wrapR: number;
  94539. /**
  94540. * With compliant hardware and browser (supporting anisotropic filtering)
  94541. * this defines the level of anisotropic filtering in the texture.
  94542. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94543. */
  94544. anisotropicFilteringLevel: number;
  94545. /**
  94546. * Define if the texture is a cube texture or if false a 2d texture.
  94547. */
  94548. isCube: boolean;
  94549. /**
  94550. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94551. */
  94552. is3D: boolean;
  94553. /**
  94554. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94555. * HDR texture are usually stored in linear space.
  94556. * This only impacts the PBR and Background materials
  94557. */
  94558. gammaSpace: boolean;
  94559. /**
  94560. * Gets or sets whether or not the texture contains RGBD data.
  94561. */
  94562. isRGBD: boolean;
  94563. /**
  94564. * Is Z inverted in the texture (useful in a cube texture).
  94565. */
  94566. invertZ: boolean;
  94567. /**
  94568. * Are mip maps generated for this texture or not.
  94569. */
  94570. readonly noMipmap: boolean;
  94571. /**
  94572. * @hidden
  94573. */
  94574. lodLevelInAlpha: boolean;
  94575. /**
  94576. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94577. */
  94578. lodGenerationOffset: number;
  94579. /**
  94580. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94581. */
  94582. lodGenerationScale: number;
  94583. /**
  94584. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94585. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94586. * average roughness values.
  94587. */
  94588. linearSpecularLOD: boolean;
  94589. /**
  94590. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94591. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94592. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94593. */
  94594. irradianceTexture: Nullable<BaseTexture>;
  94595. /**
  94596. * Define if the texture is a render target.
  94597. */
  94598. isRenderTarget: boolean;
  94599. /**
  94600. * Define the unique id of the texture in the scene.
  94601. */
  94602. readonly uid: string;
  94603. /**
  94604. * Return a string representation of the texture.
  94605. * @returns the texture as a string
  94606. */
  94607. toString(): string;
  94608. /**
  94609. * Get the class name of the texture.
  94610. * @returns "BaseTexture"
  94611. */
  94612. getClassName(): string;
  94613. /**
  94614. * Define the list of animation attached to the texture.
  94615. */
  94616. animations: Animation[];
  94617. /**
  94618. * An event triggered when the texture is disposed.
  94619. */
  94620. onDisposeObservable: Observable<BaseTexture>;
  94621. private _onDisposeObserver;
  94622. /**
  94623. * Callback triggered when the texture has been disposed.
  94624. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94625. */
  94626. onDispose: () => void;
  94627. /**
  94628. * Define the current state of the loading sequence when in delayed load mode.
  94629. */
  94630. delayLoadState: number;
  94631. private _scene;
  94632. /** @hidden */
  94633. _texture: Nullable<InternalTexture>;
  94634. private _uid;
  94635. /**
  94636. * Define if the texture is preventinga material to render or not.
  94637. * If not and the texture is not ready, the engine will use a default black texture instead.
  94638. */
  94639. readonly isBlocking: boolean;
  94640. /**
  94641. * Instantiates a new BaseTexture.
  94642. * Base class of all the textures in babylon.
  94643. * It groups all the common properties the materials, post process, lights... might need
  94644. * in order to make a correct use of the texture.
  94645. * @param scene Define the scene the texture blongs to
  94646. */
  94647. constructor(scene: Nullable<Scene>);
  94648. /**
  94649. * Get the scene the texture belongs to.
  94650. * @returns the scene or null if undefined
  94651. */
  94652. getScene(): Nullable<Scene>;
  94653. /**
  94654. * Get the texture transform matrix used to offset tile the texture for istance.
  94655. * @returns the transformation matrix
  94656. */
  94657. getTextureMatrix(): Matrix;
  94658. /**
  94659. * Get the texture reflection matrix used to rotate/transform the reflection.
  94660. * @returns the reflection matrix
  94661. */
  94662. getReflectionTextureMatrix(): Matrix;
  94663. /**
  94664. * Get the underlying lower level texture from Babylon.
  94665. * @returns the insternal texture
  94666. */
  94667. getInternalTexture(): Nullable<InternalTexture>;
  94668. /**
  94669. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94670. * @returns true if ready or not blocking
  94671. */
  94672. isReadyOrNotBlocking(): boolean;
  94673. /**
  94674. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94675. * @returns true if fully ready
  94676. */
  94677. isReady(): boolean;
  94678. private _cachedSize;
  94679. /**
  94680. * Get the size of the texture.
  94681. * @returns the texture size.
  94682. */
  94683. getSize(): ISize;
  94684. /**
  94685. * Get the base size of the texture.
  94686. * It can be different from the size if the texture has been resized for POT for instance
  94687. * @returns the base size
  94688. */
  94689. getBaseSize(): ISize;
  94690. /**
  94691. * Update the sampling mode of the texture.
  94692. * Default is Trilinear mode.
  94693. *
  94694. * | Value | Type | Description |
  94695. * | ----- | ------------------ | ----------- |
  94696. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94697. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94698. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94699. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94700. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94701. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94702. * | 7 | NEAREST_LINEAR | |
  94703. * | 8 | NEAREST_NEAREST | |
  94704. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94705. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94706. * | 11 | LINEAR_LINEAR | |
  94707. * | 12 | LINEAR_NEAREST | |
  94708. *
  94709. * > _mag_: magnification filter (close to the viewer)
  94710. * > _min_: minification filter (far from the viewer)
  94711. * > _mip_: filter used between mip map levels
  94712. *@param samplingMode Define the new sampling mode of the texture
  94713. */
  94714. updateSamplingMode(samplingMode: number): void;
  94715. /**
  94716. * Scales the texture if is `canRescale()`
  94717. * @param ratio the resize factor we want to use to rescale
  94718. */
  94719. scale(ratio: number): void;
  94720. /**
  94721. * Get if the texture can rescale.
  94722. */
  94723. readonly canRescale: boolean;
  94724. /** @hidden */
  94725. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94726. /** @hidden */
  94727. _rebuild(): void;
  94728. /**
  94729. * Triggers the load sequence in delayed load mode.
  94730. */
  94731. delayLoad(): void;
  94732. /**
  94733. * Clones the texture.
  94734. * @returns the cloned texture
  94735. */
  94736. clone(): Nullable<BaseTexture>;
  94737. /**
  94738. * Get the texture underlying type (INT, FLOAT...)
  94739. */
  94740. readonly textureType: number;
  94741. /**
  94742. * Get the texture underlying format (RGB, RGBA...)
  94743. */
  94744. readonly textureFormat: number;
  94745. /**
  94746. * Indicates that textures need to be re-calculated for all materials
  94747. */
  94748. protected _markAllSubMeshesAsTexturesDirty(): void;
  94749. /**
  94750. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94751. * This will returns an RGBA array buffer containing either in values (0-255) or
  94752. * float values (0-1) depending of the underlying buffer type.
  94753. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94754. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94755. * @param buffer defines a user defined buffer to fill with data (can be null)
  94756. * @returns The Array buffer containing the pixels data.
  94757. */
  94758. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94759. /**
  94760. * Release and destroy the underlying lower level texture aka internalTexture.
  94761. */
  94762. releaseInternalTexture(): void;
  94763. /** @hidden */
  94764. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94765. /** @hidden */
  94766. readonly _lodTextureMid: Nullable<BaseTexture>;
  94767. /** @hidden */
  94768. readonly _lodTextureLow: Nullable<BaseTexture>;
  94769. /**
  94770. * Dispose the texture and release its associated resources.
  94771. */
  94772. dispose(): void;
  94773. /**
  94774. * Serialize the texture into a JSON representation that can be parsed later on.
  94775. * @returns the JSON representation of the texture
  94776. */
  94777. serialize(): any;
  94778. /**
  94779. * Helper function to be called back once a list of texture contains only ready textures.
  94780. * @param textures Define the list of textures to wait for
  94781. * @param callback Define the callback triggered once the entire list will be ready
  94782. */
  94783. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94784. }
  94785. }
  94786. declare module BABYLON {
  94787. /**
  94788. * Options to be used when creating an effect.
  94789. */
  94790. export interface IEffectCreationOptions {
  94791. /**
  94792. * Atrributes that will be used in the shader.
  94793. */
  94794. attributes: string[];
  94795. /**
  94796. * Uniform varible names that will be set in the shader.
  94797. */
  94798. uniformsNames: string[];
  94799. /**
  94800. * Uniform buffer varible names that will be set in the shader.
  94801. */
  94802. uniformBuffersNames: string[];
  94803. /**
  94804. * Sampler texture variable names that will be set in the shader.
  94805. */
  94806. samplers: string[];
  94807. /**
  94808. * Define statements that will be set in the shader.
  94809. */
  94810. defines: any;
  94811. /**
  94812. * Possible fallbacks for this effect to improve performance when needed.
  94813. */
  94814. fallbacks: Nullable<IEffectFallbacks>;
  94815. /**
  94816. * Callback that will be called when the shader is compiled.
  94817. */
  94818. onCompiled: Nullable<(effect: Effect) => void>;
  94819. /**
  94820. * Callback that will be called if an error occurs during shader compilation.
  94821. */
  94822. onError: Nullable<(effect: Effect, errors: string) => void>;
  94823. /**
  94824. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94825. */
  94826. indexParameters?: any;
  94827. /**
  94828. * Max number of lights that can be used in the shader.
  94829. */
  94830. maxSimultaneousLights?: number;
  94831. /**
  94832. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94833. */
  94834. transformFeedbackVaryings?: Nullable<string[]>;
  94835. }
  94836. /**
  94837. * Effect containing vertex and fragment shader that can be executed on an object.
  94838. */
  94839. export class Effect implements IDisposable {
  94840. /**
  94841. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94842. */
  94843. static ShadersRepository: string;
  94844. /**
  94845. * Name of the effect.
  94846. */
  94847. name: any;
  94848. /**
  94849. * String container all the define statements that should be set on the shader.
  94850. */
  94851. defines: string;
  94852. /**
  94853. * Callback that will be called when the shader is compiled.
  94854. */
  94855. onCompiled: Nullable<(effect: Effect) => void>;
  94856. /**
  94857. * Callback that will be called if an error occurs during shader compilation.
  94858. */
  94859. onError: Nullable<(effect: Effect, errors: string) => void>;
  94860. /**
  94861. * Callback that will be called when effect is bound.
  94862. */
  94863. onBind: Nullable<(effect: Effect) => void>;
  94864. /**
  94865. * Unique ID of the effect.
  94866. */
  94867. uniqueId: number;
  94868. /**
  94869. * Observable that will be called when the shader is compiled.
  94870. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94871. */
  94872. onCompileObservable: Observable<Effect>;
  94873. /**
  94874. * Observable that will be called if an error occurs during shader compilation.
  94875. */
  94876. onErrorObservable: Observable<Effect>;
  94877. /** @hidden */
  94878. _onBindObservable: Nullable<Observable<Effect>>;
  94879. /**
  94880. * Observable that will be called when effect is bound.
  94881. */
  94882. readonly onBindObservable: Observable<Effect>;
  94883. /** @hidden */
  94884. _bonesComputationForcedToCPU: boolean;
  94885. private static _uniqueIdSeed;
  94886. private _engine;
  94887. private _uniformBuffersNames;
  94888. private _uniformsNames;
  94889. private _samplerList;
  94890. private _samplers;
  94891. private _isReady;
  94892. private _compilationError;
  94893. private _allFallbacksProcessed;
  94894. private _attributesNames;
  94895. private _attributes;
  94896. private _uniforms;
  94897. /**
  94898. * Key for the effect.
  94899. * @hidden
  94900. */
  94901. _key: string;
  94902. private _indexParameters;
  94903. private _fallbacks;
  94904. private _vertexSourceCode;
  94905. private _fragmentSourceCode;
  94906. private _vertexSourceCodeOverride;
  94907. private _fragmentSourceCodeOverride;
  94908. private _transformFeedbackVaryings;
  94909. /**
  94910. * Compiled shader to webGL program.
  94911. * @hidden
  94912. */
  94913. _pipelineContext: Nullable<IPipelineContext>;
  94914. private _valueCache;
  94915. private static _baseCache;
  94916. /**
  94917. * Instantiates an effect.
  94918. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94919. * @param baseName Name of the effect.
  94920. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94921. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94922. * @param samplers List of sampler variables that will be passed to the shader.
  94923. * @param engine Engine to be used to render the effect
  94924. * @param defines Define statements to be added to the shader.
  94925. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94926. * @param onCompiled Callback that will be called when the shader is compiled.
  94927. * @param onError Callback that will be called if an error occurs during shader compilation.
  94928. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94929. */
  94930. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94931. private _useFinalCode;
  94932. /**
  94933. * Unique key for this effect
  94934. */
  94935. readonly key: string;
  94936. /**
  94937. * If the effect has been compiled and prepared.
  94938. * @returns if the effect is compiled and prepared.
  94939. */
  94940. isReady(): boolean;
  94941. private _isReadyInternal;
  94942. /**
  94943. * The engine the effect was initialized with.
  94944. * @returns the engine.
  94945. */
  94946. getEngine(): Engine;
  94947. /**
  94948. * The pipeline context for this effect
  94949. * @returns the associated pipeline context
  94950. */
  94951. getPipelineContext(): Nullable<IPipelineContext>;
  94952. /**
  94953. * The set of names of attribute variables for the shader.
  94954. * @returns An array of attribute names.
  94955. */
  94956. getAttributesNames(): string[];
  94957. /**
  94958. * Returns the attribute at the given index.
  94959. * @param index The index of the attribute.
  94960. * @returns The location of the attribute.
  94961. */
  94962. getAttributeLocation(index: number): number;
  94963. /**
  94964. * Returns the attribute based on the name of the variable.
  94965. * @param name of the attribute to look up.
  94966. * @returns the attribute location.
  94967. */
  94968. getAttributeLocationByName(name: string): number;
  94969. /**
  94970. * The number of attributes.
  94971. * @returns the numnber of attributes.
  94972. */
  94973. getAttributesCount(): number;
  94974. /**
  94975. * Gets the index of a uniform variable.
  94976. * @param uniformName of the uniform to look up.
  94977. * @returns the index.
  94978. */
  94979. getUniformIndex(uniformName: string): number;
  94980. /**
  94981. * Returns the attribute based on the name of the variable.
  94982. * @param uniformName of the uniform to look up.
  94983. * @returns the location of the uniform.
  94984. */
  94985. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94986. /**
  94987. * Returns an array of sampler variable names
  94988. * @returns The array of sampler variable neames.
  94989. */
  94990. getSamplers(): string[];
  94991. /**
  94992. * The error from the last compilation.
  94993. * @returns the error string.
  94994. */
  94995. getCompilationError(): string;
  94996. /**
  94997. * Gets a boolean indicating that all fallbacks were used during compilation
  94998. * @returns true if all fallbacks were used
  94999. */
  95000. allFallbacksProcessed(): boolean;
  95001. /**
  95002. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95003. * @param func The callback to be used.
  95004. */
  95005. executeWhenCompiled(func: (effect: Effect) => void): void;
  95006. private _checkIsReady;
  95007. private _loadShader;
  95008. /**
  95009. * Recompiles the webGL program
  95010. * @param vertexSourceCode The source code for the vertex shader.
  95011. * @param fragmentSourceCode The source code for the fragment shader.
  95012. * @param onCompiled Callback called when completed.
  95013. * @param onError Callback called on error.
  95014. * @hidden
  95015. */
  95016. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95017. /**
  95018. * Prepares the effect
  95019. * @hidden
  95020. */
  95021. _prepareEffect(): void;
  95022. private _processCompilationErrors;
  95023. /**
  95024. * Checks if the effect is supported. (Must be called after compilation)
  95025. */
  95026. readonly isSupported: boolean;
  95027. /**
  95028. * Binds a texture to the engine to be used as output of the shader.
  95029. * @param channel Name of the output variable.
  95030. * @param texture Texture to bind.
  95031. * @hidden
  95032. */
  95033. _bindTexture(channel: string, texture: InternalTexture): void;
  95034. /**
  95035. * Sets a texture on the engine to be used in the shader.
  95036. * @param channel Name of the sampler variable.
  95037. * @param texture Texture to set.
  95038. */
  95039. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95040. /**
  95041. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95042. * @param channel Name of the sampler variable.
  95043. * @param texture Texture to set.
  95044. */
  95045. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95046. /**
  95047. * Sets an array of textures on the engine to be used in the shader.
  95048. * @param channel Name of the variable.
  95049. * @param textures Textures to set.
  95050. */
  95051. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95052. /**
  95053. * 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)
  95054. * @param channel Name of the sampler variable.
  95055. * @param postProcess Post process to get the input texture from.
  95056. */
  95057. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95058. /**
  95059. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95060. * 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)
  95061. * @param channel Name of the sampler variable.
  95062. * @param postProcess Post process to get the output texture from.
  95063. */
  95064. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95065. /** @hidden */
  95066. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95067. /** @hidden */
  95068. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95069. /** @hidden */
  95070. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95071. /** @hidden */
  95072. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95073. /**
  95074. * Binds a buffer to a uniform.
  95075. * @param buffer Buffer to bind.
  95076. * @param name Name of the uniform variable to bind to.
  95077. */
  95078. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95079. /**
  95080. * Binds block to a uniform.
  95081. * @param blockName Name of the block to bind.
  95082. * @param index Index to bind.
  95083. */
  95084. bindUniformBlock(blockName: string, index: number): void;
  95085. /**
  95086. * Sets an interger value on a uniform variable.
  95087. * @param uniformName Name of the variable.
  95088. * @param value Value to be set.
  95089. * @returns this effect.
  95090. */
  95091. setInt(uniformName: string, value: number): Effect;
  95092. /**
  95093. * Sets an int array on a uniform variable.
  95094. * @param uniformName Name of the variable.
  95095. * @param array array to be set.
  95096. * @returns this effect.
  95097. */
  95098. setIntArray(uniformName: string, array: Int32Array): Effect;
  95099. /**
  95100. * 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)
  95101. * @param uniformName Name of the variable.
  95102. * @param array array to be set.
  95103. * @returns this effect.
  95104. */
  95105. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95106. /**
  95107. * 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)
  95108. * @param uniformName Name of the variable.
  95109. * @param array array to be set.
  95110. * @returns this effect.
  95111. */
  95112. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95113. /**
  95114. * 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)
  95115. * @param uniformName Name of the variable.
  95116. * @param array array to be set.
  95117. * @returns this effect.
  95118. */
  95119. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95120. /**
  95121. * Sets an float array on a uniform variable.
  95122. * @param uniformName Name of the variable.
  95123. * @param array array to be set.
  95124. * @returns this effect.
  95125. */
  95126. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95127. /**
  95128. * 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)
  95129. * @param uniformName Name of the variable.
  95130. * @param array array to be set.
  95131. * @returns this effect.
  95132. */
  95133. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95134. /**
  95135. * 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)
  95136. * @param uniformName Name of the variable.
  95137. * @param array array to be set.
  95138. * @returns this effect.
  95139. */
  95140. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95141. /**
  95142. * 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)
  95143. * @param uniformName Name of the variable.
  95144. * @param array array to be set.
  95145. * @returns this effect.
  95146. */
  95147. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95148. /**
  95149. * Sets an array on a uniform variable.
  95150. * @param uniformName Name of the variable.
  95151. * @param array array to be set.
  95152. * @returns this effect.
  95153. */
  95154. setArray(uniformName: string, array: number[]): Effect;
  95155. /**
  95156. * 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)
  95157. * @param uniformName Name of the variable.
  95158. * @param array array to be set.
  95159. * @returns this effect.
  95160. */
  95161. setArray2(uniformName: string, array: number[]): Effect;
  95162. /**
  95163. * 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)
  95164. * @param uniformName Name of the variable.
  95165. * @param array array to be set.
  95166. * @returns this effect.
  95167. */
  95168. setArray3(uniformName: string, array: number[]): Effect;
  95169. /**
  95170. * 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)
  95171. * @param uniformName Name of the variable.
  95172. * @param array array to be set.
  95173. * @returns this effect.
  95174. */
  95175. setArray4(uniformName: string, array: number[]): Effect;
  95176. /**
  95177. * Sets matrices on a uniform variable.
  95178. * @param uniformName Name of the variable.
  95179. * @param matrices matrices to be set.
  95180. * @returns this effect.
  95181. */
  95182. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95183. /**
  95184. * Sets matrix on a uniform variable.
  95185. * @param uniformName Name of the variable.
  95186. * @param matrix matrix to be set.
  95187. * @returns this effect.
  95188. */
  95189. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95190. /**
  95191. * 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)
  95192. * @param uniformName Name of the variable.
  95193. * @param matrix matrix to be set.
  95194. * @returns this effect.
  95195. */
  95196. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95197. /**
  95198. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95199. * @param uniformName Name of the variable.
  95200. * @param matrix matrix to be set.
  95201. * @returns this effect.
  95202. */
  95203. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95204. /**
  95205. * Sets a float on a uniform variable.
  95206. * @param uniformName Name of the variable.
  95207. * @param value value to be set.
  95208. * @returns this effect.
  95209. */
  95210. setFloat(uniformName: string, value: number): Effect;
  95211. /**
  95212. * Sets a boolean on a uniform variable.
  95213. * @param uniformName Name of the variable.
  95214. * @param bool value to be set.
  95215. * @returns this effect.
  95216. */
  95217. setBool(uniformName: string, bool: boolean): Effect;
  95218. /**
  95219. * Sets a Vector2 on a uniform variable.
  95220. * @param uniformName Name of the variable.
  95221. * @param vector2 vector2 to be set.
  95222. * @returns this effect.
  95223. */
  95224. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95225. /**
  95226. * Sets a float2 on a uniform variable.
  95227. * @param uniformName Name of the variable.
  95228. * @param x First float in float2.
  95229. * @param y Second float in float2.
  95230. * @returns this effect.
  95231. */
  95232. setFloat2(uniformName: string, x: number, y: number): Effect;
  95233. /**
  95234. * Sets a Vector3 on a uniform variable.
  95235. * @param uniformName Name of the variable.
  95236. * @param vector3 Value to be set.
  95237. * @returns this effect.
  95238. */
  95239. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95240. /**
  95241. * Sets a float3 on a uniform variable.
  95242. * @param uniformName Name of the variable.
  95243. * @param x First float in float3.
  95244. * @param y Second float in float3.
  95245. * @param z Third float in float3.
  95246. * @returns this effect.
  95247. */
  95248. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95249. /**
  95250. * Sets a Vector4 on a uniform variable.
  95251. * @param uniformName Name of the variable.
  95252. * @param vector4 Value to be set.
  95253. * @returns this effect.
  95254. */
  95255. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95256. /**
  95257. * Sets a float4 on a uniform variable.
  95258. * @param uniformName Name of the variable.
  95259. * @param x First float in float4.
  95260. * @param y Second float in float4.
  95261. * @param z Third float in float4.
  95262. * @param w Fourth float in float4.
  95263. * @returns this effect.
  95264. */
  95265. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95266. /**
  95267. * Sets a Color3 on a uniform variable.
  95268. * @param uniformName Name of the variable.
  95269. * @param color3 Value to be set.
  95270. * @returns this effect.
  95271. */
  95272. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95273. /**
  95274. * Sets a Color4 on a uniform variable.
  95275. * @param uniformName Name of the variable.
  95276. * @param color3 Value to be set.
  95277. * @param alpha Alpha value to be set.
  95278. * @returns this effect.
  95279. */
  95280. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95281. /**
  95282. * Sets a Color4 on a uniform variable
  95283. * @param uniformName defines the name of the variable
  95284. * @param color4 defines the value to be set
  95285. * @returns this effect.
  95286. */
  95287. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95288. /** Release all associated resources */
  95289. dispose(): void;
  95290. /**
  95291. * This function will add a new shader to the shader store
  95292. * @param name the name of the shader
  95293. * @param pixelShader optional pixel shader content
  95294. * @param vertexShader optional vertex shader content
  95295. */
  95296. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95297. /**
  95298. * Store of each shader (The can be looked up using effect.key)
  95299. */
  95300. static ShadersStore: {
  95301. [key: string]: string;
  95302. };
  95303. /**
  95304. * Store of each included file for a shader (The can be looked up using effect.key)
  95305. */
  95306. static IncludesShadersStore: {
  95307. [key: string]: string;
  95308. };
  95309. /**
  95310. * Resets the cache of effects.
  95311. */
  95312. static ResetCache(): void;
  95313. }
  95314. }
  95315. declare module BABYLON {
  95316. /**
  95317. * Class used to describe the capabilities of the engine relatively to the current browser
  95318. */
  95319. export class EngineCapabilities {
  95320. /** Maximum textures units per fragment shader */
  95321. maxTexturesImageUnits: number;
  95322. /** Maximum texture units per vertex shader */
  95323. maxVertexTextureImageUnits: number;
  95324. /** Maximum textures units in the entire pipeline */
  95325. maxCombinedTexturesImageUnits: number;
  95326. /** Maximum texture size */
  95327. maxTextureSize: number;
  95328. /** Maximum cube texture size */
  95329. maxCubemapTextureSize: number;
  95330. /** Maximum render texture size */
  95331. maxRenderTextureSize: number;
  95332. /** Maximum number of vertex attributes */
  95333. maxVertexAttribs: number;
  95334. /** Maximum number of varyings */
  95335. maxVaryingVectors: number;
  95336. /** Maximum number of uniforms per vertex shader */
  95337. maxVertexUniformVectors: number;
  95338. /** Maximum number of uniforms per fragment shader */
  95339. maxFragmentUniformVectors: number;
  95340. /** Defines if standard derivates (dx/dy) are supported */
  95341. standardDerivatives: boolean;
  95342. /** Defines if s3tc texture compression is supported */
  95343. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95344. /** Defines if pvrtc texture compression is supported */
  95345. pvrtc: any;
  95346. /** Defines if etc1 texture compression is supported */
  95347. etc1: any;
  95348. /** Defines if etc2 texture compression is supported */
  95349. etc2: any;
  95350. /** Defines if astc texture compression is supported */
  95351. astc: any;
  95352. /** Defines if float textures are supported */
  95353. textureFloat: boolean;
  95354. /** Defines if vertex array objects are supported */
  95355. vertexArrayObject: boolean;
  95356. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95357. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95358. /** Gets the maximum level of anisotropy supported */
  95359. maxAnisotropy: number;
  95360. /** Defines if instancing is supported */
  95361. instancedArrays: boolean;
  95362. /** Defines if 32 bits indices are supported */
  95363. uintIndices: boolean;
  95364. /** Defines if high precision shaders are supported */
  95365. highPrecisionShaderSupported: boolean;
  95366. /** Defines if depth reading in the fragment shader is supported */
  95367. fragmentDepthSupported: boolean;
  95368. /** Defines if float texture linear filtering is supported*/
  95369. textureFloatLinearFiltering: boolean;
  95370. /** Defines if rendering to float textures is supported */
  95371. textureFloatRender: boolean;
  95372. /** Defines if half float textures are supported*/
  95373. textureHalfFloat: boolean;
  95374. /** Defines if half float texture linear filtering is supported*/
  95375. textureHalfFloatLinearFiltering: boolean;
  95376. /** Defines if rendering to half float textures is supported */
  95377. textureHalfFloatRender: boolean;
  95378. /** Defines if textureLOD shader command is supported */
  95379. textureLOD: boolean;
  95380. /** Defines if draw buffers extension is supported */
  95381. drawBuffersExtension: boolean;
  95382. /** Defines if depth textures are supported */
  95383. depthTextureExtension: boolean;
  95384. /** Defines if float color buffer are supported */
  95385. colorBufferFloat: boolean;
  95386. /** Gets disjoint timer query extension (null if not supported) */
  95387. timerQuery: EXT_disjoint_timer_query;
  95388. /** Defines if timestamp can be used with timer query */
  95389. canUseTimestampForTimerQuery: boolean;
  95390. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95391. multiview: any;
  95392. /** Function used to let the system compiles shaders in background */
  95393. parallelShaderCompile: {
  95394. COMPLETION_STATUS_KHR: number;
  95395. };
  95396. /** Max number of texture samples for MSAA */
  95397. maxMSAASamples: number;
  95398. /** Defines if the blend min max extension is supported */
  95399. blendMinMax: boolean;
  95400. }
  95401. }
  95402. declare module BABYLON {
  95403. /**
  95404. * @hidden
  95405. **/
  95406. export class DepthCullingState {
  95407. private _isDepthTestDirty;
  95408. private _isDepthMaskDirty;
  95409. private _isDepthFuncDirty;
  95410. private _isCullFaceDirty;
  95411. private _isCullDirty;
  95412. private _isZOffsetDirty;
  95413. private _isFrontFaceDirty;
  95414. private _depthTest;
  95415. private _depthMask;
  95416. private _depthFunc;
  95417. private _cull;
  95418. private _cullFace;
  95419. private _zOffset;
  95420. private _frontFace;
  95421. /**
  95422. * Initializes the state.
  95423. */
  95424. constructor();
  95425. readonly isDirty: boolean;
  95426. zOffset: number;
  95427. cullFace: Nullable<number>;
  95428. cull: Nullable<boolean>;
  95429. depthFunc: Nullable<number>;
  95430. depthMask: boolean;
  95431. depthTest: boolean;
  95432. frontFace: Nullable<number>;
  95433. reset(): void;
  95434. apply(gl: WebGLRenderingContext): void;
  95435. }
  95436. }
  95437. declare module BABYLON {
  95438. /**
  95439. * @hidden
  95440. **/
  95441. export class StencilState {
  95442. /** 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 */
  95443. static readonly ALWAYS: number;
  95444. /** Passed to stencilOperation to specify that stencil value must be kept */
  95445. static readonly KEEP: number;
  95446. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95447. static readonly REPLACE: number;
  95448. private _isStencilTestDirty;
  95449. private _isStencilMaskDirty;
  95450. private _isStencilFuncDirty;
  95451. private _isStencilOpDirty;
  95452. private _stencilTest;
  95453. private _stencilMask;
  95454. private _stencilFunc;
  95455. private _stencilFuncRef;
  95456. private _stencilFuncMask;
  95457. private _stencilOpStencilFail;
  95458. private _stencilOpDepthFail;
  95459. private _stencilOpStencilDepthPass;
  95460. readonly isDirty: boolean;
  95461. stencilFunc: number;
  95462. stencilFuncRef: number;
  95463. stencilFuncMask: number;
  95464. stencilOpStencilFail: number;
  95465. stencilOpDepthFail: number;
  95466. stencilOpStencilDepthPass: number;
  95467. stencilMask: number;
  95468. stencilTest: boolean;
  95469. constructor();
  95470. reset(): void;
  95471. apply(gl: WebGLRenderingContext): void;
  95472. }
  95473. }
  95474. declare module BABYLON {
  95475. /**
  95476. * @hidden
  95477. **/
  95478. export class AlphaState {
  95479. private _isAlphaBlendDirty;
  95480. private _isBlendFunctionParametersDirty;
  95481. private _isBlendEquationParametersDirty;
  95482. private _isBlendConstantsDirty;
  95483. private _alphaBlend;
  95484. private _blendFunctionParameters;
  95485. private _blendEquationParameters;
  95486. private _blendConstants;
  95487. /**
  95488. * Initializes the state.
  95489. */
  95490. constructor();
  95491. readonly isDirty: boolean;
  95492. alphaBlend: boolean;
  95493. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95494. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95495. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95496. reset(): void;
  95497. apply(gl: WebGLRenderingContext): void;
  95498. }
  95499. }
  95500. declare module BABYLON {
  95501. /** @hidden */
  95502. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95503. attributeProcessor(attribute: string): string;
  95504. varyingProcessor(varying: string, isFragment: boolean): string;
  95505. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95506. }
  95507. }
  95508. declare module BABYLON {
  95509. /**
  95510. * Interface for attribute information associated with buffer instanciation
  95511. */
  95512. export class InstancingAttributeInfo {
  95513. /**
  95514. * Index/offset of the attribute in the vertex shader
  95515. */
  95516. index: number;
  95517. /**
  95518. * size of the attribute, 1, 2, 3 or 4
  95519. */
  95520. attributeSize: number;
  95521. /**
  95522. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95523. * default is FLOAT
  95524. */
  95525. attribyteType: number;
  95526. /**
  95527. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95528. */
  95529. normalized: boolean;
  95530. /**
  95531. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95532. */
  95533. offset: number;
  95534. /**
  95535. * Name of the GLSL attribute, for debugging purpose only
  95536. */
  95537. attributeName: string;
  95538. }
  95539. }
  95540. declare module BABYLON {
  95541. interface ThinEngine {
  95542. /**
  95543. * Update a video texture
  95544. * @param texture defines the texture to update
  95545. * @param video defines the video element to use
  95546. * @param invertY defines if data must be stored with Y axis inverted
  95547. */
  95548. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95549. }
  95550. }
  95551. declare module BABYLON {
  95552. /**
  95553. * Settings for finer control over video usage
  95554. */
  95555. export interface VideoTextureSettings {
  95556. /**
  95557. * Applies `autoplay` to video, if specified
  95558. */
  95559. autoPlay?: boolean;
  95560. /**
  95561. * Applies `loop` to video, if specified
  95562. */
  95563. loop?: boolean;
  95564. /**
  95565. * Automatically updates internal texture from video at every frame in the render loop
  95566. */
  95567. autoUpdateTexture: boolean;
  95568. /**
  95569. * Image src displayed during the video loading or until the user interacts with the video.
  95570. */
  95571. poster?: string;
  95572. }
  95573. /**
  95574. * If you want to display a video in your scene, this is the special texture for that.
  95575. * This special texture works similar to other textures, with the exception of a few parameters.
  95576. * @see https://doc.babylonjs.com/how_to/video_texture
  95577. */
  95578. export class VideoTexture extends Texture {
  95579. /**
  95580. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95581. */
  95582. readonly autoUpdateTexture: boolean;
  95583. /**
  95584. * The video instance used by the texture internally
  95585. */
  95586. readonly video: HTMLVideoElement;
  95587. private _onUserActionRequestedObservable;
  95588. /**
  95589. * Event triggerd when a dom action is required by the user to play the video.
  95590. * This happens due to recent changes in browser policies preventing video to auto start.
  95591. */
  95592. readonly onUserActionRequestedObservable: Observable<Texture>;
  95593. private _generateMipMaps;
  95594. private _engine;
  95595. private _stillImageCaptured;
  95596. private _displayingPosterTexture;
  95597. private _settings;
  95598. private _createInternalTextureOnEvent;
  95599. private _frameId;
  95600. /**
  95601. * Creates a video texture.
  95602. * If you want to display a video in your scene, this is the special texture for that.
  95603. * This special texture works similar to other textures, with the exception of a few parameters.
  95604. * @see https://doc.babylonjs.com/how_to/video_texture
  95605. * @param name optional name, will detect from video source, if not defined
  95606. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95607. * @param scene is obviously the current scene.
  95608. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95609. * @param invertY is false by default but can be used to invert video on Y axis
  95610. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95611. * @param settings allows finer control over video usage
  95612. */
  95613. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95614. private _getName;
  95615. private _getVideo;
  95616. private _createInternalTexture;
  95617. private reset;
  95618. /**
  95619. * @hidden Internal method to initiate `update`.
  95620. */
  95621. _rebuild(): void;
  95622. /**
  95623. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95624. */
  95625. update(): void;
  95626. /**
  95627. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95628. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95629. */
  95630. updateTexture(isVisible: boolean): void;
  95631. protected _updateInternalTexture: () => void;
  95632. /**
  95633. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95634. * @param url New url.
  95635. */
  95636. updateURL(url: string): void;
  95637. /**
  95638. * Dispose the texture and release its associated resources.
  95639. */
  95640. dispose(): void;
  95641. /**
  95642. * Creates a video texture straight from a stream.
  95643. * @param scene Define the scene the texture should be created in
  95644. * @param stream Define the stream the texture should be created from
  95645. * @returns The created video texture as a promise
  95646. */
  95647. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95648. /**
  95649. * Creates a video texture straight from your WebCam video feed.
  95650. * @param scene Define the scene the texture should be created in
  95651. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95652. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95653. * @returns The created video texture as a promise
  95654. */
  95655. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95656. minWidth: number;
  95657. maxWidth: number;
  95658. minHeight: number;
  95659. maxHeight: number;
  95660. deviceId: string;
  95661. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95662. /**
  95663. * Creates a video texture straight from your WebCam video feed.
  95664. * @param scene Define the scene the texture should be created in
  95665. * @param onReady Define a callback to triggered once the texture will be ready
  95666. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95667. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95668. */
  95669. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95670. minWidth: number;
  95671. maxWidth: number;
  95672. minHeight: number;
  95673. maxHeight: number;
  95674. deviceId: string;
  95675. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95676. }
  95677. }
  95678. declare module BABYLON {
  95679. /**
  95680. * Defines the interface used by objects working like Scene
  95681. * @hidden
  95682. */
  95683. interface ISceneLike {
  95684. _addPendingData(data: any): void;
  95685. _removePendingData(data: any): void;
  95686. offlineProvider: IOfflineProvider;
  95687. }
  95688. /** Interface defining initialization parameters for Engine class */
  95689. export interface EngineOptions extends WebGLContextAttributes {
  95690. /**
  95691. * Defines if the engine should no exceed a specified device ratio
  95692. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95693. */
  95694. limitDeviceRatio?: number;
  95695. /**
  95696. * Defines if webvr should be enabled automatically
  95697. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95698. */
  95699. autoEnableWebVR?: boolean;
  95700. /**
  95701. * Defines if webgl2 should be turned off even if supported
  95702. * @see http://doc.babylonjs.com/features/webgl2
  95703. */
  95704. disableWebGL2Support?: boolean;
  95705. /**
  95706. * Defines if webaudio should be initialized as well
  95707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95708. */
  95709. audioEngine?: boolean;
  95710. /**
  95711. * Defines if animations should run using a deterministic lock step
  95712. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95713. */
  95714. deterministicLockstep?: boolean;
  95715. /** Defines the maximum steps to use with deterministic lock step mode */
  95716. lockstepMaxSteps?: number;
  95717. /**
  95718. * Defines that engine should ignore context lost events
  95719. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95720. */
  95721. doNotHandleContextLost?: boolean;
  95722. /**
  95723. * Defines that engine should ignore modifying touch action attribute and style
  95724. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95725. */
  95726. doNotHandleTouchAction?: boolean;
  95727. /**
  95728. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95729. */
  95730. useHighPrecisionFloats?: boolean;
  95731. }
  95732. /**
  95733. * The base engine class (root of all engines)
  95734. */
  95735. export class ThinEngine {
  95736. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95737. static ExceptionList: ({
  95738. key: string;
  95739. capture: string;
  95740. captureConstraint: number;
  95741. targets: string[];
  95742. } | {
  95743. key: string;
  95744. capture: null;
  95745. captureConstraint: null;
  95746. targets: string[];
  95747. })[];
  95748. /** @hidden */
  95749. static _TextureLoaders: IInternalTextureLoader[];
  95750. /**
  95751. * Returns the current npm package of the sdk
  95752. */
  95753. static readonly NpmPackage: string;
  95754. /**
  95755. * Returns the current version of the framework
  95756. */
  95757. static readonly Version: string;
  95758. /**
  95759. * Returns a string describing the current engine
  95760. */
  95761. readonly description: string;
  95762. /**
  95763. * Gets or sets the epsilon value used by collision engine
  95764. */
  95765. static CollisionsEpsilon: number;
  95766. /**
  95767. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95768. */
  95769. static ShadersRepository: string;
  95770. /** @hidden */
  95771. _shaderProcessor: IShaderProcessor;
  95772. /**
  95773. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95774. */
  95775. forcePOTTextures: boolean;
  95776. /**
  95777. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95778. */
  95779. isFullscreen: boolean;
  95780. /**
  95781. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95782. */
  95783. cullBackFaces: boolean;
  95784. /**
  95785. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95786. */
  95787. renderEvenInBackground: boolean;
  95788. /**
  95789. * Gets or sets a boolean indicating that cache can be kept between frames
  95790. */
  95791. preventCacheWipeBetweenFrames: boolean;
  95792. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95793. validateShaderPrograms: boolean;
  95794. /**
  95795. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95796. */
  95797. disableUniformBuffers: boolean;
  95798. /** @hidden */
  95799. _uniformBuffers: UniformBuffer[];
  95800. /**
  95801. * Gets a boolean indicating that the engine supports uniform buffers
  95802. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95803. */
  95804. readonly supportsUniformBuffers: boolean;
  95805. /** @hidden */
  95806. _gl: WebGLRenderingContext;
  95807. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95808. protected _windowIsBackground: boolean;
  95809. protected _webGLVersion: number;
  95810. protected _highPrecisionShadersAllowed: boolean;
  95811. /** @hidden */
  95812. readonly _shouldUseHighPrecisionShader: boolean;
  95813. /**
  95814. * Gets a boolean indicating that only power of 2 textures are supported
  95815. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95816. */
  95817. readonly needPOTTextures: boolean;
  95818. /** @hidden */
  95819. _badOS: boolean;
  95820. /** @hidden */
  95821. _badDesktopOS: boolean;
  95822. private _hardwareScalingLevel;
  95823. /** @hidden */
  95824. _caps: EngineCapabilities;
  95825. private _isStencilEnable;
  95826. protected _colorWrite: boolean;
  95827. private _glVersion;
  95828. private _glRenderer;
  95829. private _glVendor;
  95830. /** @hidden */
  95831. _videoTextureSupported: boolean;
  95832. protected _renderingQueueLaunched: boolean;
  95833. protected _activeRenderLoops: (() => void)[];
  95834. /**
  95835. * Observable signaled when a context lost event is raised
  95836. */
  95837. onContextLostObservable: Observable<ThinEngine>;
  95838. /**
  95839. * Observable signaled when a context restored event is raised
  95840. */
  95841. onContextRestoredObservable: Observable<ThinEngine>;
  95842. private _onContextLost;
  95843. private _onContextRestored;
  95844. protected _contextWasLost: boolean;
  95845. /** @hidden */
  95846. _doNotHandleContextLost: boolean;
  95847. /**
  95848. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95849. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95850. */
  95851. doNotHandleContextLost: boolean;
  95852. /**
  95853. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95854. */
  95855. disableVertexArrayObjects: boolean;
  95856. /** @hidden */
  95857. protected _depthCullingState: DepthCullingState;
  95858. /** @hidden */
  95859. protected _stencilState: StencilState;
  95860. /** @hidden */
  95861. protected _alphaState: AlphaState;
  95862. /** @hidden */
  95863. _internalTexturesCache: InternalTexture[];
  95864. /** @hidden */
  95865. protected _activeChannel: number;
  95866. private _currentTextureChannel;
  95867. /** @hidden */
  95868. protected _boundTexturesCache: {
  95869. [key: string]: Nullable<InternalTexture>;
  95870. };
  95871. /** @hidden */
  95872. protected _currentEffect: Nullable<Effect>;
  95873. /** @hidden */
  95874. protected _currentProgram: Nullable<WebGLProgram>;
  95875. private _compiledEffects;
  95876. private _vertexAttribArraysEnabled;
  95877. /** @hidden */
  95878. protected _cachedViewport: Nullable<IViewportLike>;
  95879. private _cachedVertexArrayObject;
  95880. /** @hidden */
  95881. protected _cachedVertexBuffers: any;
  95882. /** @hidden */
  95883. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95884. /** @hidden */
  95885. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95886. /** @hidden */
  95887. _currentRenderTarget: Nullable<InternalTexture>;
  95888. private _uintIndicesCurrentlySet;
  95889. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  95890. /** @hidden */
  95891. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95892. private _currentBufferPointers;
  95893. private _currentInstanceLocations;
  95894. private _currentInstanceBuffers;
  95895. private _textureUnits;
  95896. /** @hidden */
  95897. _workingCanvas: Nullable<HTMLCanvasElement>;
  95898. /** @hidden */
  95899. _workingContext: Nullable<CanvasRenderingContext2D>;
  95900. /** @hidden */
  95901. _bindedRenderFunction: any;
  95902. private _vaoRecordInProgress;
  95903. private _mustWipeVertexAttributes;
  95904. private _emptyTexture;
  95905. private _emptyCubeTexture;
  95906. private _emptyTexture3D;
  95907. /** @hidden */
  95908. _frameHandler: number;
  95909. private _nextFreeTextureSlots;
  95910. private _maxSimultaneousTextures;
  95911. private _activeRequests;
  95912. protected _texturesSupported: string[];
  95913. /** @hidden */
  95914. _textureFormatInUse: Nullable<string>;
  95915. protected readonly _supportsHardwareTextureRescaling: boolean;
  95916. /**
  95917. * Gets the list of texture formats supported
  95918. */
  95919. readonly texturesSupported: Array<string>;
  95920. /**
  95921. * Gets the list of texture formats in use
  95922. */
  95923. readonly textureFormatInUse: Nullable<string>;
  95924. /**
  95925. * Gets the current viewport
  95926. */
  95927. readonly currentViewport: Nullable<IViewportLike>;
  95928. /**
  95929. * Gets the default empty texture
  95930. */
  95931. readonly emptyTexture: InternalTexture;
  95932. /**
  95933. * Gets the default empty 3D texture
  95934. */
  95935. readonly emptyTexture3D: InternalTexture;
  95936. /**
  95937. * Gets the default empty cube texture
  95938. */
  95939. readonly emptyCubeTexture: InternalTexture;
  95940. /**
  95941. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95942. */
  95943. readonly premultipliedAlpha: boolean;
  95944. /**
  95945. * Observable event triggered before each texture is initialized
  95946. */
  95947. onBeforeTextureInitObservable: Observable<Texture>;
  95948. /**
  95949. * Creates a new engine
  95950. * @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
  95951. * @param antialias defines enable antialiasing (default: false)
  95952. * @param options defines further options to be sent to the getContext() function
  95953. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95954. */
  95955. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95956. private _rebuildInternalTextures;
  95957. private _rebuildEffects;
  95958. /**
  95959. * Gets a boolean indicating if all created effects are ready
  95960. * @returns true if all effects are ready
  95961. */
  95962. areAllEffectsReady(): boolean;
  95963. protected _rebuildBuffers(): void;
  95964. private _initGLContext;
  95965. /**
  95966. * Gets version of the current webGL context
  95967. */
  95968. readonly webGLVersion: number;
  95969. /**
  95970. * Gets a string idenfifying the name of the class
  95971. * @returns "Engine" string
  95972. */
  95973. getClassName(): string;
  95974. /**
  95975. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95976. */
  95977. readonly isStencilEnable: boolean;
  95978. /** @hidden */
  95979. _prepareWorkingCanvas(): void;
  95980. /**
  95981. * Reset the texture cache to empty state
  95982. */
  95983. resetTextureCache(): void;
  95984. /**
  95985. * Gets an object containing information about the current webGL context
  95986. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95987. */
  95988. getGlInfo(): {
  95989. vendor: string;
  95990. renderer: string;
  95991. version: string;
  95992. };
  95993. /**
  95994. * Defines the hardware scaling level.
  95995. * By default the hardware scaling level is computed from the window device ratio.
  95996. * 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.
  95997. * @param level defines the level to use
  95998. */
  95999. setHardwareScalingLevel(level: number): void;
  96000. /**
  96001. * Gets the current hardware scaling level.
  96002. * By default the hardware scaling level is computed from the window device ratio.
  96003. * 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.
  96004. * @returns a number indicating the current hardware scaling level
  96005. */
  96006. getHardwareScalingLevel(): number;
  96007. /**
  96008. * Gets the list of loaded textures
  96009. * @returns an array containing all loaded textures
  96010. */
  96011. getLoadedTexturesCache(): InternalTexture[];
  96012. /**
  96013. * Gets the object containing all engine capabilities
  96014. * @returns the EngineCapabilities object
  96015. */
  96016. getCaps(): EngineCapabilities;
  96017. /**
  96018. * stop executing a render loop function and remove it from the execution array
  96019. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96020. */
  96021. stopRenderLoop(renderFunction?: () => void): void;
  96022. /** @hidden */
  96023. _renderLoop(): void;
  96024. /**
  96025. * Gets the HTML canvas attached with the current webGL context
  96026. * @returns a HTML canvas
  96027. */
  96028. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96029. /**
  96030. * Gets host window
  96031. * @returns the host window object
  96032. */
  96033. getHostWindow(): Window;
  96034. /**
  96035. * Gets the current render width
  96036. * @param useScreen defines if screen size must be used (or the current render target if any)
  96037. * @returns a number defining the current render width
  96038. */
  96039. getRenderWidth(useScreen?: boolean): number;
  96040. /**
  96041. * Gets the current render height
  96042. * @param useScreen defines if screen size must be used (or the current render target if any)
  96043. * @returns a number defining the current render height
  96044. */
  96045. getRenderHeight(useScreen?: boolean): number;
  96046. /**
  96047. * Can be used to override the current requestAnimationFrame requester.
  96048. * @hidden
  96049. */
  96050. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96051. /**
  96052. * Register and execute a render loop. The engine can have more than one render function
  96053. * @param renderFunction defines the function to continuously execute
  96054. */
  96055. runRenderLoop(renderFunction: () => void): void;
  96056. /**
  96057. * Clear the current render buffer or the current render target (if any is set up)
  96058. * @param color defines the color to use
  96059. * @param backBuffer defines if the back buffer must be cleared
  96060. * @param depth defines if the depth buffer must be cleared
  96061. * @param stencil defines if the stencil buffer must be cleared
  96062. */
  96063. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96064. private _viewportCached;
  96065. /** @hidden */
  96066. _viewport(x: number, y: number, width: number, height: number): void;
  96067. /**
  96068. * Set the WebGL's viewport
  96069. * @param viewport defines the viewport element to be used
  96070. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96071. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96072. */
  96073. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96074. /**
  96075. * Begin a new frame
  96076. */
  96077. beginFrame(): void;
  96078. /**
  96079. * Enf the current frame
  96080. */
  96081. endFrame(): void;
  96082. /**
  96083. * Resize the view according to the canvas' size
  96084. */
  96085. resize(): void;
  96086. /**
  96087. * Force a specific size of the canvas
  96088. * @param width defines the new canvas' width
  96089. * @param height defines the new canvas' height
  96090. */
  96091. setSize(width: number, height: number): void;
  96092. /**
  96093. * Binds the frame buffer to the specified texture.
  96094. * @param texture The texture to render to or null for the default canvas
  96095. * @param faceIndex The face of the texture to render to in case of cube texture
  96096. * @param requiredWidth The width of the target to render to
  96097. * @param requiredHeight The height of the target to render to
  96098. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96099. * @param depthStencilTexture The depth stencil texture to use to render
  96100. * @param lodLevel defines le lod level to bind to the frame buffer
  96101. */
  96102. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96103. /** @hidden */
  96104. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96105. /**
  96106. * Unbind the current render target texture from the webGL context
  96107. * @param texture defines the render target texture to unbind
  96108. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96109. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96110. */
  96111. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96112. /**
  96113. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96114. */
  96115. flushFramebuffer(): void;
  96116. /**
  96117. * Unbind the current render target and bind the default framebuffer
  96118. */
  96119. restoreDefaultFramebuffer(): void;
  96120. private _resetVertexBufferBinding;
  96121. /**
  96122. * Creates a vertex buffer
  96123. * @param data the data for the vertex buffer
  96124. * @returns the new WebGL static buffer
  96125. */
  96126. createVertexBuffer(data: DataArray): DataBuffer;
  96127. private _createVertexBuffer;
  96128. /**
  96129. * Creates a dynamic vertex buffer
  96130. * @param data the data for the dynamic vertex buffer
  96131. * @returns the new WebGL dynamic buffer
  96132. */
  96133. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96134. /**
  96135. * Updates a dynamic vertex buffer.
  96136. * @param vertexBuffer the vertex buffer to update
  96137. * @param data the data used to update the vertex buffer
  96138. * @param byteOffset the byte offset of the data
  96139. * @param byteLength the byte length of the data
  96140. */
  96141. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96142. protected _resetIndexBufferBinding(): void;
  96143. /**
  96144. * Creates a new index buffer
  96145. * @param indices defines the content of the index buffer
  96146. * @param updatable defines if the index buffer must be updatable
  96147. * @returns a new webGL buffer
  96148. */
  96149. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96150. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96151. /**
  96152. * Bind a webGL buffer to the webGL context
  96153. * @param buffer defines the buffer to bind
  96154. */
  96155. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96156. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96157. private bindBuffer;
  96158. /**
  96159. * update the bound buffer with the given data
  96160. * @param data defines the data to update
  96161. */
  96162. updateArrayBuffer(data: Float32Array): void;
  96163. private _vertexAttribPointer;
  96164. private _bindIndexBufferWithCache;
  96165. private _bindVertexBuffersAttributes;
  96166. /**
  96167. * Records a vertex array object
  96168. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96169. * @param vertexBuffers defines the list of vertex buffers to store
  96170. * @param indexBuffer defines the index buffer to store
  96171. * @param effect defines the effect to store
  96172. * @returns the new vertex array object
  96173. */
  96174. recordVertexArrayObject(vertexBuffers: {
  96175. [key: string]: VertexBuffer;
  96176. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96177. /**
  96178. * Bind a specific vertex array object
  96179. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96180. * @param vertexArrayObject defines the vertex array object to bind
  96181. * @param indexBuffer defines the index buffer to bind
  96182. */
  96183. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96184. /**
  96185. * Bind webGl buffers directly to the webGL context
  96186. * @param vertexBuffer defines the vertex buffer to bind
  96187. * @param indexBuffer defines the index buffer to bind
  96188. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96189. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96190. * @param effect defines the effect associated with the vertex buffer
  96191. */
  96192. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96193. private _unbindVertexArrayObject;
  96194. /**
  96195. * Bind a list of vertex buffers to the webGL context
  96196. * @param vertexBuffers defines the list of vertex buffers to bind
  96197. * @param indexBuffer defines the index buffer to bind
  96198. * @param effect defines the effect associated with the vertex buffers
  96199. */
  96200. bindBuffers(vertexBuffers: {
  96201. [key: string]: Nullable<VertexBuffer>;
  96202. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96203. /**
  96204. * Unbind all instance attributes
  96205. */
  96206. unbindInstanceAttributes(): void;
  96207. /**
  96208. * Release and free the memory of a vertex array object
  96209. * @param vao defines the vertex array object to delete
  96210. */
  96211. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96212. /** @hidden */
  96213. _releaseBuffer(buffer: DataBuffer): boolean;
  96214. protected _deleteBuffer(buffer: DataBuffer): void;
  96215. /**
  96216. * Creates a webGL buffer to use with instanciation
  96217. * @param capacity defines the size of the buffer
  96218. * @returns the webGL buffer
  96219. */
  96220. createInstancesBuffer(capacity: number): DataBuffer;
  96221. /**
  96222. * Delete a webGL buffer used with instanciation
  96223. * @param buffer defines the webGL buffer to delete
  96224. */
  96225. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96226. /**
  96227. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96228. * @param instancesBuffer defines the webGL buffer to update and bind
  96229. * @param data defines the data to store in the buffer
  96230. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96231. */
  96232. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96233. /**
  96234. * Apply all cached states (depth, culling, stencil and alpha)
  96235. */
  96236. applyStates(): void;
  96237. /**
  96238. * Send a draw order
  96239. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96240. * @param indexStart defines the starting index
  96241. * @param indexCount defines the number of index to draw
  96242. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96243. */
  96244. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96245. /**
  96246. * Draw a list of points
  96247. * @param verticesStart defines the index of first vertex to draw
  96248. * @param verticesCount defines the count of vertices to draw
  96249. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96250. */
  96251. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96252. /**
  96253. * Draw a list of unindexed primitives
  96254. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96255. * @param verticesStart defines the index of first vertex to draw
  96256. * @param verticesCount defines the count of vertices to draw
  96257. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96258. */
  96259. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96260. /**
  96261. * Draw a list of indexed primitives
  96262. * @param fillMode defines the primitive to use
  96263. * @param indexStart defines the starting index
  96264. * @param indexCount defines the number of index to draw
  96265. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96266. */
  96267. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96268. /**
  96269. * Draw a list of unindexed primitives
  96270. * @param fillMode defines the primitive to use
  96271. * @param verticesStart defines the index of first vertex to draw
  96272. * @param verticesCount defines the count of vertices to draw
  96273. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96274. */
  96275. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96276. private _drawMode;
  96277. /** @hidden */
  96278. protected _reportDrawCall(): void;
  96279. /** @hidden */
  96280. _releaseEffect(effect: Effect): void;
  96281. /** @hidden */
  96282. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96283. /**
  96284. * Create a new effect (used to store vertex/fragment shaders)
  96285. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96286. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96287. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96288. * @param samplers defines an array of string used to represent textures
  96289. * @param defines defines the string containing the defines to use to compile the shaders
  96290. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96291. * @param onCompiled defines a function to call when the effect creation is successful
  96292. * @param onError defines a function to call when the effect creation has failed
  96293. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96294. * @returns the new Effect
  96295. */
  96296. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96297. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96298. private _compileShader;
  96299. private _compileRawShader;
  96300. /**
  96301. * Directly creates a webGL program
  96302. * @param pipelineContext defines the pipeline context to attach to
  96303. * @param vertexCode defines the vertex shader code to use
  96304. * @param fragmentCode defines the fragment shader code to use
  96305. * @param context defines the webGL context to use (if not set, the current one will be used)
  96306. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96307. * @returns the new webGL program
  96308. */
  96309. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96310. /**
  96311. * Creates a webGL program
  96312. * @param pipelineContext defines the pipeline context to attach to
  96313. * @param vertexCode defines the vertex shader code to use
  96314. * @param fragmentCode defines the fragment shader code to use
  96315. * @param defines defines the string containing the defines to use to compile the shaders
  96316. * @param context defines the webGL context to use (if not set, the current one will be used)
  96317. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96318. * @returns the new webGL program
  96319. */
  96320. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96321. /**
  96322. * Creates a new pipeline context
  96323. * @returns the new pipeline
  96324. */
  96325. createPipelineContext(): IPipelineContext;
  96326. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96327. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96328. /** @hidden */
  96329. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96330. /** @hidden */
  96331. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96332. /** @hidden */
  96333. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96334. /**
  96335. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96336. * @param pipelineContext defines the pipeline context to use
  96337. * @param uniformsNames defines the list of uniform names
  96338. * @returns an array of webGL uniform locations
  96339. */
  96340. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96341. /**
  96342. * Gets the lsit of active attributes for a given webGL program
  96343. * @param pipelineContext defines the pipeline context to use
  96344. * @param attributesNames defines the list of attribute names to get
  96345. * @returns an array of indices indicating the offset of each attribute
  96346. */
  96347. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96348. /**
  96349. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96350. * @param effect defines the effect to activate
  96351. */
  96352. enableEffect(effect: Nullable<Effect>): void;
  96353. /**
  96354. * Set the value of an uniform to an array of int32
  96355. * @param uniform defines the webGL uniform location where to store the value
  96356. * @param array defines the array of int32 to store
  96357. */
  96358. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96359. /**
  96360. * Set the value of an uniform to an array of int32 (stored as vec2)
  96361. * @param uniform defines the webGL uniform location where to store the value
  96362. * @param array defines the array of int32 to store
  96363. */
  96364. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96365. /**
  96366. * Set the value of an uniform to an array of int32 (stored as vec3)
  96367. * @param uniform defines the webGL uniform location where to store the value
  96368. * @param array defines the array of int32 to store
  96369. */
  96370. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96371. /**
  96372. * Set the value of an uniform to an array of int32 (stored as vec4)
  96373. * @param uniform defines the webGL uniform location where to store the value
  96374. * @param array defines the array of int32 to store
  96375. */
  96376. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96377. /**
  96378. * Set the value of an uniform to an array of float32
  96379. * @param uniform defines the webGL uniform location where to store the value
  96380. * @param array defines the array of float32 to store
  96381. */
  96382. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96383. /**
  96384. * Set the value of an uniform to an array of float32 (stored as vec2)
  96385. * @param uniform defines the webGL uniform location where to store the value
  96386. * @param array defines the array of float32 to store
  96387. */
  96388. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96389. /**
  96390. * Set the value of an uniform to an array of float32 (stored as vec3)
  96391. * @param uniform defines the webGL uniform location where to store the value
  96392. * @param array defines the array of float32 to store
  96393. */
  96394. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96395. /**
  96396. * Set the value of an uniform to an array of float32 (stored as vec4)
  96397. * @param uniform defines the webGL uniform location where to store the value
  96398. * @param array defines the array of float32 to store
  96399. */
  96400. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96401. /**
  96402. * Set the value of an uniform to an array of number
  96403. * @param uniform defines the webGL uniform location where to store the value
  96404. * @param array defines the array of number to store
  96405. */
  96406. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96407. /**
  96408. * Set the value of an uniform to an array of number (stored as vec2)
  96409. * @param uniform defines the webGL uniform location where to store the value
  96410. * @param array defines the array of number to store
  96411. */
  96412. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96413. /**
  96414. * Set the value of an uniform to an array of number (stored as vec3)
  96415. * @param uniform defines the webGL uniform location where to store the value
  96416. * @param array defines the array of number to store
  96417. */
  96418. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96419. /**
  96420. * Set the value of an uniform to an array of number (stored as vec4)
  96421. * @param uniform defines the webGL uniform location where to store the value
  96422. * @param array defines the array of number to store
  96423. */
  96424. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96425. /**
  96426. * Set the value of an uniform to an array of float32 (stored as matrices)
  96427. * @param uniform defines the webGL uniform location where to store the value
  96428. * @param matrices defines the array of float32 to store
  96429. */
  96430. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96431. /**
  96432. * Set the value of an uniform to a matrix (3x3)
  96433. * @param uniform defines the webGL uniform location where to store the value
  96434. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96435. */
  96436. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96437. /**
  96438. * Set the value of an uniform to a matrix (2x2)
  96439. * @param uniform defines the webGL uniform location where to store the value
  96440. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96441. */
  96442. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96443. /**
  96444. * Set the value of an uniform to a number (int)
  96445. * @param uniform defines the webGL uniform location where to store the value
  96446. * @param value defines the int number to store
  96447. */
  96448. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96449. /**
  96450. * Set the value of an uniform to a number (float)
  96451. * @param uniform defines the webGL uniform location where to store the value
  96452. * @param value defines the float number to store
  96453. */
  96454. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96455. /**
  96456. * Set the value of an uniform to a vec2
  96457. * @param uniform defines the webGL uniform location where to store the value
  96458. * @param x defines the 1st component of the value
  96459. * @param y defines the 2nd component of the value
  96460. */
  96461. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96462. /**
  96463. * Set the value of an uniform to a vec3
  96464. * @param uniform defines the webGL uniform location where to store the value
  96465. * @param x defines the 1st component of the value
  96466. * @param y defines the 2nd component of the value
  96467. * @param z defines the 3rd component of the value
  96468. */
  96469. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96470. /**
  96471. * Set the value of an uniform to a boolean
  96472. * @param uniform defines the webGL uniform location where to store the value
  96473. * @param bool defines the boolean to store
  96474. */
  96475. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96476. /**
  96477. * Set the value of an uniform to a vec4
  96478. * @param uniform defines the webGL uniform location where to store the value
  96479. * @param x defines the 1st component of the value
  96480. * @param y defines the 2nd component of the value
  96481. * @param z defines the 3rd component of the value
  96482. * @param w defines the 4th component of the value
  96483. */
  96484. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96485. /**
  96486. * Sets a Color4 on a uniform variable
  96487. * @param uniform defines the uniform location
  96488. * @param color4 defines the value to be set
  96489. */
  96490. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96491. /**
  96492. * Gets the depth culling state manager
  96493. */
  96494. readonly depthCullingState: DepthCullingState;
  96495. /**
  96496. * Gets the alpha state manager
  96497. */
  96498. readonly alphaState: AlphaState;
  96499. /**
  96500. * Gets the stencil state manager
  96501. */
  96502. readonly stencilState: StencilState;
  96503. /**
  96504. * Clears the list of texture accessible through engine.
  96505. * This can help preventing texture load conflict due to name collision.
  96506. */
  96507. clearInternalTexturesCache(): void;
  96508. /**
  96509. * Force the entire cache to be cleared
  96510. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96511. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96512. */
  96513. wipeCaches(bruteForce?: boolean): void;
  96514. /** @hidden */
  96515. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96516. min: number;
  96517. mag: number;
  96518. };
  96519. /** @hidden */
  96520. _createTexture(): WebGLTexture;
  96521. /**
  96522. * Usually called from Texture.ts.
  96523. * Passed information to create a WebGLTexture
  96524. * @param urlArg defines a value which contains one of the following:
  96525. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96526. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96527. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96528. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96529. * @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)
  96530. * @param scene needed for loading to the correct scene
  96531. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96532. * @param onLoad optional callback to be called upon successful completion
  96533. * @param onError optional callback to be called upon failure
  96534. * @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
  96535. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96536. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96537. * @param forcedExtension defines the extension to use to pick the right loader
  96538. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96539. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96540. */
  96541. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96542. /**
  96543. * @hidden
  96544. */
  96545. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96546. /**
  96547. * Creates a raw texture
  96548. * @param data defines the data to store in the texture
  96549. * @param width defines the width of the texture
  96550. * @param height defines the height of the texture
  96551. * @param format defines the format of the data
  96552. * @param generateMipMaps defines if the engine should generate the mip levels
  96553. * @param invertY defines if data must be stored with Y axis inverted
  96554. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96555. * @param compression defines the compression used (null by default)
  96556. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96557. * @returns the raw texture inside an InternalTexture
  96558. */
  96559. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96560. /**
  96561. * Creates a new raw cube texture
  96562. * @param data defines the array of data to use to create each face
  96563. * @param size defines the size of the textures
  96564. * @param format defines the format of the data
  96565. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96566. * @param generateMipMaps defines if the engine should generate the mip levels
  96567. * @param invertY defines if data must be stored with Y axis inverted
  96568. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96569. * @param compression defines the compression used (null by default)
  96570. * @returns the cube texture as an InternalTexture
  96571. */
  96572. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96573. /**
  96574. * Creates a new raw 3D texture
  96575. * @param data defines the data used to create the texture
  96576. * @param width defines the width of the texture
  96577. * @param height defines the height of the texture
  96578. * @param depth defines the depth of the texture
  96579. * @param format defines the format of the texture
  96580. * @param generateMipMaps defines if the engine must generate mip levels
  96581. * @param invertY defines if data must be stored with Y axis inverted
  96582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96583. * @param compression defines the compressed used (can be null)
  96584. * @param textureType defines the compressed used (can be null)
  96585. * @returns a new raw 3D texture (stored in an InternalTexture)
  96586. */
  96587. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96588. private _unpackFlipYCached;
  96589. /**
  96590. * In case you are sharing the context with other applications, it might
  96591. * be interested to not cache the unpack flip y state to ensure a consistent
  96592. * value would be set.
  96593. */
  96594. enableUnpackFlipYCached: boolean;
  96595. /** @hidden */
  96596. _unpackFlipY(value: boolean): void;
  96597. /** @hidden */
  96598. _getUnpackAlignement(): number;
  96599. /**
  96600. * Update the sampling mode of a given texture
  96601. * @param samplingMode defines the required sampling mode
  96602. * @param texture defines the texture to update
  96603. */
  96604. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96605. /**
  96606. * Updates a depth texture Comparison Mode and Function.
  96607. * If the comparison Function is equal to 0, the mode will be set to none.
  96608. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96609. * @param texture The texture to set the comparison function for
  96610. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96611. */
  96612. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96613. /** @hidden */
  96614. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96615. width: number;
  96616. height: number;
  96617. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96618. /**
  96619. * Creates a depth stencil texture.
  96620. * This is only available in WebGL 2 or with the depth texture extension available.
  96621. * @param size The size of face edge in the texture.
  96622. * @param options The options defining the texture.
  96623. * @returns The texture
  96624. */
  96625. createDepthStencilTexture(size: number | {
  96626. width: number;
  96627. height: number;
  96628. }, options: DepthTextureCreationOptions): InternalTexture;
  96629. /**
  96630. * Creates a depth stencil texture.
  96631. * This is only available in WebGL 2 or with the depth texture extension available.
  96632. * @param size The size of face edge in the texture.
  96633. * @param options The options defining the texture.
  96634. * @returns The texture
  96635. */
  96636. private _createDepthStencilTexture;
  96637. /** @hidden */
  96638. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96639. /** @hidden */
  96640. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96641. /** @hidden */
  96642. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96643. /** @hidden */
  96644. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96645. /**
  96646. * @hidden
  96647. */
  96648. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96649. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96650. private _prepareWebGLTexture;
  96651. /** @hidden */
  96652. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96653. /** @hidden */
  96654. _releaseFramebufferObjects(texture: InternalTexture): void;
  96655. /** @hidden */
  96656. _releaseTexture(texture: InternalTexture): void;
  96657. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96658. protected _setProgram(program: WebGLProgram): void;
  96659. protected _boundUniforms: {
  96660. [key: number]: WebGLUniformLocation;
  96661. };
  96662. /**
  96663. * Binds an effect to the webGL context
  96664. * @param effect defines the effect to bind
  96665. */
  96666. bindSamplers(effect: Effect): void;
  96667. private _activateCurrentTexture;
  96668. /** @hidden */
  96669. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96670. /** @hidden */
  96671. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96672. /**
  96673. * Unbind all textures from the webGL context
  96674. */
  96675. unbindAllTextures(): void;
  96676. /**
  96677. * Sets a texture to the according uniform.
  96678. * @param channel The texture channel
  96679. * @param uniform The uniform to set
  96680. * @param texture The texture to apply
  96681. */
  96682. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96683. private _bindSamplerUniformToChannel;
  96684. private _getTextureWrapMode;
  96685. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96686. /**
  96687. * Sets an array of texture to the webGL context
  96688. * @param channel defines the channel where the texture array must be set
  96689. * @param uniform defines the associated uniform location
  96690. * @param textures defines the array of textures to bind
  96691. */
  96692. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96693. /** @hidden */
  96694. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96695. private _setTextureParameterFloat;
  96696. private _setTextureParameterInteger;
  96697. /**
  96698. * Unbind all vertex attributes from the webGL context
  96699. */
  96700. unbindAllAttributes(): void;
  96701. /**
  96702. * 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
  96703. */
  96704. releaseEffects(): void;
  96705. /**
  96706. * Dispose and release all associated resources
  96707. */
  96708. dispose(): void;
  96709. /**
  96710. * Attach a new callback raised when context lost event is fired
  96711. * @param callback defines the callback to call
  96712. */
  96713. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96714. /**
  96715. * Attach a new callback raised when context restored event is fired
  96716. * @param callback defines the callback to call
  96717. */
  96718. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96719. /**
  96720. * Get the current error code of the webGL context
  96721. * @returns the error code
  96722. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96723. */
  96724. getError(): number;
  96725. private _canRenderToFloatFramebuffer;
  96726. private _canRenderToHalfFloatFramebuffer;
  96727. private _canRenderToFramebuffer;
  96728. /** @hidden */
  96729. _getWebGLTextureType(type: number): number;
  96730. /** @hidden */
  96731. _getInternalFormat(format: number): number;
  96732. /** @hidden */
  96733. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96734. /** @hidden */
  96735. _getRGBAMultiSampleBufferFormat(type: number): number;
  96736. /** @hidden */
  96737. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  96738. /**
  96739. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96740. * @returns true if the engine can be created
  96741. * @ignorenaming
  96742. */
  96743. static isSupported(): boolean;
  96744. /**
  96745. * Find the next highest power of two.
  96746. * @param x Number to start search from.
  96747. * @return Next highest power of two.
  96748. */
  96749. static CeilingPOT(x: number): number;
  96750. /**
  96751. * Find the next lowest power of two.
  96752. * @param x Number to start search from.
  96753. * @return Next lowest power of two.
  96754. */
  96755. static FloorPOT(x: number): number;
  96756. /**
  96757. * Find the nearest power of two.
  96758. * @param x Number to start search from.
  96759. * @return Next nearest power of two.
  96760. */
  96761. static NearestPOT(x: number): number;
  96762. /**
  96763. * Get the closest exponent of two
  96764. * @param value defines the value to approximate
  96765. * @param max defines the maximum value to return
  96766. * @param mode defines how to define the closest value
  96767. * @returns closest exponent of two of the given value
  96768. */
  96769. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96770. /**
  96771. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96772. * @param func - the function to be called
  96773. * @param requester - the object that will request the next frame. Falls back to window.
  96774. * @returns frame number
  96775. */
  96776. static QueueNewFrame(func: () => void, requester?: any): number;
  96777. }
  96778. }
  96779. declare module BABYLON {
  96780. /**
  96781. * Class representing spherical harmonics coefficients to the 3rd degree
  96782. */
  96783. export class SphericalHarmonics {
  96784. /**
  96785. * Defines whether or not the harmonics have been prescaled for rendering.
  96786. */
  96787. preScaled: boolean;
  96788. /**
  96789. * The l0,0 coefficients of the spherical harmonics
  96790. */
  96791. l00: Vector3;
  96792. /**
  96793. * The l1,-1 coefficients of the spherical harmonics
  96794. */
  96795. l1_1: Vector3;
  96796. /**
  96797. * The l1,0 coefficients of the spherical harmonics
  96798. */
  96799. l10: Vector3;
  96800. /**
  96801. * The l1,1 coefficients of the spherical harmonics
  96802. */
  96803. l11: Vector3;
  96804. /**
  96805. * The l2,-2 coefficients of the spherical harmonics
  96806. */
  96807. l2_2: Vector3;
  96808. /**
  96809. * The l2,-1 coefficients of the spherical harmonics
  96810. */
  96811. l2_1: Vector3;
  96812. /**
  96813. * The l2,0 coefficients of the spherical harmonics
  96814. */
  96815. l20: Vector3;
  96816. /**
  96817. * The l2,1 coefficients of the spherical harmonics
  96818. */
  96819. l21: Vector3;
  96820. /**
  96821. * The l2,2 coefficients of the spherical harmonics
  96822. */
  96823. l22: Vector3;
  96824. /**
  96825. * Adds a light to the spherical harmonics
  96826. * @param direction the direction of the light
  96827. * @param color the color of the light
  96828. * @param deltaSolidAngle the delta solid angle of the light
  96829. */
  96830. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  96831. /**
  96832. * Scales the spherical harmonics by the given amount
  96833. * @param scale the amount to scale
  96834. */
  96835. scaleInPlace(scale: number): void;
  96836. /**
  96837. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  96838. *
  96839. * ```
  96840. * E_lm = A_l * L_lm
  96841. * ```
  96842. *
  96843. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  96844. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  96845. * the scaling factors are given in equation 9.
  96846. */
  96847. convertIncidentRadianceToIrradiance(): void;
  96848. /**
  96849. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  96850. *
  96851. * ```
  96852. * L = (1/pi) * E * rho
  96853. * ```
  96854. *
  96855. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  96856. */
  96857. convertIrradianceToLambertianRadiance(): void;
  96858. /**
  96859. * Integrates the reconstruction coefficients directly in to the SH preventing further
  96860. * required operations at run time.
  96861. *
  96862. * This is simply done by scaling back the SH with Ylm constants parameter.
  96863. * The trigonometric part being applied by the shader at run time.
  96864. */
  96865. preScaleForRendering(): void;
  96866. /**
  96867. * Constructs a spherical harmonics from an array.
  96868. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  96869. * @returns the spherical harmonics
  96870. */
  96871. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  96872. /**
  96873. * Gets the spherical harmonics from polynomial
  96874. * @param polynomial the spherical polynomial
  96875. * @returns the spherical harmonics
  96876. */
  96877. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  96878. }
  96879. /**
  96880. * Class representing spherical polynomial coefficients to the 3rd degree
  96881. */
  96882. export class SphericalPolynomial {
  96883. private _harmonics;
  96884. /**
  96885. * The spherical harmonics used to create the polynomials.
  96886. */
  96887. readonly preScaledHarmonics: SphericalHarmonics;
  96888. /**
  96889. * The x coefficients of the spherical polynomial
  96890. */
  96891. x: Vector3;
  96892. /**
  96893. * The y coefficients of the spherical polynomial
  96894. */
  96895. y: Vector3;
  96896. /**
  96897. * The z coefficients of the spherical polynomial
  96898. */
  96899. z: Vector3;
  96900. /**
  96901. * The xx coefficients of the spherical polynomial
  96902. */
  96903. xx: Vector3;
  96904. /**
  96905. * The yy coefficients of the spherical polynomial
  96906. */
  96907. yy: Vector3;
  96908. /**
  96909. * The zz coefficients of the spherical polynomial
  96910. */
  96911. zz: Vector3;
  96912. /**
  96913. * The xy coefficients of the spherical polynomial
  96914. */
  96915. xy: Vector3;
  96916. /**
  96917. * The yz coefficients of the spherical polynomial
  96918. */
  96919. yz: Vector3;
  96920. /**
  96921. * The zx coefficients of the spherical polynomial
  96922. */
  96923. zx: Vector3;
  96924. /**
  96925. * Adds an ambient color to the spherical polynomial
  96926. * @param color the color to add
  96927. */
  96928. addAmbient(color: Color3): void;
  96929. /**
  96930. * Scales the spherical polynomial by the given amount
  96931. * @param scale the amount to scale
  96932. */
  96933. scaleInPlace(scale: number): void;
  96934. /**
  96935. * Gets the spherical polynomial from harmonics
  96936. * @param harmonics the spherical harmonics
  96937. * @returns the spherical polynomial
  96938. */
  96939. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  96940. /**
  96941. * Constructs a spherical polynomial from an array.
  96942. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  96943. * @returns the spherical polynomial
  96944. */
  96945. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  96946. }
  96947. }
  96948. declare module BABYLON {
  96949. /**
  96950. * Defines the source of the internal texture
  96951. */
  96952. export enum InternalTextureSource {
  96953. /**
  96954. * The source of the texture data is unknown
  96955. */
  96956. Unknown = 0,
  96957. /**
  96958. * Texture data comes from an URL
  96959. */
  96960. Url = 1,
  96961. /**
  96962. * Texture data is only used for temporary storage
  96963. */
  96964. Temp = 2,
  96965. /**
  96966. * Texture data comes from raw data (ArrayBuffer)
  96967. */
  96968. Raw = 3,
  96969. /**
  96970. * Texture content is dynamic (video or dynamic texture)
  96971. */
  96972. Dynamic = 4,
  96973. /**
  96974. * Texture content is generated by rendering to it
  96975. */
  96976. RenderTarget = 5,
  96977. /**
  96978. * Texture content is part of a multi render target process
  96979. */
  96980. MultiRenderTarget = 6,
  96981. /**
  96982. * Texture data comes from a cube data file
  96983. */
  96984. Cube = 7,
  96985. /**
  96986. * Texture data comes from a raw cube data
  96987. */
  96988. CubeRaw = 8,
  96989. /**
  96990. * Texture data come from a prefiltered cube data file
  96991. */
  96992. CubePrefiltered = 9,
  96993. /**
  96994. * Texture content is raw 3D data
  96995. */
  96996. Raw3D = 10,
  96997. /**
  96998. * Texture content is a depth texture
  96999. */
  97000. Depth = 11,
  97001. /**
  97002. * Texture data comes from a raw cube data encoded with RGBD
  97003. */
  97004. CubeRawRGBD = 12
  97005. }
  97006. /**
  97007. * Class used to store data associated with WebGL texture data for the engine
  97008. * This class should not be used directly
  97009. */
  97010. export class InternalTexture {
  97011. /** @hidden */
  97012. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97013. /**
  97014. * Defines if the texture is ready
  97015. */
  97016. isReady: boolean;
  97017. /**
  97018. * Defines if the texture is a cube texture
  97019. */
  97020. isCube: boolean;
  97021. /**
  97022. * Defines if the texture contains 3D data
  97023. */
  97024. is3D: boolean;
  97025. /**
  97026. * Defines if the texture contains multiview data
  97027. */
  97028. isMultiview: boolean;
  97029. /**
  97030. * Gets the URL used to load this texture
  97031. */
  97032. url: string;
  97033. /**
  97034. * Gets the sampling mode of the texture
  97035. */
  97036. samplingMode: number;
  97037. /**
  97038. * Gets a boolean indicating if the texture needs mipmaps generation
  97039. */
  97040. generateMipMaps: boolean;
  97041. /**
  97042. * Gets the number of samples used by the texture (WebGL2+ only)
  97043. */
  97044. samples: number;
  97045. /**
  97046. * Gets the type of the texture (int, float...)
  97047. */
  97048. type: number;
  97049. /**
  97050. * Gets the format of the texture (RGB, RGBA...)
  97051. */
  97052. format: number;
  97053. /**
  97054. * Observable called when the texture is loaded
  97055. */
  97056. onLoadedObservable: Observable<InternalTexture>;
  97057. /**
  97058. * Gets the width of the texture
  97059. */
  97060. width: number;
  97061. /**
  97062. * Gets the height of the texture
  97063. */
  97064. height: number;
  97065. /**
  97066. * Gets the depth of the texture
  97067. */
  97068. depth: number;
  97069. /**
  97070. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97071. */
  97072. baseWidth: number;
  97073. /**
  97074. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97075. */
  97076. baseHeight: number;
  97077. /**
  97078. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97079. */
  97080. baseDepth: number;
  97081. /**
  97082. * Gets a boolean indicating if the texture is inverted on Y axis
  97083. */
  97084. invertY: boolean;
  97085. /** @hidden */
  97086. _invertVScale: boolean;
  97087. /** @hidden */
  97088. _associatedChannel: number;
  97089. /** @hidden */
  97090. _source: InternalTextureSource;
  97091. /** @hidden */
  97092. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97093. /** @hidden */
  97094. _bufferView: Nullable<ArrayBufferView>;
  97095. /** @hidden */
  97096. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97097. /** @hidden */
  97098. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97099. /** @hidden */
  97100. _size: number;
  97101. /** @hidden */
  97102. _extension: string;
  97103. /** @hidden */
  97104. _files: Nullable<string[]>;
  97105. /** @hidden */
  97106. _workingCanvas: Nullable<HTMLCanvasElement>;
  97107. /** @hidden */
  97108. _workingContext: Nullable<CanvasRenderingContext2D>;
  97109. /** @hidden */
  97110. _framebuffer: Nullable<WebGLFramebuffer>;
  97111. /** @hidden */
  97112. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97113. /** @hidden */
  97114. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97115. /** @hidden */
  97116. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97117. /** @hidden */
  97118. _attachments: Nullable<number[]>;
  97119. /** @hidden */
  97120. _cachedCoordinatesMode: Nullable<number>;
  97121. /** @hidden */
  97122. _cachedWrapU: Nullable<number>;
  97123. /** @hidden */
  97124. _cachedWrapV: Nullable<number>;
  97125. /** @hidden */
  97126. _cachedWrapR: Nullable<number>;
  97127. /** @hidden */
  97128. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97129. /** @hidden */
  97130. _isDisabled: boolean;
  97131. /** @hidden */
  97132. _compression: Nullable<string>;
  97133. /** @hidden */
  97134. _generateStencilBuffer: boolean;
  97135. /** @hidden */
  97136. _generateDepthBuffer: boolean;
  97137. /** @hidden */
  97138. _comparisonFunction: number;
  97139. /** @hidden */
  97140. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97141. /** @hidden */
  97142. _lodGenerationScale: number;
  97143. /** @hidden */
  97144. _lodGenerationOffset: number;
  97145. /** @hidden */
  97146. _colorTextureArray: Nullable<WebGLTexture>;
  97147. /** @hidden */
  97148. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97149. /** @hidden */
  97150. _lodTextureHigh: Nullable<BaseTexture>;
  97151. /** @hidden */
  97152. _lodTextureMid: Nullable<BaseTexture>;
  97153. /** @hidden */
  97154. _lodTextureLow: Nullable<BaseTexture>;
  97155. /** @hidden */
  97156. _isRGBD: boolean;
  97157. /** @hidden */
  97158. _linearSpecularLOD: boolean;
  97159. /** @hidden */
  97160. _irradianceTexture: Nullable<BaseTexture>;
  97161. /** @hidden */
  97162. _webGLTexture: Nullable<WebGLTexture>;
  97163. /** @hidden */
  97164. _references: number;
  97165. private _engine;
  97166. /**
  97167. * Gets the Engine the texture belongs to.
  97168. * @returns The babylon engine
  97169. */
  97170. getEngine(): ThinEngine;
  97171. /**
  97172. * Gets the data source type of the texture
  97173. */
  97174. readonly source: InternalTextureSource;
  97175. /**
  97176. * Creates a new InternalTexture
  97177. * @param engine defines the engine to use
  97178. * @param source defines the type of data that will be used
  97179. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97180. */
  97181. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97182. /**
  97183. * Increments the number of references (ie. the number of Texture that point to it)
  97184. */
  97185. incrementReferences(): void;
  97186. /**
  97187. * Change the size of the texture (not the size of the content)
  97188. * @param width defines the new width
  97189. * @param height defines the new height
  97190. * @param depth defines the new depth (1 by default)
  97191. */
  97192. updateSize(width: int, height: int, depth?: int): void;
  97193. /** @hidden */
  97194. _rebuild(): void;
  97195. /** @hidden */
  97196. _swapAndDie(target: InternalTexture): void;
  97197. /**
  97198. * Dispose the current allocated resources
  97199. */
  97200. dispose(): void;
  97201. }
  97202. }
  97203. declare module BABYLON {
  97204. /**
  97205. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97207. */
  97208. export class Analyser {
  97209. /**
  97210. * Gets or sets the smoothing
  97211. * @ignorenaming
  97212. */
  97213. SMOOTHING: number;
  97214. /**
  97215. * Gets or sets the FFT table size
  97216. * @ignorenaming
  97217. */
  97218. FFT_SIZE: number;
  97219. /**
  97220. * Gets or sets the bar graph amplitude
  97221. * @ignorenaming
  97222. */
  97223. BARGRAPHAMPLITUDE: number;
  97224. /**
  97225. * Gets or sets the position of the debug canvas
  97226. * @ignorenaming
  97227. */
  97228. DEBUGCANVASPOS: {
  97229. x: number;
  97230. y: number;
  97231. };
  97232. /**
  97233. * Gets or sets the debug canvas size
  97234. * @ignorenaming
  97235. */
  97236. DEBUGCANVASSIZE: {
  97237. width: number;
  97238. height: number;
  97239. };
  97240. private _byteFreqs;
  97241. private _byteTime;
  97242. private _floatFreqs;
  97243. private _webAudioAnalyser;
  97244. private _debugCanvas;
  97245. private _debugCanvasContext;
  97246. private _scene;
  97247. private _registerFunc;
  97248. private _audioEngine;
  97249. /**
  97250. * Creates a new analyser
  97251. * @param scene defines hosting scene
  97252. */
  97253. constructor(scene: Scene);
  97254. /**
  97255. * Get the number of data values you will have to play with for the visualization
  97256. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97257. * @returns a number
  97258. */
  97259. getFrequencyBinCount(): number;
  97260. /**
  97261. * Gets the current frequency data as a byte array
  97262. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97263. * @returns a Uint8Array
  97264. */
  97265. getByteFrequencyData(): Uint8Array;
  97266. /**
  97267. * Gets the current waveform as a byte array
  97268. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97269. * @returns a Uint8Array
  97270. */
  97271. getByteTimeDomainData(): Uint8Array;
  97272. /**
  97273. * Gets the current frequency data as a float array
  97274. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97275. * @returns a Float32Array
  97276. */
  97277. getFloatFrequencyData(): Float32Array;
  97278. /**
  97279. * Renders the debug canvas
  97280. */
  97281. drawDebugCanvas(): void;
  97282. /**
  97283. * Stops rendering the debug canvas and removes it
  97284. */
  97285. stopDebugCanvas(): void;
  97286. /**
  97287. * Connects two audio nodes
  97288. * @param inputAudioNode defines first node to connect
  97289. * @param outputAudioNode defines second node to connect
  97290. */
  97291. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97292. /**
  97293. * Releases all associated resources
  97294. */
  97295. dispose(): void;
  97296. }
  97297. }
  97298. declare module BABYLON {
  97299. /**
  97300. * This represents an audio engine and it is responsible
  97301. * to play, synchronize and analyse sounds throughout the application.
  97302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97303. */
  97304. export interface IAudioEngine extends IDisposable {
  97305. /**
  97306. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97307. */
  97308. readonly canUseWebAudio: boolean;
  97309. /**
  97310. * Gets the current AudioContext if available.
  97311. */
  97312. readonly audioContext: Nullable<AudioContext>;
  97313. /**
  97314. * The master gain node defines the global audio volume of your audio engine.
  97315. */
  97316. readonly masterGain: GainNode;
  97317. /**
  97318. * Gets whether or not mp3 are supported by your browser.
  97319. */
  97320. readonly isMP3supported: boolean;
  97321. /**
  97322. * Gets whether or not ogg are supported by your browser.
  97323. */
  97324. readonly isOGGsupported: boolean;
  97325. /**
  97326. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97327. * @ignoreNaming
  97328. */
  97329. WarnedWebAudioUnsupported: boolean;
  97330. /**
  97331. * Defines if the audio engine relies on a custom unlocked button.
  97332. * In this case, the embedded button will not be displayed.
  97333. */
  97334. useCustomUnlockedButton: boolean;
  97335. /**
  97336. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97337. */
  97338. readonly unlocked: boolean;
  97339. /**
  97340. * Event raised when audio has been unlocked on the browser.
  97341. */
  97342. onAudioUnlockedObservable: Observable<AudioEngine>;
  97343. /**
  97344. * Event raised when audio has been locked on the browser.
  97345. */
  97346. onAudioLockedObservable: Observable<AudioEngine>;
  97347. /**
  97348. * Flags the audio engine in Locked state.
  97349. * This happens due to new browser policies preventing audio to autoplay.
  97350. */
  97351. lock(): void;
  97352. /**
  97353. * Unlocks the audio engine once a user action has been done on the dom.
  97354. * This is helpful to resume play once browser policies have been satisfied.
  97355. */
  97356. unlock(): void;
  97357. }
  97358. /**
  97359. * This represents the default audio engine used in babylon.
  97360. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97362. */
  97363. export class AudioEngine implements IAudioEngine {
  97364. private _audioContext;
  97365. private _audioContextInitialized;
  97366. private _muteButton;
  97367. private _hostElement;
  97368. /**
  97369. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97370. */
  97371. canUseWebAudio: boolean;
  97372. /**
  97373. * The master gain node defines the global audio volume of your audio engine.
  97374. */
  97375. masterGain: GainNode;
  97376. /**
  97377. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97378. * @ignoreNaming
  97379. */
  97380. WarnedWebAudioUnsupported: boolean;
  97381. /**
  97382. * Gets whether or not mp3 are supported by your browser.
  97383. */
  97384. isMP3supported: boolean;
  97385. /**
  97386. * Gets whether or not ogg are supported by your browser.
  97387. */
  97388. isOGGsupported: boolean;
  97389. /**
  97390. * Gets whether audio has been unlocked on the device.
  97391. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97392. * a user interaction has happened.
  97393. */
  97394. unlocked: boolean;
  97395. /**
  97396. * Defines if the audio engine relies on a custom unlocked button.
  97397. * In this case, the embedded button will not be displayed.
  97398. */
  97399. useCustomUnlockedButton: boolean;
  97400. /**
  97401. * Event raised when audio has been unlocked on the browser.
  97402. */
  97403. onAudioUnlockedObservable: Observable<AudioEngine>;
  97404. /**
  97405. * Event raised when audio has been locked on the browser.
  97406. */
  97407. onAudioLockedObservable: Observable<AudioEngine>;
  97408. /**
  97409. * Gets the current AudioContext if available.
  97410. */
  97411. readonly audioContext: Nullable<AudioContext>;
  97412. private _connectedAnalyser;
  97413. /**
  97414. * Instantiates a new audio engine.
  97415. *
  97416. * There should be only one per page as some browsers restrict the number
  97417. * of audio contexts you can create.
  97418. * @param hostElement defines the host element where to display the mute icon if necessary
  97419. */
  97420. constructor(hostElement?: Nullable<HTMLElement>);
  97421. /**
  97422. * Flags the audio engine in Locked state.
  97423. * This happens due to new browser policies preventing audio to autoplay.
  97424. */
  97425. lock(): void;
  97426. /**
  97427. * Unlocks the audio engine once a user action has been done on the dom.
  97428. * This is helpful to resume play once browser policies have been satisfied.
  97429. */
  97430. unlock(): void;
  97431. private _resumeAudioContext;
  97432. private _initializeAudioContext;
  97433. private _tryToRun;
  97434. private _triggerRunningState;
  97435. private _triggerSuspendedState;
  97436. private _displayMuteButton;
  97437. private _moveButtonToTopLeft;
  97438. private _onResize;
  97439. private _hideMuteButton;
  97440. /**
  97441. * Destroy and release the resources associated with the audio ccontext.
  97442. */
  97443. dispose(): void;
  97444. /**
  97445. * Gets the global volume sets on the master gain.
  97446. * @returns the global volume if set or -1 otherwise
  97447. */
  97448. getGlobalVolume(): number;
  97449. /**
  97450. * Sets the global volume of your experience (sets on the master gain).
  97451. * @param newVolume Defines the new global volume of the application
  97452. */
  97453. setGlobalVolume(newVolume: number): void;
  97454. /**
  97455. * Connect the audio engine to an audio analyser allowing some amazing
  97456. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97458. * @param analyser The analyser to connect to the engine
  97459. */
  97460. connectToAnalyser(analyser: Analyser): void;
  97461. }
  97462. }
  97463. declare module BABYLON {
  97464. /**
  97465. * Interface used to present a loading screen while loading a scene
  97466. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97467. */
  97468. export interface ILoadingScreen {
  97469. /**
  97470. * Function called to display the loading screen
  97471. */
  97472. displayLoadingUI: () => void;
  97473. /**
  97474. * Function called to hide the loading screen
  97475. */
  97476. hideLoadingUI: () => void;
  97477. /**
  97478. * Gets or sets the color to use for the background
  97479. */
  97480. loadingUIBackgroundColor: string;
  97481. /**
  97482. * Gets or sets the text to display while loading
  97483. */
  97484. loadingUIText: string;
  97485. }
  97486. /**
  97487. * Class used for the default loading screen
  97488. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97489. */
  97490. export class DefaultLoadingScreen implements ILoadingScreen {
  97491. private _renderingCanvas;
  97492. private _loadingText;
  97493. private _loadingDivBackgroundColor;
  97494. private _loadingDiv;
  97495. private _loadingTextDiv;
  97496. /** Gets or sets the logo url to use for the default loading screen */
  97497. static DefaultLogoUrl: string;
  97498. /** Gets or sets the spinner url to use for the default loading screen */
  97499. static DefaultSpinnerUrl: string;
  97500. /**
  97501. * Creates a new default loading screen
  97502. * @param _renderingCanvas defines the canvas used to render the scene
  97503. * @param _loadingText defines the default text to display
  97504. * @param _loadingDivBackgroundColor defines the default background color
  97505. */
  97506. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97507. /**
  97508. * Function called to display the loading screen
  97509. */
  97510. displayLoadingUI(): void;
  97511. /**
  97512. * Function called to hide the loading screen
  97513. */
  97514. hideLoadingUI(): void;
  97515. /**
  97516. * Gets or sets the text to display while loading
  97517. */
  97518. loadingUIText: string;
  97519. /**
  97520. * Gets or sets the color to use for the background
  97521. */
  97522. loadingUIBackgroundColor: string;
  97523. private _resizeLoadingUI;
  97524. }
  97525. }
  97526. declare module BABYLON {
  97527. /**
  97528. * Interface for any object that can request an animation frame
  97529. */
  97530. export interface ICustomAnimationFrameRequester {
  97531. /**
  97532. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97533. */
  97534. renderFunction?: Function;
  97535. /**
  97536. * Called to request the next frame to render to
  97537. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97538. */
  97539. requestAnimationFrame: Function;
  97540. /**
  97541. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97542. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97543. */
  97544. requestID?: number;
  97545. }
  97546. }
  97547. declare module BABYLON {
  97548. /**
  97549. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97550. */
  97551. export class PerformanceMonitor {
  97552. private _enabled;
  97553. private _rollingFrameTime;
  97554. private _lastFrameTimeMs;
  97555. /**
  97556. * constructor
  97557. * @param frameSampleSize The number of samples required to saturate the sliding window
  97558. */
  97559. constructor(frameSampleSize?: number);
  97560. /**
  97561. * Samples current frame
  97562. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97563. */
  97564. sampleFrame(timeMs?: number): void;
  97565. /**
  97566. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97567. */
  97568. readonly averageFrameTime: number;
  97569. /**
  97570. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97571. */
  97572. readonly averageFrameTimeVariance: number;
  97573. /**
  97574. * Returns the frame time of the most recent frame
  97575. */
  97576. readonly instantaneousFrameTime: number;
  97577. /**
  97578. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97579. */
  97580. readonly averageFPS: number;
  97581. /**
  97582. * Returns the average framerate in frames per second using the most recent frame time
  97583. */
  97584. readonly instantaneousFPS: number;
  97585. /**
  97586. * Returns true if enough samples have been taken to completely fill the sliding window
  97587. */
  97588. readonly isSaturated: boolean;
  97589. /**
  97590. * Enables contributions to the sliding window sample set
  97591. */
  97592. enable(): void;
  97593. /**
  97594. * Disables contributions to the sliding window sample set
  97595. * Samples will not be interpolated over the disabled period
  97596. */
  97597. disable(): void;
  97598. /**
  97599. * Returns true if sampling is enabled
  97600. */
  97601. readonly isEnabled: boolean;
  97602. /**
  97603. * Resets performance monitor
  97604. */
  97605. reset(): void;
  97606. }
  97607. /**
  97608. * RollingAverage
  97609. *
  97610. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97611. */
  97612. export class RollingAverage {
  97613. /**
  97614. * Current average
  97615. */
  97616. average: number;
  97617. /**
  97618. * Current variance
  97619. */
  97620. variance: number;
  97621. protected _samples: Array<number>;
  97622. protected _sampleCount: number;
  97623. protected _pos: number;
  97624. protected _m2: number;
  97625. /**
  97626. * constructor
  97627. * @param length The number of samples required to saturate the sliding window
  97628. */
  97629. constructor(length: number);
  97630. /**
  97631. * Adds a sample to the sample set
  97632. * @param v The sample value
  97633. */
  97634. add(v: number): void;
  97635. /**
  97636. * Returns previously added values or null if outside of history or outside the sliding window domain
  97637. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97638. * @return Value previously recorded with add() or null if outside of range
  97639. */
  97640. history(i: number): number;
  97641. /**
  97642. * Returns true if enough samples have been taken to completely fill the sliding window
  97643. * @return true if sample-set saturated
  97644. */
  97645. isSaturated(): boolean;
  97646. /**
  97647. * Resets the rolling average (equivalent to 0 samples taken so far)
  97648. */
  97649. reset(): void;
  97650. /**
  97651. * Wraps a value around the sample range boundaries
  97652. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97653. * @return Wrapped position in sample range
  97654. */
  97655. protected _wrapPosition(i: number): number;
  97656. }
  97657. }
  97658. declare module BABYLON {
  97659. /**
  97660. * This class is used to track a performance counter which is number based.
  97661. * The user has access to many properties which give statistics of different nature.
  97662. *
  97663. * The implementer can track two kinds of Performance Counter: time and count.
  97664. * 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.
  97665. * 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.
  97666. */
  97667. export class PerfCounter {
  97668. /**
  97669. * Gets or sets a global boolean to turn on and off all the counters
  97670. */
  97671. static Enabled: boolean;
  97672. /**
  97673. * Returns the smallest value ever
  97674. */
  97675. readonly min: number;
  97676. /**
  97677. * Returns the biggest value ever
  97678. */
  97679. readonly max: number;
  97680. /**
  97681. * Returns the average value since the performance counter is running
  97682. */
  97683. readonly average: number;
  97684. /**
  97685. * Returns the average value of the last second the counter was monitored
  97686. */
  97687. readonly lastSecAverage: number;
  97688. /**
  97689. * Returns the current value
  97690. */
  97691. readonly current: number;
  97692. /**
  97693. * Gets the accumulated total
  97694. */
  97695. readonly total: number;
  97696. /**
  97697. * Gets the total value count
  97698. */
  97699. readonly count: number;
  97700. /**
  97701. * Creates a new counter
  97702. */
  97703. constructor();
  97704. /**
  97705. * Call this method to start monitoring a new frame.
  97706. * 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.
  97707. */
  97708. fetchNewFrame(): void;
  97709. /**
  97710. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  97711. * @param newCount the count value to add to the monitored count
  97712. * @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.
  97713. */
  97714. addCount(newCount: number, fetchResult: boolean): void;
  97715. /**
  97716. * Start monitoring this performance counter
  97717. */
  97718. beginMonitoring(): void;
  97719. /**
  97720. * Compute the time lapsed since the previous beginMonitoring() call.
  97721. * @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
  97722. */
  97723. endMonitoring(newFrame?: boolean): void;
  97724. private _fetchResult;
  97725. private _startMonitoringTime;
  97726. private _min;
  97727. private _max;
  97728. private _average;
  97729. private _current;
  97730. private _totalValueCount;
  97731. private _totalAccumulated;
  97732. private _lastSecAverage;
  97733. private _lastSecAccumulated;
  97734. private _lastSecTime;
  97735. private _lastSecValueCount;
  97736. }
  97737. }
  97738. declare module BABYLON {
  97739. /**
  97740. * Defines the interface used by display changed events
  97741. */
  97742. export interface IDisplayChangedEventArgs {
  97743. /** Gets the vrDisplay object (if any) */
  97744. vrDisplay: Nullable<any>;
  97745. /** Gets a boolean indicating if webVR is supported */
  97746. vrSupported: boolean;
  97747. }
  97748. /**
  97749. * Defines the interface used by objects containing a viewport (like a camera)
  97750. */
  97751. interface IViewportOwnerLike {
  97752. /**
  97753. * Gets or sets the viewport
  97754. */
  97755. viewport: IViewportLike;
  97756. }
  97757. /**
  97758. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97759. */
  97760. export class Engine extends ThinEngine {
  97761. /** Defines that alpha blending is disabled */
  97762. static readonly ALPHA_DISABLE: number;
  97763. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97764. static readonly ALPHA_ADD: number;
  97765. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97766. static readonly ALPHA_COMBINE: number;
  97767. /** Defines that alpha blending to DEST - SRC * DEST */
  97768. static readonly ALPHA_SUBTRACT: number;
  97769. /** Defines that alpha blending to SRC * DEST */
  97770. static readonly ALPHA_MULTIPLY: number;
  97771. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97772. static readonly ALPHA_MAXIMIZED: number;
  97773. /** Defines that alpha blending to SRC + DEST */
  97774. static readonly ALPHA_ONEONE: number;
  97775. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97776. static readonly ALPHA_PREMULTIPLIED: number;
  97777. /**
  97778. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97779. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97780. */
  97781. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97782. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97783. static readonly ALPHA_INTERPOLATE: number;
  97784. /**
  97785. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97786. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97787. */
  97788. static readonly ALPHA_SCREENMODE: number;
  97789. /** Defines that the ressource is not delayed*/
  97790. static readonly DELAYLOADSTATE_NONE: number;
  97791. /** Defines that the ressource was successfully delay loaded */
  97792. static readonly DELAYLOADSTATE_LOADED: number;
  97793. /** Defines that the ressource is currently delay loading */
  97794. static readonly DELAYLOADSTATE_LOADING: number;
  97795. /** Defines that the ressource is delayed and has not started loading */
  97796. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97797. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97798. static readonly NEVER: number;
  97799. /** 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 */
  97800. static readonly ALWAYS: number;
  97801. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97802. static readonly LESS: number;
  97803. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97804. static readonly EQUAL: number;
  97805. /** 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 */
  97806. static readonly LEQUAL: number;
  97807. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97808. static readonly GREATER: number;
  97809. /** 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 */
  97810. static readonly GEQUAL: number;
  97811. /** 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 */
  97812. static readonly NOTEQUAL: number;
  97813. /** Passed to stencilOperation to specify that stencil value must be kept */
  97814. static readonly KEEP: number;
  97815. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97816. static readonly REPLACE: number;
  97817. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97818. static readonly INCR: number;
  97819. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97820. static readonly DECR: number;
  97821. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97822. static readonly INVERT: number;
  97823. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97824. static readonly INCR_WRAP: number;
  97825. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97826. static readonly DECR_WRAP: number;
  97827. /** Texture is not repeating outside of 0..1 UVs */
  97828. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97829. /** Texture is repeating outside of 0..1 UVs */
  97830. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97831. /** Texture is repeating and mirrored */
  97832. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97833. /** ALPHA */
  97834. static readonly TEXTUREFORMAT_ALPHA: number;
  97835. /** LUMINANCE */
  97836. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97837. /** LUMINANCE_ALPHA */
  97838. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97839. /** RGB */
  97840. static readonly TEXTUREFORMAT_RGB: number;
  97841. /** RGBA */
  97842. static readonly TEXTUREFORMAT_RGBA: number;
  97843. /** RED */
  97844. static readonly TEXTUREFORMAT_RED: number;
  97845. /** RED (2nd reference) */
  97846. static readonly TEXTUREFORMAT_R: number;
  97847. /** RG */
  97848. static readonly TEXTUREFORMAT_RG: number;
  97849. /** RED_INTEGER */
  97850. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97851. /** RED_INTEGER (2nd reference) */
  97852. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97853. /** RG_INTEGER */
  97854. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97855. /** RGB_INTEGER */
  97856. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97857. /** RGBA_INTEGER */
  97858. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97859. /** UNSIGNED_BYTE */
  97860. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97861. /** UNSIGNED_BYTE (2nd reference) */
  97862. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97863. /** FLOAT */
  97864. static readonly TEXTURETYPE_FLOAT: number;
  97865. /** HALF_FLOAT */
  97866. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97867. /** BYTE */
  97868. static readonly TEXTURETYPE_BYTE: number;
  97869. /** SHORT */
  97870. static readonly TEXTURETYPE_SHORT: number;
  97871. /** UNSIGNED_SHORT */
  97872. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97873. /** INT */
  97874. static readonly TEXTURETYPE_INT: number;
  97875. /** UNSIGNED_INT */
  97876. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97877. /** UNSIGNED_SHORT_4_4_4_4 */
  97878. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97879. /** UNSIGNED_SHORT_5_5_5_1 */
  97880. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97881. /** UNSIGNED_SHORT_5_6_5 */
  97882. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97883. /** UNSIGNED_INT_2_10_10_10_REV */
  97884. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97885. /** UNSIGNED_INT_24_8 */
  97886. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97887. /** UNSIGNED_INT_10F_11F_11F_REV */
  97888. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97889. /** UNSIGNED_INT_5_9_9_9_REV */
  97890. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97891. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97892. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97893. /** nearest is mag = nearest and min = nearest and mip = linear */
  97894. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97895. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97896. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97897. /** Trilinear is mag = linear and min = linear and mip = linear */
  97898. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97899. /** nearest is mag = nearest and min = nearest and mip = linear */
  97900. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97901. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97902. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97903. /** Trilinear is mag = linear and min = linear and mip = linear */
  97904. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97905. /** mag = nearest and min = nearest and mip = nearest */
  97906. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97907. /** mag = nearest and min = linear and mip = nearest */
  97908. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97909. /** mag = nearest and min = linear and mip = linear */
  97910. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97911. /** mag = nearest and min = linear and mip = none */
  97912. static readonly TEXTURE_NEAREST_LINEAR: number;
  97913. /** mag = nearest and min = nearest and mip = none */
  97914. static readonly TEXTURE_NEAREST_NEAREST: number;
  97915. /** mag = linear and min = nearest and mip = nearest */
  97916. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97917. /** mag = linear and min = nearest and mip = linear */
  97918. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97919. /** mag = linear and min = linear and mip = none */
  97920. static readonly TEXTURE_LINEAR_LINEAR: number;
  97921. /** mag = linear and min = nearest and mip = none */
  97922. static readonly TEXTURE_LINEAR_NEAREST: number;
  97923. /** Explicit coordinates mode */
  97924. static readonly TEXTURE_EXPLICIT_MODE: number;
  97925. /** Spherical coordinates mode */
  97926. static readonly TEXTURE_SPHERICAL_MODE: number;
  97927. /** Planar coordinates mode */
  97928. static readonly TEXTURE_PLANAR_MODE: number;
  97929. /** Cubic coordinates mode */
  97930. static readonly TEXTURE_CUBIC_MODE: number;
  97931. /** Projection coordinates mode */
  97932. static readonly TEXTURE_PROJECTION_MODE: number;
  97933. /** Skybox coordinates mode */
  97934. static readonly TEXTURE_SKYBOX_MODE: number;
  97935. /** Inverse Cubic coordinates mode */
  97936. static readonly TEXTURE_INVCUBIC_MODE: number;
  97937. /** Equirectangular coordinates mode */
  97938. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97939. /** Equirectangular Fixed coordinates mode */
  97940. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97941. /** Equirectangular Fixed Mirrored coordinates mode */
  97942. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97943. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97944. static readonly SCALEMODE_FLOOR: number;
  97945. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97946. static readonly SCALEMODE_NEAREST: number;
  97947. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97948. static readonly SCALEMODE_CEILING: number;
  97949. /**
  97950. * Returns the current npm package of the sdk
  97951. */
  97952. static readonly NpmPackage: string;
  97953. /**
  97954. * Returns the current version of the framework
  97955. */
  97956. static readonly Version: string;
  97957. /** Gets the list of created engines */
  97958. static readonly Instances: Engine[];
  97959. /**
  97960. * Gets the latest created engine
  97961. */
  97962. static readonly LastCreatedEngine: Nullable<Engine>;
  97963. /**
  97964. * Gets the latest created scene
  97965. */
  97966. static readonly LastCreatedScene: Nullable<Scene>;
  97967. /**
  97968. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97969. * @param flag defines which part of the materials must be marked as dirty
  97970. * @param predicate defines a predicate used to filter which materials should be affected
  97971. */
  97972. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97973. /**
  97974. * Method called to create the default loading screen.
  97975. * This can be overriden in your own app.
  97976. * @param canvas The rendering canvas element
  97977. * @returns The loading screen
  97978. */
  97979. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97980. /**
  97981. * Method called to create the default rescale post process on each engine.
  97982. */
  97983. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97984. /**
  97985. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97986. **/
  97987. enableOfflineSupport: boolean;
  97988. /**
  97989. * 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)
  97990. **/
  97991. disableManifestCheck: boolean;
  97992. /**
  97993. * Gets the list of created scenes
  97994. */
  97995. scenes: Scene[];
  97996. /**
  97997. * Event raised when a new scene is created
  97998. */
  97999. onNewSceneAddedObservable: Observable<Scene>;
  98000. /**
  98001. * Gets the list of created postprocesses
  98002. */
  98003. postProcesses: PostProcess[];
  98004. /**
  98005. * Gets a boolean indicating if the pointer is currently locked
  98006. */
  98007. isPointerLock: boolean;
  98008. /**
  98009. * Observable event triggered each time the rendering canvas is resized
  98010. */
  98011. onResizeObservable: Observable<Engine>;
  98012. /**
  98013. * Observable event triggered each time the canvas loses focus
  98014. */
  98015. onCanvasBlurObservable: Observable<Engine>;
  98016. /**
  98017. * Observable event triggered each time the canvas gains focus
  98018. */
  98019. onCanvasFocusObservable: Observable<Engine>;
  98020. /**
  98021. * Observable event triggered each time the canvas receives pointerout event
  98022. */
  98023. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98024. /**
  98025. * Observable raised when the engine begins a new frame
  98026. */
  98027. onBeginFrameObservable: Observable<Engine>;
  98028. /**
  98029. * If set, will be used to request the next animation frame for the render loop
  98030. */
  98031. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98032. /**
  98033. * Observable raised when the engine ends the current frame
  98034. */
  98035. onEndFrameObservable: Observable<Engine>;
  98036. /**
  98037. * Observable raised when the engine is about to compile a shader
  98038. */
  98039. onBeforeShaderCompilationObservable: Observable<Engine>;
  98040. /**
  98041. * Observable raised when the engine has jsut compiled a shader
  98042. */
  98043. onAfterShaderCompilationObservable: Observable<Engine>;
  98044. /**
  98045. * Gets the audio engine
  98046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98047. * @ignorenaming
  98048. */
  98049. static audioEngine: IAudioEngine;
  98050. /**
  98051. * Default AudioEngine factory responsible of creating the Audio Engine.
  98052. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98053. */
  98054. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98055. /**
  98056. * Default offline support factory responsible of creating a tool used to store data locally.
  98057. * By default, this will create a Database object if the workload has been embedded.
  98058. */
  98059. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98060. private _loadingScreen;
  98061. private _pointerLockRequested;
  98062. private _dummyFramebuffer;
  98063. private _rescalePostProcess;
  98064. /** @hidden */
  98065. protected _alphaMode: number;
  98066. /** @hidden */
  98067. protected _alphaEquation: number;
  98068. private _deterministicLockstep;
  98069. private _lockstepMaxSteps;
  98070. protected readonly _supportsHardwareTextureRescaling: boolean;
  98071. private _fps;
  98072. private _deltaTime;
  98073. /** @hidden */
  98074. _drawCalls: PerfCounter;
  98075. /**
  98076. * Turn this value on if you want to pause FPS computation when in background
  98077. */
  98078. disablePerformanceMonitorInBackground: boolean;
  98079. private _performanceMonitor;
  98080. /**
  98081. * Gets the performance monitor attached to this engine
  98082. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98083. */
  98084. readonly performanceMonitor: PerformanceMonitor;
  98085. private _onFocus;
  98086. private _onBlur;
  98087. private _onCanvasPointerOut;
  98088. private _onCanvasBlur;
  98089. private _onCanvasFocus;
  98090. private _onFullscreenChange;
  98091. private _onPointerLockChange;
  98092. /**
  98093. * Creates a new engine
  98094. * @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
  98095. * @param antialias defines enable antialiasing (default: false)
  98096. * @param options defines further options to be sent to the getContext() function
  98097. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98098. */
  98099. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98100. /**
  98101. * Gets current aspect ratio
  98102. * @param viewportOwner defines the camera to use to get the aspect ratio
  98103. * @param useScreen defines if screen size must be used (or the current render target if any)
  98104. * @returns a number defining the aspect ratio
  98105. */
  98106. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98107. /**
  98108. * Gets current screen aspect ratio
  98109. * @returns a number defining the aspect ratio
  98110. */
  98111. getScreenAspectRatio(): number;
  98112. /**
  98113. * Gets host document
  98114. * @returns the host document object
  98115. */
  98116. getHostDocument(): Document;
  98117. /**
  98118. * Gets the client rect of the HTML canvas attached with the current webGL context
  98119. * @returns a client rectanglee
  98120. */
  98121. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98122. /**
  98123. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98125. * @returns true if engine is in deterministic lock step mode
  98126. */
  98127. isDeterministicLockStep(): boolean;
  98128. /**
  98129. * Gets the max steps when engine is running in deterministic lock step
  98130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98131. * @returns the max steps
  98132. */
  98133. getLockstepMaxSteps(): number;
  98134. /**
  98135. * Force the mipmap generation for the given render target texture
  98136. * @param texture defines the render target texture to use
  98137. */
  98138. generateMipMapsForCubemap(texture: InternalTexture): void;
  98139. /** States */
  98140. /**
  98141. * Set various states to the webGL context
  98142. * @param culling defines backface culling state
  98143. * @param zOffset defines the value to apply to zOffset (0 by default)
  98144. * @param force defines if states must be applied even if cache is up to date
  98145. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98146. */
  98147. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98148. /**
  98149. * Set the z offset to apply to current rendering
  98150. * @param value defines the offset to apply
  98151. */
  98152. setZOffset(value: number): void;
  98153. /**
  98154. * Gets the current value of the zOffset
  98155. * @returns the current zOffset state
  98156. */
  98157. getZOffset(): number;
  98158. /**
  98159. * Enable or disable depth buffering
  98160. * @param enable defines the state to set
  98161. */
  98162. setDepthBuffer(enable: boolean): void;
  98163. /**
  98164. * Gets a boolean indicating if depth writing is enabled
  98165. * @returns the current depth writing state
  98166. */
  98167. getDepthWrite(): boolean;
  98168. /**
  98169. * Enable or disable depth writing
  98170. * @param enable defines the state to set
  98171. */
  98172. setDepthWrite(enable: boolean): void;
  98173. /**
  98174. * Enable or disable color writing
  98175. * @param enable defines the state to set
  98176. */
  98177. setColorWrite(enable: boolean): void;
  98178. /**
  98179. * Gets a boolean indicating if color writing is enabled
  98180. * @returns the current color writing state
  98181. */
  98182. getColorWrite(): boolean;
  98183. /**
  98184. * Sets alpha constants used by some alpha blending modes
  98185. * @param r defines the red component
  98186. * @param g defines the green component
  98187. * @param b defines the blue component
  98188. * @param a defines the alpha component
  98189. */
  98190. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98191. /**
  98192. * Sets the current alpha mode
  98193. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98194. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98195. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98196. */
  98197. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98198. /**
  98199. * Gets the current alpha mode
  98200. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98201. * @returns the current alpha mode
  98202. */
  98203. getAlphaMode(): number;
  98204. /**
  98205. * Sets the current alpha equation
  98206. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98207. */
  98208. setAlphaEquation(equation: number): void;
  98209. /**
  98210. * Gets the current alpha equation.
  98211. * @returns the current alpha equation
  98212. */
  98213. getAlphaEquation(): number;
  98214. /**
  98215. * Gets a boolean indicating if stencil buffer is enabled
  98216. * @returns the current stencil buffer state
  98217. */
  98218. getStencilBuffer(): boolean;
  98219. /**
  98220. * Enable or disable the stencil buffer
  98221. * @param enable defines if the stencil buffer must be enabled or disabled
  98222. */
  98223. setStencilBuffer(enable: boolean): void;
  98224. /**
  98225. * Gets the current stencil mask
  98226. * @returns a number defining the new stencil mask to use
  98227. */
  98228. getStencilMask(): number;
  98229. /**
  98230. * Sets the current stencil mask
  98231. * @param mask defines the new stencil mask to use
  98232. */
  98233. setStencilMask(mask: number): void;
  98234. /**
  98235. * Gets the current stencil function
  98236. * @returns a number defining the stencil function to use
  98237. */
  98238. getStencilFunction(): number;
  98239. /**
  98240. * Gets the current stencil reference value
  98241. * @returns a number defining the stencil reference value to use
  98242. */
  98243. getStencilFunctionReference(): number;
  98244. /**
  98245. * Gets the current stencil mask
  98246. * @returns a number defining the stencil mask to use
  98247. */
  98248. getStencilFunctionMask(): number;
  98249. /**
  98250. * Sets the current stencil function
  98251. * @param stencilFunc defines the new stencil function to use
  98252. */
  98253. setStencilFunction(stencilFunc: number): void;
  98254. /**
  98255. * Sets the current stencil reference
  98256. * @param reference defines the new stencil reference to use
  98257. */
  98258. setStencilFunctionReference(reference: number): void;
  98259. /**
  98260. * Sets the current stencil mask
  98261. * @param mask defines the new stencil mask to use
  98262. */
  98263. setStencilFunctionMask(mask: number): void;
  98264. /**
  98265. * Gets the current stencil operation when stencil fails
  98266. * @returns a number defining stencil operation to use when stencil fails
  98267. */
  98268. getStencilOperationFail(): number;
  98269. /**
  98270. * Gets the current stencil operation when depth fails
  98271. * @returns a number defining stencil operation to use when depth fails
  98272. */
  98273. getStencilOperationDepthFail(): number;
  98274. /**
  98275. * Gets the current stencil operation when stencil passes
  98276. * @returns a number defining stencil operation to use when stencil passes
  98277. */
  98278. getStencilOperationPass(): number;
  98279. /**
  98280. * Sets the stencil operation to use when stencil fails
  98281. * @param operation defines the stencil operation to use when stencil fails
  98282. */
  98283. setStencilOperationFail(operation: number): void;
  98284. /**
  98285. * Sets the stencil operation to use when depth fails
  98286. * @param operation defines the stencil operation to use when depth fails
  98287. */
  98288. setStencilOperationDepthFail(operation: number): void;
  98289. /**
  98290. * Sets the stencil operation to use when stencil passes
  98291. * @param operation defines the stencil operation to use when stencil passes
  98292. */
  98293. setStencilOperationPass(operation: number): void;
  98294. /**
  98295. * Sets a boolean indicating if the dithering state is enabled or disabled
  98296. * @param value defines the dithering state
  98297. */
  98298. setDitheringState(value: boolean): void;
  98299. /**
  98300. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98301. * @param value defines the rasterizer state
  98302. */
  98303. setRasterizerState(value: boolean): void;
  98304. /**
  98305. * Gets the current depth function
  98306. * @returns a number defining the depth function
  98307. */
  98308. getDepthFunction(): Nullable<number>;
  98309. /**
  98310. * Sets the current depth function
  98311. * @param depthFunc defines the function to use
  98312. */
  98313. setDepthFunction(depthFunc: number): void;
  98314. /**
  98315. * Sets the current depth function to GREATER
  98316. */
  98317. setDepthFunctionToGreater(): void;
  98318. /**
  98319. * Sets the current depth function to GEQUAL
  98320. */
  98321. setDepthFunctionToGreaterOrEqual(): void;
  98322. /**
  98323. * Sets the current depth function to LESS
  98324. */
  98325. setDepthFunctionToLess(): void;
  98326. /**
  98327. * Sets the current depth function to LEQUAL
  98328. */
  98329. setDepthFunctionToLessOrEqual(): void;
  98330. private _cachedStencilBuffer;
  98331. private _cachedStencilFunction;
  98332. private _cachedStencilMask;
  98333. private _cachedStencilOperationPass;
  98334. private _cachedStencilOperationFail;
  98335. private _cachedStencilOperationDepthFail;
  98336. private _cachedStencilReference;
  98337. /**
  98338. * Caches the the state of the stencil buffer
  98339. */
  98340. cacheStencilState(): void;
  98341. /**
  98342. * Restores the state of the stencil buffer
  98343. */
  98344. restoreStencilState(): void;
  98345. /**
  98346. * Directly set the WebGL Viewport
  98347. * @param x defines the x coordinate of the viewport (in screen space)
  98348. * @param y defines the y coordinate of the viewport (in screen space)
  98349. * @param width defines the width of the viewport (in screen space)
  98350. * @param height defines the height of the viewport (in screen space)
  98351. * @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
  98352. */
  98353. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98354. /**
  98355. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98356. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98357. * @param y defines the y-coordinate of the corner of the clear rectangle
  98358. * @param width defines the width of the clear rectangle
  98359. * @param height defines the height of the clear rectangle
  98360. * @param clearColor defines the clear color
  98361. */
  98362. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98363. /**
  98364. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98365. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98366. * @param y defines the y-coordinate of the corner of the clear rectangle
  98367. * @param width defines the width of the clear rectangle
  98368. * @param height defines the height of the clear rectangle
  98369. */
  98370. enableScissor(x: number, y: number, width: number, height: number): void;
  98371. /**
  98372. * Disable previously set scissor test rectangle
  98373. */
  98374. disableScissor(): void;
  98375. protected _reportDrawCall(): void;
  98376. /**
  98377. * Initializes a webVR display and starts listening to display change events
  98378. * The onVRDisplayChangedObservable will be notified upon these changes
  98379. * @returns The onVRDisplayChangedObservable
  98380. */
  98381. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98382. /** @hidden */
  98383. _prepareVRComponent(): void;
  98384. /** @hidden */
  98385. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98386. /** @hidden */
  98387. _submitVRFrame(): void;
  98388. /**
  98389. * Call this function to leave webVR mode
  98390. * Will do nothing if webVR is not supported or if there is no webVR device
  98391. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98392. */
  98393. disableVR(): void;
  98394. /**
  98395. * Gets a boolean indicating that the system is in VR mode and is presenting
  98396. * @returns true if VR mode is engaged
  98397. */
  98398. isVRPresenting(): boolean;
  98399. /** @hidden */
  98400. _requestVRFrame(): void;
  98401. /** @hidden */
  98402. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98403. /**
  98404. * Gets the source code of the vertex shader associated with a specific webGL program
  98405. * @param program defines the program to use
  98406. * @returns a string containing the source code of the vertex shader associated with the program
  98407. */
  98408. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98409. /**
  98410. * Gets the source code of the fragment shader associated with a specific webGL program
  98411. * @param program defines the program to use
  98412. * @returns a string containing the source code of the fragment shader associated with the program
  98413. */
  98414. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98415. /**
  98416. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98417. * @param x defines the x coordinate of the rectangle where pixels must be read
  98418. * @param y defines the y coordinate of the rectangle where pixels must be read
  98419. * @param width defines the width of the rectangle where pixels must be read
  98420. * @param height defines the height of the rectangle where pixels must be read
  98421. * @returns a Uint8Array containing RGBA colors
  98422. */
  98423. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98424. /**
  98425. * Sets a depth stencil texture from a render target to the according uniform.
  98426. * @param channel The texture channel
  98427. * @param uniform The uniform to set
  98428. * @param texture The render target texture containing the depth stencil texture to apply
  98429. */
  98430. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98431. /**
  98432. * Sets a texture to the webGL context from a postprocess
  98433. * @param channel defines the channel to use
  98434. * @param postProcess defines the source postprocess
  98435. */
  98436. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98437. /**
  98438. * Binds the output of the passed in post process to the texture channel specified
  98439. * @param channel The channel the texture should be bound to
  98440. * @param postProcess The post process which's output should be bound
  98441. */
  98442. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98443. /** @hidden */
  98444. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98445. protected _rebuildBuffers(): void;
  98446. _renderLoop(): void;
  98447. /**
  98448. * Toggle full screen mode
  98449. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98450. */
  98451. switchFullscreen(requestPointerLock: boolean): void;
  98452. /**
  98453. * Enters full screen mode
  98454. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98455. */
  98456. enterFullscreen(requestPointerLock: boolean): void;
  98457. /**
  98458. * Exits full screen mode
  98459. */
  98460. exitFullscreen(): void;
  98461. /**
  98462. * Enters Pointerlock mode
  98463. */
  98464. enterPointerlock(): void;
  98465. /**
  98466. * Exits Pointerlock mode
  98467. */
  98468. exitPointerlock(): void;
  98469. /**
  98470. * Begin a new frame
  98471. */
  98472. beginFrame(): void;
  98473. /**
  98474. * Enf the current frame
  98475. */
  98476. endFrame(): void;
  98477. resize(): void;
  98478. /**
  98479. * Set the compressed texture format to use, based on the formats you have, and the formats
  98480. * supported by the hardware / browser.
  98481. *
  98482. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98483. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98484. * to API arguments needed to compressed textures. This puts the burden on the container
  98485. * generator to house the arcane code for determining these for current & future formats.
  98486. *
  98487. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98488. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98489. *
  98490. * Note: The result of this call is not taken into account when a texture is base64.
  98491. *
  98492. * @param formatsAvailable defines the list of those format families you have created
  98493. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98494. *
  98495. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98496. * @returns The extension selected.
  98497. */
  98498. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98499. /**
  98500. * Force a specific size of the canvas
  98501. * @param width defines the new canvas' width
  98502. * @param height defines the new canvas' height
  98503. */
  98504. setSize(width: number, height: number): void;
  98505. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98506. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98507. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98508. _releaseTexture(texture: InternalTexture): void;
  98509. /**
  98510. * @hidden
  98511. * Rescales a texture
  98512. * @param source input texutre
  98513. * @param destination destination texture
  98514. * @param scene scene to use to render the resize
  98515. * @param internalFormat format to use when resizing
  98516. * @param onComplete callback to be called when resize has completed
  98517. */
  98518. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98519. /**
  98520. * Gets the current framerate
  98521. * @returns a number representing the framerate
  98522. */
  98523. getFps(): number;
  98524. /**
  98525. * Gets the time spent between current and previous frame
  98526. * @returns a number representing the delta time in ms
  98527. */
  98528. getDeltaTime(): number;
  98529. private _measureFps;
  98530. /**
  98531. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98532. * @param renderTarget The render target to set the frame buffer for
  98533. */
  98534. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98535. /**
  98536. * Update a dynamic index buffer
  98537. * @param indexBuffer defines the target index buffer
  98538. * @param indices defines the data to update
  98539. * @param offset defines the offset in the target index buffer where update should start
  98540. */
  98541. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98542. /**
  98543. * Updates the sample count of a render target texture
  98544. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98545. * @param texture defines the texture to update
  98546. * @param samples defines the sample count to set
  98547. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98548. */
  98549. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98550. /** @hidden */
  98551. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98552. dispose(): void;
  98553. private _disableTouchAction;
  98554. /**
  98555. * Display the loading screen
  98556. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98557. */
  98558. displayLoadingUI(): void;
  98559. /**
  98560. * Hide the loading screen
  98561. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98562. */
  98563. hideLoadingUI(): void;
  98564. /**
  98565. * Gets the current loading screen object
  98566. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98567. */
  98568. /**
  98569. * Sets the current loading screen object
  98570. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98571. */
  98572. loadingScreen: ILoadingScreen;
  98573. /**
  98574. * Sets the current loading screen text
  98575. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98576. */
  98577. loadingUIText: string;
  98578. /**
  98579. * Sets the current loading screen background color
  98580. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98581. */
  98582. loadingUIBackgroundColor: string;
  98583. /** Pointerlock and fullscreen */
  98584. /**
  98585. * Ask the browser to promote the current element to pointerlock mode
  98586. * @param element defines the DOM element to promote
  98587. */
  98588. static _RequestPointerlock(element: HTMLElement): void;
  98589. /**
  98590. * Asks the browser to exit pointerlock mode
  98591. */
  98592. static _ExitPointerlock(): void;
  98593. /**
  98594. * Ask the browser to promote the current element to fullscreen rendering mode
  98595. * @param element defines the DOM element to promote
  98596. */
  98597. static _RequestFullscreen(element: HTMLElement): void;
  98598. /**
  98599. * Asks the browser to exit fullscreen mode
  98600. */
  98601. static _ExitFullscreen(): void;
  98602. }
  98603. }
  98604. declare module BABYLON {
  98605. /**
  98606. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98607. * during the life time of the application.
  98608. */
  98609. export class EngineStore {
  98610. /** Gets the list of created engines */
  98611. static Instances: Engine[];
  98612. /** @hidden */
  98613. static _LastCreatedScene: Nullable<Scene>;
  98614. /**
  98615. * Gets the latest created engine
  98616. */
  98617. static readonly LastCreatedEngine: Nullable<Engine>;
  98618. /**
  98619. * Gets the latest created scene
  98620. */
  98621. static readonly LastCreatedScene: Nullable<Scene>;
  98622. /**
  98623. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98624. * @ignorenaming
  98625. */
  98626. static UseFallbackTexture: boolean;
  98627. /**
  98628. * Texture content used if a texture cannot loaded
  98629. * @ignorenaming
  98630. */
  98631. static FallbackTexture: string;
  98632. }
  98633. }
  98634. declare module BABYLON {
  98635. /**
  98636. * Helper class that provides a small promise polyfill
  98637. */
  98638. export class PromisePolyfill {
  98639. /**
  98640. * Static function used to check if the polyfill is required
  98641. * If this is the case then the function will inject the polyfill to window.Promise
  98642. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98643. */
  98644. static Apply(force?: boolean): void;
  98645. }
  98646. }
  98647. declare module BABYLON {
  98648. /**
  98649. * Interface for screenshot methods with describe argument called `size` as object with options
  98650. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98651. */
  98652. export interface IScreenshotSize {
  98653. /**
  98654. * number in pixels for canvas height
  98655. */
  98656. height?: number;
  98657. /**
  98658. * multiplier allowing render at a higher or lower resolution
  98659. * If value is defined then height and width will be ignored and taken from camera
  98660. */
  98661. precision?: number;
  98662. /**
  98663. * number in pixels for canvas width
  98664. */
  98665. width?: number;
  98666. }
  98667. }
  98668. declare module BABYLON {
  98669. interface IColor4Like {
  98670. r: float;
  98671. g: float;
  98672. b: float;
  98673. a: float;
  98674. }
  98675. /**
  98676. * Class containing a set of static utilities functions
  98677. */
  98678. export class Tools {
  98679. /**
  98680. * Gets or sets the base URL to use to load assets
  98681. */
  98682. static BaseUrl: string;
  98683. /**
  98684. * Enable/Disable Custom HTTP Request Headers globally.
  98685. * default = false
  98686. * @see CustomRequestHeaders
  98687. */
  98688. static UseCustomRequestHeaders: boolean;
  98689. /**
  98690. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98691. * i.e. when loading files, where the server/service expects an Authorization header
  98692. */
  98693. static CustomRequestHeaders: {
  98694. [key: string]: string;
  98695. };
  98696. /**
  98697. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98698. */
  98699. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98700. /**
  98701. * Default behaviour for cors in the application.
  98702. * It can be a string if the expected behavior is identical in the entire app.
  98703. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98704. */
  98705. static CorsBehavior: string | ((url: string | string[]) => string);
  98706. /**
  98707. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98708. * @ignorenaming
  98709. */
  98710. static UseFallbackTexture: boolean;
  98711. /**
  98712. * Use this object to register external classes like custom textures or material
  98713. * to allow the laoders to instantiate them
  98714. */
  98715. static RegisteredExternalClasses: {
  98716. [key: string]: Object;
  98717. };
  98718. /**
  98719. * Texture content used if a texture cannot loaded
  98720. * @ignorenaming
  98721. */
  98722. static fallbackTexture: string;
  98723. /**
  98724. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98725. * @param u defines the coordinate on X axis
  98726. * @param v defines the coordinate on Y axis
  98727. * @param width defines the width of the source data
  98728. * @param height defines the height of the source data
  98729. * @param pixels defines the source byte array
  98730. * @param color defines the output color
  98731. */
  98732. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98733. /**
  98734. * Interpolates between a and b via alpha
  98735. * @param a The lower value (returned when alpha = 0)
  98736. * @param b The upper value (returned when alpha = 1)
  98737. * @param alpha The interpolation-factor
  98738. * @return The mixed value
  98739. */
  98740. static Mix(a: number, b: number, alpha: number): number;
  98741. /**
  98742. * Tries to instantiate a new object from a given class name
  98743. * @param className defines the class name to instantiate
  98744. * @returns the new object or null if the system was not able to do the instantiation
  98745. */
  98746. static Instantiate(className: string): any;
  98747. /**
  98748. * Provides a slice function that will work even on IE
  98749. * @param data defines the array to slice
  98750. * @param start defines the start of the data (optional)
  98751. * @param end defines the end of the data (optional)
  98752. * @returns the new sliced array
  98753. */
  98754. static Slice<T>(data: T, start?: number, end?: number): T;
  98755. /**
  98756. * Polyfill for setImmediate
  98757. * @param action defines the action to execute after the current execution block
  98758. */
  98759. static SetImmediate(action: () => void): void;
  98760. /**
  98761. * Function indicating if a number is an exponent of 2
  98762. * @param value defines the value to test
  98763. * @returns true if the value is an exponent of 2
  98764. */
  98765. static IsExponentOfTwo(value: number): boolean;
  98766. private static _tmpFloatArray;
  98767. /**
  98768. * Returns the nearest 32-bit single precision float representation of a Number
  98769. * @param value A Number. If the parameter is of a different type, it will get converted
  98770. * to a number or to NaN if it cannot be converted
  98771. * @returns number
  98772. */
  98773. static FloatRound(value: number): number;
  98774. /**
  98775. * Extracts the filename from a path
  98776. * @param path defines the path to use
  98777. * @returns the filename
  98778. */
  98779. static GetFilename(path: string): string;
  98780. /**
  98781. * Extracts the "folder" part of a path (everything before the filename).
  98782. * @param uri The URI to extract the info from
  98783. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98784. * @returns The "folder" part of the path
  98785. */
  98786. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98787. /**
  98788. * Extracts text content from a DOM element hierarchy
  98789. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98790. */
  98791. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98792. /**
  98793. * Convert an angle in radians to degrees
  98794. * @param angle defines the angle to convert
  98795. * @returns the angle in degrees
  98796. */
  98797. static ToDegrees(angle: number): number;
  98798. /**
  98799. * Convert an angle in degrees to radians
  98800. * @param angle defines the angle to convert
  98801. * @returns the angle in radians
  98802. */
  98803. static ToRadians(angle: number): number;
  98804. /**
  98805. * Encode a buffer to a base64 string
  98806. * @param buffer defines the buffer to encode
  98807. * @returns the encoded string
  98808. */
  98809. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98810. /**
  98811. * Returns an array if obj is not an array
  98812. * @param obj defines the object to evaluate as an array
  98813. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98814. * @returns either obj directly if obj is an array or a new array containing obj
  98815. */
  98816. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98817. /**
  98818. * Gets the pointer prefix to use
  98819. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98820. */
  98821. static GetPointerPrefix(): string;
  98822. /**
  98823. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98824. * @param url define the url we are trying
  98825. * @param element define the dom element where to configure the cors policy
  98826. */
  98827. static SetCorsBehavior(url: string | string[], element: {
  98828. crossOrigin: string | null;
  98829. }): void;
  98830. /**
  98831. * Removes unwanted characters from an url
  98832. * @param url defines the url to clean
  98833. * @returns the cleaned url
  98834. */
  98835. static CleanUrl(url: string): string;
  98836. /**
  98837. * Gets or sets a function used to pre-process url before using them to load assets
  98838. */
  98839. static PreprocessUrl: (url: string) => string;
  98840. /**
  98841. * Loads an image as an HTMLImageElement.
  98842. * @param input url string, ArrayBuffer, or Blob to load
  98843. * @param onLoad callback called when the image successfully loads
  98844. * @param onError callback called when the image fails to load
  98845. * @param offlineProvider offline provider for caching
  98846. * @returns the HTMLImageElement of the loaded image
  98847. */
  98848. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98849. /**
  98850. * Loads a file
  98851. * @param url url string, ArrayBuffer, or Blob to load
  98852. * @param onSuccess callback called when the file successfully loads
  98853. * @param onProgress callback called while file is loading (if the server supports this mode)
  98854. * @param offlineProvider defines the offline provider for caching
  98855. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98856. * @param onError callback called when the file fails to load
  98857. * @returns a file request object
  98858. */
  98859. 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;
  98860. /**
  98861. * Loads a file from a url
  98862. * @param url the file url to load
  98863. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98864. */
  98865. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98866. /**
  98867. * Load a script (identified by an url). When the url returns, the
  98868. * content of this file is added into a new script element, attached to the DOM (body element)
  98869. * @param scriptUrl defines the url of the script to laod
  98870. * @param onSuccess defines the callback called when the script is loaded
  98871. * @param onError defines the callback to call if an error occurs
  98872. * @param scriptId defines the id of the script element
  98873. */
  98874. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98875. /**
  98876. * Load an asynchronous script (identified by an url). When the url returns, the
  98877. * content of this file is added into a new script element, attached to the DOM (body element)
  98878. * @param scriptUrl defines the url of the script to laod
  98879. * @param scriptId defines the id of the script element
  98880. * @returns a promise request object
  98881. */
  98882. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98883. /**
  98884. * Loads a file from a blob
  98885. * @param fileToLoad defines the blob to use
  98886. * @param callback defines the callback to call when data is loaded
  98887. * @param progressCallback defines the callback to call during loading process
  98888. * @returns a file request object
  98889. */
  98890. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98891. /**
  98892. * Loads a file
  98893. * @param fileToLoad defines the file to load
  98894. * @param callback defines the callback to call when data is loaded
  98895. * @param progressCallBack defines the callback to call during loading process
  98896. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98897. * @returns a file request object
  98898. */
  98899. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98900. /**
  98901. * Creates a data url from a given string content
  98902. * @param content defines the content to convert
  98903. * @returns the new data url link
  98904. */
  98905. static FileAsURL(content: string): string;
  98906. /**
  98907. * Format the given number to a specific decimal format
  98908. * @param value defines the number to format
  98909. * @param decimals defines the number of decimals to use
  98910. * @returns the formatted string
  98911. */
  98912. static Format(value: number, decimals?: number): string;
  98913. /**
  98914. * Tries to copy an object by duplicating every property
  98915. * @param source defines the source object
  98916. * @param destination defines the target object
  98917. * @param doNotCopyList defines a list of properties to avoid
  98918. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98919. */
  98920. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98921. /**
  98922. * Gets a boolean indicating if the given object has no own property
  98923. * @param obj defines the object to test
  98924. * @returns true if object has no own property
  98925. */
  98926. static IsEmpty(obj: any): boolean;
  98927. /**
  98928. * Function used to register events at window level
  98929. * @param windowElement defines the Window object to use
  98930. * @param events defines the events to register
  98931. */
  98932. static RegisterTopRootEvents(windowElement: Window, events: {
  98933. name: string;
  98934. handler: Nullable<(e: FocusEvent) => any>;
  98935. }[]): void;
  98936. /**
  98937. * Function used to unregister events from window level
  98938. * @param windowElement defines the Window object to use
  98939. * @param events defines the events to unregister
  98940. */
  98941. static UnregisterTopRootEvents(windowElement: Window, events: {
  98942. name: string;
  98943. handler: Nullable<(e: FocusEvent) => any>;
  98944. }[]): void;
  98945. /**
  98946. * @ignore
  98947. */
  98948. static _ScreenshotCanvas: HTMLCanvasElement;
  98949. /**
  98950. * Dumps the current bound framebuffer
  98951. * @param width defines the rendering width
  98952. * @param height defines the rendering height
  98953. * @param engine defines the hosting engine
  98954. * @param successCallback defines the callback triggered once the data are available
  98955. * @param mimeType defines the mime type of the result
  98956. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98957. */
  98958. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98959. /**
  98960. * Converts the canvas data to blob.
  98961. * This acts as a polyfill for browsers not supporting the to blob function.
  98962. * @param canvas Defines the canvas to extract the data from
  98963. * @param successCallback Defines the callback triggered once the data are available
  98964. * @param mimeType Defines the mime type of the result
  98965. */
  98966. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98967. /**
  98968. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98969. * @param successCallback defines the callback triggered once the data are available
  98970. * @param mimeType defines the mime type of the result
  98971. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98972. */
  98973. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98974. /**
  98975. * Downloads a blob in the browser
  98976. * @param blob defines the blob to download
  98977. * @param fileName defines the name of the downloaded file
  98978. */
  98979. static Download(blob: Blob, fileName: string): void;
  98980. /**
  98981. * Captures a screenshot of the current rendering
  98982. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98983. * @param engine defines the rendering engine
  98984. * @param camera defines the source camera
  98985. * @param size This parameter can be set to a single number or to an object with the
  98986. * following (optional) properties: precision, width, height. If a single number is passed,
  98987. * it will be used for both width and height. If an object is passed, the screenshot size
  98988. * will be derived from the parameters. The precision property is a multiplier allowing
  98989. * rendering at a higher or lower resolution
  98990. * @param successCallback defines the callback receives a single parameter which contains the
  98991. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98992. * src parameter of an <img> to display it
  98993. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98994. * Check your browser for supported MIME types
  98995. */
  98996. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98997. /**
  98998. * Captures a screenshot of the current rendering
  98999. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99000. * @param engine defines the rendering engine
  99001. * @param camera defines the source camera
  99002. * @param size This parameter can be set to a single number or to an object with the
  99003. * following (optional) properties: precision, width, height. If a single number is passed,
  99004. * it will be used for both width and height. If an object is passed, the screenshot size
  99005. * will be derived from the parameters. The precision property is a multiplier allowing
  99006. * rendering at a higher or lower resolution
  99007. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99008. * Check your browser for supported MIME types
  99009. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99010. * to the src parameter of an <img> to display it
  99011. */
  99012. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99013. /**
  99014. * Generates an image screenshot from the specified camera.
  99015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99016. * @param engine The engine to use for rendering
  99017. * @param camera The camera to use for rendering
  99018. * @param size This parameter can be set to a single number or to an object with the
  99019. * following (optional) properties: precision, width, height. If a single number is passed,
  99020. * it will be used for both width and height. If an object is passed, the screenshot size
  99021. * will be derived from the parameters. The precision property is a multiplier allowing
  99022. * rendering at a higher or lower resolution
  99023. * @param successCallback The callback receives a single parameter which contains the
  99024. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99025. * src parameter of an <img> to display it
  99026. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99027. * Check your browser for supported MIME types
  99028. * @param samples Texture samples (default: 1)
  99029. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99030. * @param fileName A name for for the downloaded file.
  99031. */
  99032. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99033. /**
  99034. * Generates an image screenshot from the specified camera.
  99035. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99036. * @param engine The engine to use for rendering
  99037. * @param camera The camera to use for rendering
  99038. * @param size This parameter can be set to a single number or to an object with the
  99039. * following (optional) properties: precision, width, height. If a single number is passed,
  99040. * it will be used for both width and height. If an object is passed, the screenshot size
  99041. * will be derived from the parameters. The precision property is a multiplier allowing
  99042. * rendering at a higher or lower resolution
  99043. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99044. * Check your browser for supported MIME types
  99045. * @param samples Texture samples (default: 1)
  99046. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99047. * @param fileName A name for for the downloaded file.
  99048. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99049. * to the src parameter of an <img> to display it
  99050. */
  99051. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99052. /**
  99053. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99054. * Be aware Math.random() could cause collisions, but:
  99055. * "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"
  99056. * @returns a pseudo random id
  99057. */
  99058. static RandomId(): string;
  99059. /**
  99060. * Test if the given uri is a base64 string
  99061. * @param uri The uri to test
  99062. * @return True if the uri is a base64 string or false otherwise
  99063. */
  99064. static IsBase64(uri: string): boolean;
  99065. /**
  99066. * Decode the given base64 uri.
  99067. * @param uri The uri to decode
  99068. * @return The decoded base64 data.
  99069. */
  99070. static DecodeBase64(uri: string): ArrayBuffer;
  99071. /**
  99072. * Gets the absolute url.
  99073. * @param url the input url
  99074. * @return the absolute url
  99075. */
  99076. static GetAbsoluteUrl(url: string): string;
  99077. /**
  99078. * No log
  99079. */
  99080. static readonly NoneLogLevel: number;
  99081. /**
  99082. * Only message logs
  99083. */
  99084. static readonly MessageLogLevel: number;
  99085. /**
  99086. * Only warning logs
  99087. */
  99088. static readonly WarningLogLevel: number;
  99089. /**
  99090. * Only error logs
  99091. */
  99092. static readonly ErrorLogLevel: number;
  99093. /**
  99094. * All logs
  99095. */
  99096. static readonly AllLogLevel: number;
  99097. /**
  99098. * Gets a value indicating the number of loading errors
  99099. * @ignorenaming
  99100. */
  99101. static readonly errorsCount: number;
  99102. /**
  99103. * Callback called when a new log is added
  99104. */
  99105. static OnNewCacheEntry: (entry: string) => void;
  99106. /**
  99107. * Log a message to the console
  99108. * @param message defines the message to log
  99109. */
  99110. static Log(message: string): void;
  99111. /**
  99112. * Write a warning message to the console
  99113. * @param message defines the message to log
  99114. */
  99115. static Warn(message: string): void;
  99116. /**
  99117. * Write an error message to the console
  99118. * @param message defines the message to log
  99119. */
  99120. static Error(message: string): void;
  99121. /**
  99122. * Gets current log cache (list of logs)
  99123. */
  99124. static readonly LogCache: string;
  99125. /**
  99126. * Clears the log cache
  99127. */
  99128. static ClearLogCache(): void;
  99129. /**
  99130. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99131. */
  99132. static LogLevels: number;
  99133. /**
  99134. * Checks if the window object exists
  99135. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99136. */
  99137. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99138. /**
  99139. * No performance log
  99140. */
  99141. static readonly PerformanceNoneLogLevel: number;
  99142. /**
  99143. * Use user marks to log performance
  99144. */
  99145. static readonly PerformanceUserMarkLogLevel: number;
  99146. /**
  99147. * Log performance to the console
  99148. */
  99149. static readonly PerformanceConsoleLogLevel: number;
  99150. private static _performance;
  99151. /**
  99152. * Sets the current performance log level
  99153. */
  99154. static PerformanceLogLevel: number;
  99155. private static _StartPerformanceCounterDisabled;
  99156. private static _EndPerformanceCounterDisabled;
  99157. private static _StartUserMark;
  99158. private static _EndUserMark;
  99159. private static _StartPerformanceConsole;
  99160. private static _EndPerformanceConsole;
  99161. /**
  99162. * Starts a performance counter
  99163. */
  99164. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99165. /**
  99166. * Ends a specific performance coutner
  99167. */
  99168. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99169. /**
  99170. * Gets either window.performance.now() if supported or Date.now() else
  99171. */
  99172. static readonly Now: number;
  99173. /**
  99174. * This method will return the name of the class used to create the instance of the given object.
  99175. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99176. * @param object the object to get the class name from
  99177. * @param isType defines if the object is actually a type
  99178. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99179. */
  99180. static GetClassName(object: any, isType?: boolean): string;
  99181. /**
  99182. * Gets the first element of an array satisfying a given predicate
  99183. * @param array defines the array to browse
  99184. * @param predicate defines the predicate to use
  99185. * @returns null if not found or the element
  99186. */
  99187. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99188. /**
  99189. * This method will return the name of the full name of the class, including its owning module (if any).
  99190. * 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).
  99191. * @param object the object to get the class name from
  99192. * @param isType defines if the object is actually a type
  99193. * @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.
  99194. * @ignorenaming
  99195. */
  99196. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99197. /**
  99198. * Returns a promise that resolves after the given amount of time.
  99199. * @param delay Number of milliseconds to delay
  99200. * @returns Promise that resolves after the given amount of time
  99201. */
  99202. static DelayAsync(delay: number): Promise<void>;
  99203. }
  99204. /**
  99205. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99206. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99207. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99208. * @param name The name of the class, case should be preserved
  99209. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99210. */
  99211. export function className(name: string, module?: string): (target: Object) => void;
  99212. /**
  99213. * An implementation of a loop for asynchronous functions.
  99214. */
  99215. export class AsyncLoop {
  99216. /**
  99217. * Defines the number of iterations for the loop
  99218. */
  99219. iterations: number;
  99220. /**
  99221. * Defines the current index of the loop.
  99222. */
  99223. index: number;
  99224. private _done;
  99225. private _fn;
  99226. private _successCallback;
  99227. /**
  99228. * Constructor.
  99229. * @param iterations the number of iterations.
  99230. * @param func the function to run each iteration
  99231. * @param successCallback the callback that will be called upon succesful execution
  99232. * @param offset starting offset.
  99233. */
  99234. constructor(
  99235. /**
  99236. * Defines the number of iterations for the loop
  99237. */
  99238. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99239. /**
  99240. * Execute the next iteration. Must be called after the last iteration was finished.
  99241. */
  99242. executeNext(): void;
  99243. /**
  99244. * Break the loop and run the success callback.
  99245. */
  99246. breakLoop(): void;
  99247. /**
  99248. * Create and run an async loop.
  99249. * @param iterations the number of iterations.
  99250. * @param fn the function to run each iteration
  99251. * @param successCallback the callback that will be called upon succesful execution
  99252. * @param offset starting offset.
  99253. * @returns the created async loop object
  99254. */
  99255. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99256. /**
  99257. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99258. * @param iterations total number of iterations
  99259. * @param syncedIterations number of synchronous iterations in each async iteration.
  99260. * @param fn the function to call each iteration.
  99261. * @param callback a success call back that will be called when iterating stops.
  99262. * @param breakFunction a break condition (optional)
  99263. * @param timeout timeout settings for the setTimeout function. default - 0.
  99264. * @returns the created async loop object
  99265. */
  99266. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99267. }
  99268. }
  99269. declare module BABYLON {
  99270. /**
  99271. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99272. * The underlying implementation relies on an associative array to ensure the best performances.
  99273. * The value can be anything including 'null' but except 'undefined'
  99274. */
  99275. export class StringDictionary<T> {
  99276. /**
  99277. * This will clear this dictionary and copy the content from the 'source' one.
  99278. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99279. * @param source the dictionary to take the content from and copy to this dictionary
  99280. */
  99281. copyFrom(source: StringDictionary<T>): void;
  99282. /**
  99283. * Get a value based from its key
  99284. * @param key the given key to get the matching value from
  99285. * @return the value if found, otherwise undefined is returned
  99286. */
  99287. get(key: string): T | undefined;
  99288. /**
  99289. * Get a value from its key or add it if it doesn't exist.
  99290. * This method will ensure you that a given key/data will be present in the dictionary.
  99291. * @param key the given key to get the matching value from
  99292. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99293. * The factory will only be invoked if there's no data for the given key.
  99294. * @return the value corresponding to the key.
  99295. */
  99296. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99297. /**
  99298. * Get a value from its key if present in the dictionary otherwise add it
  99299. * @param key the key to get the value from
  99300. * @param val if there's no such key/value pair in the dictionary add it with this value
  99301. * @return the value corresponding to the key
  99302. */
  99303. getOrAdd(key: string, val: T): T;
  99304. /**
  99305. * Check if there's a given key in the dictionary
  99306. * @param key the key to check for
  99307. * @return true if the key is present, false otherwise
  99308. */
  99309. contains(key: string): boolean;
  99310. /**
  99311. * Add a new key and its corresponding value
  99312. * @param key the key to add
  99313. * @param value the value corresponding to the key
  99314. * @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
  99315. */
  99316. add(key: string, value: T): boolean;
  99317. /**
  99318. * Update a specific value associated to a key
  99319. * @param key defines the key to use
  99320. * @param value defines the value to store
  99321. * @returns true if the value was updated (or false if the key was not found)
  99322. */
  99323. set(key: string, value: T): boolean;
  99324. /**
  99325. * Get the element of the given key and remove it from the dictionary
  99326. * @param key defines the key to search
  99327. * @returns the value associated with the key or null if not found
  99328. */
  99329. getAndRemove(key: string): Nullable<T>;
  99330. /**
  99331. * Remove a key/value from the dictionary.
  99332. * @param key the key to remove
  99333. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99334. */
  99335. remove(key: string): boolean;
  99336. /**
  99337. * Clear the whole content of the dictionary
  99338. */
  99339. clear(): void;
  99340. /**
  99341. * Gets the current count
  99342. */
  99343. readonly count: number;
  99344. /**
  99345. * Execute a callback on each key/val of the dictionary.
  99346. * Note that you can remove any element in this dictionary in the callback implementation
  99347. * @param callback the callback to execute on a given key/value pair
  99348. */
  99349. forEach(callback: (key: string, val: T) => void): void;
  99350. /**
  99351. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99352. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99353. * Note that you can remove any element in this dictionary in the callback implementation
  99354. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99355. * @returns the first item
  99356. */
  99357. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99358. private _count;
  99359. private _data;
  99360. }
  99361. }
  99362. declare module BABYLON {
  99363. /** @hidden */
  99364. export interface ICollisionCoordinator {
  99365. createCollider(): Collider;
  99366. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99367. init(scene: Scene): void;
  99368. }
  99369. /** @hidden */
  99370. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99371. private _scene;
  99372. private _scaledPosition;
  99373. private _scaledVelocity;
  99374. private _finalPosition;
  99375. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99376. createCollider(): Collider;
  99377. init(scene: Scene): void;
  99378. private _collideWithWorld;
  99379. }
  99380. }
  99381. declare module BABYLON {
  99382. /**
  99383. * Class used to manage all inputs for the scene.
  99384. */
  99385. export class InputManager {
  99386. /** The distance in pixel that you have to move to prevent some events */
  99387. static DragMovementThreshold: number;
  99388. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99389. static LongPressDelay: number;
  99390. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99391. static DoubleClickDelay: number;
  99392. /** If you need to check double click without raising a single click at first click, enable this flag */
  99393. static ExclusiveDoubleClickMode: boolean;
  99394. private _wheelEventName;
  99395. private _onPointerMove;
  99396. private _onPointerDown;
  99397. private _onPointerUp;
  99398. private _initClickEvent;
  99399. private _initActionManager;
  99400. private _delayedSimpleClick;
  99401. private _delayedSimpleClickTimeout;
  99402. private _previousDelayedSimpleClickTimeout;
  99403. private _meshPickProceed;
  99404. private _previousButtonPressed;
  99405. private _currentPickResult;
  99406. private _previousPickResult;
  99407. private _totalPointersPressed;
  99408. private _doubleClickOccured;
  99409. private _pointerOverMesh;
  99410. private _pickedDownMesh;
  99411. private _pickedUpMesh;
  99412. private _pointerX;
  99413. private _pointerY;
  99414. private _unTranslatedPointerX;
  99415. private _unTranslatedPointerY;
  99416. private _startingPointerPosition;
  99417. private _previousStartingPointerPosition;
  99418. private _startingPointerTime;
  99419. private _previousStartingPointerTime;
  99420. private _pointerCaptures;
  99421. private _onKeyDown;
  99422. private _onKeyUp;
  99423. private _onCanvasFocusObserver;
  99424. private _onCanvasBlurObserver;
  99425. private _scene;
  99426. /**
  99427. * Creates a new InputManager
  99428. * @param scene defines the hosting scene
  99429. */
  99430. constructor(scene: Scene);
  99431. /**
  99432. * Gets the mesh that is currently under the pointer
  99433. */
  99434. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99435. /**
  99436. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99437. */
  99438. readonly unTranslatedPointer: Vector2;
  99439. /**
  99440. * Gets or sets the current on-screen X position of the pointer
  99441. */
  99442. pointerX: number;
  99443. /**
  99444. * Gets or sets the current on-screen Y position of the pointer
  99445. */
  99446. pointerY: number;
  99447. private _updatePointerPosition;
  99448. private _processPointerMove;
  99449. private _setRayOnPointerInfo;
  99450. private _checkPrePointerObservable;
  99451. /**
  99452. * Use this method to simulate a pointer move on a mesh
  99453. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99454. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99455. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99456. */
  99457. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99458. /**
  99459. * Use this method to simulate a pointer down on a mesh
  99460. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99461. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99462. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99463. */
  99464. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99465. private _processPointerDown;
  99466. /** @hidden */
  99467. _isPointerSwiping(): boolean;
  99468. /**
  99469. * Use this method to simulate a pointer up on a mesh
  99470. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99471. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99472. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99473. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99474. */
  99475. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99476. private _processPointerUp;
  99477. /**
  99478. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99479. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99480. * @returns true if the pointer was captured
  99481. */
  99482. isPointerCaptured(pointerId?: number): boolean;
  99483. /**
  99484. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99485. * @param attachUp defines if you want to attach events to pointerup
  99486. * @param attachDown defines if you want to attach events to pointerdown
  99487. * @param attachMove defines if you want to attach events to pointermove
  99488. */
  99489. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99490. /**
  99491. * Detaches all event handlers
  99492. */
  99493. detachControl(): void;
  99494. /**
  99495. * Force the value of meshUnderPointer
  99496. * @param mesh defines the mesh to use
  99497. */
  99498. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99499. /**
  99500. * Gets the mesh under the pointer
  99501. * @returns a Mesh or null if no mesh is under the pointer
  99502. */
  99503. getPointerOverMesh(): Nullable<AbstractMesh>;
  99504. }
  99505. }
  99506. declare module BABYLON {
  99507. /**
  99508. * Helper class used to generate session unique ID
  99509. */
  99510. export class UniqueIdGenerator {
  99511. private static _UniqueIdCounter;
  99512. /**
  99513. * Gets an unique (relatively to the current scene) Id
  99514. */
  99515. static readonly UniqueId: number;
  99516. }
  99517. }
  99518. declare module BABYLON {
  99519. /**
  99520. * This class defines the direct association between an animation and a target
  99521. */
  99522. export class TargetedAnimation {
  99523. /**
  99524. * Animation to perform
  99525. */
  99526. animation: Animation;
  99527. /**
  99528. * Target to animate
  99529. */
  99530. target: any;
  99531. /**
  99532. * Serialize the object
  99533. * @returns the JSON object representing the current entity
  99534. */
  99535. serialize(): any;
  99536. }
  99537. /**
  99538. * Use this class to create coordinated animations on multiple targets
  99539. */
  99540. export class AnimationGroup implements IDisposable {
  99541. /** The name of the animation group */
  99542. name: string;
  99543. private _scene;
  99544. private _targetedAnimations;
  99545. private _animatables;
  99546. private _from;
  99547. private _to;
  99548. private _isStarted;
  99549. private _isPaused;
  99550. private _speedRatio;
  99551. private _loopAnimation;
  99552. /**
  99553. * Gets or sets the unique id of the node
  99554. */
  99555. uniqueId: number;
  99556. /**
  99557. * This observable will notify when one animation have ended
  99558. */
  99559. onAnimationEndObservable: Observable<TargetedAnimation>;
  99560. /**
  99561. * Observer raised when one animation loops
  99562. */
  99563. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99564. /**
  99565. * This observable will notify when all animations have ended.
  99566. */
  99567. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99568. /**
  99569. * This observable will notify when all animations have paused.
  99570. */
  99571. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99572. /**
  99573. * This observable will notify when all animations are playing.
  99574. */
  99575. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99576. /**
  99577. * Gets the first frame
  99578. */
  99579. readonly from: number;
  99580. /**
  99581. * Gets the last frame
  99582. */
  99583. readonly to: number;
  99584. /**
  99585. * Define if the animations are started
  99586. */
  99587. readonly isStarted: boolean;
  99588. /**
  99589. * Gets a value indicating that the current group is playing
  99590. */
  99591. readonly isPlaying: boolean;
  99592. /**
  99593. * Gets or sets the speed ratio to use for all animations
  99594. */
  99595. /**
  99596. * Gets or sets the speed ratio to use for all animations
  99597. */
  99598. speedRatio: number;
  99599. /**
  99600. * Gets or sets if all animations should loop or not
  99601. */
  99602. loopAnimation: boolean;
  99603. /**
  99604. * Gets the targeted animations for this animation group
  99605. */
  99606. readonly targetedAnimations: Array<TargetedAnimation>;
  99607. /**
  99608. * returning the list of animatables controlled by this animation group.
  99609. */
  99610. readonly animatables: Array<Animatable>;
  99611. /**
  99612. * Instantiates a new Animation Group.
  99613. * This helps managing several animations at once.
  99614. * @see http://doc.babylonjs.com/how_to/group
  99615. * @param name Defines the name of the group
  99616. * @param scene Defines the scene the group belongs to
  99617. */
  99618. constructor(
  99619. /** The name of the animation group */
  99620. name: string, scene?: Nullable<Scene>);
  99621. /**
  99622. * Add an animation (with its target) in the group
  99623. * @param animation defines the animation we want to add
  99624. * @param target defines the target of the animation
  99625. * @returns the TargetedAnimation object
  99626. */
  99627. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99628. /**
  99629. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99630. * It can add constant keys at begin or end
  99631. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99632. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99633. * @returns the animation group
  99634. */
  99635. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99636. /**
  99637. * Start all animations on given targets
  99638. * @param loop defines if animations must loop
  99639. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99640. * @param from defines the from key (optional)
  99641. * @param to defines the to key (optional)
  99642. * @returns the current animation group
  99643. */
  99644. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99645. /**
  99646. * Pause all animations
  99647. * @returns the animation group
  99648. */
  99649. pause(): AnimationGroup;
  99650. /**
  99651. * Play all animations to initial state
  99652. * This function will start() the animations if they were not started or will restart() them if they were paused
  99653. * @param loop defines if animations must loop
  99654. * @returns the animation group
  99655. */
  99656. play(loop?: boolean): AnimationGroup;
  99657. /**
  99658. * Reset all animations to initial state
  99659. * @returns the animation group
  99660. */
  99661. reset(): AnimationGroup;
  99662. /**
  99663. * Restart animations from key 0
  99664. * @returns the animation group
  99665. */
  99666. restart(): AnimationGroup;
  99667. /**
  99668. * Stop all animations
  99669. * @returns the animation group
  99670. */
  99671. stop(): AnimationGroup;
  99672. /**
  99673. * Set animation weight for all animatables
  99674. * @param weight defines the weight to use
  99675. * @return the animationGroup
  99676. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99677. */
  99678. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99679. /**
  99680. * Synchronize and normalize all animatables with a source animatable
  99681. * @param root defines the root animatable to synchronize with
  99682. * @return the animationGroup
  99683. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99684. */
  99685. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99686. /**
  99687. * Goes to a specific frame in this animation group
  99688. * @param frame the frame number to go to
  99689. * @return the animationGroup
  99690. */
  99691. goToFrame(frame: number): AnimationGroup;
  99692. /**
  99693. * Dispose all associated resources
  99694. */
  99695. dispose(): void;
  99696. private _checkAnimationGroupEnded;
  99697. /**
  99698. * Clone the current animation group and returns a copy
  99699. * @param newName defines the name of the new group
  99700. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99701. * @returns the new aniamtion group
  99702. */
  99703. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99704. /**
  99705. * Serializes the animationGroup to an object
  99706. * @returns Serialized object
  99707. */
  99708. serialize(): any;
  99709. /**
  99710. * Returns a new AnimationGroup object parsed from the source provided.
  99711. * @param parsedAnimationGroup defines the source
  99712. * @param scene defines the scene that will receive the animationGroup
  99713. * @returns a new AnimationGroup
  99714. */
  99715. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99716. /**
  99717. * Returns the string "AnimationGroup"
  99718. * @returns "AnimationGroup"
  99719. */
  99720. getClassName(): string;
  99721. /**
  99722. * Creates a detailled string about the object
  99723. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99724. * @returns a string representing the object
  99725. */
  99726. toString(fullDetails?: boolean): string;
  99727. }
  99728. }
  99729. declare module BABYLON {
  99730. /**
  99731. * Define an interface for all classes that will hold resources
  99732. */
  99733. export interface IDisposable {
  99734. /**
  99735. * Releases all held resources
  99736. */
  99737. dispose(): void;
  99738. }
  99739. /** Interface defining initialization parameters for Scene class */
  99740. export interface SceneOptions {
  99741. /**
  99742. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99743. * It will improve performance when the number of geometries becomes important.
  99744. */
  99745. useGeometryUniqueIdsMap?: boolean;
  99746. /**
  99747. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99748. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99749. */
  99750. useMaterialMeshMap?: boolean;
  99751. /**
  99752. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99753. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99754. */
  99755. useClonedMeshhMap?: boolean;
  99756. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99757. virtual?: boolean;
  99758. }
  99759. /**
  99760. * Represents a scene to be rendered by the engine.
  99761. * @see http://doc.babylonjs.com/features/scene
  99762. */
  99763. export class Scene extends AbstractScene implements IAnimatable {
  99764. /** The fog is deactivated */
  99765. static readonly FOGMODE_NONE: number;
  99766. /** The fog density is following an exponential function */
  99767. static readonly FOGMODE_EXP: number;
  99768. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99769. static readonly FOGMODE_EXP2: number;
  99770. /** The fog density is following a linear function. */
  99771. static readonly FOGMODE_LINEAR: number;
  99772. /**
  99773. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99774. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99775. */
  99776. static MinDeltaTime: number;
  99777. /**
  99778. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99780. */
  99781. static MaxDeltaTime: number;
  99782. /**
  99783. * Factory used to create the default material.
  99784. * @param name The name of the material to create
  99785. * @param scene The scene to create the material for
  99786. * @returns The default material
  99787. */
  99788. static DefaultMaterialFactory(scene: Scene): Material;
  99789. /**
  99790. * Factory used to create the a collision coordinator.
  99791. * @returns The collision coordinator
  99792. */
  99793. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99794. /** @hidden */
  99795. _inputManager: InputManager;
  99796. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99797. cameraToUseForPointers: Nullable<Camera>;
  99798. /** @hidden */
  99799. readonly _isScene: boolean;
  99800. /**
  99801. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99802. */
  99803. autoClear: boolean;
  99804. /**
  99805. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99806. */
  99807. autoClearDepthAndStencil: boolean;
  99808. /**
  99809. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99810. */
  99811. clearColor: Color4;
  99812. /**
  99813. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99814. */
  99815. ambientColor: Color3;
  99816. /**
  99817. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99818. * It should only be one of the following (if not the default embedded one):
  99819. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99820. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99821. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99822. * The material properties need to be setup according to the type of texture in use.
  99823. */
  99824. environmentBRDFTexture: BaseTexture;
  99825. /** @hidden */
  99826. protected _environmentTexture: Nullable<BaseTexture>;
  99827. /**
  99828. * Texture used in all pbr material as the reflection texture.
  99829. * As in the majority of the scene they are the same (exception for multi room and so on),
  99830. * this is easier to reference from here than from all the materials.
  99831. */
  99832. /**
  99833. * Texture used in all pbr material as the reflection texture.
  99834. * As in the majority of the scene they are the same (exception for multi room and so on),
  99835. * this is easier to set here than in all the materials.
  99836. */
  99837. environmentTexture: Nullable<BaseTexture>;
  99838. /** @hidden */
  99839. protected _environmentIntensity: number;
  99840. /**
  99841. * Intensity of the environment in all pbr material.
  99842. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99843. * As in the majority of the scene they are the same (exception for multi room and so on),
  99844. * this is easier to reference from here than from all the materials.
  99845. */
  99846. /**
  99847. * Intensity of the environment in all pbr material.
  99848. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99849. * As in the majority of the scene they are the same (exception for multi room and so on),
  99850. * this is easier to set here than in all the materials.
  99851. */
  99852. environmentIntensity: number;
  99853. /** @hidden */
  99854. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99855. /**
  99856. * Default image processing configuration used either in the rendering
  99857. * Forward main pass or through the imageProcessingPostProcess if present.
  99858. * As in the majority of the scene they are the same (exception for multi camera),
  99859. * this is easier to reference from here than from all the materials and post process.
  99860. *
  99861. * No setter as we it is a shared configuration, you can set the values instead.
  99862. */
  99863. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99864. private _forceWireframe;
  99865. /**
  99866. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99867. */
  99868. forceWireframe: boolean;
  99869. private _forcePointsCloud;
  99870. /**
  99871. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99872. */
  99873. forcePointsCloud: boolean;
  99874. /**
  99875. * Gets or sets the active clipplane 1
  99876. */
  99877. clipPlane: Nullable<Plane>;
  99878. /**
  99879. * Gets or sets the active clipplane 2
  99880. */
  99881. clipPlane2: Nullable<Plane>;
  99882. /**
  99883. * Gets or sets the active clipplane 3
  99884. */
  99885. clipPlane3: Nullable<Plane>;
  99886. /**
  99887. * Gets or sets the active clipplane 4
  99888. */
  99889. clipPlane4: Nullable<Plane>;
  99890. /**
  99891. * Gets or sets a boolean indicating if animations are enabled
  99892. */
  99893. animationsEnabled: boolean;
  99894. private _animationPropertiesOverride;
  99895. /**
  99896. * Gets or sets the animation properties override
  99897. */
  99898. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99899. /**
  99900. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99901. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99902. */
  99903. useConstantAnimationDeltaTime: boolean;
  99904. /**
  99905. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99906. * Please note that it requires to run a ray cast through the scene on every frame
  99907. */
  99908. constantlyUpdateMeshUnderPointer: boolean;
  99909. /**
  99910. * Defines the HTML cursor to use when hovering over interactive elements
  99911. */
  99912. hoverCursor: string;
  99913. /**
  99914. * Defines the HTML default cursor to use (empty by default)
  99915. */
  99916. defaultCursor: string;
  99917. /**
  99918. * This is used to call preventDefault() on pointer down
  99919. * in order to block unwanted artifacts like system double clicks
  99920. */
  99921. preventDefaultOnPointerDown: boolean;
  99922. /**
  99923. * This is used to call preventDefault() on pointer up
  99924. * in order to block unwanted artifacts like system double clicks
  99925. */
  99926. preventDefaultOnPointerUp: boolean;
  99927. /**
  99928. * Gets or sets user defined metadata
  99929. */
  99930. metadata: any;
  99931. /**
  99932. * For internal use only. Please do not use.
  99933. */
  99934. reservedDataStore: any;
  99935. /**
  99936. * Gets the name of the plugin used to load this scene (null by default)
  99937. */
  99938. loadingPluginName: string;
  99939. /**
  99940. * Use this array to add regular expressions used to disable offline support for specific urls
  99941. */
  99942. disableOfflineSupportExceptionRules: RegExp[];
  99943. /**
  99944. * An event triggered when the scene is disposed.
  99945. */
  99946. onDisposeObservable: Observable<Scene>;
  99947. private _onDisposeObserver;
  99948. /** Sets a function to be executed when this scene is disposed. */
  99949. onDispose: () => void;
  99950. /**
  99951. * An event triggered before rendering the scene (right after animations and physics)
  99952. */
  99953. onBeforeRenderObservable: Observable<Scene>;
  99954. private _onBeforeRenderObserver;
  99955. /** Sets a function to be executed before rendering this scene */
  99956. beforeRender: Nullable<() => void>;
  99957. /**
  99958. * An event triggered after rendering the scene
  99959. */
  99960. onAfterRenderObservable: Observable<Scene>;
  99961. /**
  99962. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99963. */
  99964. onAfterRenderCameraObservable: Observable<Camera>;
  99965. private _onAfterRenderObserver;
  99966. /** Sets a function to be executed after rendering this scene */
  99967. afterRender: Nullable<() => void>;
  99968. /**
  99969. * An event triggered before animating the scene
  99970. */
  99971. onBeforeAnimationsObservable: Observable<Scene>;
  99972. /**
  99973. * An event triggered after animations processing
  99974. */
  99975. onAfterAnimationsObservable: Observable<Scene>;
  99976. /**
  99977. * An event triggered before draw calls are ready to be sent
  99978. */
  99979. onBeforeDrawPhaseObservable: Observable<Scene>;
  99980. /**
  99981. * An event triggered after draw calls have been sent
  99982. */
  99983. onAfterDrawPhaseObservable: Observable<Scene>;
  99984. /**
  99985. * An event triggered when the scene is ready
  99986. */
  99987. onReadyObservable: Observable<Scene>;
  99988. /**
  99989. * An event triggered before rendering a camera
  99990. */
  99991. onBeforeCameraRenderObservable: Observable<Camera>;
  99992. private _onBeforeCameraRenderObserver;
  99993. /** Sets a function to be executed before rendering a camera*/
  99994. beforeCameraRender: () => void;
  99995. /**
  99996. * An event triggered after rendering a camera
  99997. */
  99998. onAfterCameraRenderObservable: Observable<Camera>;
  99999. private _onAfterCameraRenderObserver;
  100000. /** Sets a function to be executed after rendering a camera*/
  100001. afterCameraRender: () => void;
  100002. /**
  100003. * An event triggered when active meshes evaluation is about to start
  100004. */
  100005. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100006. /**
  100007. * An event triggered when active meshes evaluation is done
  100008. */
  100009. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100010. /**
  100011. * An event triggered when particles rendering is about to start
  100012. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100013. */
  100014. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100015. /**
  100016. * An event triggered when particles rendering is done
  100017. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100018. */
  100019. onAfterParticlesRenderingObservable: Observable<Scene>;
  100020. /**
  100021. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100022. */
  100023. onDataLoadedObservable: Observable<Scene>;
  100024. /**
  100025. * An event triggered when a camera is created
  100026. */
  100027. onNewCameraAddedObservable: Observable<Camera>;
  100028. /**
  100029. * An event triggered when a camera is removed
  100030. */
  100031. onCameraRemovedObservable: Observable<Camera>;
  100032. /**
  100033. * An event triggered when a light is created
  100034. */
  100035. onNewLightAddedObservable: Observable<Light>;
  100036. /**
  100037. * An event triggered when a light is removed
  100038. */
  100039. onLightRemovedObservable: Observable<Light>;
  100040. /**
  100041. * An event triggered when a geometry is created
  100042. */
  100043. onNewGeometryAddedObservable: Observable<Geometry>;
  100044. /**
  100045. * An event triggered when a geometry is removed
  100046. */
  100047. onGeometryRemovedObservable: Observable<Geometry>;
  100048. /**
  100049. * An event triggered when a transform node is created
  100050. */
  100051. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100052. /**
  100053. * An event triggered when a transform node is removed
  100054. */
  100055. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100056. /**
  100057. * An event triggered when a mesh is created
  100058. */
  100059. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100060. /**
  100061. * An event triggered when a mesh is removed
  100062. */
  100063. onMeshRemovedObservable: Observable<AbstractMesh>;
  100064. /**
  100065. * An event triggered when a skeleton is created
  100066. */
  100067. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100068. /**
  100069. * An event triggered when a skeleton is removed
  100070. */
  100071. onSkeletonRemovedObservable: Observable<Skeleton>;
  100072. /**
  100073. * An event triggered when a material is created
  100074. */
  100075. onNewMaterialAddedObservable: Observable<Material>;
  100076. /**
  100077. * An event triggered when a material is removed
  100078. */
  100079. onMaterialRemovedObservable: Observable<Material>;
  100080. /**
  100081. * An event triggered when a texture is created
  100082. */
  100083. onNewTextureAddedObservable: Observable<BaseTexture>;
  100084. /**
  100085. * An event triggered when a texture is removed
  100086. */
  100087. onTextureRemovedObservable: Observable<BaseTexture>;
  100088. /**
  100089. * An event triggered when render targets are about to be rendered
  100090. * Can happen multiple times per frame.
  100091. */
  100092. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100093. /**
  100094. * An event triggered when render targets were rendered.
  100095. * Can happen multiple times per frame.
  100096. */
  100097. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100098. /**
  100099. * An event triggered before calculating deterministic simulation step
  100100. */
  100101. onBeforeStepObservable: Observable<Scene>;
  100102. /**
  100103. * An event triggered after calculating deterministic simulation step
  100104. */
  100105. onAfterStepObservable: Observable<Scene>;
  100106. /**
  100107. * An event triggered when the activeCamera property is updated
  100108. */
  100109. onActiveCameraChanged: Observable<Scene>;
  100110. /**
  100111. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100112. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100113. * 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)
  100114. */
  100115. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100116. /**
  100117. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100118. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100119. * 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)
  100120. */
  100121. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100122. /**
  100123. * This Observable will when a mesh has been imported into the scene.
  100124. */
  100125. onMeshImportedObservable: Observable<AbstractMesh>;
  100126. /**
  100127. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100128. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100129. */
  100130. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100131. /** @hidden */
  100132. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100133. /**
  100134. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100135. */
  100136. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100137. /**
  100138. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100139. */
  100140. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100141. /**
  100142. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100143. */
  100144. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100145. /** Callback called when a pointer move is detected */
  100146. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100147. /** Callback called when a pointer down is detected */
  100148. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100149. /** Callback called when a pointer up is detected */
  100150. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100151. /** Callback called when a pointer pick is detected */
  100152. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100153. /**
  100154. * 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).
  100155. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100156. */
  100157. onPrePointerObservable: Observable<PointerInfoPre>;
  100158. /**
  100159. * Observable event triggered each time an input event is received from the rendering canvas
  100160. */
  100161. onPointerObservable: Observable<PointerInfo>;
  100162. /**
  100163. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100164. */
  100165. readonly unTranslatedPointer: Vector2;
  100166. /**
  100167. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100168. */
  100169. static DragMovementThreshold: number;
  100170. /**
  100171. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100172. */
  100173. static LongPressDelay: number;
  100174. /**
  100175. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100176. */
  100177. static DoubleClickDelay: number;
  100178. /** If you need to check double click without raising a single click at first click, enable this flag */
  100179. static ExclusiveDoubleClickMode: boolean;
  100180. /** @hidden */
  100181. _mirroredCameraPosition: Nullable<Vector3>;
  100182. /**
  100183. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100184. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100185. */
  100186. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100187. /**
  100188. * Observable event triggered each time an keyboard event is received from the hosting window
  100189. */
  100190. onKeyboardObservable: Observable<KeyboardInfo>;
  100191. private _useRightHandedSystem;
  100192. /**
  100193. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100194. */
  100195. useRightHandedSystem: boolean;
  100196. private _timeAccumulator;
  100197. private _currentStepId;
  100198. private _currentInternalStep;
  100199. /**
  100200. * Sets the step Id used by deterministic lock step
  100201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100202. * @param newStepId defines the step Id
  100203. */
  100204. setStepId(newStepId: number): void;
  100205. /**
  100206. * Gets the step Id used by deterministic lock step
  100207. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100208. * @returns the step Id
  100209. */
  100210. getStepId(): number;
  100211. /**
  100212. * Gets the internal step used by deterministic lock step
  100213. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100214. * @returns the internal step
  100215. */
  100216. getInternalStep(): number;
  100217. private _fogEnabled;
  100218. /**
  100219. * Gets or sets a boolean indicating if fog is enabled on this scene
  100220. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100221. * (Default is true)
  100222. */
  100223. fogEnabled: boolean;
  100224. private _fogMode;
  100225. /**
  100226. * Gets or sets the fog mode to use
  100227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100228. * | mode | value |
  100229. * | --- | --- |
  100230. * | FOGMODE_NONE | 0 |
  100231. * | FOGMODE_EXP | 1 |
  100232. * | FOGMODE_EXP2 | 2 |
  100233. * | FOGMODE_LINEAR | 3 |
  100234. */
  100235. fogMode: number;
  100236. /**
  100237. * Gets or sets the fog color to use
  100238. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100239. * (Default is Color3(0.2, 0.2, 0.3))
  100240. */
  100241. fogColor: Color3;
  100242. /**
  100243. * Gets or sets the fog density to use
  100244. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100245. * (Default is 0.1)
  100246. */
  100247. fogDensity: number;
  100248. /**
  100249. * Gets or sets the fog start distance to use
  100250. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100251. * (Default is 0)
  100252. */
  100253. fogStart: number;
  100254. /**
  100255. * Gets or sets the fog end distance to use
  100256. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100257. * (Default is 1000)
  100258. */
  100259. fogEnd: number;
  100260. private _shadowsEnabled;
  100261. /**
  100262. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100263. */
  100264. shadowsEnabled: boolean;
  100265. private _lightsEnabled;
  100266. /**
  100267. * Gets or sets a boolean indicating if lights are enabled on this scene
  100268. */
  100269. lightsEnabled: boolean;
  100270. /** All of the active cameras added to this scene. */
  100271. activeCameras: Camera[];
  100272. /** @hidden */
  100273. _activeCamera: Nullable<Camera>;
  100274. /** Gets or sets the current active camera */
  100275. activeCamera: Nullable<Camera>;
  100276. private _defaultMaterial;
  100277. /** The default material used on meshes when no material is affected */
  100278. /** The default material used on meshes when no material is affected */
  100279. defaultMaterial: Material;
  100280. private _texturesEnabled;
  100281. /**
  100282. * Gets or sets a boolean indicating if textures are enabled on this scene
  100283. */
  100284. texturesEnabled: boolean;
  100285. /**
  100286. * Gets or sets a boolean indicating if particles are enabled on this scene
  100287. */
  100288. particlesEnabled: boolean;
  100289. /**
  100290. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100291. */
  100292. spritesEnabled: boolean;
  100293. private _skeletonsEnabled;
  100294. /**
  100295. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100296. */
  100297. skeletonsEnabled: boolean;
  100298. /**
  100299. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100300. */
  100301. lensFlaresEnabled: boolean;
  100302. /**
  100303. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100305. */
  100306. collisionsEnabled: boolean;
  100307. private _collisionCoordinator;
  100308. /** @hidden */
  100309. readonly collisionCoordinator: ICollisionCoordinator;
  100310. /**
  100311. * Defines the gravity applied to this scene (used only for collisions)
  100312. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100313. */
  100314. gravity: Vector3;
  100315. /**
  100316. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100317. */
  100318. postProcessesEnabled: boolean;
  100319. /**
  100320. * The list of postprocesses added to the scene
  100321. */
  100322. postProcesses: PostProcess[];
  100323. /**
  100324. * Gets the current postprocess manager
  100325. */
  100326. postProcessManager: PostProcessManager;
  100327. /**
  100328. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100329. */
  100330. renderTargetsEnabled: boolean;
  100331. /**
  100332. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100333. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100334. */
  100335. dumpNextRenderTargets: boolean;
  100336. /**
  100337. * The list of user defined render targets added to the scene
  100338. */
  100339. customRenderTargets: RenderTargetTexture[];
  100340. /**
  100341. * Defines if texture loading must be delayed
  100342. * If true, textures will only be loaded when they need to be rendered
  100343. */
  100344. useDelayedTextureLoading: boolean;
  100345. /**
  100346. * Gets the list of meshes imported to the scene through SceneLoader
  100347. */
  100348. importedMeshesFiles: String[];
  100349. /**
  100350. * Gets or sets a boolean indicating if probes are enabled on this scene
  100351. */
  100352. probesEnabled: boolean;
  100353. /**
  100354. * Gets or sets the current offline provider to use to store scene data
  100355. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100356. */
  100357. offlineProvider: IOfflineProvider;
  100358. /**
  100359. * Gets or sets the action manager associated with the scene
  100360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100361. */
  100362. actionManager: AbstractActionManager;
  100363. private _meshesForIntersections;
  100364. /**
  100365. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100366. */
  100367. proceduralTexturesEnabled: boolean;
  100368. private _engine;
  100369. private _totalVertices;
  100370. /** @hidden */
  100371. _activeIndices: PerfCounter;
  100372. /** @hidden */
  100373. _activeParticles: PerfCounter;
  100374. /** @hidden */
  100375. _activeBones: PerfCounter;
  100376. private _animationRatio;
  100377. /** @hidden */
  100378. _animationTimeLast: number;
  100379. /** @hidden */
  100380. _animationTime: number;
  100381. /**
  100382. * Gets or sets a general scale for animation speed
  100383. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100384. */
  100385. animationTimeScale: number;
  100386. /** @hidden */
  100387. _cachedMaterial: Nullable<Material>;
  100388. /** @hidden */
  100389. _cachedEffect: Nullable<Effect>;
  100390. /** @hidden */
  100391. _cachedVisibility: Nullable<number>;
  100392. private _renderId;
  100393. private _frameId;
  100394. private _executeWhenReadyTimeoutId;
  100395. private _intermediateRendering;
  100396. private _viewUpdateFlag;
  100397. private _projectionUpdateFlag;
  100398. /** @hidden */
  100399. _toBeDisposed: Nullable<IDisposable>[];
  100400. private _activeRequests;
  100401. /** @hidden */
  100402. _pendingData: any[];
  100403. private _isDisposed;
  100404. /**
  100405. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100406. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100407. */
  100408. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100409. private _activeMeshes;
  100410. private _processedMaterials;
  100411. private _renderTargets;
  100412. /** @hidden */
  100413. _activeParticleSystems: SmartArray<IParticleSystem>;
  100414. private _activeSkeletons;
  100415. private _softwareSkinnedMeshes;
  100416. private _renderingManager;
  100417. /** @hidden */
  100418. _activeAnimatables: Animatable[];
  100419. private _transformMatrix;
  100420. private _sceneUbo;
  100421. /** @hidden */
  100422. _viewMatrix: Matrix;
  100423. private _projectionMatrix;
  100424. /** @hidden */
  100425. _forcedViewPosition: Nullable<Vector3>;
  100426. /** @hidden */
  100427. _frustumPlanes: Plane[];
  100428. /**
  100429. * Gets the list of frustum planes (built from the active camera)
  100430. */
  100431. readonly frustumPlanes: Plane[];
  100432. /**
  100433. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100434. * This is useful if there are more lights that the maximum simulteanous authorized
  100435. */
  100436. requireLightSorting: boolean;
  100437. /** @hidden */
  100438. readonly useMaterialMeshMap: boolean;
  100439. /** @hidden */
  100440. readonly useClonedMeshhMap: boolean;
  100441. private _externalData;
  100442. private _uid;
  100443. /**
  100444. * @hidden
  100445. * Backing store of defined scene components.
  100446. */
  100447. _components: ISceneComponent[];
  100448. /**
  100449. * @hidden
  100450. * Backing store of defined scene components.
  100451. */
  100452. _serializableComponents: ISceneSerializableComponent[];
  100453. /**
  100454. * List of components to register on the next registration step.
  100455. */
  100456. private _transientComponents;
  100457. /**
  100458. * Registers the transient components if needed.
  100459. */
  100460. private _registerTransientComponents;
  100461. /**
  100462. * @hidden
  100463. * Add a component to the scene.
  100464. * Note that the ccomponent could be registered on th next frame if this is called after
  100465. * the register component stage.
  100466. * @param component Defines the component to add to the scene
  100467. */
  100468. _addComponent(component: ISceneComponent): void;
  100469. /**
  100470. * @hidden
  100471. * Gets a component from the scene.
  100472. * @param name defines the name of the component to retrieve
  100473. * @returns the component or null if not present
  100474. */
  100475. _getComponent(name: string): Nullable<ISceneComponent>;
  100476. /**
  100477. * @hidden
  100478. * Defines the actions happening before camera updates.
  100479. */
  100480. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100481. /**
  100482. * @hidden
  100483. * Defines the actions happening before clear the canvas.
  100484. */
  100485. _beforeClearStage: Stage<SimpleStageAction>;
  100486. /**
  100487. * @hidden
  100488. * Defines the actions when collecting render targets for the frame.
  100489. */
  100490. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100491. /**
  100492. * @hidden
  100493. * Defines the actions happening for one camera in the frame.
  100494. */
  100495. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100496. /**
  100497. * @hidden
  100498. * Defines the actions happening during the per mesh ready checks.
  100499. */
  100500. _isReadyForMeshStage: Stage<MeshStageAction>;
  100501. /**
  100502. * @hidden
  100503. * Defines the actions happening before evaluate active mesh checks.
  100504. */
  100505. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100506. /**
  100507. * @hidden
  100508. * Defines the actions happening during the evaluate sub mesh checks.
  100509. */
  100510. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100511. /**
  100512. * @hidden
  100513. * Defines the actions happening during the active mesh stage.
  100514. */
  100515. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100516. /**
  100517. * @hidden
  100518. * Defines the actions happening during the per camera render target step.
  100519. */
  100520. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100521. /**
  100522. * @hidden
  100523. * Defines the actions happening just before the active camera is drawing.
  100524. */
  100525. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100526. /**
  100527. * @hidden
  100528. * Defines the actions happening just before a render target is drawing.
  100529. */
  100530. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100531. /**
  100532. * @hidden
  100533. * Defines the actions happening just before a rendering group is drawing.
  100534. */
  100535. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100536. /**
  100537. * @hidden
  100538. * Defines the actions happening just before a mesh is drawing.
  100539. */
  100540. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100541. /**
  100542. * @hidden
  100543. * Defines the actions happening just after a mesh has been drawn.
  100544. */
  100545. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100546. /**
  100547. * @hidden
  100548. * Defines the actions happening just after a rendering group has been drawn.
  100549. */
  100550. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100551. /**
  100552. * @hidden
  100553. * Defines the actions happening just after the active camera has been drawn.
  100554. */
  100555. _afterCameraDrawStage: Stage<CameraStageAction>;
  100556. /**
  100557. * @hidden
  100558. * Defines the actions happening just after a render target has been drawn.
  100559. */
  100560. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100561. /**
  100562. * @hidden
  100563. * Defines the actions happening just after rendering all cameras and computing intersections.
  100564. */
  100565. _afterRenderStage: Stage<SimpleStageAction>;
  100566. /**
  100567. * @hidden
  100568. * Defines the actions happening when a pointer move event happens.
  100569. */
  100570. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100571. /**
  100572. * @hidden
  100573. * Defines the actions happening when a pointer down event happens.
  100574. */
  100575. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100576. /**
  100577. * @hidden
  100578. * Defines the actions happening when a pointer up event happens.
  100579. */
  100580. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100581. /**
  100582. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100583. */
  100584. private geometriesByUniqueId;
  100585. /**
  100586. * Creates a new Scene
  100587. * @param engine defines the engine to use to render this scene
  100588. * @param options defines the scene options
  100589. */
  100590. constructor(engine: Engine, options?: SceneOptions);
  100591. /**
  100592. * Gets a string idenfifying the name of the class
  100593. * @returns "Scene" string
  100594. */
  100595. getClassName(): string;
  100596. private _defaultMeshCandidates;
  100597. /**
  100598. * @hidden
  100599. */
  100600. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100601. private _defaultSubMeshCandidates;
  100602. /**
  100603. * @hidden
  100604. */
  100605. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100606. /**
  100607. * Sets the default candidate providers for the scene.
  100608. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100609. * and getCollidingSubMeshCandidates to their default function
  100610. */
  100611. setDefaultCandidateProviders(): void;
  100612. /**
  100613. * Gets the mesh that is currently under the pointer
  100614. */
  100615. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100616. /**
  100617. * Gets or sets the current on-screen X position of the pointer
  100618. */
  100619. pointerX: number;
  100620. /**
  100621. * Gets or sets the current on-screen Y position of the pointer
  100622. */
  100623. pointerY: number;
  100624. /**
  100625. * Gets the cached material (ie. the latest rendered one)
  100626. * @returns the cached material
  100627. */
  100628. getCachedMaterial(): Nullable<Material>;
  100629. /**
  100630. * Gets the cached effect (ie. the latest rendered one)
  100631. * @returns the cached effect
  100632. */
  100633. getCachedEffect(): Nullable<Effect>;
  100634. /**
  100635. * Gets the cached visibility state (ie. the latest rendered one)
  100636. * @returns the cached visibility state
  100637. */
  100638. getCachedVisibility(): Nullable<number>;
  100639. /**
  100640. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100641. * @param material defines the current material
  100642. * @param effect defines the current effect
  100643. * @param visibility defines the current visibility state
  100644. * @returns true if one parameter is not cached
  100645. */
  100646. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100647. /**
  100648. * Gets the engine associated with the scene
  100649. * @returns an Engine
  100650. */
  100651. getEngine(): Engine;
  100652. /**
  100653. * Gets the total number of vertices rendered per frame
  100654. * @returns the total number of vertices rendered per frame
  100655. */
  100656. getTotalVertices(): number;
  100657. /**
  100658. * Gets the performance counter for total vertices
  100659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100660. */
  100661. readonly totalVerticesPerfCounter: PerfCounter;
  100662. /**
  100663. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100664. * @returns the total number of active indices rendered per frame
  100665. */
  100666. getActiveIndices(): number;
  100667. /**
  100668. * Gets the performance counter for active indices
  100669. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100670. */
  100671. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100672. /**
  100673. * Gets the total number of active particles rendered per frame
  100674. * @returns the total number of active particles rendered per frame
  100675. */
  100676. getActiveParticles(): number;
  100677. /**
  100678. * Gets the performance counter for active particles
  100679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100680. */
  100681. readonly activeParticlesPerfCounter: PerfCounter;
  100682. /**
  100683. * Gets the total number of active bones rendered per frame
  100684. * @returns the total number of active bones rendered per frame
  100685. */
  100686. getActiveBones(): number;
  100687. /**
  100688. * Gets the performance counter for active bones
  100689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100690. */
  100691. readonly activeBonesPerfCounter: PerfCounter;
  100692. /**
  100693. * Gets the array of active meshes
  100694. * @returns an array of AbstractMesh
  100695. */
  100696. getActiveMeshes(): SmartArray<AbstractMesh>;
  100697. /**
  100698. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100699. * @returns a number
  100700. */
  100701. getAnimationRatio(): number;
  100702. /**
  100703. * Gets an unique Id for the current render phase
  100704. * @returns a number
  100705. */
  100706. getRenderId(): number;
  100707. /**
  100708. * Gets an unique Id for the current frame
  100709. * @returns a number
  100710. */
  100711. getFrameId(): number;
  100712. /** Call this function if you want to manually increment the render Id*/
  100713. incrementRenderId(): void;
  100714. private _createUbo;
  100715. /**
  100716. * Use this method to simulate a pointer move on a mesh
  100717. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100718. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100719. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100720. * @returns the current scene
  100721. */
  100722. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100723. /**
  100724. * Use this method to simulate a pointer down on a mesh
  100725. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100726. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100727. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100728. * @returns the current scene
  100729. */
  100730. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100731. /**
  100732. * Use this method to simulate a pointer up on a mesh
  100733. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100734. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100735. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100736. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100737. * @returns the current scene
  100738. */
  100739. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100740. /**
  100741. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100742. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100743. * @returns true if the pointer was captured
  100744. */
  100745. isPointerCaptured(pointerId?: number): boolean;
  100746. /**
  100747. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100748. * @param attachUp defines if you want to attach events to pointerup
  100749. * @param attachDown defines if you want to attach events to pointerdown
  100750. * @param attachMove defines if you want to attach events to pointermove
  100751. */
  100752. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100753. /** Detaches all event handlers*/
  100754. detachControl(): void;
  100755. /**
  100756. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100757. * Delay loaded resources are not taking in account
  100758. * @return true if all required resources are ready
  100759. */
  100760. isReady(): boolean;
  100761. /** Resets all cached information relative to material (including effect and visibility) */
  100762. resetCachedMaterial(): void;
  100763. /**
  100764. * Registers a function to be called before every frame render
  100765. * @param func defines the function to register
  100766. */
  100767. registerBeforeRender(func: () => void): void;
  100768. /**
  100769. * Unregisters a function called before every frame render
  100770. * @param func defines the function to unregister
  100771. */
  100772. unregisterBeforeRender(func: () => void): void;
  100773. /**
  100774. * Registers a function to be called after every frame render
  100775. * @param func defines the function to register
  100776. */
  100777. registerAfterRender(func: () => void): void;
  100778. /**
  100779. * Unregisters a function called after every frame render
  100780. * @param func defines the function to unregister
  100781. */
  100782. unregisterAfterRender(func: () => void): void;
  100783. private _executeOnceBeforeRender;
  100784. /**
  100785. * The provided function will run before render once and will be disposed afterwards.
  100786. * A timeout delay can be provided so that the function will be executed in N ms.
  100787. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100788. * @param func The function to be executed.
  100789. * @param timeout optional delay in ms
  100790. */
  100791. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100792. /** @hidden */
  100793. _addPendingData(data: any): void;
  100794. /** @hidden */
  100795. _removePendingData(data: any): void;
  100796. /**
  100797. * Returns the number of items waiting to be loaded
  100798. * @returns the number of items waiting to be loaded
  100799. */
  100800. getWaitingItemsCount(): number;
  100801. /**
  100802. * Returns a boolean indicating if the scene is still loading data
  100803. */
  100804. readonly isLoading: boolean;
  100805. /**
  100806. * Registers a function to be executed when the scene is ready
  100807. * @param {Function} func - the function to be executed
  100808. */
  100809. executeWhenReady(func: () => void): void;
  100810. /**
  100811. * Returns a promise that resolves when the scene is ready
  100812. * @returns A promise that resolves when the scene is ready
  100813. */
  100814. whenReadyAsync(): Promise<void>;
  100815. /** @hidden */
  100816. _checkIsReady(): void;
  100817. /**
  100818. * Gets all animatable attached to the scene
  100819. */
  100820. readonly animatables: Animatable[];
  100821. /**
  100822. * Resets the last animation time frame.
  100823. * Useful to override when animations start running when loading a scene for the first time.
  100824. */
  100825. resetLastAnimationTimeFrame(): void;
  100826. /**
  100827. * Gets the current view matrix
  100828. * @returns a Matrix
  100829. */
  100830. getViewMatrix(): Matrix;
  100831. /**
  100832. * Gets the current projection matrix
  100833. * @returns a Matrix
  100834. */
  100835. getProjectionMatrix(): Matrix;
  100836. /**
  100837. * Gets the current transform matrix
  100838. * @returns a Matrix made of View * Projection
  100839. */
  100840. getTransformMatrix(): Matrix;
  100841. /**
  100842. * Sets the current transform matrix
  100843. * @param viewL defines the View matrix to use
  100844. * @param projectionL defines the Projection matrix to use
  100845. * @param viewR defines the right View matrix to use (if provided)
  100846. * @param projectionR defines the right Projection matrix to use (if provided)
  100847. */
  100848. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100849. /**
  100850. * Gets the uniform buffer used to store scene data
  100851. * @returns a UniformBuffer
  100852. */
  100853. getSceneUniformBuffer(): UniformBuffer;
  100854. /**
  100855. * Gets an unique (relatively to the current scene) Id
  100856. * @returns an unique number for the scene
  100857. */
  100858. getUniqueId(): number;
  100859. /**
  100860. * Add a mesh to the list of scene's meshes
  100861. * @param newMesh defines the mesh to add
  100862. * @param recursive if all child meshes should also be added to the scene
  100863. */
  100864. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100865. /**
  100866. * Remove a mesh for the list of scene's meshes
  100867. * @param toRemove defines the mesh to remove
  100868. * @param recursive if all child meshes should also be removed from the scene
  100869. * @returns the index where the mesh was in the mesh list
  100870. */
  100871. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100872. /**
  100873. * Add a transform node to the list of scene's transform nodes
  100874. * @param newTransformNode defines the transform node to add
  100875. */
  100876. addTransformNode(newTransformNode: TransformNode): void;
  100877. /**
  100878. * Remove a transform node for the list of scene's transform nodes
  100879. * @param toRemove defines the transform node to remove
  100880. * @returns the index where the transform node was in the transform node list
  100881. */
  100882. removeTransformNode(toRemove: TransformNode): number;
  100883. /**
  100884. * Remove a skeleton for the list of scene's skeletons
  100885. * @param toRemove defines the skeleton to remove
  100886. * @returns the index where the skeleton was in the skeleton list
  100887. */
  100888. removeSkeleton(toRemove: Skeleton): number;
  100889. /**
  100890. * Remove a morph target for the list of scene's morph targets
  100891. * @param toRemove defines the morph target to remove
  100892. * @returns the index where the morph target was in the morph target list
  100893. */
  100894. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100895. /**
  100896. * Remove a light for the list of scene's lights
  100897. * @param toRemove defines the light to remove
  100898. * @returns the index where the light was in the light list
  100899. */
  100900. removeLight(toRemove: Light): number;
  100901. /**
  100902. * Remove a camera for the list of scene's cameras
  100903. * @param toRemove defines the camera to remove
  100904. * @returns the index where the camera was in the camera list
  100905. */
  100906. removeCamera(toRemove: Camera): number;
  100907. /**
  100908. * Remove a particle system for the list of scene's particle systems
  100909. * @param toRemove defines the particle system to remove
  100910. * @returns the index where the particle system was in the particle system list
  100911. */
  100912. removeParticleSystem(toRemove: IParticleSystem): number;
  100913. /**
  100914. * Remove a animation for the list of scene's animations
  100915. * @param toRemove defines the animation to remove
  100916. * @returns the index where the animation was in the animation list
  100917. */
  100918. removeAnimation(toRemove: Animation): number;
  100919. /**
  100920. * Will stop the animation of the given target
  100921. * @param target - the target
  100922. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100923. * @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)
  100924. */
  100925. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100926. /**
  100927. * Removes the given animation group from this scene.
  100928. * @param toRemove The animation group to remove
  100929. * @returns The index of the removed animation group
  100930. */
  100931. removeAnimationGroup(toRemove: AnimationGroup): number;
  100932. /**
  100933. * Removes the given multi-material from this scene.
  100934. * @param toRemove The multi-material to remove
  100935. * @returns The index of the removed multi-material
  100936. */
  100937. removeMultiMaterial(toRemove: MultiMaterial): number;
  100938. /**
  100939. * Removes the given material from this scene.
  100940. * @param toRemove The material to remove
  100941. * @returns The index of the removed material
  100942. */
  100943. removeMaterial(toRemove: Material): number;
  100944. /**
  100945. * Removes the given action manager from this scene.
  100946. * @param toRemove The action manager to remove
  100947. * @returns The index of the removed action manager
  100948. */
  100949. removeActionManager(toRemove: AbstractActionManager): number;
  100950. /**
  100951. * Removes the given texture from this scene.
  100952. * @param toRemove The texture to remove
  100953. * @returns The index of the removed texture
  100954. */
  100955. removeTexture(toRemove: BaseTexture): number;
  100956. /**
  100957. * Adds the given light to this scene
  100958. * @param newLight The light to add
  100959. */
  100960. addLight(newLight: Light): void;
  100961. /**
  100962. * Sorts the list list based on light priorities
  100963. */
  100964. sortLightsByPriority(): void;
  100965. /**
  100966. * Adds the given camera to this scene
  100967. * @param newCamera The camera to add
  100968. */
  100969. addCamera(newCamera: Camera): void;
  100970. /**
  100971. * Adds the given skeleton to this scene
  100972. * @param newSkeleton The skeleton to add
  100973. */
  100974. addSkeleton(newSkeleton: Skeleton): void;
  100975. /**
  100976. * Adds the given particle system to this scene
  100977. * @param newParticleSystem The particle system to add
  100978. */
  100979. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100980. /**
  100981. * Adds the given animation to this scene
  100982. * @param newAnimation The animation to add
  100983. */
  100984. addAnimation(newAnimation: Animation): void;
  100985. /**
  100986. * Adds the given animation group to this scene.
  100987. * @param newAnimationGroup The animation group to add
  100988. */
  100989. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100990. /**
  100991. * Adds the given multi-material to this scene
  100992. * @param newMultiMaterial The multi-material to add
  100993. */
  100994. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100995. /**
  100996. * Adds the given material to this scene
  100997. * @param newMaterial The material to add
  100998. */
  100999. addMaterial(newMaterial: Material): void;
  101000. /**
  101001. * Adds the given morph target to this scene
  101002. * @param newMorphTargetManager The morph target to add
  101003. */
  101004. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101005. /**
  101006. * Adds the given geometry to this scene
  101007. * @param newGeometry The geometry to add
  101008. */
  101009. addGeometry(newGeometry: Geometry): void;
  101010. /**
  101011. * Adds the given action manager to this scene
  101012. * @param newActionManager The action manager to add
  101013. */
  101014. addActionManager(newActionManager: AbstractActionManager): void;
  101015. /**
  101016. * Adds the given texture to this scene.
  101017. * @param newTexture The texture to add
  101018. */
  101019. addTexture(newTexture: BaseTexture): void;
  101020. /**
  101021. * Switch active camera
  101022. * @param newCamera defines the new active camera
  101023. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101024. */
  101025. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101026. /**
  101027. * sets the active camera of the scene using its ID
  101028. * @param id defines the camera's ID
  101029. * @return the new active camera or null if none found.
  101030. */
  101031. setActiveCameraByID(id: string): Nullable<Camera>;
  101032. /**
  101033. * sets the active camera of the scene using its name
  101034. * @param name defines the camera's name
  101035. * @returns the new active camera or null if none found.
  101036. */
  101037. setActiveCameraByName(name: string): Nullable<Camera>;
  101038. /**
  101039. * get an animation group using its name
  101040. * @param name defines the material's name
  101041. * @return the animation group or null if none found.
  101042. */
  101043. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101044. /**
  101045. * Get a material using its unique id
  101046. * @param uniqueId defines the material's unique id
  101047. * @return the material or null if none found.
  101048. */
  101049. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101050. /**
  101051. * get a material using its id
  101052. * @param id defines the material's ID
  101053. * @return the material or null if none found.
  101054. */
  101055. getMaterialByID(id: string): Nullable<Material>;
  101056. /**
  101057. * Gets a the last added material using a given id
  101058. * @param id defines the material's ID
  101059. * @return the last material with the given id or null if none found.
  101060. */
  101061. getLastMaterialByID(id: string): Nullable<Material>;
  101062. /**
  101063. * Gets a material using its name
  101064. * @param name defines the material's name
  101065. * @return the material or null if none found.
  101066. */
  101067. getMaterialByName(name: string): Nullable<Material>;
  101068. /**
  101069. * Get a texture using its unique id
  101070. * @param uniqueId defines the texture's unique id
  101071. * @return the texture or null if none found.
  101072. */
  101073. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101074. /**
  101075. * Gets a camera using its id
  101076. * @param id defines the id to look for
  101077. * @returns the camera or null if not found
  101078. */
  101079. getCameraByID(id: string): Nullable<Camera>;
  101080. /**
  101081. * Gets a camera using its unique id
  101082. * @param uniqueId defines the unique id to look for
  101083. * @returns the camera or null if not found
  101084. */
  101085. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101086. /**
  101087. * Gets a camera using its name
  101088. * @param name defines the camera's name
  101089. * @return the camera or null if none found.
  101090. */
  101091. getCameraByName(name: string): Nullable<Camera>;
  101092. /**
  101093. * Gets a bone using its id
  101094. * @param id defines the bone's id
  101095. * @return the bone or null if not found
  101096. */
  101097. getBoneByID(id: string): Nullable<Bone>;
  101098. /**
  101099. * Gets a bone using its id
  101100. * @param name defines the bone's name
  101101. * @return the bone or null if not found
  101102. */
  101103. getBoneByName(name: string): Nullable<Bone>;
  101104. /**
  101105. * Gets a light node using its name
  101106. * @param name defines the the light's name
  101107. * @return the light or null if none found.
  101108. */
  101109. getLightByName(name: string): Nullable<Light>;
  101110. /**
  101111. * Gets a light node using its id
  101112. * @param id defines the light's id
  101113. * @return the light or null if none found.
  101114. */
  101115. getLightByID(id: string): Nullable<Light>;
  101116. /**
  101117. * Gets a light node using its scene-generated unique ID
  101118. * @param uniqueId defines the light's unique id
  101119. * @return the light or null if none found.
  101120. */
  101121. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101122. /**
  101123. * Gets a particle system by id
  101124. * @param id defines the particle system id
  101125. * @return the corresponding system or null if none found
  101126. */
  101127. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101128. /**
  101129. * Gets a geometry using its ID
  101130. * @param id defines the geometry's id
  101131. * @return the geometry or null if none found.
  101132. */
  101133. getGeometryByID(id: string): Nullable<Geometry>;
  101134. private _getGeometryByUniqueID;
  101135. /**
  101136. * Add a new geometry to this scene
  101137. * @param geometry defines the geometry to be added to the scene.
  101138. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101139. * @return a boolean defining if the geometry was added or not
  101140. */
  101141. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101142. /**
  101143. * Removes an existing geometry
  101144. * @param geometry defines the geometry to be removed from the scene
  101145. * @return a boolean defining if the geometry was removed or not
  101146. */
  101147. removeGeometry(geometry: Geometry): boolean;
  101148. /**
  101149. * Gets the list of geometries attached to the scene
  101150. * @returns an array of Geometry
  101151. */
  101152. getGeometries(): Geometry[];
  101153. /**
  101154. * Gets the first added mesh found of a given ID
  101155. * @param id defines the id to search for
  101156. * @return the mesh found or null if not found at all
  101157. */
  101158. getMeshByID(id: string): Nullable<AbstractMesh>;
  101159. /**
  101160. * Gets a list of meshes using their id
  101161. * @param id defines the id to search for
  101162. * @returns a list of meshes
  101163. */
  101164. getMeshesByID(id: string): Array<AbstractMesh>;
  101165. /**
  101166. * Gets the first added transform node found of a given ID
  101167. * @param id defines the id to search for
  101168. * @return the found transform node or null if not found at all.
  101169. */
  101170. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101171. /**
  101172. * Gets a transform node with its auto-generated unique id
  101173. * @param uniqueId efines the unique id to search for
  101174. * @return the found transform node or null if not found at all.
  101175. */
  101176. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101177. /**
  101178. * Gets a list of transform nodes using their id
  101179. * @param id defines the id to search for
  101180. * @returns a list of transform nodes
  101181. */
  101182. getTransformNodesByID(id: string): Array<TransformNode>;
  101183. /**
  101184. * Gets a mesh with its auto-generated unique id
  101185. * @param uniqueId defines the unique id to search for
  101186. * @return the found mesh or null if not found at all.
  101187. */
  101188. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101189. /**
  101190. * Gets a the last added mesh using a given id
  101191. * @param id defines the id to search for
  101192. * @return the found mesh or null if not found at all.
  101193. */
  101194. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101195. /**
  101196. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101197. * @param id defines the id to search for
  101198. * @return the found node or null if not found at all
  101199. */
  101200. getLastEntryByID(id: string): Nullable<Node>;
  101201. /**
  101202. * Gets a node (Mesh, Camera, Light) using a given id
  101203. * @param id defines the id to search for
  101204. * @return the found node or null if not found at all
  101205. */
  101206. getNodeByID(id: string): Nullable<Node>;
  101207. /**
  101208. * Gets a node (Mesh, Camera, Light) using a given name
  101209. * @param name defines the name to search for
  101210. * @return the found node or null if not found at all.
  101211. */
  101212. getNodeByName(name: string): Nullable<Node>;
  101213. /**
  101214. * Gets a mesh using a given name
  101215. * @param name defines the name to search for
  101216. * @return the found mesh or null if not found at all.
  101217. */
  101218. getMeshByName(name: string): Nullable<AbstractMesh>;
  101219. /**
  101220. * Gets a transform node using a given name
  101221. * @param name defines the name to search for
  101222. * @return the found transform node or null if not found at all.
  101223. */
  101224. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101225. /**
  101226. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101227. * @param id defines the id to search for
  101228. * @return the found skeleton or null if not found at all.
  101229. */
  101230. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101231. /**
  101232. * Gets a skeleton using a given auto generated unique id
  101233. * @param uniqueId defines the unique id to search for
  101234. * @return the found skeleton or null if not found at all.
  101235. */
  101236. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101237. /**
  101238. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101239. * @param id defines the id to search for
  101240. * @return the found skeleton or null if not found at all.
  101241. */
  101242. getSkeletonById(id: string): Nullable<Skeleton>;
  101243. /**
  101244. * Gets a skeleton using a given name
  101245. * @param name defines the name to search for
  101246. * @return the found skeleton or null if not found at all.
  101247. */
  101248. getSkeletonByName(name: string): Nullable<Skeleton>;
  101249. /**
  101250. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101251. * @param id defines the id to search for
  101252. * @return the found morph target manager or null if not found at all.
  101253. */
  101254. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101255. /**
  101256. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101257. * @param id defines the id to search for
  101258. * @return the found morph target or null if not found at all.
  101259. */
  101260. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101261. /**
  101262. * Gets a boolean indicating if the given mesh is active
  101263. * @param mesh defines the mesh to look for
  101264. * @returns true if the mesh is in the active list
  101265. */
  101266. isActiveMesh(mesh: AbstractMesh): boolean;
  101267. /**
  101268. * Return a unique id as a string which can serve as an identifier for the scene
  101269. */
  101270. readonly uid: string;
  101271. /**
  101272. * Add an externaly attached data from its key.
  101273. * This method call will fail and return false, if such key already exists.
  101274. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101275. * @param key the unique key that identifies the data
  101276. * @param data the data object to associate to the key for this Engine instance
  101277. * @return true if no such key were already present and the data was added successfully, false otherwise
  101278. */
  101279. addExternalData<T>(key: string, data: T): boolean;
  101280. /**
  101281. * Get an externaly attached data from its key
  101282. * @param key the unique key that identifies the data
  101283. * @return the associated data, if present (can be null), or undefined if not present
  101284. */
  101285. getExternalData<T>(key: string): Nullable<T>;
  101286. /**
  101287. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101288. * @param key the unique key that identifies the data
  101289. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101290. * @return the associated data, can be null if the factory returned null.
  101291. */
  101292. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101293. /**
  101294. * Remove an externaly attached data from the Engine instance
  101295. * @param key the unique key that identifies the data
  101296. * @return true if the data was successfully removed, false if it doesn't exist
  101297. */
  101298. removeExternalData(key: string): boolean;
  101299. private _evaluateSubMesh;
  101300. /**
  101301. * Clear the processed materials smart array preventing retention point in material dispose.
  101302. */
  101303. freeProcessedMaterials(): void;
  101304. private _preventFreeActiveMeshesAndRenderingGroups;
  101305. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101306. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101307. * when disposing several meshes in a row or a hierarchy of meshes.
  101308. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101309. */
  101310. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101311. /**
  101312. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101313. */
  101314. freeActiveMeshes(): void;
  101315. /**
  101316. * Clear the info related to rendering groups preventing retention points during dispose.
  101317. */
  101318. freeRenderingGroups(): void;
  101319. /** @hidden */
  101320. _isInIntermediateRendering(): boolean;
  101321. /**
  101322. * Lambda returning the list of potentially active meshes.
  101323. */
  101324. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101325. /**
  101326. * Lambda returning the list of potentially active sub meshes.
  101327. */
  101328. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101329. /**
  101330. * Lambda returning the list of potentially intersecting sub meshes.
  101331. */
  101332. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101333. /**
  101334. * Lambda returning the list of potentially colliding sub meshes.
  101335. */
  101336. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101337. private _activeMeshesFrozen;
  101338. /**
  101339. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101340. * @returns the current scene
  101341. */
  101342. freezeActiveMeshes(): Scene;
  101343. /**
  101344. * Use this function to restart evaluating active meshes on every frame
  101345. * @returns the current scene
  101346. */
  101347. unfreezeActiveMeshes(): Scene;
  101348. private _evaluateActiveMeshes;
  101349. private _activeMesh;
  101350. /**
  101351. * Update the transform matrix to update from the current active camera
  101352. * @param force defines a boolean used to force the update even if cache is up to date
  101353. */
  101354. updateTransformMatrix(force?: boolean): void;
  101355. private _bindFrameBuffer;
  101356. /** @hidden */
  101357. _allowPostProcessClearColor: boolean;
  101358. /** @hidden */
  101359. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101360. private _processSubCameras;
  101361. private _checkIntersections;
  101362. /** @hidden */
  101363. _advancePhysicsEngineStep(step: number): void;
  101364. /**
  101365. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101366. */
  101367. getDeterministicFrameTime: () => number;
  101368. /** @hidden */
  101369. _animate(): void;
  101370. /** Execute all animations (for a frame) */
  101371. animate(): void;
  101372. /**
  101373. * Render the scene
  101374. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101375. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101376. */
  101377. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101378. /**
  101379. * Freeze all materials
  101380. * A frozen material will not be updatable but should be faster to render
  101381. */
  101382. freezeMaterials(): void;
  101383. /**
  101384. * Unfreeze all materials
  101385. * A frozen material will not be updatable but should be faster to render
  101386. */
  101387. unfreezeMaterials(): void;
  101388. /**
  101389. * Releases all held ressources
  101390. */
  101391. dispose(): void;
  101392. /**
  101393. * Gets if the scene is already disposed
  101394. */
  101395. readonly isDisposed: boolean;
  101396. /**
  101397. * Call this function to reduce memory footprint of the scene.
  101398. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101399. */
  101400. clearCachedVertexData(): void;
  101401. /**
  101402. * This function will remove the local cached buffer data from texture.
  101403. * It will save memory but will prevent the texture from being rebuilt
  101404. */
  101405. cleanCachedTextureBuffer(): void;
  101406. /**
  101407. * Get the world extend vectors with an optional filter
  101408. *
  101409. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101410. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101411. */
  101412. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101413. min: Vector3;
  101414. max: Vector3;
  101415. };
  101416. /**
  101417. * Creates a ray that can be used to pick in the scene
  101418. * @param x defines the x coordinate of the origin (on-screen)
  101419. * @param y defines the y coordinate of the origin (on-screen)
  101420. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101421. * @param camera defines the camera to use for the picking
  101422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101423. * @returns a Ray
  101424. */
  101425. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101426. /**
  101427. * Creates a ray that can be used to pick in the scene
  101428. * @param x defines the x coordinate of the origin (on-screen)
  101429. * @param y defines the y coordinate of the origin (on-screen)
  101430. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101431. * @param result defines the ray where to store the picking ray
  101432. * @param camera defines the camera to use for the picking
  101433. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101434. * @returns the current scene
  101435. */
  101436. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101437. /**
  101438. * Creates a ray that can be used to pick in the scene
  101439. * @param x defines the x coordinate of the origin (on-screen)
  101440. * @param y defines the y coordinate of the origin (on-screen)
  101441. * @param camera defines the camera to use for the picking
  101442. * @returns a Ray
  101443. */
  101444. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101445. /**
  101446. * Creates a ray that can be used to pick in the scene
  101447. * @param x defines the x coordinate of the origin (on-screen)
  101448. * @param y defines the y coordinate of the origin (on-screen)
  101449. * @param result defines the ray where to store the picking ray
  101450. * @param camera defines the camera to use for the picking
  101451. * @returns the current scene
  101452. */
  101453. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101454. /** Launch a ray to try to pick a mesh in the scene
  101455. * @param x position on screen
  101456. * @param y position on screen
  101457. * @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
  101458. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101459. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101461. * @returns a PickingInfo
  101462. */
  101463. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101464. /** Use the given ray to pick a mesh in the scene
  101465. * @param ray The ray to use to pick meshes
  101466. * @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
  101467. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101469. * @returns a PickingInfo
  101470. */
  101471. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101472. /**
  101473. * Launch a ray to try to pick a mesh in the scene
  101474. * @param x X position on screen
  101475. * @param y Y position on screen
  101476. * @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
  101477. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101479. * @returns an array of PickingInfo
  101480. */
  101481. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101482. /**
  101483. * Launch a ray to try to pick a mesh in the scene
  101484. * @param ray Ray to use
  101485. * @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
  101486. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101487. * @returns an array of PickingInfo
  101488. */
  101489. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101490. /**
  101491. * Force the value of meshUnderPointer
  101492. * @param mesh defines the mesh to use
  101493. */
  101494. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101495. /**
  101496. * Gets the mesh under the pointer
  101497. * @returns a Mesh or null if no mesh is under the pointer
  101498. */
  101499. getPointerOverMesh(): Nullable<AbstractMesh>;
  101500. /** @hidden */
  101501. _rebuildGeometries(): void;
  101502. /** @hidden */
  101503. _rebuildTextures(): void;
  101504. private _getByTags;
  101505. /**
  101506. * Get a list of meshes by tags
  101507. * @param tagsQuery defines the tags query to use
  101508. * @param forEach defines a predicate used to filter results
  101509. * @returns an array of Mesh
  101510. */
  101511. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101512. /**
  101513. * Get a list of cameras by tags
  101514. * @param tagsQuery defines the tags query to use
  101515. * @param forEach defines a predicate used to filter results
  101516. * @returns an array of Camera
  101517. */
  101518. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101519. /**
  101520. * Get a list of lights by tags
  101521. * @param tagsQuery defines the tags query to use
  101522. * @param forEach defines a predicate used to filter results
  101523. * @returns an array of Light
  101524. */
  101525. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101526. /**
  101527. * Get a list of materials by tags
  101528. * @param tagsQuery defines the tags query to use
  101529. * @param forEach defines a predicate used to filter results
  101530. * @returns an array of Material
  101531. */
  101532. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101533. /**
  101534. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101535. * This allowed control for front to back rendering or reversly depending of the special needs.
  101536. *
  101537. * @param renderingGroupId The rendering group id corresponding to its index
  101538. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101539. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101540. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101541. */
  101542. 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;
  101543. /**
  101544. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101545. *
  101546. * @param renderingGroupId The rendering group id corresponding to its index
  101547. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101548. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101549. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101550. */
  101551. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101552. /**
  101553. * Gets the current auto clear configuration for one rendering group of the rendering
  101554. * manager.
  101555. * @param index the rendering group index to get the information for
  101556. * @returns The auto clear setup for the requested rendering group
  101557. */
  101558. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101559. private _blockMaterialDirtyMechanism;
  101560. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101561. blockMaterialDirtyMechanism: boolean;
  101562. /**
  101563. * Will flag all materials as dirty to trigger new shader compilation
  101564. * @param flag defines the flag used to specify which material part must be marked as dirty
  101565. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101566. */
  101567. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101568. /** @hidden */
  101569. _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;
  101570. /** @hidden */
  101571. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101572. }
  101573. }
  101574. declare module BABYLON {
  101575. /**
  101576. * Set of assets to keep when moving a scene into an asset container.
  101577. */
  101578. export class KeepAssets extends AbstractScene {
  101579. }
  101580. /**
  101581. * Container with a set of assets that can be added or removed from a scene.
  101582. */
  101583. export class AssetContainer extends AbstractScene {
  101584. /**
  101585. * The scene the AssetContainer belongs to.
  101586. */
  101587. scene: Scene;
  101588. /**
  101589. * Instantiates an AssetContainer.
  101590. * @param scene The scene the AssetContainer belongs to.
  101591. */
  101592. constructor(scene: Scene);
  101593. /**
  101594. * Adds all the assets from the container to the scene.
  101595. */
  101596. addAllToScene(): void;
  101597. /**
  101598. * Removes all the assets in the container from the scene
  101599. */
  101600. removeAllFromScene(): void;
  101601. /**
  101602. * Disposes all the assets in the container
  101603. */
  101604. dispose(): void;
  101605. private _moveAssets;
  101606. /**
  101607. * Removes all the assets contained in the scene and adds them to the container.
  101608. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101609. */
  101610. moveAllFromScene(keepAssets?: KeepAssets): void;
  101611. /**
  101612. * 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.
  101613. * @returns the root mesh
  101614. */
  101615. createRootMesh(): Mesh;
  101616. }
  101617. }
  101618. declare module BABYLON {
  101619. /**
  101620. * Defines how the parser contract is defined.
  101621. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101622. */
  101623. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101624. /**
  101625. * Defines how the individual parser contract is defined.
  101626. * These parser can parse an individual asset
  101627. */
  101628. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101629. /**
  101630. * Base class of the scene acting as a container for the different elements composing a scene.
  101631. * This class is dynamically extended by the different components of the scene increasing
  101632. * flexibility and reducing coupling
  101633. */
  101634. export abstract class AbstractScene {
  101635. /**
  101636. * Stores the list of available parsers in the application.
  101637. */
  101638. private static _BabylonFileParsers;
  101639. /**
  101640. * Stores the list of available individual parsers in the application.
  101641. */
  101642. private static _IndividualBabylonFileParsers;
  101643. /**
  101644. * Adds a parser in the list of available ones
  101645. * @param name Defines the name of the parser
  101646. * @param parser Defines the parser to add
  101647. */
  101648. static AddParser(name: string, parser: BabylonFileParser): void;
  101649. /**
  101650. * Gets a general parser from the list of avaialble ones
  101651. * @param name Defines the name of the parser
  101652. * @returns the requested parser or null
  101653. */
  101654. static GetParser(name: string): Nullable<BabylonFileParser>;
  101655. /**
  101656. * Adds n individual parser in the list of available ones
  101657. * @param name Defines the name of the parser
  101658. * @param parser Defines the parser to add
  101659. */
  101660. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101661. /**
  101662. * Gets an individual parser from the list of avaialble ones
  101663. * @param name Defines the name of the parser
  101664. * @returns the requested parser or null
  101665. */
  101666. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101667. /**
  101668. * Parser json data and populate both a scene and its associated container object
  101669. * @param jsonData Defines the data to parse
  101670. * @param scene Defines the scene to parse the data for
  101671. * @param container Defines the container attached to the parsing sequence
  101672. * @param rootUrl Defines the root url of the data
  101673. */
  101674. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101675. /**
  101676. * Gets the list of root nodes (ie. nodes with no parent)
  101677. */
  101678. rootNodes: Node[];
  101679. /** All of the cameras added to this scene
  101680. * @see http://doc.babylonjs.com/babylon101/cameras
  101681. */
  101682. cameras: Camera[];
  101683. /**
  101684. * All of the lights added to this scene
  101685. * @see http://doc.babylonjs.com/babylon101/lights
  101686. */
  101687. lights: Light[];
  101688. /**
  101689. * All of the (abstract) meshes added to this scene
  101690. */
  101691. meshes: AbstractMesh[];
  101692. /**
  101693. * The list of skeletons added to the scene
  101694. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101695. */
  101696. skeletons: Skeleton[];
  101697. /**
  101698. * All of the particle systems added to this scene
  101699. * @see http://doc.babylonjs.com/babylon101/particles
  101700. */
  101701. particleSystems: IParticleSystem[];
  101702. /**
  101703. * Gets a list of Animations associated with the scene
  101704. */
  101705. animations: Animation[];
  101706. /**
  101707. * All of the animation groups added to this scene
  101708. * @see http://doc.babylonjs.com/how_to/group
  101709. */
  101710. animationGroups: AnimationGroup[];
  101711. /**
  101712. * All of the multi-materials added to this scene
  101713. * @see http://doc.babylonjs.com/how_to/multi_materials
  101714. */
  101715. multiMaterials: MultiMaterial[];
  101716. /**
  101717. * All of the materials added to this scene
  101718. * In the context of a Scene, it is not supposed to be modified manually.
  101719. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101720. * Note also that the order of the Material wihin the array is not significant and might change.
  101721. * @see http://doc.babylonjs.com/babylon101/materials
  101722. */
  101723. materials: Material[];
  101724. /**
  101725. * The list of morph target managers added to the scene
  101726. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101727. */
  101728. morphTargetManagers: MorphTargetManager[];
  101729. /**
  101730. * The list of geometries used in the scene.
  101731. */
  101732. geometries: Geometry[];
  101733. /**
  101734. * All of the tranform nodes added to this scene
  101735. * In the context of a Scene, it is not supposed to be modified manually.
  101736. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101737. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101738. * @see http://doc.babylonjs.com/how_to/transformnode
  101739. */
  101740. transformNodes: TransformNode[];
  101741. /**
  101742. * ActionManagers available on the scene.
  101743. */
  101744. actionManagers: AbstractActionManager[];
  101745. /**
  101746. * Textures to keep.
  101747. */
  101748. textures: BaseTexture[];
  101749. /**
  101750. * Environment texture for the scene
  101751. */
  101752. environmentTexture: Nullable<BaseTexture>;
  101753. }
  101754. }
  101755. declare module BABYLON {
  101756. /**
  101757. * Interface used to define options for Sound class
  101758. */
  101759. export interface ISoundOptions {
  101760. /**
  101761. * Does the sound autoplay once loaded.
  101762. */
  101763. autoplay?: boolean;
  101764. /**
  101765. * Does the sound loop after it finishes playing once.
  101766. */
  101767. loop?: boolean;
  101768. /**
  101769. * Sound's volume
  101770. */
  101771. volume?: number;
  101772. /**
  101773. * Is it a spatial sound?
  101774. */
  101775. spatialSound?: boolean;
  101776. /**
  101777. * Maximum distance to hear that sound
  101778. */
  101779. maxDistance?: number;
  101780. /**
  101781. * Uses user defined attenuation function
  101782. */
  101783. useCustomAttenuation?: boolean;
  101784. /**
  101785. * Define the roll off factor of spatial sounds.
  101786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101787. */
  101788. rolloffFactor?: number;
  101789. /**
  101790. * Define the reference distance the sound should be heard perfectly.
  101791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101792. */
  101793. refDistance?: number;
  101794. /**
  101795. * Define the distance attenuation model the sound will follow.
  101796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101797. */
  101798. distanceModel?: string;
  101799. /**
  101800. * Defines the playback speed (1 by default)
  101801. */
  101802. playbackRate?: number;
  101803. /**
  101804. * Defines if the sound is from a streaming source
  101805. */
  101806. streaming?: boolean;
  101807. /**
  101808. * Defines an optional length (in seconds) inside the sound file
  101809. */
  101810. length?: number;
  101811. /**
  101812. * Defines an optional offset (in seconds) inside the sound file
  101813. */
  101814. offset?: number;
  101815. /**
  101816. * If true, URLs will not be required to state the audio file codec to use.
  101817. */
  101818. skipCodecCheck?: boolean;
  101819. }
  101820. /**
  101821. * Defines a sound that can be played in the application.
  101822. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101824. */
  101825. export class Sound {
  101826. /**
  101827. * The name of the sound in the scene.
  101828. */
  101829. name: string;
  101830. /**
  101831. * Does the sound autoplay once loaded.
  101832. */
  101833. autoplay: boolean;
  101834. /**
  101835. * Does the sound loop after it finishes playing once.
  101836. */
  101837. loop: boolean;
  101838. /**
  101839. * Does the sound use a custom attenuation curve to simulate the falloff
  101840. * happening when the source gets further away from the camera.
  101841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101842. */
  101843. useCustomAttenuation: boolean;
  101844. /**
  101845. * The sound track id this sound belongs to.
  101846. */
  101847. soundTrackId: number;
  101848. /**
  101849. * Is this sound currently played.
  101850. */
  101851. isPlaying: boolean;
  101852. /**
  101853. * Is this sound currently paused.
  101854. */
  101855. isPaused: boolean;
  101856. /**
  101857. * Does this sound enables spatial sound.
  101858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101859. */
  101860. spatialSound: boolean;
  101861. /**
  101862. * Define the reference distance the sound should be heard perfectly.
  101863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101864. */
  101865. refDistance: number;
  101866. /**
  101867. * Define the roll off factor of spatial sounds.
  101868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101869. */
  101870. rolloffFactor: number;
  101871. /**
  101872. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101874. */
  101875. maxDistance: number;
  101876. /**
  101877. * Define the distance attenuation model the sound will follow.
  101878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101879. */
  101880. distanceModel: string;
  101881. /**
  101882. * @hidden
  101883. * Back Compat
  101884. **/
  101885. onended: () => any;
  101886. /**
  101887. * Observable event when the current playing sound finishes.
  101888. */
  101889. onEndedObservable: Observable<Sound>;
  101890. private _panningModel;
  101891. private _playbackRate;
  101892. private _streaming;
  101893. private _startTime;
  101894. private _startOffset;
  101895. private _position;
  101896. /** @hidden */
  101897. _positionInEmitterSpace: boolean;
  101898. private _localDirection;
  101899. private _volume;
  101900. private _isReadyToPlay;
  101901. private _isDirectional;
  101902. private _readyToPlayCallback;
  101903. private _audioBuffer;
  101904. private _soundSource;
  101905. private _streamingSource;
  101906. private _soundPanner;
  101907. private _soundGain;
  101908. private _inputAudioNode;
  101909. private _outputAudioNode;
  101910. private _coneInnerAngle;
  101911. private _coneOuterAngle;
  101912. private _coneOuterGain;
  101913. private _scene;
  101914. private _connectedTransformNode;
  101915. private _customAttenuationFunction;
  101916. private _registerFunc;
  101917. private _isOutputConnected;
  101918. private _htmlAudioElement;
  101919. private _urlType;
  101920. private _length?;
  101921. private _offset?;
  101922. /** @hidden */
  101923. static _SceneComponentInitialization: (scene: Scene) => void;
  101924. /**
  101925. * Create a sound and attach it to a scene
  101926. * @param name Name of your sound
  101927. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101928. * @param scene defines the scene the sound belongs to
  101929. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101930. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101931. */
  101932. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101933. /**
  101934. * Release the sound and its associated resources
  101935. */
  101936. dispose(): void;
  101937. /**
  101938. * Gets if the sounds is ready to be played or not.
  101939. * @returns true if ready, otherwise false
  101940. */
  101941. isReady(): boolean;
  101942. private _soundLoaded;
  101943. /**
  101944. * Sets the data of the sound from an audiobuffer
  101945. * @param audioBuffer The audioBuffer containing the data
  101946. */
  101947. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101948. /**
  101949. * Updates the current sounds options such as maxdistance, loop...
  101950. * @param options A JSON object containing values named as the object properties
  101951. */
  101952. updateOptions(options: ISoundOptions): void;
  101953. private _createSpatialParameters;
  101954. private _updateSpatialParameters;
  101955. /**
  101956. * Switch the panning model to HRTF:
  101957. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101959. */
  101960. switchPanningModelToHRTF(): void;
  101961. /**
  101962. * Switch the panning model to Equal Power:
  101963. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101965. */
  101966. switchPanningModelToEqualPower(): void;
  101967. private _switchPanningModel;
  101968. /**
  101969. * Connect this sound to a sound track audio node like gain...
  101970. * @param soundTrackAudioNode the sound track audio node to connect to
  101971. */
  101972. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101973. /**
  101974. * Transform this sound into a directional source
  101975. * @param coneInnerAngle Size of the inner cone in degree
  101976. * @param coneOuterAngle Size of the outer cone in degree
  101977. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101978. */
  101979. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101980. /**
  101981. * Gets or sets the inner angle for the directional cone.
  101982. */
  101983. /**
  101984. * Gets or sets the inner angle for the directional cone.
  101985. */
  101986. directionalConeInnerAngle: number;
  101987. /**
  101988. * Gets or sets the outer angle for the directional cone.
  101989. */
  101990. /**
  101991. * Gets or sets the outer angle for the directional cone.
  101992. */
  101993. directionalConeOuterAngle: number;
  101994. /**
  101995. * Sets the position of the emitter if spatial sound is enabled
  101996. * @param newPosition Defines the new posisiton
  101997. */
  101998. setPosition(newPosition: Vector3): void;
  101999. /**
  102000. * Sets the local direction of the emitter if spatial sound is enabled
  102001. * @param newLocalDirection Defines the new local direction
  102002. */
  102003. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102004. private _updateDirection;
  102005. /** @hidden */
  102006. updateDistanceFromListener(): void;
  102007. /**
  102008. * Sets a new custom attenuation function for the sound.
  102009. * @param callback Defines the function used for the attenuation
  102010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102011. */
  102012. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102013. /**
  102014. * Play the sound
  102015. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102016. * @param offset (optional) Start the sound at a specific time in seconds
  102017. * @param length (optional) Sound duration (in seconds)
  102018. */
  102019. play(time?: number, offset?: number, length?: number): void;
  102020. private _onended;
  102021. /**
  102022. * Stop the sound
  102023. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102024. */
  102025. stop(time?: number): void;
  102026. /**
  102027. * Put the sound in pause
  102028. */
  102029. pause(): void;
  102030. /**
  102031. * Sets a dedicated volume for this sounds
  102032. * @param newVolume Define the new volume of the sound
  102033. * @param time Define time for gradual change to new volume
  102034. */
  102035. setVolume(newVolume: number, time?: number): void;
  102036. /**
  102037. * Set the sound play back rate
  102038. * @param newPlaybackRate Define the playback rate the sound should be played at
  102039. */
  102040. setPlaybackRate(newPlaybackRate: number): void;
  102041. /**
  102042. * Gets the volume of the sound.
  102043. * @returns the volume of the sound
  102044. */
  102045. getVolume(): number;
  102046. /**
  102047. * Attach the sound to a dedicated mesh
  102048. * @param transformNode The transform node to connect the sound with
  102049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102050. */
  102051. attachToMesh(transformNode: TransformNode): void;
  102052. /**
  102053. * Detach the sound from the previously attached mesh
  102054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102055. */
  102056. detachFromMesh(): void;
  102057. private _onRegisterAfterWorldMatrixUpdate;
  102058. /**
  102059. * Clone the current sound in the scene.
  102060. * @returns the new sound clone
  102061. */
  102062. clone(): Nullable<Sound>;
  102063. /**
  102064. * Gets the current underlying audio buffer containing the data
  102065. * @returns the audio buffer
  102066. */
  102067. getAudioBuffer(): Nullable<AudioBuffer>;
  102068. /**
  102069. * Serializes the Sound in a JSON representation
  102070. * @returns the JSON representation of the sound
  102071. */
  102072. serialize(): any;
  102073. /**
  102074. * Parse a JSON representation of a sound to innstantiate in a given scene
  102075. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102076. * @param scene Define the scene the new parsed sound should be created in
  102077. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102078. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102079. * @returns the newly parsed sound
  102080. */
  102081. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102082. }
  102083. }
  102084. declare module BABYLON {
  102085. /**
  102086. * This defines an action helpful to play a defined sound on a triggered action.
  102087. */
  102088. export class PlaySoundAction extends Action {
  102089. private _sound;
  102090. /**
  102091. * Instantiate the action
  102092. * @param triggerOptions defines the trigger options
  102093. * @param sound defines the sound to play
  102094. * @param condition defines the trigger related conditions
  102095. */
  102096. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102097. /** @hidden */
  102098. _prepare(): void;
  102099. /**
  102100. * Execute the action and play the sound.
  102101. */
  102102. execute(): void;
  102103. /**
  102104. * Serializes the actions and its related information.
  102105. * @param parent defines the object to serialize in
  102106. * @returns the serialized object
  102107. */
  102108. serialize(parent: any): any;
  102109. }
  102110. /**
  102111. * This defines an action helpful to stop a defined sound on a triggered action.
  102112. */
  102113. export class StopSoundAction extends Action {
  102114. private _sound;
  102115. /**
  102116. * Instantiate the action
  102117. * @param triggerOptions defines the trigger options
  102118. * @param sound defines the sound to stop
  102119. * @param condition defines the trigger related conditions
  102120. */
  102121. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102122. /** @hidden */
  102123. _prepare(): void;
  102124. /**
  102125. * Execute the action and stop the sound.
  102126. */
  102127. execute(): void;
  102128. /**
  102129. * Serializes the actions and its related information.
  102130. * @param parent defines the object to serialize in
  102131. * @returns the serialized object
  102132. */
  102133. serialize(parent: any): any;
  102134. }
  102135. }
  102136. declare module BABYLON {
  102137. /**
  102138. * This defines an action responsible to change the value of a property
  102139. * by interpolating between its current value and the newly set one once triggered.
  102140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102141. */
  102142. export class InterpolateValueAction extends Action {
  102143. /**
  102144. * Defines the path of the property where the value should be interpolated
  102145. */
  102146. propertyPath: string;
  102147. /**
  102148. * Defines the target value at the end of the interpolation.
  102149. */
  102150. value: any;
  102151. /**
  102152. * Defines the time it will take for the property to interpolate to the value.
  102153. */
  102154. duration: number;
  102155. /**
  102156. * Defines if the other scene animations should be stopped when the action has been triggered
  102157. */
  102158. stopOtherAnimations?: boolean;
  102159. /**
  102160. * Defines a callback raised once the interpolation animation has been done.
  102161. */
  102162. onInterpolationDone?: () => void;
  102163. /**
  102164. * Observable triggered once the interpolation animation has been done.
  102165. */
  102166. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102167. private _target;
  102168. private _effectiveTarget;
  102169. private _property;
  102170. /**
  102171. * Instantiate the action
  102172. * @param triggerOptions defines the trigger options
  102173. * @param target defines the object containing the value to interpolate
  102174. * @param propertyPath defines the path to the property in the target object
  102175. * @param value defines the target value at the end of the interpolation
  102176. * @param duration deines the time it will take for the property to interpolate to the value.
  102177. * @param condition defines the trigger related conditions
  102178. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102179. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102180. */
  102181. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102182. /** @hidden */
  102183. _prepare(): void;
  102184. /**
  102185. * Execute the action starts the value interpolation.
  102186. */
  102187. execute(): void;
  102188. /**
  102189. * Serializes the actions and its related information.
  102190. * @param parent defines the object to serialize in
  102191. * @returns the serialized object
  102192. */
  102193. serialize(parent: any): any;
  102194. }
  102195. }
  102196. declare module BABYLON {
  102197. /**
  102198. * Options allowed during the creation of a sound track.
  102199. */
  102200. export interface ISoundTrackOptions {
  102201. /**
  102202. * The volume the sound track should take during creation
  102203. */
  102204. volume?: number;
  102205. /**
  102206. * Define if the sound track is the main sound track of the scene
  102207. */
  102208. mainTrack?: boolean;
  102209. }
  102210. /**
  102211. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102212. * It will be also used in a future release to apply effects on a specific track.
  102213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102214. */
  102215. export class SoundTrack {
  102216. /**
  102217. * The unique identifier of the sound track in the scene.
  102218. */
  102219. id: number;
  102220. /**
  102221. * The list of sounds included in the sound track.
  102222. */
  102223. soundCollection: Array<Sound>;
  102224. private _outputAudioNode;
  102225. private _scene;
  102226. private _isMainTrack;
  102227. private _connectedAnalyser;
  102228. private _options;
  102229. private _isInitialized;
  102230. /**
  102231. * Creates a new sound track.
  102232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102233. * @param scene Define the scene the sound track belongs to
  102234. * @param options
  102235. */
  102236. constructor(scene: Scene, options?: ISoundTrackOptions);
  102237. private _initializeSoundTrackAudioGraph;
  102238. /**
  102239. * Release the sound track and its associated resources
  102240. */
  102241. dispose(): void;
  102242. /**
  102243. * Adds a sound to this sound track
  102244. * @param sound define the cound to add
  102245. * @ignoreNaming
  102246. */
  102247. AddSound(sound: Sound): void;
  102248. /**
  102249. * Removes a sound to this sound track
  102250. * @param sound define the cound to remove
  102251. * @ignoreNaming
  102252. */
  102253. RemoveSound(sound: Sound): void;
  102254. /**
  102255. * Set a global volume for the full sound track.
  102256. * @param newVolume Define the new volume of the sound track
  102257. */
  102258. setVolume(newVolume: number): void;
  102259. /**
  102260. * Switch the panning model to HRTF:
  102261. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102263. */
  102264. switchPanningModelToHRTF(): void;
  102265. /**
  102266. * Switch the panning model to Equal Power:
  102267. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102269. */
  102270. switchPanningModelToEqualPower(): void;
  102271. /**
  102272. * Connect the sound track to an audio analyser allowing some amazing
  102273. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102275. * @param analyser The analyser to connect to the engine
  102276. */
  102277. connectToAnalyser(analyser: Analyser): void;
  102278. }
  102279. }
  102280. declare module BABYLON {
  102281. interface AbstractScene {
  102282. /**
  102283. * The list of sounds used in the scene.
  102284. */
  102285. sounds: Nullable<Array<Sound>>;
  102286. }
  102287. interface Scene {
  102288. /**
  102289. * @hidden
  102290. * Backing field
  102291. */
  102292. _mainSoundTrack: SoundTrack;
  102293. /**
  102294. * The main sound track played by the scene.
  102295. * It cotains your primary collection of sounds.
  102296. */
  102297. mainSoundTrack: SoundTrack;
  102298. /**
  102299. * The list of sound tracks added to the scene
  102300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102301. */
  102302. soundTracks: Nullable<Array<SoundTrack>>;
  102303. /**
  102304. * Gets a sound using a given name
  102305. * @param name defines the name to search for
  102306. * @return the found sound or null if not found at all.
  102307. */
  102308. getSoundByName(name: string): Nullable<Sound>;
  102309. /**
  102310. * Gets or sets if audio support is enabled
  102311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102312. */
  102313. audioEnabled: boolean;
  102314. /**
  102315. * Gets or sets if audio will be output to headphones
  102316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102317. */
  102318. headphone: boolean;
  102319. /**
  102320. * Gets or sets custom audio listener position provider
  102321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102322. */
  102323. audioListenerPositionProvider: Nullable<() => Vector3>;
  102324. }
  102325. /**
  102326. * Defines the sound scene component responsible to manage any sounds
  102327. * in a given scene.
  102328. */
  102329. export class AudioSceneComponent implements ISceneSerializableComponent {
  102330. /**
  102331. * The component name helpfull to identify the component in the list of scene components.
  102332. */
  102333. readonly name: string;
  102334. /**
  102335. * The scene the component belongs to.
  102336. */
  102337. scene: Scene;
  102338. private _audioEnabled;
  102339. /**
  102340. * Gets whether audio is enabled or not.
  102341. * Please use related enable/disable method to switch state.
  102342. */
  102343. readonly audioEnabled: boolean;
  102344. private _headphone;
  102345. /**
  102346. * Gets whether audio is outputing to headphone or not.
  102347. * Please use the according Switch methods to change output.
  102348. */
  102349. readonly headphone: boolean;
  102350. private _audioListenerPositionProvider;
  102351. /**
  102352. * Gets the current audio listener position provider
  102353. */
  102354. /**
  102355. * Sets a custom listener position for all sounds in the scene
  102356. * By default, this is the position of the first active camera
  102357. */
  102358. audioListenerPositionProvider: Nullable<() => Vector3>;
  102359. /**
  102360. * Creates a new instance of the component for the given scene
  102361. * @param scene Defines the scene to register the component in
  102362. */
  102363. constructor(scene: Scene);
  102364. /**
  102365. * Registers the component in a given scene
  102366. */
  102367. register(): void;
  102368. /**
  102369. * Rebuilds the elements related to this component in case of
  102370. * context lost for instance.
  102371. */
  102372. rebuild(): void;
  102373. /**
  102374. * Serializes the component data to the specified json object
  102375. * @param serializationObject The object to serialize to
  102376. */
  102377. serialize(serializationObject: any): void;
  102378. /**
  102379. * Adds all the elements from the container to the scene
  102380. * @param container the container holding the elements
  102381. */
  102382. addFromContainer(container: AbstractScene): void;
  102383. /**
  102384. * Removes all the elements in the container from the scene
  102385. * @param container contains the elements to remove
  102386. * @param dispose if the removed element should be disposed (default: false)
  102387. */
  102388. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102389. /**
  102390. * Disposes the component and the associated ressources.
  102391. */
  102392. dispose(): void;
  102393. /**
  102394. * Disables audio in the associated scene.
  102395. */
  102396. disableAudio(): void;
  102397. /**
  102398. * Enables audio in the associated scene.
  102399. */
  102400. enableAudio(): void;
  102401. /**
  102402. * Switch audio to headphone output.
  102403. */
  102404. switchAudioModeForHeadphones(): void;
  102405. /**
  102406. * Switch audio to normal speakers.
  102407. */
  102408. switchAudioModeForNormalSpeakers(): void;
  102409. private _afterRender;
  102410. }
  102411. }
  102412. declare module BABYLON {
  102413. /**
  102414. * Wraps one or more Sound objects and selects one with random weight for playback.
  102415. */
  102416. export class WeightedSound {
  102417. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102418. loop: boolean;
  102419. private _coneInnerAngle;
  102420. private _coneOuterAngle;
  102421. private _volume;
  102422. /** A Sound is currently playing. */
  102423. isPlaying: boolean;
  102424. /** A Sound is currently paused. */
  102425. isPaused: boolean;
  102426. private _sounds;
  102427. private _weights;
  102428. private _currentIndex?;
  102429. /**
  102430. * Creates a new WeightedSound from the list of sounds given.
  102431. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102432. * @param sounds Array of Sounds that will be selected from.
  102433. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102434. */
  102435. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102436. /**
  102437. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102438. */
  102439. /**
  102440. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102441. */
  102442. directionalConeInnerAngle: number;
  102443. /**
  102444. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102445. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102446. */
  102447. /**
  102448. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102449. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102450. */
  102451. directionalConeOuterAngle: number;
  102452. /**
  102453. * Playback volume.
  102454. */
  102455. /**
  102456. * Playback volume.
  102457. */
  102458. volume: number;
  102459. private _onended;
  102460. /**
  102461. * Suspend playback
  102462. */
  102463. pause(): void;
  102464. /**
  102465. * Stop playback
  102466. */
  102467. stop(): void;
  102468. /**
  102469. * Start playback.
  102470. * @param startOffset Position the clip head at a specific time in seconds.
  102471. */
  102472. play(startOffset?: number): void;
  102473. }
  102474. }
  102475. declare module BABYLON {
  102476. /**
  102477. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102478. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102479. */
  102480. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102481. /**
  102482. * Gets the name of the behavior.
  102483. */
  102484. readonly name: string;
  102485. /**
  102486. * The easing function used by animations
  102487. */
  102488. static EasingFunction: BackEase;
  102489. /**
  102490. * The easing mode used by animations
  102491. */
  102492. static EasingMode: number;
  102493. /**
  102494. * The duration of the animation, in milliseconds
  102495. */
  102496. transitionDuration: number;
  102497. /**
  102498. * Length of the distance animated by the transition when lower radius is reached
  102499. */
  102500. lowerRadiusTransitionRange: number;
  102501. /**
  102502. * Length of the distance animated by the transition when upper radius is reached
  102503. */
  102504. upperRadiusTransitionRange: number;
  102505. private _autoTransitionRange;
  102506. /**
  102507. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102508. */
  102509. /**
  102510. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102511. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102512. */
  102513. autoTransitionRange: boolean;
  102514. private _attachedCamera;
  102515. private _onAfterCheckInputsObserver;
  102516. private _onMeshTargetChangedObserver;
  102517. /**
  102518. * Initializes the behavior.
  102519. */
  102520. init(): void;
  102521. /**
  102522. * Attaches the behavior to its arc rotate camera.
  102523. * @param camera Defines the camera to attach the behavior to
  102524. */
  102525. attach(camera: ArcRotateCamera): void;
  102526. /**
  102527. * Detaches the behavior from its current arc rotate camera.
  102528. */
  102529. detach(): void;
  102530. private _radiusIsAnimating;
  102531. private _radiusBounceTransition;
  102532. private _animatables;
  102533. private _cachedWheelPrecision;
  102534. /**
  102535. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102536. * @param radiusLimit The limit to check against.
  102537. * @return Bool to indicate if at limit.
  102538. */
  102539. private _isRadiusAtLimit;
  102540. /**
  102541. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102542. * @param radiusDelta The delta by which to animate to. Can be negative.
  102543. */
  102544. private _applyBoundRadiusAnimation;
  102545. /**
  102546. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102547. */
  102548. protected _clearAnimationLocks(): void;
  102549. /**
  102550. * Stops and removes all animations that have been applied to the camera
  102551. */
  102552. stopAllAnimations(): void;
  102553. }
  102554. }
  102555. declare module BABYLON {
  102556. /**
  102557. * 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.
  102558. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102559. */
  102560. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102561. /**
  102562. * Gets the name of the behavior.
  102563. */
  102564. readonly name: string;
  102565. private _mode;
  102566. private _radiusScale;
  102567. private _positionScale;
  102568. private _defaultElevation;
  102569. private _elevationReturnTime;
  102570. private _elevationReturnWaitTime;
  102571. private _zoomStopsAnimation;
  102572. private _framingTime;
  102573. /**
  102574. * The easing function used by animations
  102575. */
  102576. static EasingFunction: ExponentialEase;
  102577. /**
  102578. * The easing mode used by animations
  102579. */
  102580. static EasingMode: number;
  102581. /**
  102582. * Sets the current mode used by the behavior
  102583. */
  102584. /**
  102585. * Gets current mode used by the behavior.
  102586. */
  102587. mode: number;
  102588. /**
  102589. * Sets the scale applied to the radius (1 by default)
  102590. */
  102591. /**
  102592. * Gets the scale applied to the radius
  102593. */
  102594. radiusScale: number;
  102595. /**
  102596. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102597. */
  102598. /**
  102599. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102600. */
  102601. positionScale: number;
  102602. /**
  102603. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102604. * behaviour is triggered, in radians.
  102605. */
  102606. /**
  102607. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102608. * behaviour is triggered, in radians.
  102609. */
  102610. defaultElevation: number;
  102611. /**
  102612. * Sets the time (in milliseconds) taken to return to the default beta position.
  102613. * Negative value indicates camera should not return to default.
  102614. */
  102615. /**
  102616. * Gets the time (in milliseconds) taken to return to the default beta position.
  102617. * Negative value indicates camera should not return to default.
  102618. */
  102619. elevationReturnTime: number;
  102620. /**
  102621. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102622. */
  102623. /**
  102624. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102625. */
  102626. elevationReturnWaitTime: number;
  102627. /**
  102628. * Sets the flag that indicates if user zooming should stop animation.
  102629. */
  102630. /**
  102631. * Gets the flag that indicates if user zooming should stop animation.
  102632. */
  102633. zoomStopsAnimation: boolean;
  102634. /**
  102635. * Sets the transition time when framing the mesh, in milliseconds
  102636. */
  102637. /**
  102638. * Gets the transition time when framing the mesh, in milliseconds
  102639. */
  102640. framingTime: number;
  102641. /**
  102642. * Define if the behavior should automatically change the configured
  102643. * camera limits and sensibilities.
  102644. */
  102645. autoCorrectCameraLimitsAndSensibility: boolean;
  102646. private _onPrePointerObservableObserver;
  102647. private _onAfterCheckInputsObserver;
  102648. private _onMeshTargetChangedObserver;
  102649. private _attachedCamera;
  102650. private _isPointerDown;
  102651. private _lastInteractionTime;
  102652. /**
  102653. * Initializes the behavior.
  102654. */
  102655. init(): void;
  102656. /**
  102657. * Attaches the behavior to its arc rotate camera.
  102658. * @param camera Defines the camera to attach the behavior to
  102659. */
  102660. attach(camera: ArcRotateCamera): void;
  102661. /**
  102662. * Detaches the behavior from its current arc rotate camera.
  102663. */
  102664. detach(): void;
  102665. private _animatables;
  102666. private _betaIsAnimating;
  102667. private _betaTransition;
  102668. private _radiusTransition;
  102669. private _vectorTransition;
  102670. /**
  102671. * Targets the given mesh and updates zoom level accordingly.
  102672. * @param mesh The mesh to target.
  102673. * @param radius Optional. If a cached radius position already exists, overrides default.
  102674. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102677. */
  102678. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102679. /**
  102680. * Targets the given mesh with its children and updates zoom level accordingly.
  102681. * @param mesh The mesh to target.
  102682. * @param radius Optional. If a cached radius position already exists, overrides default.
  102683. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102684. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102685. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102686. */
  102687. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102688. /**
  102689. * Targets the given meshes with their children and updates zoom level accordingly.
  102690. * @param meshes The mesh to target.
  102691. * @param radius Optional. If a cached radius position already exists, overrides default.
  102692. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102693. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102694. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102695. */
  102696. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102697. /**
  102698. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102699. * @param minimumWorld Determines the smaller position of the bounding box extend
  102700. * @param maximumWorld Determines the bigger position of the bounding box extend
  102701. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102702. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102703. */
  102704. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102705. /**
  102706. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102707. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102708. * frustum width.
  102709. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102710. * to fully enclose the mesh in the viewing frustum.
  102711. */
  102712. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102713. /**
  102714. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102715. * is automatically returned to its default position (expected to be above ground plane).
  102716. */
  102717. private _maintainCameraAboveGround;
  102718. /**
  102719. * Returns the frustum slope based on the canvas ratio and camera FOV
  102720. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102721. */
  102722. private _getFrustumSlope;
  102723. /**
  102724. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102725. */
  102726. private _clearAnimationLocks;
  102727. /**
  102728. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102729. */
  102730. private _applyUserInteraction;
  102731. /**
  102732. * Stops and removes all animations that have been applied to the camera
  102733. */
  102734. stopAllAnimations(): void;
  102735. /**
  102736. * Gets a value indicating if the user is moving the camera
  102737. */
  102738. readonly isUserIsMoving: boolean;
  102739. /**
  102740. * The camera can move all the way towards the mesh.
  102741. */
  102742. static IgnoreBoundsSizeMode: number;
  102743. /**
  102744. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102745. */
  102746. static FitFrustumSidesMode: number;
  102747. }
  102748. }
  102749. declare module BABYLON {
  102750. /**
  102751. * Base class for Camera Pointer Inputs.
  102752. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102753. * for example usage.
  102754. */
  102755. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102756. /**
  102757. * Defines the camera the input is attached to.
  102758. */
  102759. abstract camera: Camera;
  102760. /**
  102761. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102762. */
  102763. protected _altKey: boolean;
  102764. protected _ctrlKey: boolean;
  102765. protected _metaKey: boolean;
  102766. protected _shiftKey: boolean;
  102767. /**
  102768. * Which mouse buttons were pressed at time of last mouse event.
  102769. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102770. */
  102771. protected _buttonsPressed: number;
  102772. /**
  102773. * Defines the buttons associated with the input to handle camera move.
  102774. */
  102775. buttons: number[];
  102776. /**
  102777. * Attach the input controls to a specific dom element to get the input from.
  102778. * @param element Defines the element the controls should be listened from
  102779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102780. */
  102781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102782. /**
  102783. * Detach the current controls from the specified dom element.
  102784. * @param element Defines the element to stop listening the inputs from
  102785. */
  102786. detachControl(element: Nullable<HTMLElement>): void;
  102787. /**
  102788. * Gets the class name of the current input.
  102789. * @returns the class name
  102790. */
  102791. getClassName(): string;
  102792. /**
  102793. * Get the friendly name associated with the input class.
  102794. * @returns the input friendly name
  102795. */
  102796. getSimpleName(): string;
  102797. /**
  102798. * Called on pointer POINTERDOUBLETAP event.
  102799. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102800. */
  102801. protected onDoubleTap(type: string): void;
  102802. /**
  102803. * Called on pointer POINTERMOVE event if only a single touch is active.
  102804. * Override this method to provide functionality.
  102805. */
  102806. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102807. /**
  102808. * Called on pointer POINTERMOVE event if multiple touches are active.
  102809. * Override this method to provide functionality.
  102810. */
  102811. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102812. /**
  102813. * Called on JS contextmenu event.
  102814. * Override this method to provide functionality.
  102815. */
  102816. protected onContextMenu(evt: PointerEvent): void;
  102817. /**
  102818. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102819. * press.
  102820. * Override this method to provide functionality.
  102821. */
  102822. protected onButtonDown(evt: PointerEvent): void;
  102823. /**
  102824. * Called each time a new POINTERUP event occurs. Ie, for each button
  102825. * release.
  102826. * Override this method to provide functionality.
  102827. */
  102828. protected onButtonUp(evt: PointerEvent): void;
  102829. /**
  102830. * Called when window becomes inactive.
  102831. * Override this method to provide functionality.
  102832. */
  102833. protected onLostFocus(): void;
  102834. private _pointerInput;
  102835. private _observer;
  102836. private _onLostFocus;
  102837. private pointA;
  102838. private pointB;
  102839. }
  102840. }
  102841. declare module BABYLON {
  102842. /**
  102843. * Manage the pointers inputs to control an arc rotate camera.
  102844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102845. */
  102846. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102847. /**
  102848. * Defines the camera the input is attached to.
  102849. */
  102850. camera: ArcRotateCamera;
  102851. /**
  102852. * Gets the class name of the current input.
  102853. * @returns the class name
  102854. */
  102855. getClassName(): string;
  102856. /**
  102857. * Defines the buttons associated with the input to handle camera move.
  102858. */
  102859. buttons: number[];
  102860. /**
  102861. * Defines the pointer angular sensibility along the X axis or how fast is
  102862. * the camera rotating.
  102863. */
  102864. angularSensibilityX: number;
  102865. /**
  102866. * Defines the pointer angular sensibility along the Y axis or how fast is
  102867. * the camera rotating.
  102868. */
  102869. angularSensibilityY: number;
  102870. /**
  102871. * Defines the pointer pinch precision or how fast is the camera zooming.
  102872. */
  102873. pinchPrecision: number;
  102874. /**
  102875. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102876. * from 0.
  102877. * It defines the percentage of current camera.radius to use as delta when
  102878. * pinch zoom is used.
  102879. */
  102880. pinchDeltaPercentage: number;
  102881. /**
  102882. * Defines the pointer panning sensibility or how fast is the camera moving.
  102883. */
  102884. panningSensibility: number;
  102885. /**
  102886. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102887. */
  102888. multiTouchPanning: boolean;
  102889. /**
  102890. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102891. * zoom (pinch) through multitouch.
  102892. */
  102893. multiTouchPanAndZoom: boolean;
  102894. /**
  102895. * Revers pinch action direction.
  102896. */
  102897. pinchInwards: boolean;
  102898. private _isPanClick;
  102899. private _twoFingerActivityCount;
  102900. private _isPinching;
  102901. /**
  102902. * Called on pointer POINTERMOVE event if only a single touch is active.
  102903. */
  102904. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102905. /**
  102906. * Called on pointer POINTERDOUBLETAP event.
  102907. */
  102908. protected onDoubleTap(type: string): void;
  102909. /**
  102910. * Called on pointer POINTERMOVE event if multiple touches are active.
  102911. */
  102912. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102913. /**
  102914. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102915. * press.
  102916. */
  102917. protected onButtonDown(evt: PointerEvent): void;
  102918. /**
  102919. * Called each time a new POINTERUP event occurs. Ie, for each button
  102920. * release.
  102921. */
  102922. protected onButtonUp(evt: PointerEvent): void;
  102923. /**
  102924. * Called when window becomes inactive.
  102925. */
  102926. protected onLostFocus(): void;
  102927. }
  102928. }
  102929. declare module BABYLON {
  102930. /**
  102931. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102933. */
  102934. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102935. /**
  102936. * Defines the camera the input is attached to.
  102937. */
  102938. camera: ArcRotateCamera;
  102939. /**
  102940. * Defines the list of key codes associated with the up action (increase alpha)
  102941. */
  102942. keysUp: number[];
  102943. /**
  102944. * Defines the list of key codes associated with the down action (decrease alpha)
  102945. */
  102946. keysDown: number[];
  102947. /**
  102948. * Defines the list of key codes associated with the left action (increase beta)
  102949. */
  102950. keysLeft: number[];
  102951. /**
  102952. * Defines the list of key codes associated with the right action (decrease beta)
  102953. */
  102954. keysRight: number[];
  102955. /**
  102956. * Defines the list of key codes associated with the reset action.
  102957. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102958. */
  102959. keysReset: number[];
  102960. /**
  102961. * Defines the panning sensibility of the inputs.
  102962. * (How fast is the camera paning)
  102963. */
  102964. panningSensibility: number;
  102965. /**
  102966. * Defines the zooming sensibility of the inputs.
  102967. * (How fast is the camera zooming)
  102968. */
  102969. zoomingSensibility: number;
  102970. /**
  102971. * Defines wether maintaining the alt key down switch the movement mode from
  102972. * orientation to zoom.
  102973. */
  102974. useAltToZoom: boolean;
  102975. /**
  102976. * Rotation speed of the camera
  102977. */
  102978. angularSpeed: number;
  102979. private _keys;
  102980. private _ctrlPressed;
  102981. private _altPressed;
  102982. private _onCanvasBlurObserver;
  102983. private _onKeyboardObserver;
  102984. private _engine;
  102985. private _scene;
  102986. /**
  102987. * Attach the input controls to a specific dom element to get the input from.
  102988. * @param element Defines the element the controls should be listened from
  102989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102990. */
  102991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102992. /**
  102993. * Detach the current controls from the specified dom element.
  102994. * @param element Defines the element to stop listening the inputs from
  102995. */
  102996. detachControl(element: Nullable<HTMLElement>): void;
  102997. /**
  102998. * Update the current camera state depending on the inputs that have been used this frame.
  102999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103000. */
  103001. checkInputs(): void;
  103002. /**
  103003. * Gets the class name of the current intput.
  103004. * @returns the class name
  103005. */
  103006. getClassName(): string;
  103007. /**
  103008. * Get the friendly name associated with the input class.
  103009. * @returns the input friendly name
  103010. */
  103011. getSimpleName(): string;
  103012. }
  103013. }
  103014. declare module BABYLON {
  103015. /**
  103016. * Manage the mouse wheel inputs to control an arc rotate camera.
  103017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103018. */
  103019. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103020. /**
  103021. * Defines the camera the input is attached to.
  103022. */
  103023. camera: ArcRotateCamera;
  103024. /**
  103025. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103026. */
  103027. wheelPrecision: number;
  103028. /**
  103029. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103030. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103031. */
  103032. wheelDeltaPercentage: number;
  103033. private _wheel;
  103034. private _observer;
  103035. private computeDeltaFromMouseWheelLegacyEvent;
  103036. /**
  103037. * Attach the input controls to a specific dom element to get the input from.
  103038. * @param element Defines the element the controls should be listened from
  103039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103040. */
  103041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103042. /**
  103043. * Detach the current controls from the specified dom element.
  103044. * @param element Defines the element to stop listening the inputs from
  103045. */
  103046. detachControl(element: Nullable<HTMLElement>): void;
  103047. /**
  103048. * Gets the class name of the current intput.
  103049. * @returns the class name
  103050. */
  103051. getClassName(): string;
  103052. /**
  103053. * Get the friendly name associated with the input class.
  103054. * @returns the input friendly name
  103055. */
  103056. getSimpleName(): string;
  103057. }
  103058. }
  103059. declare module BABYLON {
  103060. /**
  103061. * Default Inputs manager for the ArcRotateCamera.
  103062. * It groups all the default supported inputs for ease of use.
  103063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103064. */
  103065. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103066. /**
  103067. * Instantiates a new ArcRotateCameraInputsManager.
  103068. * @param camera Defines the camera the inputs belong to
  103069. */
  103070. constructor(camera: ArcRotateCamera);
  103071. /**
  103072. * Add mouse wheel input support to the input manager.
  103073. * @returns the current input manager
  103074. */
  103075. addMouseWheel(): ArcRotateCameraInputsManager;
  103076. /**
  103077. * Add pointers input support to the input manager.
  103078. * @returns the current input manager
  103079. */
  103080. addPointers(): ArcRotateCameraInputsManager;
  103081. /**
  103082. * Add keyboard input support to the input manager.
  103083. * @returns the current input manager
  103084. */
  103085. addKeyboard(): ArcRotateCameraInputsManager;
  103086. }
  103087. }
  103088. declare module BABYLON {
  103089. /**
  103090. * This represents an orbital type of camera.
  103091. *
  103092. * 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.
  103093. * 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.
  103094. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103095. */
  103096. export class ArcRotateCamera extends TargetCamera {
  103097. /**
  103098. * Defines the rotation angle of the camera along the longitudinal axis.
  103099. */
  103100. alpha: number;
  103101. /**
  103102. * Defines the rotation angle of the camera along the latitudinal axis.
  103103. */
  103104. beta: number;
  103105. /**
  103106. * Defines the radius of the camera from it s target point.
  103107. */
  103108. radius: number;
  103109. protected _target: Vector3;
  103110. protected _targetHost: Nullable<AbstractMesh>;
  103111. /**
  103112. * Defines the target point of the camera.
  103113. * The camera looks towards it form the radius distance.
  103114. */
  103115. target: Vector3;
  103116. /**
  103117. * Define the current local position of the camera in the scene
  103118. */
  103119. position: Vector3;
  103120. protected _upVector: Vector3;
  103121. protected _upToYMatrix: Matrix;
  103122. protected _YToUpMatrix: Matrix;
  103123. /**
  103124. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103125. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103126. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103127. */
  103128. upVector: Vector3;
  103129. /**
  103130. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103131. */
  103132. setMatUp(): void;
  103133. /**
  103134. * Current inertia value on the longitudinal axis.
  103135. * The bigger this number the longer it will take for the camera to stop.
  103136. */
  103137. inertialAlphaOffset: number;
  103138. /**
  103139. * Current inertia value on the latitudinal axis.
  103140. * The bigger this number the longer it will take for the camera to stop.
  103141. */
  103142. inertialBetaOffset: number;
  103143. /**
  103144. * Current inertia value on the radius axis.
  103145. * The bigger this number the longer it will take for the camera to stop.
  103146. */
  103147. inertialRadiusOffset: number;
  103148. /**
  103149. * Minimum allowed angle on the longitudinal axis.
  103150. * This can help limiting how the Camera is able to move in the scene.
  103151. */
  103152. lowerAlphaLimit: Nullable<number>;
  103153. /**
  103154. * Maximum allowed angle on the longitudinal axis.
  103155. * This can help limiting how the Camera is able to move in the scene.
  103156. */
  103157. upperAlphaLimit: Nullable<number>;
  103158. /**
  103159. * Minimum allowed angle on the latitudinal axis.
  103160. * This can help limiting how the Camera is able to move in the scene.
  103161. */
  103162. lowerBetaLimit: number;
  103163. /**
  103164. * Maximum allowed angle on the latitudinal axis.
  103165. * This can help limiting how the Camera is able to move in the scene.
  103166. */
  103167. upperBetaLimit: number;
  103168. /**
  103169. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103170. * This can help limiting how the Camera is able to move in the scene.
  103171. */
  103172. lowerRadiusLimit: Nullable<number>;
  103173. /**
  103174. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103175. * This can help limiting how the Camera is able to move in the scene.
  103176. */
  103177. upperRadiusLimit: Nullable<number>;
  103178. /**
  103179. * Defines the current inertia value used during panning of the camera along the X axis.
  103180. */
  103181. inertialPanningX: number;
  103182. /**
  103183. * Defines the current inertia value used during panning of the camera along the Y axis.
  103184. */
  103185. inertialPanningY: number;
  103186. /**
  103187. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103188. * Basically if your fingers moves away from more than this distance you will be considered
  103189. * in pinch mode.
  103190. */
  103191. pinchToPanMaxDistance: number;
  103192. /**
  103193. * Defines the maximum distance the camera can pan.
  103194. * This could help keeping the cammera always in your scene.
  103195. */
  103196. panningDistanceLimit: Nullable<number>;
  103197. /**
  103198. * Defines the target of the camera before paning.
  103199. */
  103200. panningOriginTarget: Vector3;
  103201. /**
  103202. * Defines the value of the inertia used during panning.
  103203. * 0 would mean stop inertia and one would mean no decelleration at all.
  103204. */
  103205. panningInertia: number;
  103206. /**
  103207. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103208. */
  103209. angularSensibilityX: number;
  103210. /**
  103211. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103212. */
  103213. angularSensibilityY: number;
  103214. /**
  103215. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103216. */
  103217. pinchPrecision: number;
  103218. /**
  103219. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103220. * It will be used instead of pinchDeltaPrecision if different from 0.
  103221. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103222. */
  103223. pinchDeltaPercentage: number;
  103224. /**
  103225. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103226. */
  103227. panningSensibility: number;
  103228. /**
  103229. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103230. */
  103231. keysUp: number[];
  103232. /**
  103233. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103234. */
  103235. keysDown: number[];
  103236. /**
  103237. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103238. */
  103239. keysLeft: number[];
  103240. /**
  103241. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103242. */
  103243. keysRight: number[];
  103244. /**
  103245. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103246. */
  103247. wheelPrecision: number;
  103248. /**
  103249. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103250. * It will be used instead of pinchDeltaPrecision if different from 0.
  103251. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103252. */
  103253. wheelDeltaPercentage: number;
  103254. /**
  103255. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103256. */
  103257. zoomOnFactor: number;
  103258. /**
  103259. * Defines a screen offset for the camera position.
  103260. */
  103261. targetScreenOffset: Vector2;
  103262. /**
  103263. * Allows the camera to be completely reversed.
  103264. * If false the camera can not arrive upside down.
  103265. */
  103266. allowUpsideDown: boolean;
  103267. /**
  103268. * Define if double tap/click is used to restore the previously saved state of the camera.
  103269. */
  103270. useInputToRestoreState: boolean;
  103271. /** @hidden */
  103272. _viewMatrix: Matrix;
  103273. /** @hidden */
  103274. _useCtrlForPanning: boolean;
  103275. /** @hidden */
  103276. _panningMouseButton: number;
  103277. /**
  103278. * Defines the input associated to the camera.
  103279. */
  103280. inputs: ArcRotateCameraInputsManager;
  103281. /** @hidden */
  103282. _reset: () => void;
  103283. /**
  103284. * Defines the allowed panning axis.
  103285. */
  103286. panningAxis: Vector3;
  103287. protected _localDirection: Vector3;
  103288. protected _transformedDirection: Vector3;
  103289. private _bouncingBehavior;
  103290. /**
  103291. * Gets the bouncing behavior of the camera if it has been enabled.
  103292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103293. */
  103294. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103295. /**
  103296. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103298. */
  103299. useBouncingBehavior: boolean;
  103300. private _framingBehavior;
  103301. /**
  103302. * Gets the framing behavior of the camera if it has been enabled.
  103303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103304. */
  103305. readonly framingBehavior: Nullable<FramingBehavior>;
  103306. /**
  103307. * Defines if the framing behavior of the camera is enabled on the camera.
  103308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103309. */
  103310. useFramingBehavior: boolean;
  103311. private _autoRotationBehavior;
  103312. /**
  103313. * Gets the auto rotation behavior of the camera if it has been enabled.
  103314. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103315. */
  103316. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103317. /**
  103318. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103320. */
  103321. useAutoRotationBehavior: boolean;
  103322. /**
  103323. * Observable triggered when the mesh target has been changed on the camera.
  103324. */
  103325. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103326. /**
  103327. * Event raised when the camera is colliding with a mesh.
  103328. */
  103329. onCollide: (collidedMesh: AbstractMesh) => void;
  103330. /**
  103331. * Defines whether the camera should check collision with the objects oh the scene.
  103332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103333. */
  103334. checkCollisions: boolean;
  103335. /**
  103336. * Defines the collision radius of the camera.
  103337. * This simulates a sphere around the camera.
  103338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103339. */
  103340. collisionRadius: Vector3;
  103341. protected _collider: Collider;
  103342. protected _previousPosition: Vector3;
  103343. protected _collisionVelocity: Vector3;
  103344. protected _newPosition: Vector3;
  103345. protected _previousAlpha: number;
  103346. protected _previousBeta: number;
  103347. protected _previousRadius: number;
  103348. protected _collisionTriggered: boolean;
  103349. protected _targetBoundingCenter: Nullable<Vector3>;
  103350. private _computationVector;
  103351. /**
  103352. * Instantiates a new ArcRotateCamera in a given scene
  103353. * @param name Defines the name of the camera
  103354. * @param alpha Defines the camera rotation along the logitudinal axis
  103355. * @param beta Defines the camera rotation along the latitudinal axis
  103356. * @param radius Defines the camera distance from its target
  103357. * @param target Defines the camera target
  103358. * @param scene Defines the scene the camera belongs to
  103359. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103360. */
  103361. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103362. /** @hidden */
  103363. _initCache(): void;
  103364. /** @hidden */
  103365. _updateCache(ignoreParentClass?: boolean): void;
  103366. protected _getTargetPosition(): Vector3;
  103367. private _storedAlpha;
  103368. private _storedBeta;
  103369. private _storedRadius;
  103370. private _storedTarget;
  103371. private _storedTargetScreenOffset;
  103372. /**
  103373. * Stores the current state of the camera (alpha, beta, radius and target)
  103374. * @returns the camera itself
  103375. */
  103376. storeState(): Camera;
  103377. /**
  103378. * @hidden
  103379. * Restored camera state. You must call storeState() first
  103380. */
  103381. _restoreStateValues(): boolean;
  103382. /** @hidden */
  103383. _isSynchronizedViewMatrix(): boolean;
  103384. /**
  103385. * Attached controls to the current camera.
  103386. * @param element Defines the element the controls should be listened from
  103387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103388. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103389. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103390. */
  103391. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103392. /**
  103393. * Detach the current controls from the camera.
  103394. * The camera will stop reacting to inputs.
  103395. * @param element Defines the element to stop listening the inputs from
  103396. */
  103397. detachControl(element: HTMLElement): void;
  103398. /** @hidden */
  103399. _checkInputs(): void;
  103400. protected _checkLimits(): void;
  103401. /**
  103402. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103403. */
  103404. rebuildAnglesAndRadius(): void;
  103405. /**
  103406. * Use a position to define the current camera related information like alpha, beta and radius
  103407. * @param position Defines the position to set the camera at
  103408. */
  103409. setPosition(position: Vector3): void;
  103410. /**
  103411. * Defines the target the camera should look at.
  103412. * This will automatically adapt alpha beta and radius to fit within the new target.
  103413. * @param target Defines the new target as a Vector or a mesh
  103414. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103415. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103416. */
  103417. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103418. /** @hidden */
  103419. _getViewMatrix(): Matrix;
  103420. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103421. /**
  103422. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103423. * @param meshes Defines the mesh to zoom on
  103424. * @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)
  103425. */
  103426. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103427. /**
  103428. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103429. * The target will be changed but the radius
  103430. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103431. * @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)
  103432. */
  103433. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103434. min: Vector3;
  103435. max: Vector3;
  103436. distance: number;
  103437. }, doNotUpdateMaxZ?: boolean): void;
  103438. /**
  103439. * @override
  103440. * Override Camera.createRigCamera
  103441. */
  103442. createRigCamera(name: string, cameraIndex: number): Camera;
  103443. /**
  103444. * @hidden
  103445. * @override
  103446. * Override Camera._updateRigCameras
  103447. */
  103448. _updateRigCameras(): void;
  103449. /**
  103450. * Destroy the camera and release the current resources hold by it.
  103451. */
  103452. dispose(): void;
  103453. /**
  103454. * Gets the current object class name.
  103455. * @return the class name
  103456. */
  103457. getClassName(): string;
  103458. }
  103459. }
  103460. declare module BABYLON {
  103461. /**
  103462. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103463. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103464. */
  103465. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103466. /**
  103467. * Gets the name of the behavior.
  103468. */
  103469. readonly name: string;
  103470. private _zoomStopsAnimation;
  103471. private _idleRotationSpeed;
  103472. private _idleRotationWaitTime;
  103473. private _idleRotationSpinupTime;
  103474. /**
  103475. * Sets the flag that indicates if user zooming should stop animation.
  103476. */
  103477. /**
  103478. * Gets the flag that indicates if user zooming should stop animation.
  103479. */
  103480. zoomStopsAnimation: boolean;
  103481. /**
  103482. * Sets the default speed at which the camera rotates around the model.
  103483. */
  103484. /**
  103485. * Gets the default speed at which the camera rotates around the model.
  103486. */
  103487. idleRotationSpeed: number;
  103488. /**
  103489. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103490. */
  103491. /**
  103492. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103493. */
  103494. idleRotationWaitTime: number;
  103495. /**
  103496. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103497. */
  103498. /**
  103499. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103500. */
  103501. idleRotationSpinupTime: number;
  103502. /**
  103503. * Gets a value indicating if the camera is currently rotating because of this behavior
  103504. */
  103505. readonly rotationInProgress: boolean;
  103506. private _onPrePointerObservableObserver;
  103507. private _onAfterCheckInputsObserver;
  103508. private _attachedCamera;
  103509. private _isPointerDown;
  103510. private _lastFrameTime;
  103511. private _lastInteractionTime;
  103512. private _cameraRotationSpeed;
  103513. /**
  103514. * Initializes the behavior.
  103515. */
  103516. init(): void;
  103517. /**
  103518. * Attaches the behavior to its arc rotate camera.
  103519. * @param camera Defines the camera to attach the behavior to
  103520. */
  103521. attach(camera: ArcRotateCamera): void;
  103522. /**
  103523. * Detaches the behavior from its current arc rotate camera.
  103524. */
  103525. detach(): void;
  103526. /**
  103527. * Returns true if user is scrolling.
  103528. * @return true if user is scrolling.
  103529. */
  103530. private _userIsZooming;
  103531. private _lastFrameRadius;
  103532. private _shouldAnimationStopForInteraction;
  103533. /**
  103534. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103535. */
  103536. private _applyUserInteraction;
  103537. private _userIsMoving;
  103538. }
  103539. }
  103540. declare module BABYLON {
  103541. /**
  103542. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103543. */
  103544. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103545. private ui;
  103546. /**
  103547. * The name of the behavior
  103548. */
  103549. name: string;
  103550. /**
  103551. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103552. */
  103553. distanceAwayFromFace: number;
  103554. /**
  103555. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103556. */
  103557. distanceAwayFromBottomOfFace: number;
  103558. private _faceVectors;
  103559. private _target;
  103560. private _scene;
  103561. private _onRenderObserver;
  103562. private _tmpMatrix;
  103563. private _tmpVector;
  103564. /**
  103565. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103566. * @param ui The transform node that should be attched to the mesh
  103567. */
  103568. constructor(ui: TransformNode);
  103569. /**
  103570. * Initializes the behavior
  103571. */
  103572. init(): void;
  103573. private _closestFace;
  103574. private _zeroVector;
  103575. private _lookAtTmpMatrix;
  103576. private _lookAtToRef;
  103577. /**
  103578. * Attaches the AttachToBoxBehavior to the passed in mesh
  103579. * @param target The mesh that the specified node will be attached to
  103580. */
  103581. attach(target: Mesh): void;
  103582. /**
  103583. * Detaches the behavior from the mesh
  103584. */
  103585. detach(): void;
  103586. }
  103587. }
  103588. declare module BABYLON {
  103589. /**
  103590. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103591. */
  103592. export class FadeInOutBehavior implements Behavior<Mesh> {
  103593. /**
  103594. * Time in milliseconds to delay before fading in (Default: 0)
  103595. */
  103596. delay: number;
  103597. /**
  103598. * Time in milliseconds for the mesh to fade in (Default: 300)
  103599. */
  103600. fadeInTime: number;
  103601. private _millisecondsPerFrame;
  103602. private _hovered;
  103603. private _hoverValue;
  103604. private _ownerNode;
  103605. /**
  103606. * Instatiates the FadeInOutBehavior
  103607. */
  103608. constructor();
  103609. /**
  103610. * The name of the behavior
  103611. */
  103612. readonly name: string;
  103613. /**
  103614. * Initializes the behavior
  103615. */
  103616. init(): void;
  103617. /**
  103618. * Attaches the fade behavior on the passed in mesh
  103619. * @param ownerNode The mesh that will be faded in/out once attached
  103620. */
  103621. attach(ownerNode: Mesh): void;
  103622. /**
  103623. * Detaches the behavior from the mesh
  103624. */
  103625. detach(): void;
  103626. /**
  103627. * Triggers the mesh to begin fading in or out
  103628. * @param value if the object should fade in or out (true to fade in)
  103629. */
  103630. fadeIn(value: boolean): void;
  103631. private _update;
  103632. private _setAllVisibility;
  103633. }
  103634. }
  103635. declare module BABYLON {
  103636. /**
  103637. * Class containing a set of static utilities functions for managing Pivots
  103638. * @hidden
  103639. */
  103640. export class PivotTools {
  103641. private static _PivotCached;
  103642. private static _OldPivotPoint;
  103643. private static _PivotTranslation;
  103644. private static _PivotTmpVector;
  103645. /** @hidden */
  103646. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103647. /** @hidden */
  103648. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103649. }
  103650. }
  103651. declare module BABYLON {
  103652. /**
  103653. * Class containing static functions to help procedurally build meshes
  103654. */
  103655. export class PlaneBuilder {
  103656. /**
  103657. * Creates a plane mesh
  103658. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103659. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103660. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103664. * @param name defines the name of the mesh
  103665. * @param options defines the options used to create the mesh
  103666. * @param scene defines the hosting scene
  103667. * @returns the plane mesh
  103668. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103669. */
  103670. static CreatePlane(name: string, options: {
  103671. size?: number;
  103672. width?: number;
  103673. height?: number;
  103674. sideOrientation?: number;
  103675. frontUVs?: Vector4;
  103676. backUVs?: Vector4;
  103677. updatable?: boolean;
  103678. sourcePlane?: Plane;
  103679. }, scene?: Nullable<Scene>): Mesh;
  103680. }
  103681. }
  103682. declare module BABYLON {
  103683. /**
  103684. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103685. */
  103686. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103687. private static _AnyMouseID;
  103688. /**
  103689. * Abstract mesh the behavior is set on
  103690. */
  103691. attachedNode: AbstractMesh;
  103692. private _dragPlane;
  103693. private _scene;
  103694. private _pointerObserver;
  103695. private _beforeRenderObserver;
  103696. private static _planeScene;
  103697. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103698. /**
  103699. * 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)
  103700. */
  103701. maxDragAngle: number;
  103702. /**
  103703. * @hidden
  103704. */
  103705. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103706. /**
  103707. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103708. */
  103709. currentDraggingPointerID: number;
  103710. /**
  103711. * The last position where the pointer hit the drag plane in world space
  103712. */
  103713. lastDragPosition: Vector3;
  103714. /**
  103715. * If the behavior is currently in a dragging state
  103716. */
  103717. dragging: boolean;
  103718. /**
  103719. * 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)
  103720. */
  103721. dragDeltaRatio: number;
  103722. /**
  103723. * If the drag plane orientation should be updated during the dragging (Default: true)
  103724. */
  103725. updateDragPlane: boolean;
  103726. private _debugMode;
  103727. private _moving;
  103728. /**
  103729. * Fires each time the attached mesh is dragged with the pointer
  103730. * * delta between last drag position and current drag position in world space
  103731. * * dragDistance along the drag axis
  103732. * * dragPlaneNormal normal of the current drag plane used during the drag
  103733. * * dragPlanePoint in world space where the drag intersects the drag plane
  103734. */
  103735. onDragObservable: Observable<{
  103736. delta: Vector3;
  103737. dragPlanePoint: Vector3;
  103738. dragPlaneNormal: Vector3;
  103739. dragDistance: number;
  103740. pointerId: number;
  103741. }>;
  103742. /**
  103743. * Fires each time a drag begins (eg. mouse down on mesh)
  103744. */
  103745. onDragStartObservable: Observable<{
  103746. dragPlanePoint: Vector3;
  103747. pointerId: number;
  103748. }>;
  103749. /**
  103750. * Fires each time a drag ends (eg. mouse release after drag)
  103751. */
  103752. onDragEndObservable: Observable<{
  103753. dragPlanePoint: Vector3;
  103754. pointerId: number;
  103755. }>;
  103756. /**
  103757. * If the attached mesh should be moved when dragged
  103758. */
  103759. moveAttached: boolean;
  103760. /**
  103761. * If the drag behavior will react to drag events (Default: true)
  103762. */
  103763. enabled: boolean;
  103764. /**
  103765. * If pointer events should start and release the drag (Default: true)
  103766. */
  103767. startAndReleaseDragOnPointerEvents: boolean;
  103768. /**
  103769. * If camera controls should be detached during the drag
  103770. */
  103771. detachCameraControls: boolean;
  103772. /**
  103773. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103774. */
  103775. useObjectOrienationForDragging: boolean;
  103776. private _options;
  103777. /**
  103778. * Creates a pointer drag behavior that can be attached to a mesh
  103779. * @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)
  103780. */
  103781. constructor(options?: {
  103782. dragAxis?: Vector3;
  103783. dragPlaneNormal?: Vector3;
  103784. });
  103785. /**
  103786. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103787. */
  103788. validateDrag: (targetPosition: Vector3) => boolean;
  103789. /**
  103790. * The name of the behavior
  103791. */
  103792. readonly name: string;
  103793. /**
  103794. * Initializes the behavior
  103795. */
  103796. init(): void;
  103797. private _tmpVector;
  103798. private _alternatePickedPoint;
  103799. private _worldDragAxis;
  103800. private _targetPosition;
  103801. private _attachedElement;
  103802. /**
  103803. * Attaches the drag behavior the passed in mesh
  103804. * @param ownerNode The mesh that will be dragged around once attached
  103805. * @param predicate Predicate to use for pick filtering
  103806. */
  103807. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103808. /**
  103809. * Force relase the drag action by code.
  103810. */
  103811. releaseDrag(): void;
  103812. private _startDragRay;
  103813. private _lastPointerRay;
  103814. /**
  103815. * Simulates the start of a pointer drag event on the behavior
  103816. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103817. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103818. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103819. */
  103820. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103821. private _startDrag;
  103822. private _dragDelta;
  103823. private _moveDrag;
  103824. private _pickWithRayOnDragPlane;
  103825. private _pointA;
  103826. private _pointB;
  103827. private _pointC;
  103828. private _lineA;
  103829. private _lineB;
  103830. private _localAxis;
  103831. private _lookAt;
  103832. private _updateDragPlanePosition;
  103833. /**
  103834. * Detaches the behavior from the mesh
  103835. */
  103836. detach(): void;
  103837. }
  103838. }
  103839. declare module BABYLON {
  103840. /**
  103841. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103842. */
  103843. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103844. private _dragBehaviorA;
  103845. private _dragBehaviorB;
  103846. private _startDistance;
  103847. private _initialScale;
  103848. private _targetScale;
  103849. private _ownerNode;
  103850. private _sceneRenderObserver;
  103851. /**
  103852. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103853. */
  103854. constructor();
  103855. /**
  103856. * The name of the behavior
  103857. */
  103858. readonly name: string;
  103859. /**
  103860. * Initializes the behavior
  103861. */
  103862. init(): void;
  103863. private _getCurrentDistance;
  103864. /**
  103865. * Attaches the scale behavior the passed in mesh
  103866. * @param ownerNode The mesh that will be scaled around once attached
  103867. */
  103868. attach(ownerNode: Mesh): void;
  103869. /**
  103870. * Detaches the behavior from the mesh
  103871. */
  103872. detach(): void;
  103873. }
  103874. }
  103875. declare module BABYLON {
  103876. /**
  103877. * 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
  103878. */
  103879. export class SixDofDragBehavior implements Behavior<Mesh> {
  103880. private static _virtualScene;
  103881. private _ownerNode;
  103882. private _sceneRenderObserver;
  103883. private _scene;
  103884. private _targetPosition;
  103885. private _virtualOriginMesh;
  103886. private _virtualDragMesh;
  103887. private _pointerObserver;
  103888. private _moving;
  103889. private _startingOrientation;
  103890. /**
  103891. * 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)
  103892. */
  103893. private zDragFactor;
  103894. /**
  103895. * If the object should rotate to face the drag origin
  103896. */
  103897. rotateDraggedObject: boolean;
  103898. /**
  103899. * If the behavior is currently in a dragging state
  103900. */
  103901. dragging: boolean;
  103902. /**
  103903. * 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)
  103904. */
  103905. dragDeltaRatio: number;
  103906. /**
  103907. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103908. */
  103909. currentDraggingPointerID: number;
  103910. /**
  103911. * If camera controls should be detached during the drag
  103912. */
  103913. detachCameraControls: boolean;
  103914. /**
  103915. * Fires each time a drag starts
  103916. */
  103917. onDragStartObservable: Observable<{}>;
  103918. /**
  103919. * Fires each time a drag ends (eg. mouse release after drag)
  103920. */
  103921. onDragEndObservable: Observable<{}>;
  103922. /**
  103923. * 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
  103924. */
  103925. constructor();
  103926. /**
  103927. * The name of the behavior
  103928. */
  103929. readonly name: string;
  103930. /**
  103931. * Initializes the behavior
  103932. */
  103933. init(): void;
  103934. /**
  103935. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103936. */
  103937. private readonly _pointerCamera;
  103938. /**
  103939. * Attaches the scale behavior the passed in mesh
  103940. * @param ownerNode The mesh that will be scaled around once attached
  103941. */
  103942. attach(ownerNode: Mesh): void;
  103943. /**
  103944. * Detaches the behavior from the mesh
  103945. */
  103946. detach(): void;
  103947. }
  103948. }
  103949. declare module BABYLON {
  103950. /**
  103951. * Class used to apply inverse kinematics to bones
  103952. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103953. */
  103954. export class BoneIKController {
  103955. private static _tmpVecs;
  103956. private static _tmpQuat;
  103957. private static _tmpMats;
  103958. /**
  103959. * Gets or sets the target mesh
  103960. */
  103961. targetMesh: AbstractMesh;
  103962. /** Gets or sets the mesh used as pole */
  103963. poleTargetMesh: AbstractMesh;
  103964. /**
  103965. * Gets or sets the bone used as pole
  103966. */
  103967. poleTargetBone: Nullable<Bone>;
  103968. /**
  103969. * Gets or sets the target position
  103970. */
  103971. targetPosition: Vector3;
  103972. /**
  103973. * Gets or sets the pole target position
  103974. */
  103975. poleTargetPosition: Vector3;
  103976. /**
  103977. * Gets or sets the pole target local offset
  103978. */
  103979. poleTargetLocalOffset: Vector3;
  103980. /**
  103981. * Gets or sets the pole angle
  103982. */
  103983. poleAngle: number;
  103984. /**
  103985. * Gets or sets the mesh associated with the controller
  103986. */
  103987. mesh: AbstractMesh;
  103988. /**
  103989. * 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)
  103990. */
  103991. slerpAmount: number;
  103992. private _bone1Quat;
  103993. private _bone1Mat;
  103994. private _bone2Ang;
  103995. private _bone1;
  103996. private _bone2;
  103997. private _bone1Length;
  103998. private _bone2Length;
  103999. private _maxAngle;
  104000. private _maxReach;
  104001. private _rightHandedSystem;
  104002. private _bendAxis;
  104003. private _slerping;
  104004. private _adjustRoll;
  104005. /**
  104006. * Gets or sets maximum allowed angle
  104007. */
  104008. maxAngle: number;
  104009. /**
  104010. * Creates a new BoneIKController
  104011. * @param mesh defines the mesh to control
  104012. * @param bone defines the bone to control
  104013. * @param options defines options to set up the controller
  104014. */
  104015. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104016. targetMesh?: AbstractMesh;
  104017. poleTargetMesh?: AbstractMesh;
  104018. poleTargetBone?: Bone;
  104019. poleTargetLocalOffset?: Vector3;
  104020. poleAngle?: number;
  104021. bendAxis?: Vector3;
  104022. maxAngle?: number;
  104023. slerpAmount?: number;
  104024. });
  104025. private _setMaxAngle;
  104026. /**
  104027. * Force the controller to update the bones
  104028. */
  104029. update(): void;
  104030. }
  104031. }
  104032. declare module BABYLON {
  104033. /**
  104034. * Class used to make a bone look toward a point in space
  104035. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104036. */
  104037. export class BoneLookController {
  104038. private static _tmpVecs;
  104039. private static _tmpQuat;
  104040. private static _tmpMats;
  104041. /**
  104042. * The target Vector3 that the bone will look at
  104043. */
  104044. target: Vector3;
  104045. /**
  104046. * The mesh that the bone is attached to
  104047. */
  104048. mesh: AbstractMesh;
  104049. /**
  104050. * The bone that will be looking to the target
  104051. */
  104052. bone: Bone;
  104053. /**
  104054. * The up axis of the coordinate system that is used when the bone is rotated
  104055. */
  104056. upAxis: Vector3;
  104057. /**
  104058. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104059. */
  104060. upAxisSpace: Space;
  104061. /**
  104062. * Used to make an adjustment to the yaw of the bone
  104063. */
  104064. adjustYaw: number;
  104065. /**
  104066. * Used to make an adjustment to the pitch of the bone
  104067. */
  104068. adjustPitch: number;
  104069. /**
  104070. * Used to make an adjustment to the roll of the bone
  104071. */
  104072. adjustRoll: number;
  104073. /**
  104074. * 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)
  104075. */
  104076. slerpAmount: number;
  104077. private _minYaw;
  104078. private _maxYaw;
  104079. private _minPitch;
  104080. private _maxPitch;
  104081. private _minYawSin;
  104082. private _minYawCos;
  104083. private _maxYawSin;
  104084. private _maxYawCos;
  104085. private _midYawConstraint;
  104086. private _minPitchTan;
  104087. private _maxPitchTan;
  104088. private _boneQuat;
  104089. private _slerping;
  104090. private _transformYawPitch;
  104091. private _transformYawPitchInv;
  104092. private _firstFrameSkipped;
  104093. private _yawRange;
  104094. private _fowardAxis;
  104095. /**
  104096. * Gets or sets the minimum yaw angle that the bone can look to
  104097. */
  104098. minYaw: number;
  104099. /**
  104100. * Gets or sets the maximum yaw angle that the bone can look to
  104101. */
  104102. maxYaw: number;
  104103. /**
  104104. * Gets or sets the minimum pitch angle that the bone can look to
  104105. */
  104106. minPitch: number;
  104107. /**
  104108. * Gets or sets the maximum pitch angle that the bone can look to
  104109. */
  104110. maxPitch: number;
  104111. /**
  104112. * Create a BoneLookController
  104113. * @param mesh the mesh that the bone belongs to
  104114. * @param bone the bone that will be looking to the target
  104115. * @param target the target Vector3 to look at
  104116. * @param options optional settings:
  104117. * * maxYaw: the maximum angle the bone will yaw to
  104118. * * minYaw: the minimum angle the bone will yaw to
  104119. * * maxPitch: the maximum angle the bone will pitch to
  104120. * * minPitch: the minimum angle the bone will yaw to
  104121. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104122. * * upAxis: the up axis of the coordinate system
  104123. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104124. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104125. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104126. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104127. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104128. * * adjustRoll: used to make an adjustment to the roll of the bone
  104129. **/
  104130. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104131. maxYaw?: number;
  104132. minYaw?: number;
  104133. maxPitch?: number;
  104134. minPitch?: number;
  104135. slerpAmount?: number;
  104136. upAxis?: Vector3;
  104137. upAxisSpace?: Space;
  104138. yawAxis?: Vector3;
  104139. pitchAxis?: Vector3;
  104140. adjustYaw?: number;
  104141. adjustPitch?: number;
  104142. adjustRoll?: number;
  104143. });
  104144. /**
  104145. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104146. */
  104147. update(): void;
  104148. private _getAngleDiff;
  104149. private _getAngleBetween;
  104150. private _isAngleBetween;
  104151. }
  104152. }
  104153. declare module BABYLON {
  104154. /**
  104155. * Manage the gamepad inputs to control an arc rotate camera.
  104156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104157. */
  104158. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104159. /**
  104160. * Defines the camera the input is attached to.
  104161. */
  104162. camera: ArcRotateCamera;
  104163. /**
  104164. * Defines the gamepad the input is gathering event from.
  104165. */
  104166. gamepad: Nullable<Gamepad>;
  104167. /**
  104168. * Defines the gamepad rotation sensiblity.
  104169. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104170. */
  104171. gamepadRotationSensibility: number;
  104172. /**
  104173. * Defines the gamepad move sensiblity.
  104174. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104175. */
  104176. gamepadMoveSensibility: number;
  104177. private _yAxisScale;
  104178. /**
  104179. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104180. */
  104181. invertYAxis: boolean;
  104182. private _onGamepadConnectedObserver;
  104183. private _onGamepadDisconnectedObserver;
  104184. /**
  104185. * Attach the input controls to a specific dom element to get the input from.
  104186. * @param element Defines the element the controls should be listened from
  104187. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104188. */
  104189. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104190. /**
  104191. * Detach the current controls from the specified dom element.
  104192. * @param element Defines the element to stop listening the inputs from
  104193. */
  104194. detachControl(element: Nullable<HTMLElement>): void;
  104195. /**
  104196. * Update the current camera state depending on the inputs that have been used this frame.
  104197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104198. */
  104199. checkInputs(): void;
  104200. /**
  104201. * Gets the class name of the current intput.
  104202. * @returns the class name
  104203. */
  104204. getClassName(): string;
  104205. /**
  104206. * Get the friendly name associated with the input class.
  104207. * @returns the input friendly name
  104208. */
  104209. getSimpleName(): string;
  104210. }
  104211. }
  104212. declare module BABYLON {
  104213. interface ArcRotateCameraInputsManager {
  104214. /**
  104215. * Add orientation input support to the input manager.
  104216. * @returns the current input manager
  104217. */
  104218. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104219. }
  104220. /**
  104221. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104223. */
  104224. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104225. /**
  104226. * Defines the camera the input is attached to.
  104227. */
  104228. camera: ArcRotateCamera;
  104229. /**
  104230. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104231. */
  104232. alphaCorrection: number;
  104233. /**
  104234. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104235. */
  104236. gammaCorrection: number;
  104237. private _alpha;
  104238. private _gamma;
  104239. private _dirty;
  104240. private _deviceOrientationHandler;
  104241. /**
  104242. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104243. */
  104244. constructor();
  104245. /**
  104246. * Attach the input controls to a specific dom element to get the input from.
  104247. * @param element Defines the element the controls should be listened from
  104248. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104249. */
  104250. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104251. /** @hidden */
  104252. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104253. /**
  104254. * Update the current camera state depending on the inputs that have been used this frame.
  104255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104256. */
  104257. checkInputs(): void;
  104258. /**
  104259. * Detach the current controls from the specified dom element.
  104260. * @param element Defines the element to stop listening the inputs from
  104261. */
  104262. detachControl(element: Nullable<HTMLElement>): void;
  104263. /**
  104264. * Gets the class name of the current intput.
  104265. * @returns the class name
  104266. */
  104267. getClassName(): string;
  104268. /**
  104269. * Get the friendly name associated with the input class.
  104270. * @returns the input friendly name
  104271. */
  104272. getSimpleName(): string;
  104273. }
  104274. }
  104275. declare module BABYLON {
  104276. /**
  104277. * Listen to mouse events to control the camera.
  104278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104279. */
  104280. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104281. /**
  104282. * Defines the camera the input is attached to.
  104283. */
  104284. camera: FlyCamera;
  104285. /**
  104286. * Defines if touch is enabled. (Default is true.)
  104287. */
  104288. touchEnabled: boolean;
  104289. /**
  104290. * Defines the buttons associated with the input to handle camera rotation.
  104291. */
  104292. buttons: number[];
  104293. /**
  104294. * Assign buttons for Yaw control.
  104295. */
  104296. buttonsYaw: number[];
  104297. /**
  104298. * Assign buttons for Pitch control.
  104299. */
  104300. buttonsPitch: number[];
  104301. /**
  104302. * Assign buttons for Roll control.
  104303. */
  104304. buttonsRoll: number[];
  104305. /**
  104306. * Detect if any button is being pressed while mouse is moved.
  104307. * -1 = Mouse locked.
  104308. * 0 = Left button.
  104309. * 1 = Middle Button.
  104310. * 2 = Right Button.
  104311. */
  104312. activeButton: number;
  104313. /**
  104314. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104315. * Higher values reduce its sensitivity.
  104316. */
  104317. angularSensibility: number;
  104318. private _mousemoveCallback;
  104319. private _observer;
  104320. private _rollObserver;
  104321. private previousPosition;
  104322. private noPreventDefault;
  104323. private element;
  104324. /**
  104325. * Listen to mouse events to control the camera.
  104326. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104328. */
  104329. constructor(touchEnabled?: boolean);
  104330. /**
  104331. * Attach the mouse control to the HTML DOM element.
  104332. * @param element Defines the element that listens to the input events.
  104333. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104334. */
  104335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104336. /**
  104337. * Detach the current controls from the specified dom element.
  104338. * @param element Defines the element to stop listening the inputs from
  104339. */
  104340. detachControl(element: Nullable<HTMLElement>): void;
  104341. /**
  104342. * Gets the class name of the current input.
  104343. * @returns the class name.
  104344. */
  104345. getClassName(): string;
  104346. /**
  104347. * Get the friendly name associated with the input class.
  104348. * @returns the input's friendly name.
  104349. */
  104350. getSimpleName(): string;
  104351. private _pointerInput;
  104352. private _onMouseMove;
  104353. /**
  104354. * Rotate camera by mouse offset.
  104355. */
  104356. private rotateCamera;
  104357. }
  104358. }
  104359. declare module BABYLON {
  104360. /**
  104361. * Default Inputs manager for the FlyCamera.
  104362. * It groups all the default supported inputs for ease of use.
  104363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104364. */
  104365. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104366. /**
  104367. * Instantiates a new FlyCameraInputsManager.
  104368. * @param camera Defines the camera the inputs belong to.
  104369. */
  104370. constructor(camera: FlyCamera);
  104371. /**
  104372. * Add keyboard input support to the input manager.
  104373. * @returns the new FlyCameraKeyboardMoveInput().
  104374. */
  104375. addKeyboard(): FlyCameraInputsManager;
  104376. /**
  104377. * Add mouse input support to the input manager.
  104378. * @param touchEnabled Enable touch screen support.
  104379. * @returns the new FlyCameraMouseInput().
  104380. */
  104381. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104382. }
  104383. }
  104384. declare module BABYLON {
  104385. /**
  104386. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104387. * such as in a 3D Space Shooter or a Flight Simulator.
  104388. */
  104389. export class FlyCamera extends TargetCamera {
  104390. /**
  104391. * Define the collision ellipsoid of the camera.
  104392. * This is helpful for simulating a camera body, like a player's body.
  104393. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104394. */
  104395. ellipsoid: Vector3;
  104396. /**
  104397. * Define an offset for the position of the ellipsoid around the camera.
  104398. * This can be helpful if the camera is attached away from the player's body center,
  104399. * such as at its head.
  104400. */
  104401. ellipsoidOffset: Vector3;
  104402. /**
  104403. * Enable or disable collisions of the camera with the rest of the scene objects.
  104404. */
  104405. checkCollisions: boolean;
  104406. /**
  104407. * Enable or disable gravity on the camera.
  104408. */
  104409. applyGravity: boolean;
  104410. /**
  104411. * Define the current direction the camera is moving to.
  104412. */
  104413. cameraDirection: Vector3;
  104414. /**
  104415. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104416. * This overrides and empties cameraRotation.
  104417. */
  104418. rotationQuaternion: Quaternion;
  104419. /**
  104420. * Track Roll to maintain the wanted Rolling when looking around.
  104421. */
  104422. _trackRoll: number;
  104423. /**
  104424. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104425. */
  104426. rollCorrect: number;
  104427. /**
  104428. * Mimic a banked turn, Rolling the camera when Yawing.
  104429. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104430. */
  104431. bankedTurn: boolean;
  104432. /**
  104433. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104434. */
  104435. bankedTurnLimit: number;
  104436. /**
  104437. * Value of 0 disables the banked Roll.
  104438. * Value of 1 is equal to the Yaw angle in radians.
  104439. */
  104440. bankedTurnMultiplier: number;
  104441. /**
  104442. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104443. */
  104444. inputs: FlyCameraInputsManager;
  104445. /**
  104446. * Gets the input sensibility for mouse input.
  104447. * Higher values reduce sensitivity.
  104448. */
  104449. /**
  104450. * Sets the input sensibility for a mouse input.
  104451. * Higher values reduce sensitivity.
  104452. */
  104453. angularSensibility: number;
  104454. /**
  104455. * Get the keys for camera movement forward.
  104456. */
  104457. /**
  104458. * Set the keys for camera movement forward.
  104459. */
  104460. keysForward: number[];
  104461. /**
  104462. * Get the keys for camera movement backward.
  104463. */
  104464. keysBackward: number[];
  104465. /**
  104466. * Get the keys for camera movement up.
  104467. */
  104468. /**
  104469. * Set the keys for camera movement up.
  104470. */
  104471. keysUp: number[];
  104472. /**
  104473. * Get the keys for camera movement down.
  104474. */
  104475. /**
  104476. * Set the keys for camera movement down.
  104477. */
  104478. keysDown: number[];
  104479. /**
  104480. * Get the keys for camera movement left.
  104481. */
  104482. /**
  104483. * Set the keys for camera movement left.
  104484. */
  104485. keysLeft: number[];
  104486. /**
  104487. * Set the keys for camera movement right.
  104488. */
  104489. /**
  104490. * Set the keys for camera movement right.
  104491. */
  104492. keysRight: number[];
  104493. /**
  104494. * Event raised when the camera collides with a mesh in the scene.
  104495. */
  104496. onCollide: (collidedMesh: AbstractMesh) => void;
  104497. private _collider;
  104498. private _needMoveForGravity;
  104499. private _oldPosition;
  104500. private _diffPosition;
  104501. private _newPosition;
  104502. /** @hidden */
  104503. _localDirection: Vector3;
  104504. /** @hidden */
  104505. _transformedDirection: Vector3;
  104506. /**
  104507. * Instantiates a FlyCamera.
  104508. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104509. * such as in a 3D Space Shooter or a Flight Simulator.
  104510. * @param name Define the name of the camera in the scene.
  104511. * @param position Define the starting position of the camera in the scene.
  104512. * @param scene Define the scene the camera belongs to.
  104513. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104514. */
  104515. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104516. /**
  104517. * Attach a control to the HTML DOM element.
  104518. * @param element Defines the element that listens to the input events.
  104519. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104520. */
  104521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104522. /**
  104523. * Detach a control from the HTML DOM element.
  104524. * The camera will stop reacting to that input.
  104525. * @param element Defines the element that listens to the input events.
  104526. */
  104527. detachControl(element: HTMLElement): void;
  104528. private _collisionMask;
  104529. /**
  104530. * Get the mask that the camera ignores in collision events.
  104531. */
  104532. /**
  104533. * Set the mask that the camera ignores in collision events.
  104534. */
  104535. collisionMask: number;
  104536. /** @hidden */
  104537. _collideWithWorld(displacement: Vector3): void;
  104538. /** @hidden */
  104539. private _onCollisionPositionChange;
  104540. /** @hidden */
  104541. _checkInputs(): void;
  104542. /** @hidden */
  104543. _decideIfNeedsToMove(): boolean;
  104544. /** @hidden */
  104545. _updatePosition(): void;
  104546. /**
  104547. * Restore the Roll to its target value at the rate specified.
  104548. * @param rate - Higher means slower restoring.
  104549. * @hidden
  104550. */
  104551. restoreRoll(rate: number): void;
  104552. /**
  104553. * Destroy the camera and release the current resources held by it.
  104554. */
  104555. dispose(): void;
  104556. /**
  104557. * Get the current object class name.
  104558. * @returns the class name.
  104559. */
  104560. getClassName(): string;
  104561. }
  104562. }
  104563. declare module BABYLON {
  104564. /**
  104565. * Listen to keyboard events to control the camera.
  104566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104567. */
  104568. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104569. /**
  104570. * Defines the camera the input is attached to.
  104571. */
  104572. camera: FlyCamera;
  104573. /**
  104574. * The list of keyboard keys used to control the forward move of the camera.
  104575. */
  104576. keysForward: number[];
  104577. /**
  104578. * The list of keyboard keys used to control the backward move of the camera.
  104579. */
  104580. keysBackward: number[];
  104581. /**
  104582. * The list of keyboard keys used to control the forward move of the camera.
  104583. */
  104584. keysUp: number[];
  104585. /**
  104586. * The list of keyboard keys used to control the backward move of the camera.
  104587. */
  104588. keysDown: number[];
  104589. /**
  104590. * The list of keyboard keys used to control the right strafe move of the camera.
  104591. */
  104592. keysRight: number[];
  104593. /**
  104594. * The list of keyboard keys used to control the left strafe move of the camera.
  104595. */
  104596. keysLeft: number[];
  104597. private _keys;
  104598. private _onCanvasBlurObserver;
  104599. private _onKeyboardObserver;
  104600. private _engine;
  104601. private _scene;
  104602. /**
  104603. * Attach the input controls to a specific dom element to get the input from.
  104604. * @param element Defines the element the controls should be listened from
  104605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104606. */
  104607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104608. /**
  104609. * Detach the current controls from the specified dom element.
  104610. * @param element Defines the element to stop listening the inputs from
  104611. */
  104612. detachControl(element: Nullable<HTMLElement>): void;
  104613. /**
  104614. * Gets the class name of the current intput.
  104615. * @returns the class name
  104616. */
  104617. getClassName(): string;
  104618. /** @hidden */
  104619. _onLostFocus(e: FocusEvent): void;
  104620. /**
  104621. * Get the friendly name associated with the input class.
  104622. * @returns the input friendly name
  104623. */
  104624. getSimpleName(): string;
  104625. /**
  104626. * Update the current camera state depending on the inputs that have been used this frame.
  104627. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104628. */
  104629. checkInputs(): void;
  104630. }
  104631. }
  104632. declare module BABYLON {
  104633. /**
  104634. * Manage the mouse wheel inputs to control a follow camera.
  104635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104636. */
  104637. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104638. /**
  104639. * Defines the camera the input is attached to.
  104640. */
  104641. camera: FollowCamera;
  104642. /**
  104643. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104644. */
  104645. axisControlRadius: boolean;
  104646. /**
  104647. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104648. */
  104649. axisControlHeight: boolean;
  104650. /**
  104651. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104652. */
  104653. axisControlRotation: boolean;
  104654. /**
  104655. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104656. * relation to mouseWheel events.
  104657. */
  104658. wheelPrecision: number;
  104659. /**
  104660. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104661. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104662. */
  104663. wheelDeltaPercentage: number;
  104664. private _wheel;
  104665. private _observer;
  104666. /**
  104667. * Attach the input controls to a specific dom element to get the input from.
  104668. * @param element Defines the element the controls should be listened from
  104669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104670. */
  104671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104672. /**
  104673. * Detach the current controls from the specified dom element.
  104674. * @param element Defines the element to stop listening the inputs from
  104675. */
  104676. detachControl(element: Nullable<HTMLElement>): void;
  104677. /**
  104678. * Gets the class name of the current intput.
  104679. * @returns the class name
  104680. */
  104681. getClassName(): string;
  104682. /**
  104683. * Get the friendly name associated with the input class.
  104684. * @returns the input friendly name
  104685. */
  104686. getSimpleName(): string;
  104687. }
  104688. }
  104689. declare module BABYLON {
  104690. /**
  104691. * Manage the pointers inputs to control an follow camera.
  104692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104693. */
  104694. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104695. /**
  104696. * Defines the camera the input is attached to.
  104697. */
  104698. camera: FollowCamera;
  104699. /**
  104700. * Gets the class name of the current input.
  104701. * @returns the class name
  104702. */
  104703. getClassName(): string;
  104704. /**
  104705. * Defines the pointer angular sensibility along the X axis or how fast is
  104706. * the camera rotating.
  104707. * A negative number will reverse the axis direction.
  104708. */
  104709. angularSensibilityX: number;
  104710. /**
  104711. * Defines the pointer angular sensibility along the Y axis or how fast is
  104712. * the camera rotating.
  104713. * A negative number will reverse the axis direction.
  104714. */
  104715. angularSensibilityY: number;
  104716. /**
  104717. * Defines the pointer pinch precision or how fast is the camera zooming.
  104718. * A negative number will reverse the axis direction.
  104719. */
  104720. pinchPrecision: number;
  104721. /**
  104722. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104723. * from 0.
  104724. * It defines the percentage of current camera.radius to use as delta when
  104725. * pinch zoom is used.
  104726. */
  104727. pinchDeltaPercentage: number;
  104728. /**
  104729. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104730. */
  104731. axisXControlRadius: boolean;
  104732. /**
  104733. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104734. */
  104735. axisXControlHeight: boolean;
  104736. /**
  104737. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104738. */
  104739. axisXControlRotation: boolean;
  104740. /**
  104741. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104742. */
  104743. axisYControlRadius: boolean;
  104744. /**
  104745. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104746. */
  104747. axisYControlHeight: boolean;
  104748. /**
  104749. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104750. */
  104751. axisYControlRotation: boolean;
  104752. /**
  104753. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104754. */
  104755. axisPinchControlRadius: boolean;
  104756. /**
  104757. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104758. */
  104759. axisPinchControlHeight: boolean;
  104760. /**
  104761. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104762. */
  104763. axisPinchControlRotation: boolean;
  104764. /**
  104765. * Log error messages if basic misconfiguration has occurred.
  104766. */
  104767. warningEnable: boolean;
  104768. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104769. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104770. private _warningCounter;
  104771. private _warning;
  104772. }
  104773. }
  104774. declare module BABYLON {
  104775. /**
  104776. * Default Inputs manager for the FollowCamera.
  104777. * It groups all the default supported inputs for ease of use.
  104778. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104779. */
  104780. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104781. /**
  104782. * Instantiates a new FollowCameraInputsManager.
  104783. * @param camera Defines the camera the inputs belong to
  104784. */
  104785. constructor(camera: FollowCamera);
  104786. /**
  104787. * Add keyboard input support to the input manager.
  104788. * @returns the current input manager
  104789. */
  104790. addKeyboard(): FollowCameraInputsManager;
  104791. /**
  104792. * Add mouse wheel input support to the input manager.
  104793. * @returns the current input manager
  104794. */
  104795. addMouseWheel(): FollowCameraInputsManager;
  104796. /**
  104797. * Add pointers input support to the input manager.
  104798. * @returns the current input manager
  104799. */
  104800. addPointers(): FollowCameraInputsManager;
  104801. /**
  104802. * Add orientation input support to the input manager.
  104803. * @returns the current input manager
  104804. */
  104805. addVRDeviceOrientation(): FollowCameraInputsManager;
  104806. }
  104807. }
  104808. declare module BABYLON {
  104809. /**
  104810. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104811. * an arc rotate version arcFollowCamera are available.
  104812. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104813. */
  104814. export class FollowCamera extends TargetCamera {
  104815. /**
  104816. * Distance the follow camera should follow an object at
  104817. */
  104818. radius: number;
  104819. /**
  104820. * Minimum allowed distance of the camera to the axis of rotation
  104821. * (The camera can not get closer).
  104822. * This can help limiting how the Camera is able to move in the scene.
  104823. */
  104824. lowerRadiusLimit: Nullable<number>;
  104825. /**
  104826. * Maximum allowed distance of the camera to the axis of rotation
  104827. * (The camera can not get further).
  104828. * This can help limiting how the Camera is able to move in the scene.
  104829. */
  104830. upperRadiusLimit: Nullable<number>;
  104831. /**
  104832. * Define a rotation offset between the camera and the object it follows
  104833. */
  104834. rotationOffset: number;
  104835. /**
  104836. * Minimum allowed angle to camera position relative to target object.
  104837. * This can help limiting how the Camera is able to move in the scene.
  104838. */
  104839. lowerRotationOffsetLimit: Nullable<number>;
  104840. /**
  104841. * Maximum allowed angle to camera position relative to target object.
  104842. * This can help limiting how the Camera is able to move in the scene.
  104843. */
  104844. upperRotationOffsetLimit: Nullable<number>;
  104845. /**
  104846. * Define a height offset between the camera and the object it follows.
  104847. * It can help following an object from the top (like a car chaing a plane)
  104848. */
  104849. heightOffset: number;
  104850. /**
  104851. * Minimum allowed height of camera position relative to target object.
  104852. * This can help limiting how the Camera is able to move in the scene.
  104853. */
  104854. lowerHeightOffsetLimit: Nullable<number>;
  104855. /**
  104856. * Maximum allowed height of camera position relative to target object.
  104857. * This can help limiting how the Camera is able to move in the scene.
  104858. */
  104859. upperHeightOffsetLimit: Nullable<number>;
  104860. /**
  104861. * Define how fast the camera can accelerate to follow it s target.
  104862. */
  104863. cameraAcceleration: number;
  104864. /**
  104865. * Define the speed limit of the camera following an object.
  104866. */
  104867. maxCameraSpeed: number;
  104868. /**
  104869. * Define the target of the camera.
  104870. */
  104871. lockedTarget: Nullable<AbstractMesh>;
  104872. /**
  104873. * Defines the input associated with the camera.
  104874. */
  104875. inputs: FollowCameraInputsManager;
  104876. /**
  104877. * Instantiates the follow camera.
  104878. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104879. * @param name Define the name of the camera in the scene
  104880. * @param position Define the position of the camera
  104881. * @param scene Define the scene the camera belong to
  104882. * @param lockedTarget Define the target of the camera
  104883. */
  104884. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104885. private _follow;
  104886. /**
  104887. * Attached controls to the current camera.
  104888. * @param element Defines the element the controls should be listened from
  104889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104890. */
  104891. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104892. /**
  104893. * Detach the current controls from the camera.
  104894. * The camera will stop reacting to inputs.
  104895. * @param element Defines the element to stop listening the inputs from
  104896. */
  104897. detachControl(element: HTMLElement): void;
  104898. /** @hidden */
  104899. _checkInputs(): void;
  104900. private _checkLimits;
  104901. /**
  104902. * Gets the camera class name.
  104903. * @returns the class name
  104904. */
  104905. getClassName(): string;
  104906. }
  104907. /**
  104908. * Arc Rotate version of the follow camera.
  104909. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104910. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104911. */
  104912. export class ArcFollowCamera extends TargetCamera {
  104913. /** The longitudinal angle of the camera */
  104914. alpha: number;
  104915. /** The latitudinal angle of the camera */
  104916. beta: number;
  104917. /** The radius of the camera from its target */
  104918. radius: number;
  104919. /** Define the camera target (the messh it should follow) */
  104920. target: Nullable<AbstractMesh>;
  104921. private _cartesianCoordinates;
  104922. /**
  104923. * Instantiates a new ArcFollowCamera
  104924. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104925. * @param name Define the name of the camera
  104926. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104927. * @param beta Define the rotation angle of the camera around the elevation axis
  104928. * @param radius Define the radius of the camera from its target point
  104929. * @param target Define the target of the camera
  104930. * @param scene Define the scene the camera belongs to
  104931. */
  104932. constructor(name: string,
  104933. /** The longitudinal angle of the camera */
  104934. alpha: number,
  104935. /** The latitudinal angle of the camera */
  104936. beta: number,
  104937. /** The radius of the camera from its target */
  104938. radius: number,
  104939. /** Define the camera target (the messh it should follow) */
  104940. target: Nullable<AbstractMesh>, scene: Scene);
  104941. private _follow;
  104942. /** @hidden */
  104943. _checkInputs(): void;
  104944. /**
  104945. * Returns the class name of the object.
  104946. * It is mostly used internally for serialization purposes.
  104947. */
  104948. getClassName(): string;
  104949. }
  104950. }
  104951. declare module BABYLON {
  104952. /**
  104953. * Manage the keyboard inputs to control the movement of a follow camera.
  104954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104955. */
  104956. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104957. /**
  104958. * Defines the camera the input is attached to.
  104959. */
  104960. camera: FollowCamera;
  104961. /**
  104962. * Defines the list of key codes associated with the up action (increase heightOffset)
  104963. */
  104964. keysHeightOffsetIncr: number[];
  104965. /**
  104966. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104967. */
  104968. keysHeightOffsetDecr: number[];
  104969. /**
  104970. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104971. */
  104972. keysHeightOffsetModifierAlt: boolean;
  104973. /**
  104974. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104975. */
  104976. keysHeightOffsetModifierCtrl: boolean;
  104977. /**
  104978. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104979. */
  104980. keysHeightOffsetModifierShift: boolean;
  104981. /**
  104982. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104983. */
  104984. keysRotationOffsetIncr: number[];
  104985. /**
  104986. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104987. */
  104988. keysRotationOffsetDecr: number[];
  104989. /**
  104990. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104991. */
  104992. keysRotationOffsetModifierAlt: boolean;
  104993. /**
  104994. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104995. */
  104996. keysRotationOffsetModifierCtrl: boolean;
  104997. /**
  104998. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104999. */
  105000. keysRotationOffsetModifierShift: boolean;
  105001. /**
  105002. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105003. */
  105004. keysRadiusIncr: number[];
  105005. /**
  105006. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105007. */
  105008. keysRadiusDecr: number[];
  105009. /**
  105010. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105011. */
  105012. keysRadiusModifierAlt: boolean;
  105013. /**
  105014. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105015. */
  105016. keysRadiusModifierCtrl: boolean;
  105017. /**
  105018. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105019. */
  105020. keysRadiusModifierShift: boolean;
  105021. /**
  105022. * Defines the rate of change of heightOffset.
  105023. */
  105024. heightSensibility: number;
  105025. /**
  105026. * Defines the rate of change of rotationOffset.
  105027. */
  105028. rotationSensibility: number;
  105029. /**
  105030. * Defines the rate of change of radius.
  105031. */
  105032. radiusSensibility: number;
  105033. private _keys;
  105034. private _ctrlPressed;
  105035. private _altPressed;
  105036. private _shiftPressed;
  105037. private _onCanvasBlurObserver;
  105038. private _onKeyboardObserver;
  105039. private _engine;
  105040. private _scene;
  105041. /**
  105042. * Attach the input controls to a specific dom element to get the input from.
  105043. * @param element Defines the element the controls should be listened from
  105044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105045. */
  105046. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105047. /**
  105048. * Detach the current controls from the specified dom element.
  105049. * @param element Defines the element to stop listening the inputs from
  105050. */
  105051. detachControl(element: Nullable<HTMLElement>): void;
  105052. /**
  105053. * Update the current camera state depending on the inputs that have been used this frame.
  105054. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105055. */
  105056. checkInputs(): void;
  105057. /**
  105058. * Gets the class name of the current input.
  105059. * @returns the class name
  105060. */
  105061. getClassName(): string;
  105062. /**
  105063. * Get the friendly name associated with the input class.
  105064. * @returns the input friendly name
  105065. */
  105066. getSimpleName(): string;
  105067. /**
  105068. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105069. * allow modification of the heightOffset value.
  105070. */
  105071. private _modifierHeightOffset;
  105072. /**
  105073. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105074. * allow modification of the rotationOffset value.
  105075. */
  105076. private _modifierRotationOffset;
  105077. /**
  105078. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105079. * allow modification of the radius value.
  105080. */
  105081. private _modifierRadius;
  105082. }
  105083. }
  105084. declare module BABYLON {
  105085. interface FreeCameraInputsManager {
  105086. /**
  105087. * @hidden
  105088. */
  105089. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105090. /**
  105091. * Add orientation input support to the input manager.
  105092. * @returns the current input manager
  105093. */
  105094. addDeviceOrientation(): FreeCameraInputsManager;
  105095. }
  105096. /**
  105097. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105098. * Screen rotation is taken into account.
  105099. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105100. */
  105101. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105102. private _camera;
  105103. private _screenOrientationAngle;
  105104. private _constantTranform;
  105105. private _screenQuaternion;
  105106. private _alpha;
  105107. private _beta;
  105108. private _gamma;
  105109. /**
  105110. * Can be used to detect if a device orientation sensor is availible on a device
  105111. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105112. * @returns a promise that will resolve on orientation change
  105113. */
  105114. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105115. /**
  105116. * @hidden
  105117. */
  105118. _onDeviceOrientationChangedObservable: Observable<void>;
  105119. /**
  105120. * Instantiates a new input
  105121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105122. */
  105123. constructor();
  105124. /**
  105125. * Define the camera controlled by the input.
  105126. */
  105127. camera: FreeCamera;
  105128. /**
  105129. * Attach the input controls to a specific dom element to get the input from.
  105130. * @param element Defines the element the controls should be listened from
  105131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105132. */
  105133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105134. private _orientationChanged;
  105135. private _deviceOrientation;
  105136. /**
  105137. * Detach the current controls from the specified dom element.
  105138. * @param element Defines the element to stop listening the inputs from
  105139. */
  105140. detachControl(element: Nullable<HTMLElement>): void;
  105141. /**
  105142. * Update the current camera state depending on the inputs that have been used this frame.
  105143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105144. */
  105145. checkInputs(): void;
  105146. /**
  105147. * Gets the class name of the current intput.
  105148. * @returns the class name
  105149. */
  105150. getClassName(): string;
  105151. /**
  105152. * Get the friendly name associated with the input class.
  105153. * @returns the input friendly name
  105154. */
  105155. getSimpleName(): string;
  105156. }
  105157. }
  105158. declare module BABYLON {
  105159. /**
  105160. * Manage the gamepad inputs to control a free camera.
  105161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105162. */
  105163. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105164. /**
  105165. * Define the camera the input is attached to.
  105166. */
  105167. camera: FreeCamera;
  105168. /**
  105169. * Define the Gamepad controlling the input
  105170. */
  105171. gamepad: Nullable<Gamepad>;
  105172. /**
  105173. * Defines the gamepad rotation sensiblity.
  105174. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105175. */
  105176. gamepadAngularSensibility: number;
  105177. /**
  105178. * Defines the gamepad move sensiblity.
  105179. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105180. */
  105181. gamepadMoveSensibility: number;
  105182. private _yAxisScale;
  105183. /**
  105184. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105185. */
  105186. invertYAxis: boolean;
  105187. private _onGamepadConnectedObserver;
  105188. private _onGamepadDisconnectedObserver;
  105189. private _cameraTransform;
  105190. private _deltaTransform;
  105191. private _vector3;
  105192. private _vector2;
  105193. /**
  105194. * Attach the input controls to a specific dom element to get the input from.
  105195. * @param element Defines the element the controls should be listened from
  105196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105197. */
  105198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105199. /**
  105200. * Detach the current controls from the specified dom element.
  105201. * @param element Defines the element to stop listening the inputs from
  105202. */
  105203. detachControl(element: Nullable<HTMLElement>): void;
  105204. /**
  105205. * Update the current camera state depending on the inputs that have been used this frame.
  105206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105207. */
  105208. checkInputs(): void;
  105209. /**
  105210. * Gets the class name of the current intput.
  105211. * @returns the class name
  105212. */
  105213. getClassName(): string;
  105214. /**
  105215. * Get the friendly name associated with the input class.
  105216. * @returns the input friendly name
  105217. */
  105218. getSimpleName(): string;
  105219. }
  105220. }
  105221. declare module BABYLON {
  105222. /**
  105223. * Defines the potential axis of a Joystick
  105224. */
  105225. export enum JoystickAxis {
  105226. /** X axis */
  105227. X = 0,
  105228. /** Y axis */
  105229. Y = 1,
  105230. /** Z axis */
  105231. Z = 2
  105232. }
  105233. /**
  105234. * Class used to define virtual joystick (used in touch mode)
  105235. */
  105236. export class VirtualJoystick {
  105237. /**
  105238. * Gets or sets a boolean indicating that left and right values must be inverted
  105239. */
  105240. reverseLeftRight: boolean;
  105241. /**
  105242. * Gets or sets a boolean indicating that up and down values must be inverted
  105243. */
  105244. reverseUpDown: boolean;
  105245. /**
  105246. * Gets the offset value for the position (ie. the change of the position value)
  105247. */
  105248. deltaPosition: Vector3;
  105249. /**
  105250. * Gets a boolean indicating if the virtual joystick was pressed
  105251. */
  105252. pressed: boolean;
  105253. /**
  105254. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105255. */
  105256. static Canvas: Nullable<HTMLCanvasElement>;
  105257. private static _globalJoystickIndex;
  105258. private static vjCanvasContext;
  105259. private static vjCanvasWidth;
  105260. private static vjCanvasHeight;
  105261. private static halfWidth;
  105262. private _action;
  105263. private _axisTargetedByLeftAndRight;
  105264. private _axisTargetedByUpAndDown;
  105265. private _joystickSensibility;
  105266. private _inversedSensibility;
  105267. private _joystickPointerID;
  105268. private _joystickColor;
  105269. private _joystickPointerPos;
  105270. private _joystickPreviousPointerPos;
  105271. private _joystickPointerStartPos;
  105272. private _deltaJoystickVector;
  105273. private _leftJoystick;
  105274. private _touches;
  105275. private _onPointerDownHandlerRef;
  105276. private _onPointerMoveHandlerRef;
  105277. private _onPointerUpHandlerRef;
  105278. private _onResize;
  105279. /**
  105280. * Creates a new virtual joystick
  105281. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105282. */
  105283. constructor(leftJoystick?: boolean);
  105284. /**
  105285. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105286. * @param newJoystickSensibility defines the new sensibility
  105287. */
  105288. setJoystickSensibility(newJoystickSensibility: number): void;
  105289. private _onPointerDown;
  105290. private _onPointerMove;
  105291. private _onPointerUp;
  105292. /**
  105293. * Change the color of the virtual joystick
  105294. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105295. */
  105296. setJoystickColor(newColor: string): void;
  105297. /**
  105298. * Defines a callback to call when the joystick is touched
  105299. * @param action defines the callback
  105300. */
  105301. setActionOnTouch(action: () => any): void;
  105302. /**
  105303. * Defines which axis you'd like to control for left & right
  105304. * @param axis defines the axis to use
  105305. */
  105306. setAxisForLeftRight(axis: JoystickAxis): void;
  105307. /**
  105308. * Defines which axis you'd like to control for up & down
  105309. * @param axis defines the axis to use
  105310. */
  105311. setAxisForUpDown(axis: JoystickAxis): void;
  105312. private _drawVirtualJoystick;
  105313. /**
  105314. * Release internal HTML canvas
  105315. */
  105316. releaseCanvas(): void;
  105317. }
  105318. }
  105319. declare module BABYLON {
  105320. interface FreeCameraInputsManager {
  105321. /**
  105322. * Add virtual joystick input support to the input manager.
  105323. * @returns the current input manager
  105324. */
  105325. addVirtualJoystick(): FreeCameraInputsManager;
  105326. }
  105327. /**
  105328. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105330. */
  105331. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105332. /**
  105333. * Defines the camera the input is attached to.
  105334. */
  105335. camera: FreeCamera;
  105336. private _leftjoystick;
  105337. private _rightjoystick;
  105338. /**
  105339. * Gets the left stick of the virtual joystick.
  105340. * @returns The virtual Joystick
  105341. */
  105342. getLeftJoystick(): VirtualJoystick;
  105343. /**
  105344. * Gets the right stick of the virtual joystick.
  105345. * @returns The virtual Joystick
  105346. */
  105347. getRightJoystick(): VirtualJoystick;
  105348. /**
  105349. * Update the current camera state depending on the inputs that have been used this frame.
  105350. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105351. */
  105352. checkInputs(): void;
  105353. /**
  105354. * Attach the input controls to a specific dom element to get the input from.
  105355. * @param element Defines the element the controls should be listened from
  105356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105357. */
  105358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105359. /**
  105360. * Detach the current controls from the specified dom element.
  105361. * @param element Defines the element to stop listening the inputs from
  105362. */
  105363. detachControl(element: Nullable<HTMLElement>): void;
  105364. /**
  105365. * Gets the class name of the current intput.
  105366. * @returns the class name
  105367. */
  105368. getClassName(): string;
  105369. /**
  105370. * Get the friendly name associated with the input class.
  105371. * @returns the input friendly name
  105372. */
  105373. getSimpleName(): string;
  105374. }
  105375. }
  105376. declare module BABYLON {
  105377. /**
  105378. * This represents a FPS type of camera controlled by touch.
  105379. * This is like a universal camera minus the Gamepad controls.
  105380. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105381. */
  105382. export class TouchCamera extends FreeCamera {
  105383. /**
  105384. * Defines the touch sensibility for rotation.
  105385. * The higher the faster.
  105386. */
  105387. touchAngularSensibility: number;
  105388. /**
  105389. * Defines the touch sensibility for move.
  105390. * The higher the faster.
  105391. */
  105392. touchMoveSensibility: number;
  105393. /**
  105394. * Instantiates a new touch camera.
  105395. * This represents a FPS type of camera controlled by touch.
  105396. * This is like a universal camera minus the Gamepad controls.
  105397. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105398. * @param name Define the name of the camera in the scene
  105399. * @param position Define the start position of the camera in the scene
  105400. * @param scene Define the scene the camera belongs to
  105401. */
  105402. constructor(name: string, position: Vector3, scene: Scene);
  105403. /**
  105404. * Gets the current object class name.
  105405. * @return the class name
  105406. */
  105407. getClassName(): string;
  105408. /** @hidden */
  105409. _setupInputs(): void;
  105410. }
  105411. }
  105412. declare module BABYLON {
  105413. /**
  105414. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105415. * being tilted forward or back and left or right.
  105416. */
  105417. export class DeviceOrientationCamera extends FreeCamera {
  105418. private _initialQuaternion;
  105419. private _quaternionCache;
  105420. private _tmpDragQuaternion;
  105421. private _disablePointerInputWhenUsingDeviceOrientation;
  105422. /**
  105423. * Creates a new device orientation camera
  105424. * @param name The name of the camera
  105425. * @param position The start position camera
  105426. * @param scene The scene the camera belongs to
  105427. */
  105428. constructor(name: string, position: Vector3, scene: Scene);
  105429. /**
  105430. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105431. */
  105432. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105433. private _dragFactor;
  105434. /**
  105435. * Enabled turning on the y axis when the orientation sensor is active
  105436. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105437. */
  105438. enableHorizontalDragging(dragFactor?: number): void;
  105439. /**
  105440. * Gets the current instance class name ("DeviceOrientationCamera").
  105441. * This helps avoiding instanceof at run time.
  105442. * @returns the class name
  105443. */
  105444. getClassName(): string;
  105445. /**
  105446. * @hidden
  105447. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105448. */
  105449. _checkInputs(): void;
  105450. /**
  105451. * Reset the camera to its default orientation on the specified axis only.
  105452. * @param axis The axis to reset
  105453. */
  105454. resetToCurrentRotation(axis?: Axis): void;
  105455. }
  105456. }
  105457. declare module BABYLON {
  105458. /**
  105459. * Defines supported buttons for XBox360 compatible gamepads
  105460. */
  105461. export enum Xbox360Button {
  105462. /** A */
  105463. A = 0,
  105464. /** B */
  105465. B = 1,
  105466. /** X */
  105467. X = 2,
  105468. /** Y */
  105469. Y = 3,
  105470. /** Start */
  105471. Start = 4,
  105472. /** Back */
  105473. Back = 5,
  105474. /** Left button */
  105475. LB = 6,
  105476. /** Right button */
  105477. RB = 7,
  105478. /** Left stick */
  105479. LeftStick = 8,
  105480. /** Right stick */
  105481. RightStick = 9
  105482. }
  105483. /** Defines values for XBox360 DPad */
  105484. export enum Xbox360Dpad {
  105485. /** Up */
  105486. Up = 0,
  105487. /** Down */
  105488. Down = 1,
  105489. /** Left */
  105490. Left = 2,
  105491. /** Right */
  105492. Right = 3
  105493. }
  105494. /**
  105495. * Defines a XBox360 gamepad
  105496. */
  105497. export class Xbox360Pad extends Gamepad {
  105498. private _leftTrigger;
  105499. private _rightTrigger;
  105500. private _onlefttriggerchanged;
  105501. private _onrighttriggerchanged;
  105502. private _onbuttondown;
  105503. private _onbuttonup;
  105504. private _ondpaddown;
  105505. private _ondpadup;
  105506. /** Observable raised when a button is pressed */
  105507. onButtonDownObservable: Observable<Xbox360Button>;
  105508. /** Observable raised when a button is released */
  105509. onButtonUpObservable: Observable<Xbox360Button>;
  105510. /** Observable raised when a pad is pressed */
  105511. onPadDownObservable: Observable<Xbox360Dpad>;
  105512. /** Observable raised when a pad is released */
  105513. onPadUpObservable: Observable<Xbox360Dpad>;
  105514. private _buttonA;
  105515. private _buttonB;
  105516. private _buttonX;
  105517. private _buttonY;
  105518. private _buttonBack;
  105519. private _buttonStart;
  105520. private _buttonLB;
  105521. private _buttonRB;
  105522. private _buttonLeftStick;
  105523. private _buttonRightStick;
  105524. private _dPadUp;
  105525. private _dPadDown;
  105526. private _dPadLeft;
  105527. private _dPadRight;
  105528. private _isXboxOnePad;
  105529. /**
  105530. * Creates a new XBox360 gamepad object
  105531. * @param id defines the id of this gamepad
  105532. * @param index defines its index
  105533. * @param gamepad defines the internal HTML gamepad object
  105534. * @param xboxOne defines if it is a XBox One gamepad
  105535. */
  105536. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105537. /**
  105538. * Defines the callback to call when left trigger is pressed
  105539. * @param callback defines the callback to use
  105540. */
  105541. onlefttriggerchanged(callback: (value: number) => void): void;
  105542. /**
  105543. * Defines the callback to call when right trigger is pressed
  105544. * @param callback defines the callback to use
  105545. */
  105546. onrighttriggerchanged(callback: (value: number) => void): void;
  105547. /**
  105548. * Gets the left trigger value
  105549. */
  105550. /**
  105551. * Sets the left trigger value
  105552. */
  105553. leftTrigger: number;
  105554. /**
  105555. * Gets the right trigger value
  105556. */
  105557. /**
  105558. * Sets the right trigger value
  105559. */
  105560. rightTrigger: number;
  105561. /**
  105562. * Defines the callback to call when a button is pressed
  105563. * @param callback defines the callback to use
  105564. */
  105565. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105566. /**
  105567. * Defines the callback to call when a button is released
  105568. * @param callback defines the callback to use
  105569. */
  105570. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105571. /**
  105572. * Defines the callback to call when a pad is pressed
  105573. * @param callback defines the callback to use
  105574. */
  105575. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105576. /**
  105577. * Defines the callback to call when a pad is released
  105578. * @param callback defines the callback to use
  105579. */
  105580. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105581. private _setButtonValue;
  105582. private _setDPadValue;
  105583. /**
  105584. * Gets the value of the `A` button
  105585. */
  105586. /**
  105587. * Sets the value of the `A` button
  105588. */
  105589. buttonA: number;
  105590. /**
  105591. * Gets the value of the `B` button
  105592. */
  105593. /**
  105594. * Sets the value of the `B` button
  105595. */
  105596. buttonB: number;
  105597. /**
  105598. * Gets the value of the `X` button
  105599. */
  105600. /**
  105601. * Sets the value of the `X` button
  105602. */
  105603. buttonX: number;
  105604. /**
  105605. * Gets the value of the `Y` button
  105606. */
  105607. /**
  105608. * Sets the value of the `Y` button
  105609. */
  105610. buttonY: number;
  105611. /**
  105612. * Gets the value of the `Start` button
  105613. */
  105614. /**
  105615. * Sets the value of the `Start` button
  105616. */
  105617. buttonStart: number;
  105618. /**
  105619. * Gets the value of the `Back` button
  105620. */
  105621. /**
  105622. * Sets the value of the `Back` button
  105623. */
  105624. buttonBack: number;
  105625. /**
  105626. * Gets the value of the `Left` button
  105627. */
  105628. /**
  105629. * Sets the value of the `Left` button
  105630. */
  105631. buttonLB: number;
  105632. /**
  105633. * Gets the value of the `Right` button
  105634. */
  105635. /**
  105636. * Sets the value of the `Right` button
  105637. */
  105638. buttonRB: number;
  105639. /**
  105640. * Gets the value of the Left joystick
  105641. */
  105642. /**
  105643. * Sets the value of the Left joystick
  105644. */
  105645. buttonLeftStick: number;
  105646. /**
  105647. * Gets the value of the Right joystick
  105648. */
  105649. /**
  105650. * Sets the value of the Right joystick
  105651. */
  105652. buttonRightStick: number;
  105653. /**
  105654. * Gets the value of D-pad up
  105655. */
  105656. /**
  105657. * Sets the value of D-pad up
  105658. */
  105659. dPadUp: number;
  105660. /**
  105661. * Gets the value of D-pad down
  105662. */
  105663. /**
  105664. * Sets the value of D-pad down
  105665. */
  105666. dPadDown: number;
  105667. /**
  105668. * Gets the value of D-pad left
  105669. */
  105670. /**
  105671. * Sets the value of D-pad left
  105672. */
  105673. dPadLeft: number;
  105674. /**
  105675. * Gets the value of D-pad right
  105676. */
  105677. /**
  105678. * Sets the value of D-pad right
  105679. */
  105680. dPadRight: number;
  105681. /**
  105682. * Force the gamepad to synchronize with device values
  105683. */
  105684. update(): void;
  105685. /**
  105686. * Disposes the gamepad
  105687. */
  105688. dispose(): void;
  105689. }
  105690. }
  105691. declare module BABYLON {
  105692. /**
  105693. * Defines supported buttons for DualShock compatible gamepads
  105694. */
  105695. export enum DualShockButton {
  105696. /** Cross */
  105697. Cross = 0,
  105698. /** Circle */
  105699. Circle = 1,
  105700. /** Square */
  105701. Square = 2,
  105702. /** Triangle */
  105703. Triangle = 3,
  105704. /** Options */
  105705. Options = 4,
  105706. /** Share */
  105707. Share = 5,
  105708. /** L1 */
  105709. L1 = 6,
  105710. /** R1 */
  105711. R1 = 7,
  105712. /** Left stick */
  105713. LeftStick = 8,
  105714. /** Right stick */
  105715. RightStick = 9
  105716. }
  105717. /** Defines values for DualShock DPad */
  105718. export enum DualShockDpad {
  105719. /** Up */
  105720. Up = 0,
  105721. /** Down */
  105722. Down = 1,
  105723. /** Left */
  105724. Left = 2,
  105725. /** Right */
  105726. Right = 3
  105727. }
  105728. /**
  105729. * Defines a DualShock gamepad
  105730. */
  105731. export class DualShockPad extends Gamepad {
  105732. private _leftTrigger;
  105733. private _rightTrigger;
  105734. private _onlefttriggerchanged;
  105735. private _onrighttriggerchanged;
  105736. private _onbuttondown;
  105737. private _onbuttonup;
  105738. private _ondpaddown;
  105739. private _ondpadup;
  105740. /** Observable raised when a button is pressed */
  105741. onButtonDownObservable: Observable<DualShockButton>;
  105742. /** Observable raised when a button is released */
  105743. onButtonUpObservable: Observable<DualShockButton>;
  105744. /** Observable raised when a pad is pressed */
  105745. onPadDownObservable: Observable<DualShockDpad>;
  105746. /** Observable raised when a pad is released */
  105747. onPadUpObservable: Observable<DualShockDpad>;
  105748. private _buttonCross;
  105749. private _buttonCircle;
  105750. private _buttonSquare;
  105751. private _buttonTriangle;
  105752. private _buttonShare;
  105753. private _buttonOptions;
  105754. private _buttonL1;
  105755. private _buttonR1;
  105756. private _buttonLeftStick;
  105757. private _buttonRightStick;
  105758. private _dPadUp;
  105759. private _dPadDown;
  105760. private _dPadLeft;
  105761. private _dPadRight;
  105762. /**
  105763. * Creates a new DualShock gamepad object
  105764. * @param id defines the id of this gamepad
  105765. * @param index defines its index
  105766. * @param gamepad defines the internal HTML gamepad object
  105767. */
  105768. constructor(id: string, index: number, gamepad: any);
  105769. /**
  105770. * Defines the callback to call when left trigger is pressed
  105771. * @param callback defines the callback to use
  105772. */
  105773. onlefttriggerchanged(callback: (value: number) => void): void;
  105774. /**
  105775. * Defines the callback to call when right trigger is pressed
  105776. * @param callback defines the callback to use
  105777. */
  105778. onrighttriggerchanged(callback: (value: number) => void): void;
  105779. /**
  105780. * Gets the left trigger value
  105781. */
  105782. /**
  105783. * Sets the left trigger value
  105784. */
  105785. leftTrigger: number;
  105786. /**
  105787. * Gets the right trigger value
  105788. */
  105789. /**
  105790. * Sets the right trigger value
  105791. */
  105792. rightTrigger: number;
  105793. /**
  105794. * Defines the callback to call when a button is pressed
  105795. * @param callback defines the callback to use
  105796. */
  105797. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105798. /**
  105799. * Defines the callback to call when a button is released
  105800. * @param callback defines the callback to use
  105801. */
  105802. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105803. /**
  105804. * Defines the callback to call when a pad is pressed
  105805. * @param callback defines the callback to use
  105806. */
  105807. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105808. /**
  105809. * Defines the callback to call when a pad is released
  105810. * @param callback defines the callback to use
  105811. */
  105812. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105813. private _setButtonValue;
  105814. private _setDPadValue;
  105815. /**
  105816. * Gets the value of the `Cross` button
  105817. */
  105818. /**
  105819. * Sets the value of the `Cross` button
  105820. */
  105821. buttonCross: number;
  105822. /**
  105823. * Gets the value of the `Circle` button
  105824. */
  105825. /**
  105826. * Sets the value of the `Circle` button
  105827. */
  105828. buttonCircle: number;
  105829. /**
  105830. * Gets the value of the `Square` button
  105831. */
  105832. /**
  105833. * Sets the value of the `Square` button
  105834. */
  105835. buttonSquare: number;
  105836. /**
  105837. * Gets the value of the `Triangle` button
  105838. */
  105839. /**
  105840. * Sets the value of the `Triangle` button
  105841. */
  105842. buttonTriangle: number;
  105843. /**
  105844. * Gets the value of the `Options` button
  105845. */
  105846. /**
  105847. * Sets the value of the `Options` button
  105848. */
  105849. buttonOptions: number;
  105850. /**
  105851. * Gets the value of the `Share` button
  105852. */
  105853. /**
  105854. * Sets the value of the `Share` button
  105855. */
  105856. buttonShare: number;
  105857. /**
  105858. * Gets the value of the `L1` button
  105859. */
  105860. /**
  105861. * Sets the value of the `L1` button
  105862. */
  105863. buttonL1: number;
  105864. /**
  105865. * Gets the value of the `R1` button
  105866. */
  105867. /**
  105868. * Sets the value of the `R1` button
  105869. */
  105870. buttonR1: number;
  105871. /**
  105872. * Gets the value of the Left joystick
  105873. */
  105874. /**
  105875. * Sets the value of the Left joystick
  105876. */
  105877. buttonLeftStick: number;
  105878. /**
  105879. * Gets the value of the Right joystick
  105880. */
  105881. /**
  105882. * Sets the value of the Right joystick
  105883. */
  105884. buttonRightStick: number;
  105885. /**
  105886. * Gets the value of D-pad up
  105887. */
  105888. /**
  105889. * Sets the value of D-pad up
  105890. */
  105891. dPadUp: number;
  105892. /**
  105893. * Gets the value of D-pad down
  105894. */
  105895. /**
  105896. * Sets the value of D-pad down
  105897. */
  105898. dPadDown: number;
  105899. /**
  105900. * Gets the value of D-pad left
  105901. */
  105902. /**
  105903. * Sets the value of D-pad left
  105904. */
  105905. dPadLeft: number;
  105906. /**
  105907. * Gets the value of D-pad right
  105908. */
  105909. /**
  105910. * Sets the value of D-pad right
  105911. */
  105912. dPadRight: number;
  105913. /**
  105914. * Force the gamepad to synchronize with device values
  105915. */
  105916. update(): void;
  105917. /**
  105918. * Disposes the gamepad
  105919. */
  105920. dispose(): void;
  105921. }
  105922. }
  105923. declare module BABYLON {
  105924. /**
  105925. * Manager for handling gamepads
  105926. */
  105927. export class GamepadManager {
  105928. private _scene?;
  105929. private _babylonGamepads;
  105930. private _oneGamepadConnected;
  105931. /** @hidden */
  105932. _isMonitoring: boolean;
  105933. private _gamepadEventSupported;
  105934. private _gamepadSupport;
  105935. /**
  105936. * observable to be triggered when the gamepad controller has been connected
  105937. */
  105938. onGamepadConnectedObservable: Observable<Gamepad>;
  105939. /**
  105940. * observable to be triggered when the gamepad controller has been disconnected
  105941. */
  105942. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105943. private _onGamepadConnectedEvent;
  105944. private _onGamepadDisconnectedEvent;
  105945. /**
  105946. * Initializes the gamepad manager
  105947. * @param _scene BabylonJS scene
  105948. */
  105949. constructor(_scene?: Scene | undefined);
  105950. /**
  105951. * The gamepads in the game pad manager
  105952. */
  105953. readonly gamepads: Gamepad[];
  105954. /**
  105955. * Get the gamepad controllers based on type
  105956. * @param type The type of gamepad controller
  105957. * @returns Nullable gamepad
  105958. */
  105959. getGamepadByType(type?: number): Nullable<Gamepad>;
  105960. /**
  105961. * Disposes the gamepad manager
  105962. */
  105963. dispose(): void;
  105964. private _addNewGamepad;
  105965. private _startMonitoringGamepads;
  105966. private _stopMonitoringGamepads;
  105967. /** @hidden */
  105968. _checkGamepadsStatus(): void;
  105969. private _updateGamepadObjects;
  105970. }
  105971. }
  105972. declare module BABYLON {
  105973. interface Scene {
  105974. /** @hidden */
  105975. _gamepadManager: Nullable<GamepadManager>;
  105976. /**
  105977. * Gets the gamepad manager associated with the scene
  105978. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105979. */
  105980. gamepadManager: GamepadManager;
  105981. }
  105982. /**
  105983. * Interface representing a free camera inputs manager
  105984. */
  105985. interface FreeCameraInputsManager {
  105986. /**
  105987. * Adds gamepad input support to the FreeCameraInputsManager.
  105988. * @returns the FreeCameraInputsManager
  105989. */
  105990. addGamepad(): FreeCameraInputsManager;
  105991. }
  105992. /**
  105993. * Interface representing an arc rotate camera inputs manager
  105994. */
  105995. interface ArcRotateCameraInputsManager {
  105996. /**
  105997. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105998. * @returns the camera inputs manager
  105999. */
  106000. addGamepad(): ArcRotateCameraInputsManager;
  106001. }
  106002. /**
  106003. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106004. */
  106005. export class GamepadSystemSceneComponent implements ISceneComponent {
  106006. /**
  106007. * The component name helpfull to identify the component in the list of scene components.
  106008. */
  106009. readonly name: string;
  106010. /**
  106011. * The scene the component belongs to.
  106012. */
  106013. scene: Scene;
  106014. /**
  106015. * Creates a new instance of the component for the given scene
  106016. * @param scene Defines the scene to register the component in
  106017. */
  106018. constructor(scene: Scene);
  106019. /**
  106020. * Registers the component in a given scene
  106021. */
  106022. register(): void;
  106023. /**
  106024. * Rebuilds the elements related to this component in case of
  106025. * context lost for instance.
  106026. */
  106027. rebuild(): void;
  106028. /**
  106029. * Disposes the component and the associated ressources
  106030. */
  106031. dispose(): void;
  106032. private _beforeCameraUpdate;
  106033. }
  106034. }
  106035. declare module BABYLON {
  106036. /**
  106037. * 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,
  106038. * which still works and will still be found in many Playgrounds.
  106039. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106040. */
  106041. export class UniversalCamera extends TouchCamera {
  106042. /**
  106043. * Defines the gamepad rotation sensiblity.
  106044. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106045. */
  106046. gamepadAngularSensibility: number;
  106047. /**
  106048. * Defines the gamepad move sensiblity.
  106049. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106050. */
  106051. gamepadMoveSensibility: number;
  106052. /**
  106053. * 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,
  106054. * which still works and will still be found in many Playgrounds.
  106055. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106056. * @param name Define the name of the camera in the scene
  106057. * @param position Define the start position of the camera in the scene
  106058. * @param scene Define the scene the camera belongs to
  106059. */
  106060. constructor(name: string, position: Vector3, scene: Scene);
  106061. /**
  106062. * Gets the current object class name.
  106063. * @return the class name
  106064. */
  106065. getClassName(): string;
  106066. }
  106067. }
  106068. declare module BABYLON {
  106069. /**
  106070. * This represents a FPS type of camera. This is only here for back compat purpose.
  106071. * Please use the UniversalCamera instead as both are identical.
  106072. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106073. */
  106074. export class GamepadCamera extends UniversalCamera {
  106075. /**
  106076. * Instantiates a new Gamepad Camera
  106077. * This represents a FPS type of camera. This is only here for back compat purpose.
  106078. * Please use the UniversalCamera instead as both are identical.
  106079. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106080. * @param name Define the name of the camera in the scene
  106081. * @param position Define the start position of the camera in the scene
  106082. * @param scene Define the scene the camera belongs to
  106083. */
  106084. constructor(name: string, position: Vector3, scene: Scene);
  106085. /**
  106086. * Gets the current object class name.
  106087. * @return the class name
  106088. */
  106089. getClassName(): string;
  106090. }
  106091. }
  106092. declare module BABYLON {
  106093. /** @hidden */
  106094. export var passPixelShader: {
  106095. name: string;
  106096. shader: string;
  106097. };
  106098. }
  106099. declare module BABYLON {
  106100. /** @hidden */
  106101. export var passCubePixelShader: {
  106102. name: string;
  106103. shader: string;
  106104. };
  106105. }
  106106. declare module BABYLON {
  106107. /**
  106108. * PassPostProcess which produces an output the same as it's input
  106109. */
  106110. export class PassPostProcess extends PostProcess {
  106111. /**
  106112. * Creates the PassPostProcess
  106113. * @param name The name of the effect.
  106114. * @param options The required width/height ratio to downsize to before computing the render pass.
  106115. * @param camera The camera to apply the render pass to.
  106116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106117. * @param engine The engine which the post process will be applied. (default: current engine)
  106118. * @param reusable If the post process can be reused on the same frame. (default: false)
  106119. * @param textureType The type of texture to be used when performing the post processing.
  106120. * @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)
  106121. */
  106122. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106123. }
  106124. /**
  106125. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106126. */
  106127. export class PassCubePostProcess extends PostProcess {
  106128. private _face;
  106129. /**
  106130. * Gets or sets the cube face to display.
  106131. * * 0 is +X
  106132. * * 1 is -X
  106133. * * 2 is +Y
  106134. * * 3 is -Y
  106135. * * 4 is +Z
  106136. * * 5 is -Z
  106137. */
  106138. face: number;
  106139. /**
  106140. * Creates the PassCubePostProcess
  106141. * @param name The name of the effect.
  106142. * @param options The required width/height ratio to downsize to before computing the render pass.
  106143. * @param camera The camera to apply the render pass to.
  106144. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106145. * @param engine The engine which the post process will be applied. (default: current engine)
  106146. * @param reusable If the post process can be reused on the same frame. (default: false)
  106147. * @param textureType The type of texture to be used when performing the post processing.
  106148. * @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)
  106149. */
  106150. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106151. }
  106152. }
  106153. declare module BABYLON {
  106154. /** @hidden */
  106155. export var anaglyphPixelShader: {
  106156. name: string;
  106157. shader: string;
  106158. };
  106159. }
  106160. declare module BABYLON {
  106161. /**
  106162. * Postprocess used to generate anaglyphic rendering
  106163. */
  106164. export class AnaglyphPostProcess extends PostProcess {
  106165. private _passedProcess;
  106166. /**
  106167. * Creates a new AnaglyphPostProcess
  106168. * @param name defines postprocess name
  106169. * @param options defines creation options or target ratio scale
  106170. * @param rigCameras defines cameras using this postprocess
  106171. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106172. * @param engine defines hosting engine
  106173. * @param reusable defines if the postprocess will be reused multiple times per frame
  106174. */
  106175. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106176. }
  106177. }
  106178. declare module BABYLON {
  106179. /**
  106180. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106181. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106182. */
  106183. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106184. /**
  106185. * Creates a new AnaglyphArcRotateCamera
  106186. * @param name defines camera name
  106187. * @param alpha defines alpha angle (in radians)
  106188. * @param beta defines beta angle (in radians)
  106189. * @param radius defines radius
  106190. * @param target defines camera target
  106191. * @param interaxialDistance defines distance between each color axis
  106192. * @param scene defines the hosting scene
  106193. */
  106194. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106195. /**
  106196. * Gets camera class name
  106197. * @returns AnaglyphArcRotateCamera
  106198. */
  106199. getClassName(): string;
  106200. }
  106201. }
  106202. declare module BABYLON {
  106203. /**
  106204. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106205. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106206. */
  106207. export class AnaglyphFreeCamera extends FreeCamera {
  106208. /**
  106209. * Creates a new AnaglyphFreeCamera
  106210. * @param name defines camera name
  106211. * @param position defines initial position
  106212. * @param interaxialDistance defines distance between each color axis
  106213. * @param scene defines the hosting scene
  106214. */
  106215. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106216. /**
  106217. * Gets camera class name
  106218. * @returns AnaglyphFreeCamera
  106219. */
  106220. getClassName(): string;
  106221. }
  106222. }
  106223. declare module BABYLON {
  106224. /**
  106225. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106226. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106227. */
  106228. export class AnaglyphGamepadCamera extends GamepadCamera {
  106229. /**
  106230. * Creates a new AnaglyphGamepadCamera
  106231. * @param name defines camera name
  106232. * @param position defines initial position
  106233. * @param interaxialDistance defines distance between each color axis
  106234. * @param scene defines the hosting scene
  106235. */
  106236. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106237. /**
  106238. * Gets camera class name
  106239. * @returns AnaglyphGamepadCamera
  106240. */
  106241. getClassName(): string;
  106242. }
  106243. }
  106244. declare module BABYLON {
  106245. /**
  106246. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106247. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106248. */
  106249. export class AnaglyphUniversalCamera extends UniversalCamera {
  106250. /**
  106251. * Creates a new AnaglyphUniversalCamera
  106252. * @param name defines camera name
  106253. * @param position defines initial position
  106254. * @param interaxialDistance defines distance between each color axis
  106255. * @param scene defines the hosting scene
  106256. */
  106257. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106258. /**
  106259. * Gets camera class name
  106260. * @returns AnaglyphUniversalCamera
  106261. */
  106262. getClassName(): string;
  106263. }
  106264. }
  106265. declare module BABYLON {
  106266. /** @hidden */
  106267. export var stereoscopicInterlacePixelShader: {
  106268. name: string;
  106269. shader: string;
  106270. };
  106271. }
  106272. declare module BABYLON {
  106273. /**
  106274. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106275. */
  106276. export class StereoscopicInterlacePostProcess extends PostProcess {
  106277. private _stepSize;
  106278. private _passedProcess;
  106279. /**
  106280. * Initializes a StereoscopicInterlacePostProcess
  106281. * @param name The name of the effect.
  106282. * @param rigCameras The rig cameras to be appled to the post process
  106283. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106285. * @param engine The engine which the post process will be applied. (default: current engine)
  106286. * @param reusable If the post process can be reused on the same frame. (default: false)
  106287. */
  106288. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106289. }
  106290. }
  106291. declare module BABYLON {
  106292. /**
  106293. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106294. * @see http://doc.babylonjs.com/features/cameras
  106295. */
  106296. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106297. /**
  106298. * Creates a new StereoscopicArcRotateCamera
  106299. * @param name defines camera name
  106300. * @param alpha defines alpha angle (in radians)
  106301. * @param beta defines beta angle (in radians)
  106302. * @param radius defines radius
  106303. * @param target defines camera target
  106304. * @param interaxialDistance defines distance between each color axis
  106305. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106306. * @param scene defines the hosting scene
  106307. */
  106308. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106309. /**
  106310. * Gets camera class name
  106311. * @returns StereoscopicArcRotateCamera
  106312. */
  106313. getClassName(): string;
  106314. }
  106315. }
  106316. declare module BABYLON {
  106317. /**
  106318. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106319. * @see http://doc.babylonjs.com/features/cameras
  106320. */
  106321. export class StereoscopicFreeCamera extends FreeCamera {
  106322. /**
  106323. * Creates a new StereoscopicFreeCamera
  106324. * @param name defines camera name
  106325. * @param position defines initial position
  106326. * @param interaxialDistance defines distance between each color axis
  106327. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106328. * @param scene defines the hosting scene
  106329. */
  106330. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106331. /**
  106332. * Gets camera class name
  106333. * @returns StereoscopicFreeCamera
  106334. */
  106335. getClassName(): string;
  106336. }
  106337. }
  106338. declare module BABYLON {
  106339. /**
  106340. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106341. * @see http://doc.babylonjs.com/features/cameras
  106342. */
  106343. export class StereoscopicGamepadCamera extends GamepadCamera {
  106344. /**
  106345. * Creates a new StereoscopicGamepadCamera
  106346. * @param name defines camera name
  106347. * @param position defines initial position
  106348. * @param interaxialDistance defines distance between each color axis
  106349. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106350. * @param scene defines the hosting scene
  106351. */
  106352. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106353. /**
  106354. * Gets camera class name
  106355. * @returns StereoscopicGamepadCamera
  106356. */
  106357. getClassName(): string;
  106358. }
  106359. }
  106360. declare module BABYLON {
  106361. /**
  106362. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106363. * @see http://doc.babylonjs.com/features/cameras
  106364. */
  106365. export class StereoscopicUniversalCamera extends UniversalCamera {
  106366. /**
  106367. * Creates a new StereoscopicUniversalCamera
  106368. * @param name defines camera name
  106369. * @param position defines initial position
  106370. * @param interaxialDistance defines distance between each color axis
  106371. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106372. * @param scene defines the hosting scene
  106373. */
  106374. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106375. /**
  106376. * Gets camera class name
  106377. * @returns StereoscopicUniversalCamera
  106378. */
  106379. getClassName(): string;
  106380. }
  106381. }
  106382. declare module BABYLON {
  106383. /**
  106384. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106385. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106386. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106387. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106388. */
  106389. export class VirtualJoysticksCamera extends FreeCamera {
  106390. /**
  106391. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106392. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106393. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106394. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106395. * @param name Define the name of the camera in the scene
  106396. * @param position Define the start position of the camera in the scene
  106397. * @param scene Define the scene the camera belongs to
  106398. */
  106399. constructor(name: string, position: Vector3, scene: Scene);
  106400. /**
  106401. * Gets the current object class name.
  106402. * @return the class name
  106403. */
  106404. getClassName(): string;
  106405. }
  106406. }
  106407. declare module BABYLON {
  106408. /**
  106409. * This represents all the required metrics to create a VR camera.
  106410. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106411. */
  106412. export class VRCameraMetrics {
  106413. /**
  106414. * Define the horizontal resolution off the screen.
  106415. */
  106416. hResolution: number;
  106417. /**
  106418. * Define the vertical resolution off the screen.
  106419. */
  106420. vResolution: number;
  106421. /**
  106422. * Define the horizontal screen size.
  106423. */
  106424. hScreenSize: number;
  106425. /**
  106426. * Define the vertical screen size.
  106427. */
  106428. vScreenSize: number;
  106429. /**
  106430. * Define the vertical screen center position.
  106431. */
  106432. vScreenCenter: number;
  106433. /**
  106434. * Define the distance of the eyes to the screen.
  106435. */
  106436. eyeToScreenDistance: number;
  106437. /**
  106438. * Define the distance between both lenses
  106439. */
  106440. lensSeparationDistance: number;
  106441. /**
  106442. * Define the distance between both viewer's eyes.
  106443. */
  106444. interpupillaryDistance: number;
  106445. /**
  106446. * Define the distortion factor of the VR postprocess.
  106447. * Please, touch with care.
  106448. */
  106449. distortionK: number[];
  106450. /**
  106451. * Define the chromatic aberration correction factors for the VR post process.
  106452. */
  106453. chromaAbCorrection: number[];
  106454. /**
  106455. * Define the scale factor of the post process.
  106456. * The smaller the better but the slower.
  106457. */
  106458. postProcessScaleFactor: number;
  106459. /**
  106460. * Define an offset for the lens center.
  106461. */
  106462. lensCenterOffset: number;
  106463. /**
  106464. * Define if the current vr camera should compensate the distortion of the lense or not.
  106465. */
  106466. compensateDistortion: boolean;
  106467. /**
  106468. * Defines if multiview should be enabled when rendering (Default: false)
  106469. */
  106470. multiviewEnabled: boolean;
  106471. /**
  106472. * Gets the rendering aspect ratio based on the provided resolutions.
  106473. */
  106474. readonly aspectRatio: number;
  106475. /**
  106476. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106477. */
  106478. readonly aspectRatioFov: number;
  106479. /**
  106480. * @hidden
  106481. */
  106482. readonly leftHMatrix: Matrix;
  106483. /**
  106484. * @hidden
  106485. */
  106486. readonly rightHMatrix: Matrix;
  106487. /**
  106488. * @hidden
  106489. */
  106490. readonly leftPreViewMatrix: Matrix;
  106491. /**
  106492. * @hidden
  106493. */
  106494. readonly rightPreViewMatrix: Matrix;
  106495. /**
  106496. * Get the default VRMetrics based on the most generic setup.
  106497. * @returns the default vr metrics
  106498. */
  106499. static GetDefault(): VRCameraMetrics;
  106500. }
  106501. }
  106502. declare module BABYLON {
  106503. /** @hidden */
  106504. export var vrDistortionCorrectionPixelShader: {
  106505. name: string;
  106506. shader: string;
  106507. };
  106508. }
  106509. declare module BABYLON {
  106510. /**
  106511. * VRDistortionCorrectionPostProcess used for mobile VR
  106512. */
  106513. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106514. private _isRightEye;
  106515. private _distortionFactors;
  106516. private _postProcessScaleFactor;
  106517. private _lensCenterOffset;
  106518. private _scaleIn;
  106519. private _scaleFactor;
  106520. private _lensCenter;
  106521. /**
  106522. * Initializes the VRDistortionCorrectionPostProcess
  106523. * @param name The name of the effect.
  106524. * @param camera The camera to apply the render pass to.
  106525. * @param isRightEye If this is for the right eye distortion
  106526. * @param vrMetrics All the required metrics for the VR camera
  106527. */
  106528. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106529. }
  106530. }
  106531. declare module BABYLON {
  106532. /**
  106533. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106534. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106535. */
  106536. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106537. /**
  106538. * Creates a new VRDeviceOrientationArcRotateCamera
  106539. * @param name defines camera name
  106540. * @param alpha defines the camera rotation along the logitudinal axis
  106541. * @param beta defines the camera rotation along the latitudinal axis
  106542. * @param radius defines the camera distance from its target
  106543. * @param target defines the camera target
  106544. * @param scene defines the scene the camera belongs to
  106545. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106546. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106547. */
  106548. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106549. /**
  106550. * Gets camera class name
  106551. * @returns VRDeviceOrientationArcRotateCamera
  106552. */
  106553. getClassName(): string;
  106554. }
  106555. }
  106556. declare module BABYLON {
  106557. /**
  106558. * Camera used to simulate VR rendering (based on FreeCamera)
  106559. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106560. */
  106561. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106562. /**
  106563. * Creates a new VRDeviceOrientationFreeCamera
  106564. * @param name defines camera name
  106565. * @param position defines the start position of the camera
  106566. * @param scene defines the scene the camera belongs to
  106567. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106568. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106569. */
  106570. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106571. /**
  106572. * Gets camera class name
  106573. * @returns VRDeviceOrientationFreeCamera
  106574. */
  106575. getClassName(): string;
  106576. }
  106577. }
  106578. declare module BABYLON {
  106579. /**
  106580. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106581. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106582. */
  106583. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106584. /**
  106585. * Creates a new VRDeviceOrientationGamepadCamera
  106586. * @param name defines camera name
  106587. * @param position defines the start position of the camera
  106588. * @param scene defines the scene the camera belongs to
  106589. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106590. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106591. */
  106592. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106593. /**
  106594. * Gets camera class name
  106595. * @returns VRDeviceOrientationGamepadCamera
  106596. */
  106597. getClassName(): string;
  106598. }
  106599. }
  106600. declare module BABYLON {
  106601. /**
  106602. * Base class of materials working in push mode in babylon JS
  106603. * @hidden
  106604. */
  106605. export class PushMaterial extends Material {
  106606. protected _activeEffect: Effect;
  106607. protected _normalMatrix: Matrix;
  106608. /**
  106609. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106610. * This means that the material can keep using a previous shader while a new one is being compiled.
  106611. * This is mostly used when shader parallel compilation is supported (true by default)
  106612. */
  106613. allowShaderHotSwapping: boolean;
  106614. constructor(name: string, scene: Scene);
  106615. getEffect(): Effect;
  106616. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106617. /**
  106618. * Binds the given world matrix to the active effect
  106619. *
  106620. * @param world the matrix to bind
  106621. */
  106622. bindOnlyWorldMatrix(world: Matrix): void;
  106623. /**
  106624. * Binds the given normal matrix to the active effect
  106625. *
  106626. * @param normalMatrix the matrix to bind
  106627. */
  106628. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106629. bind(world: Matrix, mesh?: Mesh): void;
  106630. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106631. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106632. }
  106633. }
  106634. declare module BABYLON {
  106635. /**
  106636. * This groups all the flags used to control the materials channel.
  106637. */
  106638. export class MaterialFlags {
  106639. private static _DiffuseTextureEnabled;
  106640. /**
  106641. * Are diffuse textures enabled in the application.
  106642. */
  106643. static DiffuseTextureEnabled: boolean;
  106644. private static _AmbientTextureEnabled;
  106645. /**
  106646. * Are ambient textures enabled in the application.
  106647. */
  106648. static AmbientTextureEnabled: boolean;
  106649. private static _OpacityTextureEnabled;
  106650. /**
  106651. * Are opacity textures enabled in the application.
  106652. */
  106653. static OpacityTextureEnabled: boolean;
  106654. private static _ReflectionTextureEnabled;
  106655. /**
  106656. * Are reflection textures enabled in the application.
  106657. */
  106658. static ReflectionTextureEnabled: boolean;
  106659. private static _EmissiveTextureEnabled;
  106660. /**
  106661. * Are emissive textures enabled in the application.
  106662. */
  106663. static EmissiveTextureEnabled: boolean;
  106664. private static _SpecularTextureEnabled;
  106665. /**
  106666. * Are specular textures enabled in the application.
  106667. */
  106668. static SpecularTextureEnabled: boolean;
  106669. private static _BumpTextureEnabled;
  106670. /**
  106671. * Are bump textures enabled in the application.
  106672. */
  106673. static BumpTextureEnabled: boolean;
  106674. private static _LightmapTextureEnabled;
  106675. /**
  106676. * Are lightmap textures enabled in the application.
  106677. */
  106678. static LightmapTextureEnabled: boolean;
  106679. private static _RefractionTextureEnabled;
  106680. /**
  106681. * Are refraction textures enabled in the application.
  106682. */
  106683. static RefractionTextureEnabled: boolean;
  106684. private static _ColorGradingTextureEnabled;
  106685. /**
  106686. * Are color grading textures enabled in the application.
  106687. */
  106688. static ColorGradingTextureEnabled: boolean;
  106689. private static _FresnelEnabled;
  106690. /**
  106691. * Are fresnels enabled in the application.
  106692. */
  106693. static FresnelEnabled: boolean;
  106694. private static _ClearCoatTextureEnabled;
  106695. /**
  106696. * Are clear coat textures enabled in the application.
  106697. */
  106698. static ClearCoatTextureEnabled: boolean;
  106699. private static _ClearCoatBumpTextureEnabled;
  106700. /**
  106701. * Are clear coat bump textures enabled in the application.
  106702. */
  106703. static ClearCoatBumpTextureEnabled: boolean;
  106704. private static _ClearCoatTintTextureEnabled;
  106705. /**
  106706. * Are clear coat tint textures enabled in the application.
  106707. */
  106708. static ClearCoatTintTextureEnabled: boolean;
  106709. private static _SheenTextureEnabled;
  106710. /**
  106711. * Are sheen textures enabled in the application.
  106712. */
  106713. static SheenTextureEnabled: boolean;
  106714. private static _AnisotropicTextureEnabled;
  106715. /**
  106716. * Are anisotropic textures enabled in the application.
  106717. */
  106718. static AnisotropicTextureEnabled: boolean;
  106719. private static _ThicknessTextureEnabled;
  106720. /**
  106721. * Are thickness textures enabled in the application.
  106722. */
  106723. static ThicknessTextureEnabled: boolean;
  106724. }
  106725. }
  106726. declare module BABYLON {
  106727. /** @hidden */
  106728. export var defaultFragmentDeclaration: {
  106729. name: string;
  106730. shader: string;
  106731. };
  106732. }
  106733. declare module BABYLON {
  106734. /** @hidden */
  106735. export var defaultUboDeclaration: {
  106736. name: string;
  106737. shader: string;
  106738. };
  106739. }
  106740. declare module BABYLON {
  106741. /** @hidden */
  106742. export var lightFragmentDeclaration: {
  106743. name: string;
  106744. shader: string;
  106745. };
  106746. }
  106747. declare module BABYLON {
  106748. /** @hidden */
  106749. export var lightUboDeclaration: {
  106750. name: string;
  106751. shader: string;
  106752. };
  106753. }
  106754. declare module BABYLON {
  106755. /** @hidden */
  106756. export var lightsFragmentFunctions: {
  106757. name: string;
  106758. shader: string;
  106759. };
  106760. }
  106761. declare module BABYLON {
  106762. /** @hidden */
  106763. export var shadowsFragmentFunctions: {
  106764. name: string;
  106765. shader: string;
  106766. };
  106767. }
  106768. declare module BABYLON {
  106769. /** @hidden */
  106770. export var fresnelFunction: {
  106771. name: string;
  106772. shader: string;
  106773. };
  106774. }
  106775. declare module BABYLON {
  106776. /** @hidden */
  106777. export var reflectionFunction: {
  106778. name: string;
  106779. shader: string;
  106780. };
  106781. }
  106782. declare module BABYLON {
  106783. /** @hidden */
  106784. export var bumpFragmentFunctions: {
  106785. name: string;
  106786. shader: string;
  106787. };
  106788. }
  106789. declare module BABYLON {
  106790. /** @hidden */
  106791. export var logDepthDeclaration: {
  106792. name: string;
  106793. shader: string;
  106794. };
  106795. }
  106796. declare module BABYLON {
  106797. /** @hidden */
  106798. export var bumpFragment: {
  106799. name: string;
  106800. shader: string;
  106801. };
  106802. }
  106803. declare module BABYLON {
  106804. /** @hidden */
  106805. export var depthPrePass: {
  106806. name: string;
  106807. shader: string;
  106808. };
  106809. }
  106810. declare module BABYLON {
  106811. /** @hidden */
  106812. export var lightFragment: {
  106813. name: string;
  106814. shader: string;
  106815. };
  106816. }
  106817. declare module BABYLON {
  106818. /** @hidden */
  106819. export var logDepthFragment: {
  106820. name: string;
  106821. shader: string;
  106822. };
  106823. }
  106824. declare module BABYLON {
  106825. /** @hidden */
  106826. export var defaultPixelShader: {
  106827. name: string;
  106828. shader: string;
  106829. };
  106830. }
  106831. declare module BABYLON {
  106832. /** @hidden */
  106833. export var defaultVertexDeclaration: {
  106834. name: string;
  106835. shader: string;
  106836. };
  106837. }
  106838. declare module BABYLON {
  106839. /** @hidden */
  106840. export var bumpVertexDeclaration: {
  106841. name: string;
  106842. shader: string;
  106843. };
  106844. }
  106845. declare module BABYLON {
  106846. /** @hidden */
  106847. export var bumpVertex: {
  106848. name: string;
  106849. shader: string;
  106850. };
  106851. }
  106852. declare module BABYLON {
  106853. /** @hidden */
  106854. export var fogVertex: {
  106855. name: string;
  106856. shader: string;
  106857. };
  106858. }
  106859. declare module BABYLON {
  106860. /** @hidden */
  106861. export var shadowsVertex: {
  106862. name: string;
  106863. shader: string;
  106864. };
  106865. }
  106866. declare module BABYLON {
  106867. /** @hidden */
  106868. export var pointCloudVertex: {
  106869. name: string;
  106870. shader: string;
  106871. };
  106872. }
  106873. declare module BABYLON {
  106874. /** @hidden */
  106875. export var logDepthVertex: {
  106876. name: string;
  106877. shader: string;
  106878. };
  106879. }
  106880. declare module BABYLON {
  106881. /** @hidden */
  106882. export var defaultVertexShader: {
  106883. name: string;
  106884. shader: string;
  106885. };
  106886. }
  106887. declare module BABYLON {
  106888. /** @hidden */
  106889. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106890. MAINUV1: boolean;
  106891. MAINUV2: boolean;
  106892. DIFFUSE: boolean;
  106893. DIFFUSEDIRECTUV: number;
  106894. AMBIENT: boolean;
  106895. AMBIENTDIRECTUV: number;
  106896. OPACITY: boolean;
  106897. OPACITYDIRECTUV: number;
  106898. OPACITYRGB: boolean;
  106899. REFLECTION: boolean;
  106900. EMISSIVE: boolean;
  106901. EMISSIVEDIRECTUV: number;
  106902. SPECULAR: boolean;
  106903. SPECULARDIRECTUV: number;
  106904. BUMP: boolean;
  106905. BUMPDIRECTUV: number;
  106906. PARALLAX: boolean;
  106907. PARALLAXOCCLUSION: boolean;
  106908. SPECULAROVERALPHA: boolean;
  106909. CLIPPLANE: boolean;
  106910. CLIPPLANE2: boolean;
  106911. CLIPPLANE3: boolean;
  106912. CLIPPLANE4: boolean;
  106913. ALPHATEST: boolean;
  106914. DEPTHPREPASS: boolean;
  106915. ALPHAFROMDIFFUSE: boolean;
  106916. POINTSIZE: boolean;
  106917. FOG: boolean;
  106918. SPECULARTERM: boolean;
  106919. DIFFUSEFRESNEL: boolean;
  106920. OPACITYFRESNEL: boolean;
  106921. REFLECTIONFRESNEL: boolean;
  106922. REFRACTIONFRESNEL: boolean;
  106923. EMISSIVEFRESNEL: boolean;
  106924. FRESNEL: boolean;
  106925. NORMAL: boolean;
  106926. UV1: boolean;
  106927. UV2: boolean;
  106928. VERTEXCOLOR: boolean;
  106929. VERTEXALPHA: boolean;
  106930. NUM_BONE_INFLUENCERS: number;
  106931. BonesPerMesh: number;
  106932. BONETEXTURE: boolean;
  106933. INSTANCES: boolean;
  106934. GLOSSINESS: boolean;
  106935. ROUGHNESS: boolean;
  106936. EMISSIVEASILLUMINATION: boolean;
  106937. LINKEMISSIVEWITHDIFFUSE: boolean;
  106938. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106939. LIGHTMAP: boolean;
  106940. LIGHTMAPDIRECTUV: number;
  106941. OBJECTSPACE_NORMALMAP: boolean;
  106942. USELIGHTMAPASSHADOWMAP: boolean;
  106943. REFLECTIONMAP_3D: boolean;
  106944. REFLECTIONMAP_SPHERICAL: boolean;
  106945. REFLECTIONMAP_PLANAR: boolean;
  106946. REFLECTIONMAP_CUBIC: boolean;
  106947. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106948. REFLECTIONMAP_PROJECTION: boolean;
  106949. REFLECTIONMAP_SKYBOX: boolean;
  106950. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106951. REFLECTIONMAP_EXPLICIT: boolean;
  106952. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106953. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106954. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106955. INVERTCUBICMAP: boolean;
  106956. LOGARITHMICDEPTH: boolean;
  106957. REFRACTION: boolean;
  106958. REFRACTIONMAP_3D: boolean;
  106959. REFLECTIONOVERALPHA: boolean;
  106960. TWOSIDEDLIGHTING: boolean;
  106961. SHADOWFLOAT: boolean;
  106962. MORPHTARGETS: boolean;
  106963. MORPHTARGETS_NORMAL: boolean;
  106964. MORPHTARGETS_TANGENT: boolean;
  106965. MORPHTARGETS_UV: boolean;
  106966. NUM_MORPH_INFLUENCERS: number;
  106967. NONUNIFORMSCALING: boolean;
  106968. PREMULTIPLYALPHA: boolean;
  106969. IMAGEPROCESSING: boolean;
  106970. VIGNETTE: boolean;
  106971. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106972. VIGNETTEBLENDMODEOPAQUE: boolean;
  106973. TONEMAPPING: boolean;
  106974. TONEMAPPING_ACES: boolean;
  106975. CONTRAST: boolean;
  106976. COLORCURVES: boolean;
  106977. COLORGRADING: boolean;
  106978. COLORGRADING3D: boolean;
  106979. SAMPLER3DGREENDEPTH: boolean;
  106980. SAMPLER3DBGRMAP: boolean;
  106981. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106982. MULTIVIEW: boolean;
  106983. /**
  106984. * If the reflection texture on this material is in linear color space
  106985. * @hidden
  106986. */
  106987. IS_REFLECTION_LINEAR: boolean;
  106988. /**
  106989. * If the refraction texture on this material is in linear color space
  106990. * @hidden
  106991. */
  106992. IS_REFRACTION_LINEAR: boolean;
  106993. EXPOSURE: boolean;
  106994. constructor();
  106995. setReflectionMode(modeToEnable: string): void;
  106996. }
  106997. /**
  106998. * This is the default material used in Babylon. It is the best trade off between quality
  106999. * and performances.
  107000. * @see http://doc.babylonjs.com/babylon101/materials
  107001. */
  107002. export class StandardMaterial extends PushMaterial {
  107003. private _diffuseTexture;
  107004. /**
  107005. * The basic texture of the material as viewed under a light.
  107006. */
  107007. diffuseTexture: Nullable<BaseTexture>;
  107008. private _ambientTexture;
  107009. /**
  107010. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107011. */
  107012. ambientTexture: Nullable<BaseTexture>;
  107013. private _opacityTexture;
  107014. /**
  107015. * Define the transparency of the material from a texture.
  107016. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107017. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107018. */
  107019. opacityTexture: Nullable<BaseTexture>;
  107020. private _reflectionTexture;
  107021. /**
  107022. * Define the texture used to display the reflection.
  107023. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107024. */
  107025. reflectionTexture: Nullable<BaseTexture>;
  107026. private _emissiveTexture;
  107027. /**
  107028. * Define texture of the material as if self lit.
  107029. * This will be mixed in the final result even in the absence of light.
  107030. */
  107031. emissiveTexture: Nullable<BaseTexture>;
  107032. private _specularTexture;
  107033. /**
  107034. * Define how the color and intensity of the highlight given by the light in the material.
  107035. */
  107036. specularTexture: Nullable<BaseTexture>;
  107037. private _bumpTexture;
  107038. /**
  107039. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107040. * 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.
  107041. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107042. */
  107043. bumpTexture: Nullable<BaseTexture>;
  107044. private _lightmapTexture;
  107045. /**
  107046. * Complex lighting can be computationally expensive to compute at runtime.
  107047. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107048. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107049. */
  107050. lightmapTexture: Nullable<BaseTexture>;
  107051. private _refractionTexture;
  107052. /**
  107053. * Define the texture used to display the refraction.
  107054. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107055. */
  107056. refractionTexture: Nullable<BaseTexture>;
  107057. /**
  107058. * The color of the material lit by the environmental background lighting.
  107059. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107060. */
  107061. ambientColor: Color3;
  107062. /**
  107063. * The basic color of the material as viewed under a light.
  107064. */
  107065. diffuseColor: Color3;
  107066. /**
  107067. * Define how the color and intensity of the highlight given by the light in the material.
  107068. */
  107069. specularColor: Color3;
  107070. /**
  107071. * Define the color of the material as if self lit.
  107072. * This will be mixed in the final result even in the absence of light.
  107073. */
  107074. emissiveColor: Color3;
  107075. /**
  107076. * Defines how sharp are the highlights in the material.
  107077. * The bigger the value the sharper giving a more glossy feeling to the result.
  107078. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107079. */
  107080. specularPower: number;
  107081. private _useAlphaFromDiffuseTexture;
  107082. /**
  107083. * Does the transparency come from the diffuse texture alpha channel.
  107084. */
  107085. useAlphaFromDiffuseTexture: boolean;
  107086. private _useEmissiveAsIllumination;
  107087. /**
  107088. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107089. */
  107090. useEmissiveAsIllumination: boolean;
  107091. private _linkEmissiveWithDiffuse;
  107092. /**
  107093. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107094. * the emissive level when the final color is close to one.
  107095. */
  107096. linkEmissiveWithDiffuse: boolean;
  107097. private _useSpecularOverAlpha;
  107098. /**
  107099. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107100. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107101. */
  107102. useSpecularOverAlpha: boolean;
  107103. private _useReflectionOverAlpha;
  107104. /**
  107105. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107106. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107107. */
  107108. useReflectionOverAlpha: boolean;
  107109. private _disableLighting;
  107110. /**
  107111. * Does lights from the scene impacts this material.
  107112. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107113. */
  107114. disableLighting: boolean;
  107115. private _useObjectSpaceNormalMap;
  107116. /**
  107117. * Allows using an object space normal map (instead of tangent space).
  107118. */
  107119. useObjectSpaceNormalMap: boolean;
  107120. private _useParallax;
  107121. /**
  107122. * Is parallax enabled or not.
  107123. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107124. */
  107125. useParallax: boolean;
  107126. private _useParallaxOcclusion;
  107127. /**
  107128. * Is parallax occlusion enabled or not.
  107129. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107130. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107131. */
  107132. useParallaxOcclusion: boolean;
  107133. /**
  107134. * 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.
  107135. */
  107136. parallaxScaleBias: number;
  107137. private _roughness;
  107138. /**
  107139. * Helps to define how blurry the reflections should appears in the material.
  107140. */
  107141. roughness: number;
  107142. /**
  107143. * In case of refraction, define the value of the index of refraction.
  107144. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107145. */
  107146. indexOfRefraction: number;
  107147. /**
  107148. * Invert the refraction texture alongside the y axis.
  107149. * It can be useful with procedural textures or probe for instance.
  107150. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107151. */
  107152. invertRefractionY: boolean;
  107153. /**
  107154. * Defines the alpha limits in alpha test mode.
  107155. */
  107156. alphaCutOff: number;
  107157. private _useLightmapAsShadowmap;
  107158. /**
  107159. * In case of light mapping, define whether the map contains light or shadow informations.
  107160. */
  107161. useLightmapAsShadowmap: boolean;
  107162. private _diffuseFresnelParameters;
  107163. /**
  107164. * Define the diffuse fresnel parameters of the material.
  107165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107166. */
  107167. diffuseFresnelParameters: FresnelParameters;
  107168. private _opacityFresnelParameters;
  107169. /**
  107170. * Define the opacity fresnel parameters of the material.
  107171. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107172. */
  107173. opacityFresnelParameters: FresnelParameters;
  107174. private _reflectionFresnelParameters;
  107175. /**
  107176. * Define the reflection fresnel parameters of the material.
  107177. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107178. */
  107179. reflectionFresnelParameters: FresnelParameters;
  107180. private _refractionFresnelParameters;
  107181. /**
  107182. * Define the refraction fresnel parameters of the material.
  107183. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107184. */
  107185. refractionFresnelParameters: FresnelParameters;
  107186. private _emissiveFresnelParameters;
  107187. /**
  107188. * Define the emissive fresnel parameters of the material.
  107189. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107190. */
  107191. emissiveFresnelParameters: FresnelParameters;
  107192. private _useReflectionFresnelFromSpecular;
  107193. /**
  107194. * If true automatically deducts the fresnels values from the material specularity.
  107195. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107196. */
  107197. useReflectionFresnelFromSpecular: boolean;
  107198. private _useGlossinessFromSpecularMapAlpha;
  107199. /**
  107200. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107201. */
  107202. useGlossinessFromSpecularMapAlpha: boolean;
  107203. private _maxSimultaneousLights;
  107204. /**
  107205. * Defines the maximum number of lights that can be used in the material
  107206. */
  107207. maxSimultaneousLights: number;
  107208. private _invertNormalMapX;
  107209. /**
  107210. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107211. */
  107212. invertNormalMapX: boolean;
  107213. private _invertNormalMapY;
  107214. /**
  107215. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107216. */
  107217. invertNormalMapY: boolean;
  107218. private _twoSidedLighting;
  107219. /**
  107220. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107221. */
  107222. twoSidedLighting: boolean;
  107223. /**
  107224. * Default configuration related to image processing available in the standard Material.
  107225. */
  107226. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107227. /**
  107228. * Gets the image processing configuration used either in this material.
  107229. */
  107230. /**
  107231. * Sets the Default image processing configuration used either in the this material.
  107232. *
  107233. * If sets to null, the scene one is in use.
  107234. */
  107235. imageProcessingConfiguration: ImageProcessingConfiguration;
  107236. /**
  107237. * Keep track of the image processing observer to allow dispose and replace.
  107238. */
  107239. private _imageProcessingObserver;
  107240. /**
  107241. * Attaches a new image processing configuration to the Standard Material.
  107242. * @param configuration
  107243. */
  107244. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107245. /**
  107246. * Gets wether the color curves effect is enabled.
  107247. */
  107248. /**
  107249. * Sets wether the color curves effect is enabled.
  107250. */
  107251. cameraColorCurvesEnabled: boolean;
  107252. /**
  107253. * Gets wether the color grading effect is enabled.
  107254. */
  107255. /**
  107256. * Gets wether the color grading effect is enabled.
  107257. */
  107258. cameraColorGradingEnabled: boolean;
  107259. /**
  107260. * Gets wether tonemapping is enabled or not.
  107261. */
  107262. /**
  107263. * Sets wether tonemapping is enabled or not
  107264. */
  107265. cameraToneMappingEnabled: boolean;
  107266. /**
  107267. * The camera exposure used on this material.
  107268. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107269. * This corresponds to a photographic exposure.
  107270. */
  107271. /**
  107272. * The camera exposure used on this material.
  107273. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107274. * This corresponds to a photographic exposure.
  107275. */
  107276. cameraExposure: number;
  107277. /**
  107278. * Gets The camera contrast used on this material.
  107279. */
  107280. /**
  107281. * Sets The camera contrast used on this material.
  107282. */
  107283. cameraContrast: number;
  107284. /**
  107285. * Gets the Color Grading 2D Lookup Texture.
  107286. */
  107287. /**
  107288. * Sets the Color Grading 2D Lookup Texture.
  107289. */
  107290. cameraColorGradingTexture: Nullable<BaseTexture>;
  107291. /**
  107292. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107293. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107294. * 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;
  107295. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107296. */
  107297. /**
  107298. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107299. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107300. * 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;
  107301. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107302. */
  107303. cameraColorCurves: Nullable<ColorCurves>;
  107304. /**
  107305. * Custom callback helping to override the default shader used in the material.
  107306. */
  107307. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107308. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107309. protected _worldViewProjectionMatrix: Matrix;
  107310. protected _globalAmbientColor: Color3;
  107311. protected _useLogarithmicDepth: boolean;
  107312. protected _rebuildInParallel: boolean;
  107313. /**
  107314. * Instantiates a new standard material.
  107315. * This is the default material used in Babylon. It is the best trade off between quality
  107316. * and performances.
  107317. * @see http://doc.babylonjs.com/babylon101/materials
  107318. * @param name Define the name of the material in the scene
  107319. * @param scene Define the scene the material belong to
  107320. */
  107321. constructor(name: string, scene: Scene);
  107322. /**
  107323. * Gets a boolean indicating that current material needs to register RTT
  107324. */
  107325. readonly hasRenderTargetTextures: boolean;
  107326. /**
  107327. * Gets the current class name of the material e.g. "StandardMaterial"
  107328. * Mainly use in serialization.
  107329. * @returns the class name
  107330. */
  107331. getClassName(): string;
  107332. /**
  107333. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107334. * You can try switching to logarithmic depth.
  107335. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107336. */
  107337. useLogarithmicDepth: boolean;
  107338. /**
  107339. * Specifies if the material will require alpha blending
  107340. * @returns a boolean specifying if alpha blending is needed
  107341. */
  107342. needAlphaBlending(): boolean;
  107343. /**
  107344. * Specifies if this material should be rendered in alpha test mode
  107345. * @returns a boolean specifying if an alpha test is needed.
  107346. */
  107347. needAlphaTesting(): boolean;
  107348. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107349. /**
  107350. * Get the texture used for alpha test purpose.
  107351. * @returns the diffuse texture in case of the standard material.
  107352. */
  107353. getAlphaTestTexture(): Nullable<BaseTexture>;
  107354. /**
  107355. * Get if the submesh is ready to be used and all its information available.
  107356. * Child classes can use it to update shaders
  107357. * @param mesh defines the mesh to check
  107358. * @param subMesh defines which submesh to check
  107359. * @param useInstances specifies that instances should be used
  107360. * @returns a boolean indicating that the submesh is ready or not
  107361. */
  107362. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107363. /**
  107364. * Builds the material UBO layouts.
  107365. * Used internally during the effect preparation.
  107366. */
  107367. buildUniformLayout(): void;
  107368. /**
  107369. * Unbinds the material from the mesh
  107370. */
  107371. unbind(): void;
  107372. /**
  107373. * Binds the submesh to this material by preparing the effect and shader to draw
  107374. * @param world defines the world transformation matrix
  107375. * @param mesh defines the mesh containing the submesh
  107376. * @param subMesh defines the submesh to bind the material to
  107377. */
  107378. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107379. /**
  107380. * Get the list of animatables in the material.
  107381. * @returns the list of animatables object used in the material
  107382. */
  107383. getAnimatables(): IAnimatable[];
  107384. /**
  107385. * Gets the active textures from the material
  107386. * @returns an array of textures
  107387. */
  107388. getActiveTextures(): BaseTexture[];
  107389. /**
  107390. * Specifies if the material uses a texture
  107391. * @param texture defines the texture to check against the material
  107392. * @returns a boolean specifying if the material uses the texture
  107393. */
  107394. hasTexture(texture: BaseTexture): boolean;
  107395. /**
  107396. * Disposes the material
  107397. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107398. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107399. */
  107400. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107401. /**
  107402. * Makes a duplicate of the material, and gives it a new name
  107403. * @param name defines the new name for the duplicated material
  107404. * @returns the cloned material
  107405. */
  107406. clone(name: string): StandardMaterial;
  107407. /**
  107408. * Serializes this material in a JSON representation
  107409. * @returns the serialized material object
  107410. */
  107411. serialize(): any;
  107412. /**
  107413. * Creates a standard material from parsed material data
  107414. * @param source defines the JSON representation of the material
  107415. * @param scene defines the hosting scene
  107416. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107417. * @returns a new standard material
  107418. */
  107419. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107420. /**
  107421. * Are diffuse textures enabled in the application.
  107422. */
  107423. static DiffuseTextureEnabled: boolean;
  107424. /**
  107425. * Are ambient textures enabled in the application.
  107426. */
  107427. static AmbientTextureEnabled: boolean;
  107428. /**
  107429. * Are opacity textures enabled in the application.
  107430. */
  107431. static OpacityTextureEnabled: boolean;
  107432. /**
  107433. * Are reflection textures enabled in the application.
  107434. */
  107435. static ReflectionTextureEnabled: boolean;
  107436. /**
  107437. * Are emissive textures enabled in the application.
  107438. */
  107439. static EmissiveTextureEnabled: boolean;
  107440. /**
  107441. * Are specular textures enabled in the application.
  107442. */
  107443. static SpecularTextureEnabled: boolean;
  107444. /**
  107445. * Are bump textures enabled in the application.
  107446. */
  107447. static BumpTextureEnabled: boolean;
  107448. /**
  107449. * Are lightmap textures enabled in the application.
  107450. */
  107451. static LightmapTextureEnabled: boolean;
  107452. /**
  107453. * Are refraction textures enabled in the application.
  107454. */
  107455. static RefractionTextureEnabled: boolean;
  107456. /**
  107457. * Are color grading textures enabled in the application.
  107458. */
  107459. static ColorGradingTextureEnabled: boolean;
  107460. /**
  107461. * Are fresnels enabled in the application.
  107462. */
  107463. static FresnelEnabled: boolean;
  107464. }
  107465. }
  107466. declare module BABYLON {
  107467. /** @hidden */
  107468. export var imageProcessingPixelShader: {
  107469. name: string;
  107470. shader: string;
  107471. };
  107472. }
  107473. declare module BABYLON {
  107474. /**
  107475. * ImageProcessingPostProcess
  107476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107477. */
  107478. export class ImageProcessingPostProcess extends PostProcess {
  107479. /**
  107480. * Default configuration related to image processing available in the PBR Material.
  107481. */
  107482. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107483. /**
  107484. * Gets the image processing configuration used either in this material.
  107485. */
  107486. /**
  107487. * Sets the Default image processing configuration used either in the this material.
  107488. *
  107489. * If sets to null, the scene one is in use.
  107490. */
  107491. imageProcessingConfiguration: ImageProcessingConfiguration;
  107492. /**
  107493. * Keep track of the image processing observer to allow dispose and replace.
  107494. */
  107495. private _imageProcessingObserver;
  107496. /**
  107497. * Attaches a new image processing configuration to the PBR Material.
  107498. * @param configuration
  107499. */
  107500. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107501. /**
  107502. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107503. */
  107504. /**
  107505. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107506. */
  107507. colorCurves: Nullable<ColorCurves>;
  107508. /**
  107509. * Gets wether the color curves effect is enabled.
  107510. */
  107511. /**
  107512. * Sets wether the color curves effect is enabled.
  107513. */
  107514. colorCurvesEnabled: boolean;
  107515. /**
  107516. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107517. */
  107518. /**
  107519. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107520. */
  107521. colorGradingTexture: Nullable<BaseTexture>;
  107522. /**
  107523. * Gets wether the color grading effect is enabled.
  107524. */
  107525. /**
  107526. * Gets wether the color grading effect is enabled.
  107527. */
  107528. colorGradingEnabled: boolean;
  107529. /**
  107530. * Gets exposure used in the effect.
  107531. */
  107532. /**
  107533. * Sets exposure used in the effect.
  107534. */
  107535. exposure: number;
  107536. /**
  107537. * Gets wether tonemapping is enabled or not.
  107538. */
  107539. /**
  107540. * Sets wether tonemapping is enabled or not
  107541. */
  107542. toneMappingEnabled: boolean;
  107543. /**
  107544. * Gets the type of tone mapping effect.
  107545. */
  107546. /**
  107547. * Sets the type of tone mapping effect.
  107548. */
  107549. toneMappingType: number;
  107550. /**
  107551. * Gets contrast used in the effect.
  107552. */
  107553. /**
  107554. * Sets contrast used in the effect.
  107555. */
  107556. contrast: number;
  107557. /**
  107558. * Gets Vignette stretch size.
  107559. */
  107560. /**
  107561. * Sets Vignette stretch size.
  107562. */
  107563. vignetteStretch: number;
  107564. /**
  107565. * Gets Vignette centre X Offset.
  107566. */
  107567. /**
  107568. * Sets Vignette centre X Offset.
  107569. */
  107570. vignetteCentreX: number;
  107571. /**
  107572. * Gets Vignette centre Y Offset.
  107573. */
  107574. /**
  107575. * Sets Vignette centre Y Offset.
  107576. */
  107577. vignetteCentreY: number;
  107578. /**
  107579. * Gets Vignette weight or intensity of the vignette effect.
  107580. */
  107581. /**
  107582. * Sets Vignette weight or intensity of the vignette effect.
  107583. */
  107584. vignetteWeight: number;
  107585. /**
  107586. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107587. * if vignetteEnabled is set to true.
  107588. */
  107589. /**
  107590. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107591. * if vignetteEnabled is set to true.
  107592. */
  107593. vignetteColor: Color4;
  107594. /**
  107595. * Gets Camera field of view used by the Vignette effect.
  107596. */
  107597. /**
  107598. * Sets Camera field of view used by the Vignette effect.
  107599. */
  107600. vignetteCameraFov: number;
  107601. /**
  107602. * Gets the vignette blend mode allowing different kind of effect.
  107603. */
  107604. /**
  107605. * Sets the vignette blend mode allowing different kind of effect.
  107606. */
  107607. vignetteBlendMode: number;
  107608. /**
  107609. * Gets wether the vignette effect is enabled.
  107610. */
  107611. /**
  107612. * Sets wether the vignette effect is enabled.
  107613. */
  107614. vignetteEnabled: boolean;
  107615. private _fromLinearSpace;
  107616. /**
  107617. * Gets wether the input of the processing is in Gamma or Linear Space.
  107618. */
  107619. /**
  107620. * Sets wether the input of the processing is in Gamma or Linear Space.
  107621. */
  107622. fromLinearSpace: boolean;
  107623. /**
  107624. * Defines cache preventing GC.
  107625. */
  107626. private _defines;
  107627. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107628. /**
  107629. * "ImageProcessingPostProcess"
  107630. * @returns "ImageProcessingPostProcess"
  107631. */
  107632. getClassName(): string;
  107633. protected _updateParameters(): void;
  107634. dispose(camera?: Camera): void;
  107635. }
  107636. }
  107637. declare module BABYLON {
  107638. /**
  107639. * Class containing static functions to help procedurally build meshes
  107640. */
  107641. export class GroundBuilder {
  107642. /**
  107643. * Creates a ground mesh
  107644. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107645. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107647. * @param name defines the name of the mesh
  107648. * @param options defines the options used to create the mesh
  107649. * @param scene defines the hosting scene
  107650. * @returns the ground mesh
  107651. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107652. */
  107653. static CreateGround(name: string, options: {
  107654. width?: number;
  107655. height?: number;
  107656. subdivisions?: number;
  107657. subdivisionsX?: number;
  107658. subdivisionsY?: number;
  107659. updatable?: boolean;
  107660. }, scene: any): Mesh;
  107661. /**
  107662. * Creates a tiled ground mesh
  107663. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107664. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107665. * * 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
  107666. * * 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
  107667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107668. * @param name defines the name of the mesh
  107669. * @param options defines the options used to create the mesh
  107670. * @param scene defines the hosting scene
  107671. * @returns the tiled ground mesh
  107672. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107673. */
  107674. static CreateTiledGround(name: string, options: {
  107675. xmin: number;
  107676. zmin: number;
  107677. xmax: number;
  107678. zmax: number;
  107679. subdivisions?: {
  107680. w: number;
  107681. h: number;
  107682. };
  107683. precision?: {
  107684. w: number;
  107685. h: number;
  107686. };
  107687. updatable?: boolean;
  107688. }, scene?: Nullable<Scene>): Mesh;
  107689. /**
  107690. * Creates a ground mesh from a height map
  107691. * * The parameter `url` sets the URL of the height map image resource.
  107692. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107693. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107694. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107695. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107696. * * 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.
  107697. * * 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).
  107698. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107700. * @param name defines the name of the mesh
  107701. * @param url defines the url to the height map
  107702. * @param options defines the options used to create the mesh
  107703. * @param scene defines the hosting scene
  107704. * @returns the ground mesh
  107705. * @see https://doc.babylonjs.com/babylon101/height_map
  107706. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107707. */
  107708. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107709. width?: number;
  107710. height?: number;
  107711. subdivisions?: number;
  107712. minHeight?: number;
  107713. maxHeight?: number;
  107714. colorFilter?: Color3;
  107715. alphaFilter?: number;
  107716. updatable?: boolean;
  107717. onReady?: (mesh: GroundMesh) => void;
  107718. }, scene?: Nullable<Scene>): GroundMesh;
  107719. }
  107720. }
  107721. declare module BABYLON {
  107722. /**
  107723. * Class containing static functions to help procedurally build meshes
  107724. */
  107725. export class TorusBuilder {
  107726. /**
  107727. * Creates a torus mesh
  107728. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107729. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107730. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107734. * @param name defines the name of the mesh
  107735. * @param options defines the options used to create the mesh
  107736. * @param scene defines the hosting scene
  107737. * @returns the torus mesh
  107738. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107739. */
  107740. static CreateTorus(name: string, options: {
  107741. diameter?: number;
  107742. thickness?: number;
  107743. tessellation?: number;
  107744. updatable?: boolean;
  107745. sideOrientation?: number;
  107746. frontUVs?: Vector4;
  107747. backUVs?: Vector4;
  107748. }, scene: any): Mesh;
  107749. }
  107750. }
  107751. declare module BABYLON {
  107752. /**
  107753. * Class containing static functions to help procedurally build meshes
  107754. */
  107755. export class CylinderBuilder {
  107756. /**
  107757. * Creates a cylinder or a cone mesh
  107758. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107759. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107760. * * 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.
  107761. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107762. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107763. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107764. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107765. * * 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).
  107766. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107767. * * 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).
  107768. * * 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
  107769. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107770. * * 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
  107771. * * 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.
  107772. * * If `enclose` is false, a ring surface is one element.
  107773. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107774. * * 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
  107775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107778. * @param name defines the name of the mesh
  107779. * @param options defines the options used to create the mesh
  107780. * @param scene defines the hosting scene
  107781. * @returns the cylinder mesh
  107782. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107783. */
  107784. static CreateCylinder(name: string, options: {
  107785. height?: number;
  107786. diameterTop?: number;
  107787. diameterBottom?: number;
  107788. diameter?: number;
  107789. tessellation?: number;
  107790. subdivisions?: number;
  107791. arc?: number;
  107792. faceColors?: Color4[];
  107793. faceUV?: Vector4[];
  107794. updatable?: boolean;
  107795. hasRings?: boolean;
  107796. enclose?: boolean;
  107797. cap?: number;
  107798. sideOrientation?: number;
  107799. frontUVs?: Vector4;
  107800. backUVs?: Vector4;
  107801. }, scene: any): Mesh;
  107802. }
  107803. }
  107804. declare module BABYLON {
  107805. /**
  107806. * Options to modify the vr teleportation behavior.
  107807. */
  107808. export interface VRTeleportationOptions {
  107809. /**
  107810. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107811. */
  107812. floorMeshName?: string;
  107813. /**
  107814. * A list of meshes to be used as the teleportation floor. (default: empty)
  107815. */
  107816. floorMeshes?: Mesh[];
  107817. }
  107818. /**
  107819. * Options to modify the vr experience helper's behavior.
  107820. */
  107821. export interface VRExperienceHelperOptions extends WebVROptions {
  107822. /**
  107823. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107824. */
  107825. createDeviceOrientationCamera?: boolean;
  107826. /**
  107827. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107828. */
  107829. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107830. /**
  107831. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107832. */
  107833. laserToggle?: boolean;
  107834. /**
  107835. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107836. */
  107837. floorMeshes?: Mesh[];
  107838. /**
  107839. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107840. */
  107841. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107842. }
  107843. /**
  107844. * Event containing information after VR has been entered
  107845. */
  107846. export class OnAfterEnteringVRObservableEvent {
  107847. /**
  107848. * If entering vr was successful
  107849. */
  107850. success: boolean;
  107851. }
  107852. /**
  107853. * Helps to quickly add VR support to an existing scene.
  107854. * See http://doc.babylonjs.com/how_to/webvr_helper
  107855. */
  107856. export class VRExperienceHelper {
  107857. /** Options to modify the vr experience helper's behavior. */
  107858. webVROptions: VRExperienceHelperOptions;
  107859. private _scene;
  107860. private _position;
  107861. private _btnVR;
  107862. private _btnVRDisplayed;
  107863. private _webVRsupported;
  107864. private _webVRready;
  107865. private _webVRrequesting;
  107866. private _webVRpresenting;
  107867. private _hasEnteredVR;
  107868. private _fullscreenVRpresenting;
  107869. private _canvas;
  107870. private _webVRCamera;
  107871. private _vrDeviceOrientationCamera;
  107872. private _deviceOrientationCamera;
  107873. private _existingCamera;
  107874. private _onKeyDown;
  107875. private _onVrDisplayPresentChange;
  107876. private _onVRDisplayChanged;
  107877. private _onVRRequestPresentStart;
  107878. private _onVRRequestPresentComplete;
  107879. /**
  107880. * 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)
  107881. */
  107882. enableGazeEvenWhenNoPointerLock: boolean;
  107883. /**
  107884. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107885. */
  107886. exitVROnDoubleTap: boolean;
  107887. /**
  107888. * Observable raised right before entering VR.
  107889. */
  107890. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107891. /**
  107892. * Observable raised when entering VR has completed.
  107893. */
  107894. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107895. /**
  107896. * Observable raised when exiting VR.
  107897. */
  107898. onExitingVRObservable: Observable<VRExperienceHelper>;
  107899. /**
  107900. * Observable raised when controller mesh is loaded.
  107901. */
  107902. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107903. /** Return this.onEnteringVRObservable
  107904. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107905. */
  107906. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107907. /** Return this.onExitingVRObservable
  107908. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107909. */
  107910. readonly onExitingVR: Observable<VRExperienceHelper>;
  107911. /** Return this.onControllerMeshLoadedObservable
  107912. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107913. */
  107914. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107915. private _rayLength;
  107916. private _useCustomVRButton;
  107917. private _teleportationRequested;
  107918. private _teleportActive;
  107919. private _floorMeshName;
  107920. private _floorMeshesCollection;
  107921. private _rotationAllowed;
  107922. private _teleportBackwardsVector;
  107923. private _teleportationTarget;
  107924. private _isDefaultTeleportationTarget;
  107925. private _postProcessMove;
  107926. private _teleportationFillColor;
  107927. private _teleportationBorderColor;
  107928. private _rotationAngle;
  107929. private _haloCenter;
  107930. private _cameraGazer;
  107931. private _padSensibilityUp;
  107932. private _padSensibilityDown;
  107933. private _leftController;
  107934. private _rightController;
  107935. /**
  107936. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107937. */
  107938. onNewMeshSelected: Observable<AbstractMesh>;
  107939. /**
  107940. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107941. * This observable will provide the mesh and the controller used to select the mesh
  107942. */
  107943. onMeshSelectedWithController: Observable<{
  107944. mesh: AbstractMesh;
  107945. controller: WebVRController;
  107946. }>;
  107947. /**
  107948. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107949. */
  107950. onNewMeshPicked: Observable<PickingInfo>;
  107951. private _circleEase;
  107952. /**
  107953. * Observable raised before camera teleportation
  107954. */
  107955. onBeforeCameraTeleport: Observable<Vector3>;
  107956. /**
  107957. * Observable raised after camera teleportation
  107958. */
  107959. onAfterCameraTeleport: Observable<Vector3>;
  107960. /**
  107961. * Observable raised when current selected mesh gets unselected
  107962. */
  107963. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107964. private _raySelectionPredicate;
  107965. /**
  107966. * To be optionaly changed by user to define custom ray selection
  107967. */
  107968. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107969. /**
  107970. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107971. */
  107972. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107973. /**
  107974. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107975. */
  107976. teleportationEnabled: boolean;
  107977. private _defaultHeight;
  107978. private _teleportationInitialized;
  107979. private _interactionsEnabled;
  107980. private _interactionsRequested;
  107981. private _displayGaze;
  107982. private _displayLaserPointer;
  107983. /**
  107984. * The mesh used to display where the user is going to teleport.
  107985. */
  107986. /**
  107987. * Sets the mesh to be used to display where the user is going to teleport.
  107988. */
  107989. teleportationTarget: Mesh;
  107990. /**
  107991. * 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
  107992. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107993. * See http://doc.babylonjs.com/resources/baking_transformations
  107994. */
  107995. gazeTrackerMesh: Mesh;
  107996. /**
  107997. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107998. */
  107999. updateGazeTrackerScale: boolean;
  108000. /**
  108001. * If the gaze trackers color should be updated when selecting meshes
  108002. */
  108003. updateGazeTrackerColor: boolean;
  108004. /**
  108005. * If the controller laser color should be updated when selecting meshes
  108006. */
  108007. updateControllerLaserColor: boolean;
  108008. /**
  108009. * The gaze tracking mesh corresponding to the left controller
  108010. */
  108011. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108012. /**
  108013. * The gaze tracking mesh corresponding to the right controller
  108014. */
  108015. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108016. /**
  108017. * If the ray of the gaze should be displayed.
  108018. */
  108019. /**
  108020. * Sets if the ray of the gaze should be displayed.
  108021. */
  108022. displayGaze: boolean;
  108023. /**
  108024. * If the ray of the LaserPointer should be displayed.
  108025. */
  108026. /**
  108027. * Sets if the ray of the LaserPointer should be displayed.
  108028. */
  108029. displayLaserPointer: boolean;
  108030. /**
  108031. * The deviceOrientationCamera used as the camera when not in VR.
  108032. */
  108033. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108034. /**
  108035. * Based on the current WebVR support, returns the current VR camera used.
  108036. */
  108037. readonly currentVRCamera: Nullable<Camera>;
  108038. /**
  108039. * The webVRCamera which is used when in VR.
  108040. */
  108041. readonly webVRCamera: WebVRFreeCamera;
  108042. /**
  108043. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108044. */
  108045. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108046. /**
  108047. * The html button that is used to trigger entering into VR.
  108048. */
  108049. readonly vrButton: Nullable<HTMLButtonElement>;
  108050. private readonly _teleportationRequestInitiated;
  108051. /**
  108052. * Defines wether or not Pointer lock should be requested when switching to
  108053. * full screen.
  108054. */
  108055. requestPointerLockOnFullScreen: boolean;
  108056. /**
  108057. * Instantiates a VRExperienceHelper.
  108058. * Helps to quickly add VR support to an existing scene.
  108059. * @param scene The scene the VRExperienceHelper belongs to.
  108060. * @param webVROptions Options to modify the vr experience helper's behavior.
  108061. */
  108062. constructor(scene: Scene,
  108063. /** Options to modify the vr experience helper's behavior. */
  108064. webVROptions?: VRExperienceHelperOptions);
  108065. private _onDefaultMeshLoaded;
  108066. private _onResize;
  108067. private _onFullscreenChange;
  108068. /**
  108069. * Gets a value indicating if we are currently in VR mode.
  108070. */
  108071. readonly isInVRMode: boolean;
  108072. private onVrDisplayPresentChange;
  108073. private onVRDisplayChanged;
  108074. private moveButtonToBottomRight;
  108075. private displayVRButton;
  108076. private updateButtonVisibility;
  108077. private _cachedAngularSensibility;
  108078. /**
  108079. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108080. * Otherwise, will use the fullscreen API.
  108081. */
  108082. enterVR(): void;
  108083. /**
  108084. * Attempt to exit VR, or fullscreen.
  108085. */
  108086. exitVR(): void;
  108087. /**
  108088. * The position of the vr experience helper.
  108089. */
  108090. /**
  108091. * Sets the position of the vr experience helper.
  108092. */
  108093. position: Vector3;
  108094. /**
  108095. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108096. */
  108097. enableInteractions(): void;
  108098. private readonly _noControllerIsActive;
  108099. private beforeRender;
  108100. private _isTeleportationFloor;
  108101. /**
  108102. * Adds a floor mesh to be used for teleportation.
  108103. * @param floorMesh the mesh to be used for teleportation.
  108104. */
  108105. addFloorMesh(floorMesh: Mesh): void;
  108106. /**
  108107. * Removes a floor mesh from being used for teleportation.
  108108. * @param floorMesh the mesh to be removed.
  108109. */
  108110. removeFloorMesh(floorMesh: Mesh): void;
  108111. /**
  108112. * Enables interactions and teleportation using the VR controllers and gaze.
  108113. * @param vrTeleportationOptions options to modify teleportation behavior.
  108114. */
  108115. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108116. private _onNewGamepadConnected;
  108117. private _tryEnableInteractionOnController;
  108118. private _onNewGamepadDisconnected;
  108119. private _enableInteractionOnController;
  108120. private _checkTeleportWithRay;
  108121. private _checkRotate;
  108122. private _checkTeleportBackwards;
  108123. private _enableTeleportationOnController;
  108124. private _createTeleportationCircles;
  108125. private _displayTeleportationTarget;
  108126. private _hideTeleportationTarget;
  108127. private _rotateCamera;
  108128. private _moveTeleportationSelectorTo;
  108129. private _workingVector;
  108130. private _workingQuaternion;
  108131. private _workingMatrix;
  108132. /**
  108133. * Teleports the users feet to the desired location
  108134. * @param location The location where the user's feet should be placed
  108135. */
  108136. teleportCamera(location: Vector3): void;
  108137. private _convertNormalToDirectionOfRay;
  108138. private _castRayAndSelectObject;
  108139. private _notifySelectedMeshUnselected;
  108140. /**
  108141. * Sets the color of the laser ray from the vr controllers.
  108142. * @param color new color for the ray.
  108143. */
  108144. changeLaserColor(color: Color3): void;
  108145. /**
  108146. * Sets the color of the ray from the vr headsets gaze.
  108147. * @param color new color for the ray.
  108148. */
  108149. changeGazeColor(color: Color3): void;
  108150. /**
  108151. * Exits VR and disposes of the vr experience helper
  108152. */
  108153. dispose(): void;
  108154. /**
  108155. * Gets the name of the VRExperienceHelper class
  108156. * @returns "VRExperienceHelper"
  108157. */
  108158. getClassName(): string;
  108159. }
  108160. }
  108161. declare module BABYLON {
  108162. /**
  108163. * Manages an XRSession to work with Babylon's engine
  108164. * @see https://doc.babylonjs.com/how_to/webxr
  108165. */
  108166. export class WebXRSessionManager implements IDisposable {
  108167. private scene;
  108168. /**
  108169. * Fires every time a new xrFrame arrives which can be used to update the camera
  108170. */
  108171. onXRFrameObservable: Observable<any>;
  108172. /**
  108173. * Fires when the xr session is ended either by the device or manually done
  108174. */
  108175. onXRSessionEnded: Observable<any>;
  108176. /**
  108177. * Underlying xr session
  108178. */
  108179. session: XRSession;
  108180. /**
  108181. * Type of reference space used when creating the session
  108182. */
  108183. referenceSpace: XRReferenceSpace;
  108184. /** @hidden */
  108185. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108186. /**
  108187. * Current XR frame
  108188. */
  108189. currentFrame: Nullable<XRFrame>;
  108190. private _xrNavigator;
  108191. private baseLayer;
  108192. /**
  108193. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108194. * @param scene The scene which the session should be created for
  108195. */
  108196. constructor(scene: Scene);
  108197. /**
  108198. * Initializes the manager
  108199. * After initialization enterXR can be called to start an XR session
  108200. * @returns Promise which resolves after it is initialized
  108201. */
  108202. initializeAsync(): Promise<void>;
  108203. /**
  108204. * Initializes an xr session
  108205. * @param xrSessionMode mode to initialize
  108206. * @returns a promise which will resolve once the session has been initialized
  108207. */
  108208. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108209. /**
  108210. * Sets the reference space on the xr session
  108211. * @param referenceSpace space to set
  108212. * @returns a promise that will resolve once the reference space has been set
  108213. */
  108214. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108215. /**
  108216. * Updates the render state of the session
  108217. * @param state state to set
  108218. * @returns a promise that resolves once the render state has been updated
  108219. */
  108220. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108221. /**
  108222. * Starts rendering to the xr layer
  108223. * @returns a promise that will resolve once rendering has started
  108224. */
  108225. startRenderingToXRAsync(): Promise<void>;
  108226. /**
  108227. * Stops the xrSession and restores the renderloop
  108228. * @returns Promise which resolves after it exits XR
  108229. */
  108230. exitXRAsync(): Promise<unknown>;
  108231. /**
  108232. * Checks if a session would be supported for the creation options specified
  108233. * @param sessionMode session mode to check if supported eg. immersive-vr
  108234. * @returns true if supported
  108235. */
  108236. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108237. /**
  108238. * @hidden
  108239. * Converts the render layer of xrSession to a render target
  108240. * @param session session to create render target for
  108241. * @param scene scene the new render target should be created for
  108242. */
  108243. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108244. /**
  108245. * Disposes of the session manager
  108246. */
  108247. dispose(): void;
  108248. }
  108249. }
  108250. declare module BABYLON {
  108251. /**
  108252. * WebXR Camera which holds the views for the xrSession
  108253. * @see https://doc.babylonjs.com/how_to/webxr
  108254. */
  108255. export class WebXRCamera extends FreeCamera {
  108256. private static _TmpMatrix;
  108257. /**
  108258. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108259. * @param name the name of the camera
  108260. * @param scene the scene to add the camera to
  108261. */
  108262. constructor(name: string, scene: Scene);
  108263. private _updateNumberOfRigCameras;
  108264. /** @hidden */
  108265. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108266. /**
  108267. * Updates the cameras position from the current pose information of the XR session
  108268. * @param xrSessionManager the session containing pose information
  108269. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108270. */
  108271. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108272. }
  108273. }
  108274. declare module BABYLON {
  108275. /**
  108276. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108277. */
  108278. export class WebXRManagedOutputCanvas implements IDisposable {
  108279. private helper;
  108280. private _canvas;
  108281. /**
  108282. * xrpresent context of the canvas which can be used to display/mirror xr content
  108283. */
  108284. canvasContext: WebGLRenderingContext;
  108285. /**
  108286. * xr layer for the canvas
  108287. */
  108288. xrLayer: Nullable<XRWebGLLayer>;
  108289. /**
  108290. * Initializes the xr layer for the session
  108291. * @param xrSession xr session
  108292. * @returns a promise that will resolve once the XR Layer has been created
  108293. */
  108294. initializeXRLayerAsync(xrSession: any): any;
  108295. /**
  108296. * Initializes the canvas to be added/removed upon entering/exiting xr
  108297. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108298. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108299. */
  108300. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108301. /**
  108302. * Disposes of the object
  108303. */
  108304. dispose(): void;
  108305. private _setManagedOutputCanvas;
  108306. private _addCanvas;
  108307. private _removeCanvas;
  108308. }
  108309. }
  108310. declare module BABYLON {
  108311. /**
  108312. * States of the webXR experience
  108313. */
  108314. export enum WebXRState {
  108315. /**
  108316. * Transitioning to being in XR mode
  108317. */
  108318. ENTERING_XR = 0,
  108319. /**
  108320. * Transitioning to non XR mode
  108321. */
  108322. EXITING_XR = 1,
  108323. /**
  108324. * In XR mode and presenting
  108325. */
  108326. IN_XR = 2,
  108327. /**
  108328. * Not entered XR mode
  108329. */
  108330. NOT_IN_XR = 3
  108331. }
  108332. /**
  108333. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108334. * @see https://doc.babylonjs.com/how_to/webxr
  108335. */
  108336. export class WebXRExperienceHelper implements IDisposable {
  108337. private scene;
  108338. /**
  108339. * 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
  108340. */
  108341. container: AbstractMesh;
  108342. /**
  108343. * Camera used to render xr content
  108344. */
  108345. camera: WebXRCamera;
  108346. /**
  108347. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108348. */
  108349. state: WebXRState;
  108350. private _setState;
  108351. private static _TmpVector;
  108352. /**
  108353. * Fires when the state of the experience helper has changed
  108354. */
  108355. onStateChangedObservable: Observable<WebXRState>;
  108356. /** Session manager used to keep track of xr session */
  108357. sessionManager: WebXRSessionManager;
  108358. private _nonVRCamera;
  108359. private _originalSceneAutoClear;
  108360. private _supported;
  108361. /**
  108362. * Creates the experience helper
  108363. * @param scene the scene to attach the experience helper to
  108364. * @returns a promise for the experience helper
  108365. */
  108366. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108367. /**
  108368. * Creates a WebXRExperienceHelper
  108369. * @param scene The scene the helper should be created in
  108370. */
  108371. private constructor();
  108372. /**
  108373. * Exits XR mode and returns the scene to its original state
  108374. * @returns promise that resolves after xr mode has exited
  108375. */
  108376. exitXRAsync(): Promise<unknown>;
  108377. /**
  108378. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108379. * @param sessionCreationOptions options for the XR session
  108380. * @param referenceSpaceType frame of reference of the XR session
  108381. * @param outputCanvas the output canvas that will be used to enter XR mode
  108382. * @returns promise that resolves after xr mode has entered
  108383. */
  108384. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108385. /**
  108386. * Updates the global position of the camera by moving the camera's container
  108387. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108388. * @param position The desired global position of the camera
  108389. */
  108390. setPositionOfCameraUsingContainer(position: Vector3): void;
  108391. /**
  108392. * Rotates the xr camera by rotating the camera's container around the camera's position
  108393. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108394. * @param rotation the desired quaternion rotation to apply to the camera
  108395. */
  108396. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108397. /**
  108398. * Disposes of the experience helper
  108399. */
  108400. dispose(): void;
  108401. }
  108402. }
  108403. declare module BABYLON {
  108404. /**
  108405. * Button which can be used to enter a different mode of XR
  108406. */
  108407. export class WebXREnterExitUIButton {
  108408. /** button element */
  108409. element: HTMLElement;
  108410. /** XR initialization options for the button */
  108411. sessionMode: XRSessionMode;
  108412. /** Reference space type */
  108413. referenceSpaceType: XRReferenceSpaceType;
  108414. /**
  108415. * Creates a WebXREnterExitUIButton
  108416. * @param element button element
  108417. * @param sessionMode XR initialization session mode
  108418. * @param referenceSpaceType the type of reference space to be used
  108419. */
  108420. constructor(
  108421. /** button element */
  108422. element: HTMLElement,
  108423. /** XR initialization options for the button */
  108424. sessionMode: XRSessionMode,
  108425. /** Reference space type */
  108426. referenceSpaceType: XRReferenceSpaceType);
  108427. /**
  108428. * Overwritable function which can be used to update the button's visuals when the state changes
  108429. * @param activeButton the current active button in the UI
  108430. */
  108431. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108432. }
  108433. /**
  108434. * Options to create the webXR UI
  108435. */
  108436. export class WebXREnterExitUIOptions {
  108437. /**
  108438. * Context to enter xr with
  108439. */
  108440. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108441. /**
  108442. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108443. */
  108444. customButtons?: Array<WebXREnterExitUIButton>;
  108445. }
  108446. /**
  108447. * UI to allow the user to enter/exit XR mode
  108448. */
  108449. export class WebXREnterExitUI implements IDisposable {
  108450. private scene;
  108451. private _overlay;
  108452. private _buttons;
  108453. private _activeButton;
  108454. /**
  108455. * Fired every time the active button is changed.
  108456. *
  108457. * When xr is entered via a button that launches xr that button will be the callback parameter
  108458. *
  108459. * When exiting xr the callback parameter will be null)
  108460. */
  108461. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108462. /**
  108463. * Creates UI to allow the user to enter/exit XR mode
  108464. * @param scene the scene to add the ui to
  108465. * @param helper the xr experience helper to enter/exit xr with
  108466. * @param options options to configure the UI
  108467. * @returns the created ui
  108468. */
  108469. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108470. private constructor();
  108471. private _updateButtons;
  108472. /**
  108473. * Disposes of the object
  108474. */
  108475. dispose(): void;
  108476. }
  108477. }
  108478. declare module BABYLON {
  108479. /**
  108480. * Represents an XR input
  108481. */
  108482. export class WebXRController {
  108483. private scene;
  108484. /** The underlying input source for the controller */
  108485. inputSource: XRInputSource;
  108486. private parentContainer;
  108487. /**
  108488. * 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
  108489. */
  108490. grip?: AbstractMesh;
  108491. /**
  108492. * Pointer which can be used to select objects or attach a visible laser to
  108493. */
  108494. pointer: AbstractMesh;
  108495. /**
  108496. * Event that fires when the controller is removed/disposed
  108497. */
  108498. onDisposeObservable: Observable<{}>;
  108499. private _tmpMatrix;
  108500. private _tmpQuaternion;
  108501. private _tmpVector;
  108502. /**
  108503. * Creates the controller
  108504. * @see https://doc.babylonjs.com/how_to/webxr
  108505. * @param scene the scene which the controller should be associated to
  108506. * @param inputSource the underlying input source for the controller
  108507. * @param parentContainer parent that the controller meshes should be children of
  108508. */
  108509. constructor(scene: Scene,
  108510. /** The underlying input source for the controller */
  108511. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108512. /**
  108513. * Updates the controller pose based on the given XRFrame
  108514. * @param xrFrame xr frame to update the pose with
  108515. * @param referenceSpace reference space to use
  108516. */
  108517. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108518. /**
  108519. * Gets a world space ray coming from the controller
  108520. * @param result the resulting ray
  108521. */
  108522. getWorldPointerRayToRef(result: Ray): void;
  108523. /**
  108524. * Disposes of the object
  108525. */
  108526. dispose(): void;
  108527. }
  108528. }
  108529. declare module BABYLON {
  108530. /**
  108531. * XR input used to track XR inputs such as controllers/rays
  108532. */
  108533. export class WebXRInput implements IDisposable {
  108534. /**
  108535. * Base experience the input listens to
  108536. */
  108537. baseExperience: WebXRExperienceHelper;
  108538. /**
  108539. * XR controllers being tracked
  108540. */
  108541. controllers: Array<WebXRController>;
  108542. private _frameObserver;
  108543. private _stateObserver;
  108544. /**
  108545. * Event when a controller has been connected/added
  108546. */
  108547. onControllerAddedObservable: Observable<WebXRController>;
  108548. /**
  108549. * Event when a controller has been removed/disconnected
  108550. */
  108551. onControllerRemovedObservable: Observable<WebXRController>;
  108552. /**
  108553. * Initializes the WebXRInput
  108554. * @param baseExperience experience helper which the input should be created for
  108555. */
  108556. constructor(
  108557. /**
  108558. * Base experience the input listens to
  108559. */
  108560. baseExperience: WebXRExperienceHelper);
  108561. private _onInputSourcesChange;
  108562. private _addAndRemoveControllers;
  108563. /**
  108564. * Disposes of the object
  108565. */
  108566. dispose(): void;
  108567. }
  108568. }
  108569. declare module BABYLON {
  108570. /**
  108571. * Enables teleportation
  108572. */
  108573. export class WebXRControllerTeleportation {
  108574. private _teleportationFillColor;
  108575. private _teleportationBorderColor;
  108576. private _tmpRay;
  108577. private _tmpVector;
  108578. /**
  108579. * Creates a WebXRControllerTeleportation
  108580. * @param input input manager to add teleportation to
  108581. * @param floorMeshes floormeshes which can be teleported to
  108582. */
  108583. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108584. }
  108585. }
  108586. declare module BABYLON {
  108587. /**
  108588. * Handles pointer input automatically for the pointer of XR controllers
  108589. */
  108590. export class WebXRControllerPointerSelection {
  108591. private static _idCounter;
  108592. private _tmpRay;
  108593. /**
  108594. * Creates a WebXRControllerPointerSelection
  108595. * @param input input manager to setup pointer selection
  108596. */
  108597. constructor(input: WebXRInput);
  108598. private _convertNormalToDirectionOfRay;
  108599. private _updatePointerDistance;
  108600. }
  108601. }
  108602. declare module BABYLON {
  108603. /**
  108604. * Class used to represent data loading progression
  108605. */
  108606. export class SceneLoaderProgressEvent {
  108607. /** defines if data length to load can be evaluated */
  108608. readonly lengthComputable: boolean;
  108609. /** defines the loaded data length */
  108610. readonly loaded: number;
  108611. /** defines the data length to load */
  108612. readonly total: number;
  108613. /**
  108614. * Create a new progress event
  108615. * @param lengthComputable defines if data length to load can be evaluated
  108616. * @param loaded defines the loaded data length
  108617. * @param total defines the data length to load
  108618. */
  108619. constructor(
  108620. /** defines if data length to load can be evaluated */
  108621. lengthComputable: boolean,
  108622. /** defines the loaded data length */
  108623. loaded: number,
  108624. /** defines the data length to load */
  108625. total: number);
  108626. /**
  108627. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108628. * @param event defines the source event
  108629. * @returns a new SceneLoaderProgressEvent
  108630. */
  108631. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108632. }
  108633. /**
  108634. * Interface used by SceneLoader plugins to define supported file extensions
  108635. */
  108636. export interface ISceneLoaderPluginExtensions {
  108637. /**
  108638. * Defines the list of supported extensions
  108639. */
  108640. [extension: string]: {
  108641. isBinary: boolean;
  108642. };
  108643. }
  108644. /**
  108645. * Interface used by SceneLoader plugin factory
  108646. */
  108647. export interface ISceneLoaderPluginFactory {
  108648. /**
  108649. * Defines the name of the factory
  108650. */
  108651. name: string;
  108652. /**
  108653. * Function called to create a new plugin
  108654. * @return the new plugin
  108655. */
  108656. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108657. /**
  108658. * Boolean indicating if the plugin can direct load specific data
  108659. */
  108660. canDirectLoad?: (data: string) => boolean;
  108661. }
  108662. /**
  108663. * Interface used to define a SceneLoader plugin
  108664. */
  108665. export interface ISceneLoaderPlugin {
  108666. /**
  108667. * The friendly name of this plugin.
  108668. */
  108669. name: string;
  108670. /**
  108671. * The file extensions supported by this plugin.
  108672. */
  108673. extensions: string | ISceneLoaderPluginExtensions;
  108674. /**
  108675. * Import meshes into a scene.
  108676. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108677. * @param scene The scene to import into
  108678. * @param data The data to import
  108679. * @param rootUrl The root url for scene and resources
  108680. * @param meshes The meshes array to import into
  108681. * @param particleSystems The particle systems array to import into
  108682. * @param skeletons The skeletons array to import into
  108683. * @param onError The callback when import fails
  108684. * @returns True if successful or false otherwise
  108685. */
  108686. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108687. /**
  108688. * Load into a scene.
  108689. * @param scene The scene to load into
  108690. * @param data The data to import
  108691. * @param rootUrl The root url for scene and resources
  108692. * @param onError The callback when import fails
  108693. * @returns true if successful or false otherwise
  108694. */
  108695. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108696. /**
  108697. * The callback that returns true if the data can be directly loaded.
  108698. */
  108699. canDirectLoad?: (data: string) => boolean;
  108700. /**
  108701. * The callback that allows custom handling of the root url based on the response url.
  108702. */
  108703. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108704. /**
  108705. * Load into an asset container.
  108706. * @param scene The scene to load into
  108707. * @param data The data to import
  108708. * @param rootUrl The root url for scene and resources
  108709. * @param onError The callback when import fails
  108710. * @returns The loaded asset container
  108711. */
  108712. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108713. }
  108714. /**
  108715. * Interface used to define an async SceneLoader plugin
  108716. */
  108717. export interface ISceneLoaderPluginAsync {
  108718. /**
  108719. * The friendly name of this plugin.
  108720. */
  108721. name: string;
  108722. /**
  108723. * The file extensions supported by this plugin.
  108724. */
  108725. extensions: string | ISceneLoaderPluginExtensions;
  108726. /**
  108727. * Import meshes into a scene.
  108728. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108729. * @param scene The scene to import into
  108730. * @param data The data to import
  108731. * @param rootUrl The root url for scene and resources
  108732. * @param onProgress The callback when the load progresses
  108733. * @param fileName Defines the name of the file to load
  108734. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108735. */
  108736. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108737. meshes: AbstractMesh[];
  108738. particleSystems: IParticleSystem[];
  108739. skeletons: Skeleton[];
  108740. animationGroups: AnimationGroup[];
  108741. }>;
  108742. /**
  108743. * Load into a scene.
  108744. * @param scene The scene to load into
  108745. * @param data The data to import
  108746. * @param rootUrl The root url for scene and resources
  108747. * @param onProgress The callback when the load progresses
  108748. * @param fileName Defines the name of the file to load
  108749. * @returns Nothing
  108750. */
  108751. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108752. /**
  108753. * The callback that returns true if the data can be directly loaded.
  108754. */
  108755. canDirectLoad?: (data: string) => boolean;
  108756. /**
  108757. * The callback that allows custom handling of the root url based on the response url.
  108758. */
  108759. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108760. /**
  108761. * Load into an asset container.
  108762. * @param scene The scene to load into
  108763. * @param data The data to import
  108764. * @param rootUrl The root url for scene and resources
  108765. * @param onProgress The callback when the load progresses
  108766. * @param fileName Defines the name of the file to load
  108767. * @returns The loaded asset container
  108768. */
  108769. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108770. }
  108771. /**
  108772. * Class used to load scene from various file formats using registered plugins
  108773. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108774. */
  108775. export class SceneLoader {
  108776. /**
  108777. * No logging while loading
  108778. */
  108779. static readonly NO_LOGGING: number;
  108780. /**
  108781. * Minimal logging while loading
  108782. */
  108783. static readonly MINIMAL_LOGGING: number;
  108784. /**
  108785. * Summary logging while loading
  108786. */
  108787. static readonly SUMMARY_LOGGING: number;
  108788. /**
  108789. * Detailled logging while loading
  108790. */
  108791. static readonly DETAILED_LOGGING: number;
  108792. /**
  108793. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108794. */
  108795. static ForceFullSceneLoadingForIncremental: boolean;
  108796. /**
  108797. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108798. */
  108799. static ShowLoadingScreen: boolean;
  108800. /**
  108801. * Defines the current logging level (while loading the scene)
  108802. * @ignorenaming
  108803. */
  108804. static loggingLevel: number;
  108805. /**
  108806. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108807. */
  108808. static CleanBoneMatrixWeights: boolean;
  108809. /**
  108810. * Event raised when a plugin is used to load a scene
  108811. */
  108812. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108813. private static _registeredPlugins;
  108814. private static _getDefaultPlugin;
  108815. private static _getPluginForExtension;
  108816. private static _getPluginForDirectLoad;
  108817. private static _getPluginForFilename;
  108818. private static _getDirectLoad;
  108819. private static _loadData;
  108820. private static _getFileInfo;
  108821. /**
  108822. * Gets a plugin that can load the given extension
  108823. * @param extension defines the extension to load
  108824. * @returns a plugin or null if none works
  108825. */
  108826. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108827. /**
  108828. * Gets a boolean indicating that the given extension can be loaded
  108829. * @param extension defines the extension to load
  108830. * @returns true if the extension is supported
  108831. */
  108832. static IsPluginForExtensionAvailable(extension: string): boolean;
  108833. /**
  108834. * Adds a new plugin to the list of registered plugins
  108835. * @param plugin defines the plugin to add
  108836. */
  108837. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108838. /**
  108839. * Import meshes into a scene
  108840. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108841. * @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)
  108842. * @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)
  108843. * @param scene the instance of BABYLON.Scene to append to
  108844. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108845. * @param onProgress a callback with a progress event for each file being loaded
  108846. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108847. * @param pluginExtension the extension used to determine the plugin
  108848. * @returns The loaded plugin
  108849. */
  108850. 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>;
  108851. /**
  108852. * Import meshes into a scene
  108853. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108854. * @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)
  108855. * @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)
  108856. * @param scene the instance of BABYLON.Scene to append to
  108857. * @param onProgress a callback with a progress event for each file being loaded
  108858. * @param pluginExtension the extension used to determine the plugin
  108859. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108860. */
  108861. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108862. meshes: AbstractMesh[];
  108863. particleSystems: IParticleSystem[];
  108864. skeletons: Skeleton[];
  108865. animationGroups: AnimationGroup[];
  108866. }>;
  108867. /**
  108868. * Load a scene
  108869. * @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)
  108870. * @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)
  108871. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108872. * @param onSuccess a callback with the scene when import succeeds
  108873. * @param onProgress a callback with a progress event for each file being loaded
  108874. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108875. * @param pluginExtension the extension used to determine the plugin
  108876. * @returns The loaded plugin
  108877. */
  108878. 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>;
  108879. /**
  108880. * Load a scene
  108881. * @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)
  108882. * @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)
  108883. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108884. * @param onProgress a callback with a progress event for each file being loaded
  108885. * @param pluginExtension the extension used to determine the plugin
  108886. * @returns The loaded scene
  108887. */
  108888. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108889. /**
  108890. * Append a scene
  108891. * @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)
  108892. * @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)
  108893. * @param scene is the instance of BABYLON.Scene to append to
  108894. * @param onSuccess a callback with the scene when import succeeds
  108895. * @param onProgress a callback with a progress event for each file being loaded
  108896. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108897. * @param pluginExtension the extension used to determine the plugin
  108898. * @returns The loaded plugin
  108899. */
  108900. 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>;
  108901. /**
  108902. * Append a scene
  108903. * @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)
  108904. * @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)
  108905. * @param scene is the instance of BABYLON.Scene to append to
  108906. * @param onProgress a callback with a progress event for each file being loaded
  108907. * @param pluginExtension the extension used to determine the plugin
  108908. * @returns The given scene
  108909. */
  108910. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108911. /**
  108912. * Load a scene into an asset container
  108913. * @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)
  108914. * @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)
  108915. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108916. * @param onSuccess a callback with the scene when import succeeds
  108917. * @param onProgress a callback with a progress event for each file being loaded
  108918. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108919. * @param pluginExtension the extension used to determine the plugin
  108920. * @returns The loaded plugin
  108921. */
  108922. 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>;
  108923. /**
  108924. * Load a scene into an asset container
  108925. * @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)
  108926. * @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)
  108927. * @param scene is the instance of Scene to append to
  108928. * @param onProgress a callback with a progress event for each file being loaded
  108929. * @param pluginExtension the extension used to determine the plugin
  108930. * @returns The loaded asset container
  108931. */
  108932. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108933. }
  108934. }
  108935. declare module BABYLON {
  108936. /**
  108937. * Generic Controller
  108938. */
  108939. export class GenericController extends WebVRController {
  108940. /**
  108941. * Base Url for the controller model.
  108942. */
  108943. static readonly MODEL_BASE_URL: string;
  108944. /**
  108945. * File name for the controller model.
  108946. */
  108947. static readonly MODEL_FILENAME: string;
  108948. /**
  108949. * Creates a new GenericController from a gamepad
  108950. * @param vrGamepad the gamepad that the controller should be created from
  108951. */
  108952. constructor(vrGamepad: any);
  108953. /**
  108954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108955. * @param scene scene in which to add meshes
  108956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108957. */
  108958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108959. /**
  108960. * Called once for each button that changed state since the last frame
  108961. * @param buttonIdx Which button index changed
  108962. * @param state New state of the button
  108963. * @param changes Which properties on the state changed since last frame
  108964. */
  108965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108966. }
  108967. }
  108968. declare module BABYLON {
  108969. /**
  108970. * Defines the WindowsMotionController object that the state of the windows motion controller
  108971. */
  108972. export class WindowsMotionController extends WebVRController {
  108973. /**
  108974. * The base url used to load the left and right controller models
  108975. */
  108976. static MODEL_BASE_URL: string;
  108977. /**
  108978. * The name of the left controller model file
  108979. */
  108980. static MODEL_LEFT_FILENAME: string;
  108981. /**
  108982. * The name of the right controller model file
  108983. */
  108984. static MODEL_RIGHT_FILENAME: string;
  108985. /**
  108986. * The controller name prefix for this controller type
  108987. */
  108988. static readonly GAMEPAD_ID_PREFIX: string;
  108989. /**
  108990. * The controller id pattern for this controller type
  108991. */
  108992. private static readonly GAMEPAD_ID_PATTERN;
  108993. private _loadedMeshInfo;
  108994. private readonly _mapping;
  108995. /**
  108996. * Fired when the trackpad on this controller is clicked
  108997. */
  108998. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108999. /**
  109000. * Fired when the trackpad on this controller is modified
  109001. */
  109002. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109003. /**
  109004. * The current x and y values of this controller's trackpad
  109005. */
  109006. trackpad: StickValues;
  109007. /**
  109008. * Creates a new WindowsMotionController from a gamepad
  109009. * @param vrGamepad the gamepad that the controller should be created from
  109010. */
  109011. constructor(vrGamepad: any);
  109012. /**
  109013. * Fired when the trigger on this controller is modified
  109014. */
  109015. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109016. /**
  109017. * Fired when the menu button on this controller is modified
  109018. */
  109019. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109020. /**
  109021. * Fired when the grip button on this controller is modified
  109022. */
  109023. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109024. /**
  109025. * Fired when the thumbstick button on this controller is modified
  109026. */
  109027. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109028. /**
  109029. * Fired when the touchpad button on this controller is modified
  109030. */
  109031. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109032. /**
  109033. * Fired when the touchpad values on this controller are modified
  109034. */
  109035. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109036. private _updateTrackpad;
  109037. /**
  109038. * Called once per frame by the engine.
  109039. */
  109040. update(): void;
  109041. /**
  109042. * Called once for each button that changed state since the last frame
  109043. * @param buttonIdx Which button index changed
  109044. * @param state New state of the button
  109045. * @param changes Which properties on the state changed since last frame
  109046. */
  109047. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109048. /**
  109049. * Moves the buttons on the controller mesh based on their current state
  109050. * @param buttonName the name of the button to move
  109051. * @param buttonValue the value of the button which determines the buttons new position
  109052. */
  109053. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109054. /**
  109055. * Moves the axis on the controller mesh based on its current state
  109056. * @param axis the index of the axis
  109057. * @param axisValue the value of the axis which determines the meshes new position
  109058. * @hidden
  109059. */
  109060. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109061. /**
  109062. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109063. * @param scene scene in which to add meshes
  109064. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109065. */
  109066. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109067. /**
  109068. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109069. * can be transformed by button presses and axes values, based on this._mapping.
  109070. *
  109071. * @param scene scene in which the meshes exist
  109072. * @param meshes list of meshes that make up the controller model to process
  109073. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109074. */
  109075. private processModel;
  109076. private createMeshInfo;
  109077. /**
  109078. * Gets the ray of the controller in the direction the controller is pointing
  109079. * @param length the length the resulting ray should be
  109080. * @returns a ray in the direction the controller is pointing
  109081. */
  109082. getForwardRay(length?: number): Ray;
  109083. /**
  109084. * Disposes of the controller
  109085. */
  109086. dispose(): void;
  109087. }
  109088. }
  109089. declare module BABYLON {
  109090. /**
  109091. * Oculus Touch Controller
  109092. */
  109093. export class OculusTouchController extends WebVRController {
  109094. /**
  109095. * Base Url for the controller model.
  109096. */
  109097. static MODEL_BASE_URL: string;
  109098. /**
  109099. * File name for the left controller model.
  109100. */
  109101. static MODEL_LEFT_FILENAME: string;
  109102. /**
  109103. * File name for the right controller model.
  109104. */
  109105. static MODEL_RIGHT_FILENAME: string;
  109106. /**
  109107. * Base Url for the Quest controller model.
  109108. */
  109109. static QUEST_MODEL_BASE_URL: string;
  109110. /**
  109111. * @hidden
  109112. * If the controllers are running on a device that needs the updated Quest controller models
  109113. */
  109114. static _IsQuest: boolean;
  109115. /**
  109116. * Fired when the secondary trigger on this controller is modified
  109117. */
  109118. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109119. /**
  109120. * Fired when the thumb rest on this controller is modified
  109121. */
  109122. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109123. /**
  109124. * Creates a new OculusTouchController from a gamepad
  109125. * @param vrGamepad the gamepad that the controller should be created from
  109126. */
  109127. constructor(vrGamepad: any);
  109128. /**
  109129. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109130. * @param scene scene in which to add meshes
  109131. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109132. */
  109133. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109134. /**
  109135. * Fired when the A button on this controller is modified
  109136. */
  109137. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109138. /**
  109139. * Fired when the B button on this controller is modified
  109140. */
  109141. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109142. /**
  109143. * Fired when the X button on this controller is modified
  109144. */
  109145. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109146. /**
  109147. * Fired when the Y button on this controller is modified
  109148. */
  109149. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109150. /**
  109151. * Called once for each button that changed state since the last frame
  109152. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109153. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109154. * 2) secondary trigger (same)
  109155. * 3) A (right) X (left), touch, pressed = value
  109156. * 4) B / Y
  109157. * 5) thumb rest
  109158. * @param buttonIdx Which button index changed
  109159. * @param state New state of the button
  109160. * @param changes Which properties on the state changed since last frame
  109161. */
  109162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109163. }
  109164. }
  109165. declare module BABYLON {
  109166. /**
  109167. * Vive Controller
  109168. */
  109169. export class ViveController extends WebVRController {
  109170. /**
  109171. * Base Url for the controller model.
  109172. */
  109173. static MODEL_BASE_URL: string;
  109174. /**
  109175. * File name for the controller model.
  109176. */
  109177. static MODEL_FILENAME: string;
  109178. /**
  109179. * Creates a new ViveController from a gamepad
  109180. * @param vrGamepad the gamepad that the controller should be created from
  109181. */
  109182. constructor(vrGamepad: any);
  109183. /**
  109184. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109185. * @param scene scene in which to add meshes
  109186. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109187. */
  109188. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109189. /**
  109190. * Fired when the left button on this controller is modified
  109191. */
  109192. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109193. /**
  109194. * Fired when the right button on this controller is modified
  109195. */
  109196. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109197. /**
  109198. * Fired when the menu button on this controller is modified
  109199. */
  109200. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109201. /**
  109202. * Called once for each button that changed state since the last frame
  109203. * Vive mapping:
  109204. * 0: touchpad
  109205. * 1: trigger
  109206. * 2: left AND right buttons
  109207. * 3: menu button
  109208. * @param buttonIdx Which button index changed
  109209. * @param state New state of the button
  109210. * @param changes Which properties on the state changed since last frame
  109211. */
  109212. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109213. }
  109214. }
  109215. declare module BABYLON {
  109216. /**
  109217. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109218. */
  109219. export class WebXRControllerModelLoader {
  109220. /**
  109221. * Creates the WebXRControllerModelLoader
  109222. * @param input xr input that creates the controllers
  109223. */
  109224. constructor(input: WebXRInput);
  109225. }
  109226. }
  109227. declare module BABYLON {
  109228. /**
  109229. * Contains an array of blocks representing the octree
  109230. */
  109231. export interface IOctreeContainer<T> {
  109232. /**
  109233. * Blocks within the octree
  109234. */
  109235. blocks: Array<OctreeBlock<T>>;
  109236. }
  109237. /**
  109238. * Class used to store a cell in an octree
  109239. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109240. */
  109241. export class OctreeBlock<T> {
  109242. /**
  109243. * Gets the content of the current block
  109244. */
  109245. entries: T[];
  109246. /**
  109247. * Gets the list of block children
  109248. */
  109249. blocks: Array<OctreeBlock<T>>;
  109250. private _depth;
  109251. private _maxDepth;
  109252. private _capacity;
  109253. private _minPoint;
  109254. private _maxPoint;
  109255. private _boundingVectors;
  109256. private _creationFunc;
  109257. /**
  109258. * Creates a new block
  109259. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109260. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109261. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109262. * @param depth defines the current depth of this block in the octree
  109263. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109264. * @param creationFunc defines a callback to call when an element is added to the block
  109265. */
  109266. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109267. /**
  109268. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109269. */
  109270. readonly capacity: number;
  109271. /**
  109272. * Gets the minimum vector (in world space) of the block's bounding box
  109273. */
  109274. readonly minPoint: Vector3;
  109275. /**
  109276. * Gets the maximum vector (in world space) of the block's bounding box
  109277. */
  109278. readonly maxPoint: Vector3;
  109279. /**
  109280. * Add a new element to this block
  109281. * @param entry defines the element to add
  109282. */
  109283. addEntry(entry: T): void;
  109284. /**
  109285. * Remove an element from this block
  109286. * @param entry defines the element to remove
  109287. */
  109288. removeEntry(entry: T): void;
  109289. /**
  109290. * Add an array of elements to this block
  109291. * @param entries defines the array of elements to add
  109292. */
  109293. addEntries(entries: T[]): void;
  109294. /**
  109295. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109296. * @param frustumPlanes defines the frustum planes to test
  109297. * @param selection defines the array to store current content if selection is positive
  109298. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109299. */
  109300. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109301. /**
  109302. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109303. * @param sphereCenter defines the bounding sphere center
  109304. * @param sphereRadius defines the bounding sphere radius
  109305. * @param selection defines the array to store current content if selection is positive
  109306. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109307. */
  109308. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109309. /**
  109310. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109311. * @param ray defines the ray to test with
  109312. * @param selection defines the array to store current content if selection is positive
  109313. */
  109314. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109315. /**
  109316. * Subdivide the content into child blocks (this block will then be empty)
  109317. */
  109318. createInnerBlocks(): void;
  109319. /**
  109320. * @hidden
  109321. */
  109322. 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;
  109323. }
  109324. }
  109325. declare module BABYLON {
  109326. /**
  109327. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109328. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109329. */
  109330. export class Octree<T> {
  109331. /** 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.) */
  109332. maxDepth: number;
  109333. /**
  109334. * Blocks within the octree containing objects
  109335. */
  109336. blocks: Array<OctreeBlock<T>>;
  109337. /**
  109338. * Content stored in the octree
  109339. */
  109340. dynamicContent: T[];
  109341. private _maxBlockCapacity;
  109342. private _selectionContent;
  109343. private _creationFunc;
  109344. /**
  109345. * Creates a octree
  109346. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109347. * @param creationFunc function to be used to instatiate the octree
  109348. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109349. * @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.)
  109350. */
  109351. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109352. /** 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.) */
  109353. maxDepth?: number);
  109354. /**
  109355. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109356. * @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);
  109357. * @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);
  109358. * @param entries meshes to be added to the octree blocks
  109359. */
  109360. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109361. /**
  109362. * Adds a mesh to the octree
  109363. * @param entry Mesh to add to the octree
  109364. */
  109365. addMesh(entry: T): void;
  109366. /**
  109367. * Remove an element from the octree
  109368. * @param entry defines the element to remove
  109369. */
  109370. removeMesh(entry: T): void;
  109371. /**
  109372. * Selects an array of meshes within the frustum
  109373. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109374. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109375. * @returns array of meshes within the frustum
  109376. */
  109377. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109378. /**
  109379. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109380. * @param sphereCenter defines the bounding sphere center
  109381. * @param sphereRadius defines the bounding sphere radius
  109382. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109383. * @returns an array of objects that intersect the sphere
  109384. */
  109385. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109386. /**
  109387. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109388. * @param ray defines the ray to test with
  109389. * @returns array of intersected objects
  109390. */
  109391. intersectsRay(ray: Ray): SmartArray<T>;
  109392. /**
  109393. * Adds a mesh into the octree block if it intersects the block
  109394. */
  109395. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109396. /**
  109397. * Adds a submesh into the octree block if it intersects the block
  109398. */
  109399. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109400. }
  109401. }
  109402. declare module BABYLON {
  109403. interface Scene {
  109404. /**
  109405. * @hidden
  109406. * Backing Filed
  109407. */
  109408. _selectionOctree: Octree<AbstractMesh>;
  109409. /**
  109410. * Gets the octree used to boost mesh selection (picking)
  109411. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109412. */
  109413. selectionOctree: Octree<AbstractMesh>;
  109414. /**
  109415. * Creates or updates the octree used to boost selection (picking)
  109416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109417. * @param maxCapacity defines the maximum capacity per leaf
  109418. * @param maxDepth defines the maximum depth of the octree
  109419. * @returns an octree of AbstractMesh
  109420. */
  109421. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109422. }
  109423. interface AbstractMesh {
  109424. /**
  109425. * @hidden
  109426. * Backing Field
  109427. */
  109428. _submeshesOctree: Octree<SubMesh>;
  109429. /**
  109430. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109431. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109432. * @param maxCapacity defines the maximum size of each block (64 by default)
  109433. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109434. * @returns the new octree
  109435. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109437. */
  109438. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109439. }
  109440. /**
  109441. * Defines the octree scene component responsible to manage any octrees
  109442. * in a given scene.
  109443. */
  109444. export class OctreeSceneComponent {
  109445. /**
  109446. * The component name help to identify the component in the list of scene components.
  109447. */
  109448. readonly name: string;
  109449. /**
  109450. * The scene the component belongs to.
  109451. */
  109452. scene: Scene;
  109453. /**
  109454. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109455. */
  109456. readonly checksIsEnabled: boolean;
  109457. /**
  109458. * Creates a new instance of the component for the given scene
  109459. * @param scene Defines the scene to register the component in
  109460. */
  109461. constructor(scene: Scene);
  109462. /**
  109463. * Registers the component in a given scene
  109464. */
  109465. register(): void;
  109466. /**
  109467. * Return the list of active meshes
  109468. * @returns the list of active meshes
  109469. */
  109470. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109471. /**
  109472. * Return the list of active sub meshes
  109473. * @param mesh The mesh to get the candidates sub meshes from
  109474. * @returns the list of active sub meshes
  109475. */
  109476. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109477. private _tempRay;
  109478. /**
  109479. * Return the list of sub meshes intersecting with a given local ray
  109480. * @param mesh defines the mesh to find the submesh for
  109481. * @param localRay defines the ray in local space
  109482. * @returns the list of intersecting sub meshes
  109483. */
  109484. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109485. /**
  109486. * Return the list of sub meshes colliding with a collider
  109487. * @param mesh defines the mesh to find the submesh for
  109488. * @param collider defines the collider to evaluate the collision against
  109489. * @returns the list of colliding sub meshes
  109490. */
  109491. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109492. /**
  109493. * Rebuilds the elements related to this component in case of
  109494. * context lost for instance.
  109495. */
  109496. rebuild(): void;
  109497. /**
  109498. * Disposes the component and the associated ressources.
  109499. */
  109500. dispose(): void;
  109501. }
  109502. }
  109503. declare module BABYLON {
  109504. /**
  109505. * Renders a layer on top of an existing scene
  109506. */
  109507. export class UtilityLayerRenderer implements IDisposable {
  109508. /** the original scene that will be rendered on top of */
  109509. originalScene: Scene;
  109510. private _pointerCaptures;
  109511. private _lastPointerEvents;
  109512. private static _DefaultUtilityLayer;
  109513. private static _DefaultKeepDepthUtilityLayer;
  109514. private _sharedGizmoLight;
  109515. private _renderCamera;
  109516. /**
  109517. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109518. * @returns the camera that is used when rendering the utility layer
  109519. */
  109520. getRenderCamera(): Nullable<Camera>;
  109521. /**
  109522. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109523. * @param cam the camera that should be used when rendering the utility layer
  109524. */
  109525. setRenderCamera(cam: Nullable<Camera>): void;
  109526. /**
  109527. * @hidden
  109528. * Light which used by gizmos to get light shading
  109529. */
  109530. _getSharedGizmoLight(): HemisphericLight;
  109531. /**
  109532. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109533. */
  109534. pickUtilitySceneFirst: boolean;
  109535. /**
  109536. * 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)
  109537. */
  109538. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109539. /**
  109540. * 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)
  109541. */
  109542. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109543. /**
  109544. * The scene that is rendered on top of the original scene
  109545. */
  109546. utilityLayerScene: Scene;
  109547. /**
  109548. * If the utility layer should automatically be rendered on top of existing scene
  109549. */
  109550. shouldRender: boolean;
  109551. /**
  109552. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109553. */
  109554. onlyCheckPointerDownEvents: boolean;
  109555. /**
  109556. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109557. */
  109558. processAllEvents: boolean;
  109559. /**
  109560. * Observable raised when the pointer move from the utility layer scene to the main scene
  109561. */
  109562. onPointerOutObservable: Observable<number>;
  109563. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109564. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109565. private _afterRenderObserver;
  109566. private _sceneDisposeObserver;
  109567. private _originalPointerObserver;
  109568. /**
  109569. * Instantiates a UtilityLayerRenderer
  109570. * @param originalScene the original scene that will be rendered on top of
  109571. * @param handleEvents boolean indicating if the utility layer should handle events
  109572. */
  109573. constructor(
  109574. /** the original scene that will be rendered on top of */
  109575. originalScene: Scene, handleEvents?: boolean);
  109576. private _notifyObservers;
  109577. /**
  109578. * Renders the utility layers scene on top of the original scene
  109579. */
  109580. render(): void;
  109581. /**
  109582. * Disposes of the renderer
  109583. */
  109584. dispose(): void;
  109585. private _updateCamera;
  109586. }
  109587. }
  109588. declare module BABYLON {
  109589. /**
  109590. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109591. */
  109592. export class Gizmo implements IDisposable {
  109593. /** The utility layer the gizmo will be added to */
  109594. gizmoLayer: UtilityLayerRenderer;
  109595. /**
  109596. * The root mesh of the gizmo
  109597. */
  109598. _rootMesh: Mesh;
  109599. private _attachedMesh;
  109600. /**
  109601. * Ratio for the scale of the gizmo (Default: 1)
  109602. */
  109603. scaleRatio: number;
  109604. /**
  109605. * If a custom mesh has been set (Default: false)
  109606. */
  109607. protected _customMeshSet: boolean;
  109608. /**
  109609. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109610. * * When set, interactions will be enabled
  109611. */
  109612. attachedMesh: Nullable<AbstractMesh>;
  109613. /**
  109614. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109615. * @param mesh The mesh to replace the default mesh of the gizmo
  109616. */
  109617. setCustomMesh(mesh: Mesh): void;
  109618. /**
  109619. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109620. */
  109621. updateGizmoRotationToMatchAttachedMesh: boolean;
  109622. /**
  109623. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109624. */
  109625. updateGizmoPositionToMatchAttachedMesh: boolean;
  109626. /**
  109627. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109628. */
  109629. updateScale: boolean;
  109630. protected _interactionsEnabled: boolean;
  109631. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109632. private _beforeRenderObserver;
  109633. private _tempVector;
  109634. /**
  109635. * Creates a gizmo
  109636. * @param gizmoLayer The utility layer the gizmo will be added to
  109637. */
  109638. constructor(
  109639. /** The utility layer the gizmo will be added to */
  109640. gizmoLayer?: UtilityLayerRenderer);
  109641. /**
  109642. * Updates the gizmo to match the attached mesh's position/rotation
  109643. */
  109644. protected _update(): void;
  109645. /**
  109646. * Disposes of the gizmo
  109647. */
  109648. dispose(): void;
  109649. }
  109650. }
  109651. declare module BABYLON {
  109652. /**
  109653. * Single plane drag gizmo
  109654. */
  109655. export class PlaneDragGizmo extends Gizmo {
  109656. /**
  109657. * Drag behavior responsible for the gizmos dragging interactions
  109658. */
  109659. dragBehavior: PointerDragBehavior;
  109660. private _pointerObserver;
  109661. /**
  109662. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109663. */
  109664. snapDistance: number;
  109665. /**
  109666. * Event that fires each time the gizmo snaps to a new location.
  109667. * * snapDistance is the the change in distance
  109668. */
  109669. onSnapObservable: Observable<{
  109670. snapDistance: number;
  109671. }>;
  109672. private _plane;
  109673. private _coloredMaterial;
  109674. private _hoverMaterial;
  109675. private _isEnabled;
  109676. private _parent;
  109677. /** @hidden */
  109678. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109679. /** @hidden */
  109680. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109681. /**
  109682. * Creates a PlaneDragGizmo
  109683. * @param gizmoLayer The utility layer the gizmo will be added to
  109684. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109685. * @param color The color of the gizmo
  109686. */
  109687. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109688. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109689. /**
  109690. * If the gizmo is enabled
  109691. */
  109692. isEnabled: boolean;
  109693. /**
  109694. * Disposes of the gizmo
  109695. */
  109696. dispose(): void;
  109697. }
  109698. }
  109699. declare module BABYLON {
  109700. /**
  109701. * Gizmo that enables dragging a mesh along 3 axis
  109702. */
  109703. export class PositionGizmo extends Gizmo {
  109704. /**
  109705. * Internal gizmo used for interactions on the x axis
  109706. */
  109707. xGizmo: AxisDragGizmo;
  109708. /**
  109709. * Internal gizmo used for interactions on the y axis
  109710. */
  109711. yGizmo: AxisDragGizmo;
  109712. /**
  109713. * Internal gizmo used for interactions on the z axis
  109714. */
  109715. zGizmo: AxisDragGizmo;
  109716. /**
  109717. * Internal gizmo used for interactions on the yz plane
  109718. */
  109719. xPlaneGizmo: PlaneDragGizmo;
  109720. /**
  109721. * Internal gizmo used for interactions on the xz plane
  109722. */
  109723. yPlaneGizmo: PlaneDragGizmo;
  109724. /**
  109725. * Internal gizmo used for interactions on the xy plane
  109726. */
  109727. zPlaneGizmo: PlaneDragGizmo;
  109728. /**
  109729. * private variables
  109730. */
  109731. private _meshAttached;
  109732. private _updateGizmoRotationToMatchAttachedMesh;
  109733. private _snapDistance;
  109734. private _scaleRatio;
  109735. /** Fires an event when any of it's sub gizmos are dragged */
  109736. onDragStartObservable: Observable<unknown>;
  109737. /** Fires an event when any of it's sub gizmos are released from dragging */
  109738. onDragEndObservable: Observable<unknown>;
  109739. /**
  109740. * If set to true, planar drag is enabled
  109741. */
  109742. private _planarGizmoEnabled;
  109743. attachedMesh: Nullable<AbstractMesh>;
  109744. /**
  109745. * Creates a PositionGizmo
  109746. * @param gizmoLayer The utility layer the gizmo will be added to
  109747. */
  109748. constructor(gizmoLayer?: UtilityLayerRenderer);
  109749. /**
  109750. * If the planar drag gizmo is enabled
  109751. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109752. */
  109753. planarGizmoEnabled: boolean;
  109754. updateGizmoRotationToMatchAttachedMesh: boolean;
  109755. /**
  109756. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109757. */
  109758. snapDistance: number;
  109759. /**
  109760. * Ratio for the scale of the gizmo (Default: 1)
  109761. */
  109762. scaleRatio: number;
  109763. /**
  109764. * Disposes of the gizmo
  109765. */
  109766. dispose(): void;
  109767. /**
  109768. * CustomMeshes are not supported by this gizmo
  109769. * @param mesh The mesh to replace the default mesh of the gizmo
  109770. */
  109771. setCustomMesh(mesh: Mesh): void;
  109772. }
  109773. }
  109774. declare module BABYLON {
  109775. /**
  109776. * Single axis drag gizmo
  109777. */
  109778. export class AxisDragGizmo extends Gizmo {
  109779. /**
  109780. * Drag behavior responsible for the gizmos dragging interactions
  109781. */
  109782. dragBehavior: PointerDragBehavior;
  109783. private _pointerObserver;
  109784. /**
  109785. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109786. */
  109787. snapDistance: number;
  109788. /**
  109789. * Event that fires each time the gizmo snaps to a new location.
  109790. * * snapDistance is the the change in distance
  109791. */
  109792. onSnapObservable: Observable<{
  109793. snapDistance: number;
  109794. }>;
  109795. private _isEnabled;
  109796. private _parent;
  109797. private _arrow;
  109798. private _coloredMaterial;
  109799. private _hoverMaterial;
  109800. /** @hidden */
  109801. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109802. /** @hidden */
  109803. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109804. /**
  109805. * Creates an AxisDragGizmo
  109806. * @param gizmoLayer The utility layer the gizmo will be added to
  109807. * @param dragAxis The axis which the gizmo will be able to drag on
  109808. * @param color The color of the gizmo
  109809. */
  109810. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109811. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109812. /**
  109813. * If the gizmo is enabled
  109814. */
  109815. isEnabled: boolean;
  109816. /**
  109817. * Disposes of the gizmo
  109818. */
  109819. dispose(): void;
  109820. }
  109821. }
  109822. declare module BABYLON.Debug {
  109823. /**
  109824. * The Axes viewer will show 3 axes in a specific point in space
  109825. */
  109826. export class AxesViewer {
  109827. private _xAxis;
  109828. private _yAxis;
  109829. private _zAxis;
  109830. private _scaleLinesFactor;
  109831. private _instanced;
  109832. /**
  109833. * Gets the hosting scene
  109834. */
  109835. scene: Scene;
  109836. /**
  109837. * Gets or sets a number used to scale line length
  109838. */
  109839. scaleLines: number;
  109840. /** Gets the node hierarchy used to render x-axis */
  109841. readonly xAxis: TransformNode;
  109842. /** Gets the node hierarchy used to render y-axis */
  109843. readonly yAxis: TransformNode;
  109844. /** Gets the node hierarchy used to render z-axis */
  109845. readonly zAxis: TransformNode;
  109846. /**
  109847. * Creates a new AxesViewer
  109848. * @param scene defines the hosting scene
  109849. * @param scaleLines defines a number used to scale line length (1 by default)
  109850. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109851. * @param xAxis defines the node hierarchy used to render the x-axis
  109852. * @param yAxis defines the node hierarchy used to render the y-axis
  109853. * @param zAxis defines the node hierarchy used to render the z-axis
  109854. */
  109855. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109856. /**
  109857. * Force the viewer to update
  109858. * @param position defines the position of the viewer
  109859. * @param xaxis defines the x axis of the viewer
  109860. * @param yaxis defines the y axis of the viewer
  109861. * @param zaxis defines the z axis of the viewer
  109862. */
  109863. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109864. /**
  109865. * Creates an instance of this axes viewer.
  109866. * @returns a new axes viewer with instanced meshes
  109867. */
  109868. createInstance(): AxesViewer;
  109869. /** Releases resources */
  109870. dispose(): void;
  109871. private static _SetRenderingGroupId;
  109872. }
  109873. }
  109874. declare module BABYLON.Debug {
  109875. /**
  109876. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109877. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109878. */
  109879. export class BoneAxesViewer extends AxesViewer {
  109880. /**
  109881. * Gets or sets the target mesh where to display the axes viewer
  109882. */
  109883. mesh: Nullable<Mesh>;
  109884. /**
  109885. * Gets or sets the target bone where to display the axes viewer
  109886. */
  109887. bone: Nullable<Bone>;
  109888. /** Gets current position */
  109889. pos: Vector3;
  109890. /** Gets direction of X axis */
  109891. xaxis: Vector3;
  109892. /** Gets direction of Y axis */
  109893. yaxis: Vector3;
  109894. /** Gets direction of Z axis */
  109895. zaxis: Vector3;
  109896. /**
  109897. * Creates a new BoneAxesViewer
  109898. * @param scene defines the hosting scene
  109899. * @param bone defines the target bone
  109900. * @param mesh defines the target mesh
  109901. * @param scaleLines defines a scaling factor for line length (1 by default)
  109902. */
  109903. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109904. /**
  109905. * Force the viewer to update
  109906. */
  109907. update(): void;
  109908. /** Releases resources */
  109909. dispose(): void;
  109910. }
  109911. }
  109912. declare module BABYLON {
  109913. /**
  109914. * Interface used to define scene explorer extensibility option
  109915. */
  109916. export interface IExplorerExtensibilityOption {
  109917. /**
  109918. * Define the option label
  109919. */
  109920. label: string;
  109921. /**
  109922. * Defines the action to execute on click
  109923. */
  109924. action: (entity: any) => void;
  109925. }
  109926. /**
  109927. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109928. */
  109929. export interface IExplorerExtensibilityGroup {
  109930. /**
  109931. * Defines a predicate to test if a given type mut be extended
  109932. */
  109933. predicate: (entity: any) => boolean;
  109934. /**
  109935. * Gets the list of options added to a type
  109936. */
  109937. entries: IExplorerExtensibilityOption[];
  109938. }
  109939. /**
  109940. * Interface used to define the options to use to create the Inspector
  109941. */
  109942. export interface IInspectorOptions {
  109943. /**
  109944. * Display in overlay mode (default: false)
  109945. */
  109946. overlay?: boolean;
  109947. /**
  109948. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109949. */
  109950. globalRoot?: HTMLElement;
  109951. /**
  109952. * Display the Scene explorer
  109953. */
  109954. showExplorer?: boolean;
  109955. /**
  109956. * Display the property inspector
  109957. */
  109958. showInspector?: boolean;
  109959. /**
  109960. * Display in embed mode (both panes on the right)
  109961. */
  109962. embedMode?: boolean;
  109963. /**
  109964. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109965. */
  109966. handleResize?: boolean;
  109967. /**
  109968. * Allow the panes to popup (default: true)
  109969. */
  109970. enablePopup?: boolean;
  109971. /**
  109972. * Allow the panes to be closed by users (default: true)
  109973. */
  109974. enableClose?: boolean;
  109975. /**
  109976. * Optional list of extensibility entries
  109977. */
  109978. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109979. /**
  109980. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109981. */
  109982. inspectorURL?: string;
  109983. }
  109984. interface Scene {
  109985. /**
  109986. * @hidden
  109987. * Backing field
  109988. */
  109989. _debugLayer: DebugLayer;
  109990. /**
  109991. * Gets the debug layer (aka Inspector) associated with the scene
  109992. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109993. */
  109994. debugLayer: DebugLayer;
  109995. }
  109996. /**
  109997. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109998. * what is happening in your scene
  109999. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110000. */
  110001. export class DebugLayer {
  110002. /**
  110003. * Define the url to get the inspector script from.
  110004. * By default it uses the babylonjs CDN.
  110005. * @ignoreNaming
  110006. */
  110007. static InspectorURL: string;
  110008. private _scene;
  110009. private BJSINSPECTOR;
  110010. private _onPropertyChangedObservable?;
  110011. /**
  110012. * Observable triggered when a property is changed through the inspector.
  110013. */
  110014. readonly onPropertyChangedObservable: any;
  110015. /**
  110016. * Instantiates a new debug layer.
  110017. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110018. * what is happening in your scene
  110019. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110020. * @param scene Defines the scene to inspect
  110021. */
  110022. constructor(scene: Scene);
  110023. /** Creates the inspector window. */
  110024. private _createInspector;
  110025. /**
  110026. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110027. * @param entity defines the entity to select
  110028. * @param lineContainerTitle defines the specific block to highlight
  110029. */
  110030. select(entity: any, lineContainerTitle?: string): void;
  110031. /** Get the inspector from bundle or global */
  110032. private _getGlobalInspector;
  110033. /**
  110034. * Get if the inspector is visible or not.
  110035. * @returns true if visible otherwise, false
  110036. */
  110037. isVisible(): boolean;
  110038. /**
  110039. * Hide the inspector and close its window.
  110040. */
  110041. hide(): void;
  110042. /**
  110043. * Launch the debugLayer.
  110044. * @param config Define the configuration of the inspector
  110045. * @return a promise fulfilled when the debug layer is visible
  110046. */
  110047. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110048. }
  110049. }
  110050. declare module BABYLON {
  110051. /**
  110052. * Class containing static functions to help procedurally build meshes
  110053. */
  110054. export class BoxBuilder {
  110055. /**
  110056. * Creates a box mesh
  110057. * * The parameter `size` sets the size (float) of each box side (default 1)
  110058. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110059. * * 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)
  110060. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110064. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110065. * @param name defines the name of the mesh
  110066. * @param options defines the options used to create the mesh
  110067. * @param scene defines the hosting scene
  110068. * @returns the box mesh
  110069. */
  110070. static CreateBox(name: string, options: {
  110071. size?: number;
  110072. width?: number;
  110073. height?: number;
  110074. depth?: number;
  110075. faceUV?: Vector4[];
  110076. faceColors?: Color4[];
  110077. sideOrientation?: number;
  110078. frontUVs?: Vector4;
  110079. backUVs?: Vector4;
  110080. wrap?: boolean;
  110081. topBaseAt?: number;
  110082. bottomBaseAt?: number;
  110083. updatable?: boolean;
  110084. }, scene?: Nullable<Scene>): Mesh;
  110085. }
  110086. }
  110087. declare module BABYLON {
  110088. /**
  110089. * Class containing static functions to help procedurally build meshes
  110090. */
  110091. export class SphereBuilder {
  110092. /**
  110093. * Creates a sphere mesh
  110094. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110095. * * 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`)
  110096. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110097. * * 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
  110098. * * 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)
  110099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110102. * @param name defines the name of the mesh
  110103. * @param options defines the options used to create the mesh
  110104. * @param scene defines the hosting scene
  110105. * @returns the sphere mesh
  110106. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110107. */
  110108. static CreateSphere(name: string, options: {
  110109. segments?: number;
  110110. diameter?: number;
  110111. diameterX?: number;
  110112. diameterY?: number;
  110113. diameterZ?: number;
  110114. arc?: number;
  110115. slice?: number;
  110116. sideOrientation?: number;
  110117. frontUVs?: Vector4;
  110118. backUVs?: Vector4;
  110119. updatable?: boolean;
  110120. }, scene?: Nullable<Scene>): Mesh;
  110121. }
  110122. }
  110123. declare module BABYLON.Debug {
  110124. /**
  110125. * Used to show the physics impostor around the specific mesh
  110126. */
  110127. export class PhysicsViewer {
  110128. /** @hidden */
  110129. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110130. /** @hidden */
  110131. protected _meshes: Array<Nullable<AbstractMesh>>;
  110132. /** @hidden */
  110133. protected _scene: Nullable<Scene>;
  110134. /** @hidden */
  110135. protected _numMeshes: number;
  110136. /** @hidden */
  110137. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110138. private _renderFunction;
  110139. private _utilityLayer;
  110140. private _debugBoxMesh;
  110141. private _debugSphereMesh;
  110142. private _debugCylinderMesh;
  110143. private _debugMaterial;
  110144. private _debugMeshMeshes;
  110145. /**
  110146. * Creates a new PhysicsViewer
  110147. * @param scene defines the hosting scene
  110148. */
  110149. constructor(scene: Scene);
  110150. /** @hidden */
  110151. protected _updateDebugMeshes(): void;
  110152. /**
  110153. * Renders a specified physic impostor
  110154. * @param impostor defines the impostor to render
  110155. * @param targetMesh defines the mesh represented by the impostor
  110156. * @returns the new debug mesh used to render the impostor
  110157. */
  110158. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110159. /**
  110160. * Hides a specified physic impostor
  110161. * @param impostor defines the impostor to hide
  110162. */
  110163. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110164. private _getDebugMaterial;
  110165. private _getDebugBoxMesh;
  110166. private _getDebugSphereMesh;
  110167. private _getDebugCylinderMesh;
  110168. private _getDebugMeshMesh;
  110169. private _getDebugMesh;
  110170. /** Releases all resources */
  110171. dispose(): void;
  110172. }
  110173. }
  110174. declare module BABYLON {
  110175. /**
  110176. * Class containing static functions to help procedurally build meshes
  110177. */
  110178. export class LinesBuilder {
  110179. /**
  110180. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110181. * * 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
  110182. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110183. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110184. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110185. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110186. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110187. * * 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
  110188. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110190. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110191. * @param name defines the name of the new line system
  110192. * @param options defines the options used to create the line system
  110193. * @param scene defines the hosting scene
  110194. * @returns a new line system mesh
  110195. */
  110196. static CreateLineSystem(name: string, options: {
  110197. lines: Vector3[][];
  110198. updatable?: boolean;
  110199. instance?: Nullable<LinesMesh>;
  110200. colors?: Nullable<Color4[][]>;
  110201. useVertexAlpha?: boolean;
  110202. }, scene: Nullable<Scene>): LinesMesh;
  110203. /**
  110204. * Creates a line mesh
  110205. * 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
  110206. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110207. * * The parameter `points` is an array successive Vector3
  110208. * * 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
  110209. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110210. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110211. * * When updating an instance, remember that only point positions can change, not the number of points
  110212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110214. * @param name defines the name of the new line system
  110215. * @param options defines the options used to create the line system
  110216. * @param scene defines the hosting scene
  110217. * @returns a new line mesh
  110218. */
  110219. static CreateLines(name: string, options: {
  110220. points: Vector3[];
  110221. updatable?: boolean;
  110222. instance?: Nullable<LinesMesh>;
  110223. colors?: Color4[];
  110224. useVertexAlpha?: boolean;
  110225. }, scene?: Nullable<Scene>): LinesMesh;
  110226. /**
  110227. * Creates a dashed line mesh
  110228. * * 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
  110229. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110230. * * The parameter `points` is an array successive Vector3
  110231. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110232. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110233. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110234. * * 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
  110235. * * When updating an instance, remember that only point positions can change, not the number of points
  110236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110237. * @param name defines the name of the mesh
  110238. * @param options defines the options used to create the mesh
  110239. * @param scene defines the hosting scene
  110240. * @returns the dashed line mesh
  110241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110242. */
  110243. static CreateDashedLines(name: string, options: {
  110244. points: Vector3[];
  110245. dashSize?: number;
  110246. gapSize?: number;
  110247. dashNb?: number;
  110248. updatable?: boolean;
  110249. instance?: LinesMesh;
  110250. }, scene?: Nullable<Scene>): LinesMesh;
  110251. }
  110252. }
  110253. declare module BABYLON {
  110254. /**
  110255. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110256. * in order to better appreciate the issue one might have.
  110257. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110258. */
  110259. export class RayHelper {
  110260. /**
  110261. * Defines the ray we are currently tryin to visualize.
  110262. */
  110263. ray: Nullable<Ray>;
  110264. private _renderPoints;
  110265. private _renderLine;
  110266. private _renderFunction;
  110267. private _scene;
  110268. private _updateToMeshFunction;
  110269. private _attachedToMesh;
  110270. private _meshSpaceDirection;
  110271. private _meshSpaceOrigin;
  110272. /**
  110273. * Helper function to create a colored helper in a scene in one line.
  110274. * @param ray Defines the ray we are currently tryin to visualize
  110275. * @param scene Defines the scene the ray is used in
  110276. * @param color Defines the color we want to see the ray in
  110277. * @returns The newly created ray helper.
  110278. */
  110279. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110280. /**
  110281. * Instantiate a new ray helper.
  110282. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110283. * in order to better appreciate the issue one might have.
  110284. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110285. * @param ray Defines the ray we are currently tryin to visualize
  110286. */
  110287. constructor(ray: Ray);
  110288. /**
  110289. * Shows the ray we are willing to debug.
  110290. * @param scene Defines the scene the ray needs to be rendered in
  110291. * @param color Defines the color the ray needs to be rendered in
  110292. */
  110293. show(scene: Scene, color?: Color3): void;
  110294. /**
  110295. * Hides the ray we are debugging.
  110296. */
  110297. hide(): void;
  110298. private _render;
  110299. /**
  110300. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110301. * @param mesh Defines the mesh we want the helper attached to
  110302. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110303. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110304. * @param length Defines the length of the ray
  110305. */
  110306. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110307. /**
  110308. * Detach the ray helper from the mesh it has previously been attached to.
  110309. */
  110310. detachFromMesh(): void;
  110311. private _updateToMesh;
  110312. /**
  110313. * Dispose the helper and release its associated resources.
  110314. */
  110315. dispose(): void;
  110316. }
  110317. }
  110318. declare module BABYLON.Debug {
  110319. /**
  110320. * Class used to render a debug view of a given skeleton
  110321. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110322. */
  110323. export class SkeletonViewer {
  110324. /** defines the skeleton to render */
  110325. skeleton: Skeleton;
  110326. /** defines the mesh attached to the skeleton */
  110327. mesh: AbstractMesh;
  110328. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110329. autoUpdateBonesMatrices: boolean;
  110330. /** defines the rendering group id to use with the viewer */
  110331. renderingGroupId: number;
  110332. /** Gets or sets the color used to render the skeleton */
  110333. color: Color3;
  110334. private _scene;
  110335. private _debugLines;
  110336. private _debugMesh;
  110337. private _isEnabled;
  110338. private _renderFunction;
  110339. private _utilityLayer;
  110340. /**
  110341. * Returns the mesh used to render the bones
  110342. */
  110343. readonly debugMesh: Nullable<LinesMesh>;
  110344. /**
  110345. * Creates a new SkeletonViewer
  110346. * @param skeleton defines the skeleton to render
  110347. * @param mesh defines the mesh attached to the skeleton
  110348. * @param scene defines the hosting scene
  110349. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110350. * @param renderingGroupId defines the rendering group id to use with the viewer
  110351. */
  110352. constructor(
  110353. /** defines the skeleton to render */
  110354. skeleton: Skeleton,
  110355. /** defines the mesh attached to the skeleton */
  110356. mesh: AbstractMesh, scene: Scene,
  110357. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110358. autoUpdateBonesMatrices?: boolean,
  110359. /** defines the rendering group id to use with the viewer */
  110360. renderingGroupId?: number);
  110361. /** Gets or sets a boolean indicating if the viewer is enabled */
  110362. isEnabled: boolean;
  110363. private _getBonePosition;
  110364. private _getLinesForBonesWithLength;
  110365. private _getLinesForBonesNoLength;
  110366. /** Update the viewer to sync with current skeleton state */
  110367. update(): void;
  110368. /** Release associated resources */
  110369. dispose(): void;
  110370. }
  110371. }
  110372. declare module BABYLON {
  110373. /**
  110374. * Options to create the null engine
  110375. */
  110376. export class NullEngineOptions {
  110377. /**
  110378. * Render width (Default: 512)
  110379. */
  110380. renderWidth: number;
  110381. /**
  110382. * Render height (Default: 256)
  110383. */
  110384. renderHeight: number;
  110385. /**
  110386. * Texture size (Default: 512)
  110387. */
  110388. textureSize: number;
  110389. /**
  110390. * If delta time between frames should be constant
  110391. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110392. */
  110393. deterministicLockstep: boolean;
  110394. /**
  110395. * Maximum about of steps between frames (Default: 4)
  110396. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110397. */
  110398. lockstepMaxSteps: number;
  110399. }
  110400. /**
  110401. * The null engine class provides support for headless version of babylon.js.
  110402. * This can be used in server side scenario or for testing purposes
  110403. */
  110404. export class NullEngine extends Engine {
  110405. private _options;
  110406. /**
  110407. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110408. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110409. * @returns true if engine is in deterministic lock step mode
  110410. */
  110411. isDeterministicLockStep(): boolean;
  110412. /**
  110413. * Gets the max steps when engine is running in deterministic lock step
  110414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110415. * @returns the max steps
  110416. */
  110417. getLockstepMaxSteps(): number;
  110418. /**
  110419. * Gets the current hardware scaling level.
  110420. * By default the hardware scaling level is computed from the window device ratio.
  110421. * 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.
  110422. * @returns a number indicating the current hardware scaling level
  110423. */
  110424. getHardwareScalingLevel(): number;
  110425. constructor(options?: NullEngineOptions);
  110426. /**
  110427. * Creates a vertex buffer
  110428. * @param vertices the data for the vertex buffer
  110429. * @returns the new WebGL static buffer
  110430. */
  110431. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110432. /**
  110433. * Creates a new index buffer
  110434. * @param indices defines the content of the index buffer
  110435. * @param updatable defines if the index buffer must be updatable
  110436. * @returns a new webGL buffer
  110437. */
  110438. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110439. /**
  110440. * Clear the current render buffer or the current render target (if any is set up)
  110441. * @param color defines the color to use
  110442. * @param backBuffer defines if the back buffer must be cleared
  110443. * @param depth defines if the depth buffer must be cleared
  110444. * @param stencil defines if the stencil buffer must be cleared
  110445. */
  110446. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110447. /**
  110448. * Gets the current render width
  110449. * @param useScreen defines if screen size must be used (or the current render target if any)
  110450. * @returns a number defining the current render width
  110451. */
  110452. getRenderWidth(useScreen?: boolean): number;
  110453. /**
  110454. * Gets the current render height
  110455. * @param useScreen defines if screen size must be used (or the current render target if any)
  110456. * @returns a number defining the current render height
  110457. */
  110458. getRenderHeight(useScreen?: boolean): number;
  110459. /**
  110460. * Set the WebGL's viewport
  110461. * @param viewport defines the viewport element to be used
  110462. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110463. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110464. */
  110465. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110466. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110467. /**
  110468. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110469. * @param pipelineContext defines the pipeline context to use
  110470. * @param uniformsNames defines the list of uniform names
  110471. * @returns an array of webGL uniform locations
  110472. */
  110473. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110474. /**
  110475. * Gets the lsit of active attributes for a given webGL program
  110476. * @param pipelineContext defines the pipeline context to use
  110477. * @param attributesNames defines the list of attribute names to get
  110478. * @returns an array of indices indicating the offset of each attribute
  110479. */
  110480. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110481. /**
  110482. * Binds an effect to the webGL context
  110483. * @param effect defines the effect to bind
  110484. */
  110485. bindSamplers(effect: Effect): void;
  110486. /**
  110487. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110488. * @param effect defines the effect to activate
  110489. */
  110490. enableEffect(effect: Effect): void;
  110491. /**
  110492. * Set various states to the webGL context
  110493. * @param culling defines backface culling state
  110494. * @param zOffset defines the value to apply to zOffset (0 by default)
  110495. * @param force defines if states must be applied even if cache is up to date
  110496. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110497. */
  110498. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110499. /**
  110500. * Set the value of an uniform to an array of int32
  110501. * @param uniform defines the webGL uniform location where to store the value
  110502. * @param array defines the array of int32 to store
  110503. */
  110504. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110505. /**
  110506. * Set the value of an uniform to an array of int32 (stored as vec2)
  110507. * @param uniform defines the webGL uniform location where to store the value
  110508. * @param array defines the array of int32 to store
  110509. */
  110510. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110511. /**
  110512. * Set the value of an uniform to an array of int32 (stored as vec3)
  110513. * @param uniform defines the webGL uniform location where to store the value
  110514. * @param array defines the array of int32 to store
  110515. */
  110516. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110517. /**
  110518. * Set the value of an uniform to an array of int32 (stored as vec4)
  110519. * @param uniform defines the webGL uniform location where to store the value
  110520. * @param array defines the array of int32 to store
  110521. */
  110522. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110523. /**
  110524. * Set the value of an uniform to an array of float32
  110525. * @param uniform defines the webGL uniform location where to store the value
  110526. * @param array defines the array of float32 to store
  110527. */
  110528. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110529. /**
  110530. * Set the value of an uniform to an array of float32 (stored as vec2)
  110531. * @param uniform defines the webGL uniform location where to store the value
  110532. * @param array defines the array of float32 to store
  110533. */
  110534. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110535. /**
  110536. * Set the value of an uniform to an array of float32 (stored as vec3)
  110537. * @param uniform defines the webGL uniform location where to store the value
  110538. * @param array defines the array of float32 to store
  110539. */
  110540. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110541. /**
  110542. * Set the value of an uniform to an array of float32 (stored as vec4)
  110543. * @param uniform defines the webGL uniform location where to store the value
  110544. * @param array defines the array of float32 to store
  110545. */
  110546. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110547. /**
  110548. * Set the value of an uniform to an array of number
  110549. * @param uniform defines the webGL uniform location where to store the value
  110550. * @param array defines the array of number to store
  110551. */
  110552. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110553. /**
  110554. * Set the value of an uniform to an array of number (stored as vec2)
  110555. * @param uniform defines the webGL uniform location where to store the value
  110556. * @param array defines the array of number to store
  110557. */
  110558. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110559. /**
  110560. * Set the value of an uniform to an array of number (stored as vec3)
  110561. * @param uniform defines the webGL uniform location where to store the value
  110562. * @param array defines the array of number to store
  110563. */
  110564. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110565. /**
  110566. * Set the value of an uniform to an array of number (stored as vec4)
  110567. * @param uniform defines the webGL uniform location where to store the value
  110568. * @param array defines the array of number to store
  110569. */
  110570. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110571. /**
  110572. * Set the value of an uniform to an array of float32 (stored as matrices)
  110573. * @param uniform defines the webGL uniform location where to store the value
  110574. * @param matrices defines the array of float32 to store
  110575. */
  110576. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110577. /**
  110578. * Set the value of an uniform to a matrix (3x3)
  110579. * @param uniform defines the webGL uniform location where to store the value
  110580. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110581. */
  110582. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110583. /**
  110584. * Set the value of an uniform to a matrix (2x2)
  110585. * @param uniform defines the webGL uniform location where to store the value
  110586. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110587. */
  110588. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110589. /**
  110590. * Set the value of an uniform to a number (float)
  110591. * @param uniform defines the webGL uniform location where to store the value
  110592. * @param value defines the float number to store
  110593. */
  110594. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110595. /**
  110596. * Set the value of an uniform to a vec2
  110597. * @param uniform defines the webGL uniform location where to store the value
  110598. * @param x defines the 1st component of the value
  110599. * @param y defines the 2nd component of the value
  110600. */
  110601. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110602. /**
  110603. * Set the value of an uniform to a vec3
  110604. * @param uniform defines the webGL uniform location where to store the value
  110605. * @param x defines the 1st component of the value
  110606. * @param y defines the 2nd component of the value
  110607. * @param z defines the 3rd component of the value
  110608. */
  110609. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110610. /**
  110611. * Set the value of an uniform to a boolean
  110612. * @param uniform defines the webGL uniform location where to store the value
  110613. * @param bool defines the boolean to store
  110614. */
  110615. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110616. /**
  110617. * Set the value of an uniform to a vec4
  110618. * @param uniform defines the webGL uniform location where to store the value
  110619. * @param x defines the 1st component of the value
  110620. * @param y defines the 2nd component of the value
  110621. * @param z defines the 3rd component of the value
  110622. * @param w defines the 4th component of the value
  110623. */
  110624. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110625. /**
  110626. * Sets the current alpha mode
  110627. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110628. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110629. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110630. */
  110631. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110632. /**
  110633. * Bind webGl buffers directly to the webGL context
  110634. * @param vertexBuffers defines the vertex buffer to bind
  110635. * @param indexBuffer defines the index buffer to bind
  110636. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110637. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110638. * @param effect defines the effect associated with the vertex buffer
  110639. */
  110640. bindBuffers(vertexBuffers: {
  110641. [key: string]: VertexBuffer;
  110642. }, indexBuffer: DataBuffer, effect: Effect): void;
  110643. /**
  110644. * Force the entire cache to be cleared
  110645. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110646. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110647. */
  110648. wipeCaches(bruteForce?: boolean): void;
  110649. /**
  110650. * Send a draw order
  110651. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110652. * @param indexStart defines the starting index
  110653. * @param indexCount defines the number of index to draw
  110654. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110655. */
  110656. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110657. /**
  110658. * Draw a list of indexed primitives
  110659. * @param fillMode defines the primitive to use
  110660. * @param indexStart defines the starting index
  110661. * @param indexCount defines the number of index to draw
  110662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110663. */
  110664. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110665. /**
  110666. * Draw a list of unindexed primitives
  110667. * @param fillMode defines the primitive to use
  110668. * @param verticesStart defines the index of first vertex to draw
  110669. * @param verticesCount defines the count of vertices to draw
  110670. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110671. */
  110672. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110673. /** @hidden */
  110674. _createTexture(): WebGLTexture;
  110675. /** @hidden */
  110676. _releaseTexture(texture: InternalTexture): void;
  110677. /**
  110678. * Usually called from Texture.ts.
  110679. * Passed information to create a WebGLTexture
  110680. * @param urlArg defines a value which contains one of the following:
  110681. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110682. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110683. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110684. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110685. * @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)
  110686. * @param scene needed for loading to the correct scene
  110687. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110688. * @param onLoad optional callback to be called upon successful completion
  110689. * @param onError optional callback to be called upon failure
  110690. * @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
  110691. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110692. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110693. * @param forcedExtension defines the extension to use to pick the right loader
  110694. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110695. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110696. */
  110697. 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;
  110698. /**
  110699. * Creates a new render target texture
  110700. * @param size defines the size of the texture
  110701. * @param options defines the options used to create the texture
  110702. * @returns a new render target texture stored in an InternalTexture
  110703. */
  110704. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110705. /**
  110706. * Update the sampling mode of a given texture
  110707. * @param samplingMode defines the required sampling mode
  110708. * @param texture defines the texture to update
  110709. */
  110710. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110711. /**
  110712. * Binds the frame buffer to the specified texture.
  110713. * @param texture The texture to render to or null for the default canvas
  110714. * @param faceIndex The face of the texture to render to in case of cube texture
  110715. * @param requiredWidth The width of the target to render to
  110716. * @param requiredHeight The height of the target to render to
  110717. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110718. * @param depthStencilTexture The depth stencil texture to use to render
  110719. * @param lodLevel defines le lod level to bind to the frame buffer
  110720. */
  110721. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110722. /**
  110723. * Unbind the current render target texture from the webGL context
  110724. * @param texture defines the render target texture to unbind
  110725. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110726. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110727. */
  110728. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110729. /**
  110730. * Creates a dynamic vertex buffer
  110731. * @param vertices the data for the dynamic vertex buffer
  110732. * @returns the new WebGL dynamic buffer
  110733. */
  110734. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110735. /**
  110736. * Update the content of a dynamic texture
  110737. * @param texture defines the texture to update
  110738. * @param canvas defines the canvas containing the source
  110739. * @param invertY defines if data must be stored with Y axis inverted
  110740. * @param premulAlpha defines if alpha is stored as premultiplied
  110741. * @param format defines the format of the data
  110742. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110743. */
  110744. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110745. /**
  110746. * Gets a boolean indicating if all created effects are ready
  110747. * @returns true if all effects are ready
  110748. */
  110749. areAllEffectsReady(): boolean;
  110750. /**
  110751. * @hidden
  110752. * Get the current error code of the webGL context
  110753. * @returns the error code
  110754. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110755. */
  110756. getError(): number;
  110757. /** @hidden */
  110758. _getUnpackAlignement(): number;
  110759. /** @hidden */
  110760. _unpackFlipY(value: boolean): void;
  110761. /**
  110762. * Update a dynamic index buffer
  110763. * @param indexBuffer defines the target index buffer
  110764. * @param indices defines the data to update
  110765. * @param offset defines the offset in the target index buffer where update should start
  110766. */
  110767. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110768. /**
  110769. * Updates a dynamic vertex buffer.
  110770. * @param vertexBuffer the vertex buffer to update
  110771. * @param vertices the data used to update the vertex buffer
  110772. * @param byteOffset the byte offset of the data (optional)
  110773. * @param byteLength the byte length of the data (optional)
  110774. */
  110775. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110776. /** @hidden */
  110777. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110778. /** @hidden */
  110779. _bindTexture(channel: number, texture: InternalTexture): void;
  110780. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110781. /**
  110782. * 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
  110783. */
  110784. releaseEffects(): void;
  110785. displayLoadingUI(): void;
  110786. hideLoadingUI(): void;
  110787. /** @hidden */
  110788. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110789. /** @hidden */
  110790. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110791. /** @hidden */
  110792. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110793. /** @hidden */
  110794. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110795. }
  110796. }
  110797. declare module BABYLON {
  110798. /** @hidden */
  110799. export class _OcclusionDataStorage {
  110800. /** @hidden */
  110801. occlusionInternalRetryCounter: number;
  110802. /** @hidden */
  110803. isOcclusionQueryInProgress: boolean;
  110804. /** @hidden */
  110805. isOccluded: boolean;
  110806. /** @hidden */
  110807. occlusionRetryCount: number;
  110808. /** @hidden */
  110809. occlusionType: number;
  110810. /** @hidden */
  110811. occlusionQueryAlgorithmType: number;
  110812. }
  110813. interface Engine {
  110814. /**
  110815. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110816. * @return the new query
  110817. */
  110818. createQuery(): WebGLQuery;
  110819. /**
  110820. * Delete and release a webGL query
  110821. * @param query defines the query to delete
  110822. * @return the current engine
  110823. */
  110824. deleteQuery(query: WebGLQuery): Engine;
  110825. /**
  110826. * Check if a given query has resolved and got its value
  110827. * @param query defines the query to check
  110828. * @returns true if the query got its value
  110829. */
  110830. isQueryResultAvailable(query: WebGLQuery): boolean;
  110831. /**
  110832. * Gets the value of a given query
  110833. * @param query defines the query to check
  110834. * @returns the value of the query
  110835. */
  110836. getQueryResult(query: WebGLQuery): number;
  110837. /**
  110838. * Initiates an occlusion query
  110839. * @param algorithmType defines the algorithm to use
  110840. * @param query defines the query to use
  110841. * @returns the current engine
  110842. * @see http://doc.babylonjs.com/features/occlusionquery
  110843. */
  110844. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110845. /**
  110846. * Ends an occlusion query
  110847. * @see http://doc.babylonjs.com/features/occlusionquery
  110848. * @param algorithmType defines the algorithm to use
  110849. * @returns the current engine
  110850. */
  110851. endOcclusionQuery(algorithmType: number): Engine;
  110852. /**
  110853. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110854. * Please note that only one query can be issued at a time
  110855. * @returns a time token used to track the time span
  110856. */
  110857. startTimeQuery(): Nullable<_TimeToken>;
  110858. /**
  110859. * Ends a time query
  110860. * @param token defines the token used to measure the time span
  110861. * @returns the time spent (in ns)
  110862. */
  110863. endTimeQuery(token: _TimeToken): int;
  110864. /** @hidden */
  110865. _currentNonTimestampToken: Nullable<_TimeToken>;
  110866. /** @hidden */
  110867. _createTimeQuery(): WebGLQuery;
  110868. /** @hidden */
  110869. _deleteTimeQuery(query: WebGLQuery): void;
  110870. /** @hidden */
  110871. _getGlAlgorithmType(algorithmType: number): number;
  110872. /** @hidden */
  110873. _getTimeQueryResult(query: WebGLQuery): any;
  110874. /** @hidden */
  110875. _getTimeQueryAvailability(query: WebGLQuery): any;
  110876. }
  110877. interface AbstractMesh {
  110878. /**
  110879. * Backing filed
  110880. * @hidden
  110881. */
  110882. __occlusionDataStorage: _OcclusionDataStorage;
  110883. /**
  110884. * Access property
  110885. * @hidden
  110886. */
  110887. _occlusionDataStorage: _OcclusionDataStorage;
  110888. /**
  110889. * 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.
  110890. * The default value is -1 which means don't break the query and wait till the result
  110891. * @see http://doc.babylonjs.com/features/occlusionquery
  110892. */
  110893. occlusionRetryCount: number;
  110894. /**
  110895. * 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:
  110896. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110897. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110898. * * 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.
  110899. * @see http://doc.babylonjs.com/features/occlusionquery
  110900. */
  110901. occlusionType: number;
  110902. /**
  110903. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110904. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110905. * * 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.
  110906. * @see http://doc.babylonjs.com/features/occlusionquery
  110907. */
  110908. occlusionQueryAlgorithmType: number;
  110909. /**
  110910. * 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
  110911. * @see http://doc.babylonjs.com/features/occlusionquery
  110912. */
  110913. isOccluded: boolean;
  110914. /**
  110915. * Flag to check the progress status of the query
  110916. * @see http://doc.babylonjs.com/features/occlusionquery
  110917. */
  110918. isOcclusionQueryInProgress: boolean;
  110919. }
  110920. }
  110921. declare module BABYLON {
  110922. /** @hidden */
  110923. export var _forceTransformFeedbackToBundle: boolean;
  110924. interface Engine {
  110925. /**
  110926. * Creates a webGL transform feedback object
  110927. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110928. * @returns the webGL transform feedback object
  110929. */
  110930. createTransformFeedback(): WebGLTransformFeedback;
  110931. /**
  110932. * Delete a webGL transform feedback object
  110933. * @param value defines the webGL transform feedback object to delete
  110934. */
  110935. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110936. /**
  110937. * Bind a webGL transform feedback object to the webgl context
  110938. * @param value defines the webGL transform feedback object to bind
  110939. */
  110940. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110941. /**
  110942. * Begins a transform feedback operation
  110943. * @param usePoints defines if points or triangles must be used
  110944. */
  110945. beginTransformFeedback(usePoints: boolean): void;
  110946. /**
  110947. * Ends a transform feedback operation
  110948. */
  110949. endTransformFeedback(): void;
  110950. /**
  110951. * Specify the varyings to use with transform feedback
  110952. * @param program defines the associated webGL program
  110953. * @param value defines the list of strings representing the varying names
  110954. */
  110955. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110956. /**
  110957. * Bind a webGL buffer for a transform feedback operation
  110958. * @param value defines the webGL buffer to bind
  110959. */
  110960. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110961. }
  110962. }
  110963. declare module BABYLON {
  110964. /**
  110965. * Creation options of the multi render target texture.
  110966. */
  110967. export interface IMultiRenderTargetOptions {
  110968. /**
  110969. * Define if the texture needs to create mip maps after render.
  110970. */
  110971. generateMipMaps?: boolean;
  110972. /**
  110973. * Define the types of all the draw buffers we want to create
  110974. */
  110975. types?: number[];
  110976. /**
  110977. * Define the sampling modes of all the draw buffers we want to create
  110978. */
  110979. samplingModes?: number[];
  110980. /**
  110981. * Define if a depth buffer is required
  110982. */
  110983. generateDepthBuffer?: boolean;
  110984. /**
  110985. * Define if a stencil buffer is required
  110986. */
  110987. generateStencilBuffer?: boolean;
  110988. /**
  110989. * Define if a depth texture is required instead of a depth buffer
  110990. */
  110991. generateDepthTexture?: boolean;
  110992. /**
  110993. * Define the number of desired draw buffers
  110994. */
  110995. textureCount?: number;
  110996. /**
  110997. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110998. */
  110999. doNotChangeAspectRatio?: boolean;
  111000. /**
  111001. * Define the default type of the buffers we are creating
  111002. */
  111003. defaultType?: number;
  111004. }
  111005. /**
  111006. * A multi render target, like a render target provides the ability to render to a texture.
  111007. * Unlike the render target, it can render to several draw buffers in one draw.
  111008. * This is specially interesting in deferred rendering or for any effects requiring more than
  111009. * just one color from a single pass.
  111010. */
  111011. export class MultiRenderTarget extends RenderTargetTexture {
  111012. private _internalTextures;
  111013. private _textures;
  111014. private _multiRenderTargetOptions;
  111015. /**
  111016. * Get if draw buffers are currently supported by the used hardware and browser.
  111017. */
  111018. readonly isSupported: boolean;
  111019. /**
  111020. * Get the list of textures generated by the multi render target.
  111021. */
  111022. readonly textures: Texture[];
  111023. /**
  111024. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111025. */
  111026. readonly depthTexture: Texture;
  111027. /**
  111028. * Set the wrapping mode on U of all the textures we are rendering to.
  111029. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111030. */
  111031. wrapU: number;
  111032. /**
  111033. * Set the wrapping mode on V of all the textures we are rendering to.
  111034. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111035. */
  111036. wrapV: number;
  111037. /**
  111038. * Instantiate a new multi render target texture.
  111039. * A multi render target, like a render target provides the ability to render to a texture.
  111040. * Unlike the render target, it can render to several draw buffers in one draw.
  111041. * This is specially interesting in deferred rendering or for any effects requiring more than
  111042. * just one color from a single pass.
  111043. * @param name Define the name of the texture
  111044. * @param size Define the size of the buffers to render to
  111045. * @param count Define the number of target we are rendering into
  111046. * @param scene Define the scene the texture belongs to
  111047. * @param options Define the options used to create the multi render target
  111048. */
  111049. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111050. /** @hidden */
  111051. _rebuild(): void;
  111052. private _createInternalTextures;
  111053. private _createTextures;
  111054. /**
  111055. * Define the number of samples used if MSAA is enabled.
  111056. */
  111057. samples: number;
  111058. /**
  111059. * Resize all the textures in the multi render target.
  111060. * Be carrefull as it will recreate all the data in the new texture.
  111061. * @param size Define the new size
  111062. */
  111063. resize(size: any): void;
  111064. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111065. /**
  111066. * Dispose the render targets and their associated resources
  111067. */
  111068. dispose(): void;
  111069. /**
  111070. * Release all the underlying texture used as draw buffers.
  111071. */
  111072. releaseInternalTextures(): void;
  111073. }
  111074. }
  111075. declare module BABYLON {
  111076. interface ThinEngine {
  111077. /**
  111078. * Unbind a list of render target textures from the webGL context
  111079. * This is used only when drawBuffer extension or webGL2 are active
  111080. * @param textures defines the render target textures to unbind
  111081. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111082. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111083. */
  111084. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111085. /**
  111086. * Create a multi render target texture
  111087. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111088. * @param size defines the size of the texture
  111089. * @param options defines the creation options
  111090. * @returns the cube texture as an InternalTexture
  111091. */
  111092. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111093. /**
  111094. * Update the sample count for a given multiple render target texture
  111095. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111096. * @param textures defines the textures to update
  111097. * @param samples defines the sample count to set
  111098. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111099. */
  111100. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111101. }
  111102. }
  111103. declare module BABYLON {
  111104. /**
  111105. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111106. */
  111107. export interface CubeMapInfo {
  111108. /**
  111109. * The pixel array for the front face.
  111110. * This is stored in format, left to right, up to down format.
  111111. */
  111112. front: Nullable<ArrayBufferView>;
  111113. /**
  111114. * The pixel array for the back face.
  111115. * This is stored in format, left to right, up to down format.
  111116. */
  111117. back: Nullable<ArrayBufferView>;
  111118. /**
  111119. * The pixel array for the left face.
  111120. * This is stored in format, left to right, up to down format.
  111121. */
  111122. left: Nullable<ArrayBufferView>;
  111123. /**
  111124. * The pixel array for the right face.
  111125. * This is stored in format, left to right, up to down format.
  111126. */
  111127. right: Nullable<ArrayBufferView>;
  111128. /**
  111129. * The pixel array for the up face.
  111130. * This is stored in format, left to right, up to down format.
  111131. */
  111132. up: Nullable<ArrayBufferView>;
  111133. /**
  111134. * The pixel array for the down face.
  111135. * This is stored in format, left to right, up to down format.
  111136. */
  111137. down: Nullable<ArrayBufferView>;
  111138. /**
  111139. * The size of the cubemap stored.
  111140. *
  111141. * Each faces will be size * size pixels.
  111142. */
  111143. size: number;
  111144. /**
  111145. * The format of the texture.
  111146. *
  111147. * RGBA, RGB.
  111148. */
  111149. format: number;
  111150. /**
  111151. * The type of the texture data.
  111152. *
  111153. * UNSIGNED_INT, FLOAT.
  111154. */
  111155. type: number;
  111156. /**
  111157. * Specifies whether the texture is in gamma space.
  111158. */
  111159. gammaSpace: boolean;
  111160. }
  111161. /**
  111162. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111163. */
  111164. export class PanoramaToCubeMapTools {
  111165. private static FACE_FRONT;
  111166. private static FACE_BACK;
  111167. private static FACE_RIGHT;
  111168. private static FACE_LEFT;
  111169. private static FACE_DOWN;
  111170. private static FACE_UP;
  111171. /**
  111172. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111173. *
  111174. * @param float32Array The source data.
  111175. * @param inputWidth The width of the input panorama.
  111176. * @param inputHeight The height of the input panorama.
  111177. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111178. * @return The cubemap data
  111179. */
  111180. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111181. private static CreateCubemapTexture;
  111182. private static CalcProjectionSpherical;
  111183. }
  111184. }
  111185. declare module BABYLON {
  111186. /**
  111187. * Helper class dealing with the extraction of spherical polynomial dataArray
  111188. * from a cube map.
  111189. */
  111190. export class CubeMapToSphericalPolynomialTools {
  111191. private static FileFaces;
  111192. /**
  111193. * Converts a texture to the according Spherical Polynomial data.
  111194. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111195. *
  111196. * @param texture The texture to extract the information from.
  111197. * @return The Spherical Polynomial data.
  111198. */
  111199. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111200. /**
  111201. * Converts a cubemap to the according Spherical Polynomial data.
  111202. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111203. *
  111204. * @param cubeInfo The Cube map to extract the information from.
  111205. * @return The Spherical Polynomial data.
  111206. */
  111207. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111208. }
  111209. }
  111210. declare module BABYLON {
  111211. interface BaseTexture {
  111212. /**
  111213. * Get the polynomial representation of the texture data.
  111214. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111215. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111216. */
  111217. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111218. }
  111219. }
  111220. declare module BABYLON {
  111221. /** @hidden */
  111222. export var rgbdEncodePixelShader: {
  111223. name: string;
  111224. shader: string;
  111225. };
  111226. }
  111227. declare module BABYLON {
  111228. /** @hidden */
  111229. export var rgbdDecodePixelShader: {
  111230. name: string;
  111231. shader: string;
  111232. };
  111233. }
  111234. declare module BABYLON {
  111235. /**
  111236. * Raw texture data and descriptor sufficient for WebGL texture upload
  111237. */
  111238. export interface EnvironmentTextureInfo {
  111239. /**
  111240. * Version of the environment map
  111241. */
  111242. version: number;
  111243. /**
  111244. * Width of image
  111245. */
  111246. width: number;
  111247. /**
  111248. * Irradiance information stored in the file.
  111249. */
  111250. irradiance: any;
  111251. /**
  111252. * Specular information stored in the file.
  111253. */
  111254. specular: any;
  111255. }
  111256. /**
  111257. * Defines One Image in the file. It requires only the position in the file
  111258. * as well as the length.
  111259. */
  111260. interface BufferImageData {
  111261. /**
  111262. * Length of the image data.
  111263. */
  111264. length: number;
  111265. /**
  111266. * Position of the data from the null terminator delimiting the end of the JSON.
  111267. */
  111268. position: number;
  111269. }
  111270. /**
  111271. * Defines the specular data enclosed in the file.
  111272. * This corresponds to the version 1 of the data.
  111273. */
  111274. export interface EnvironmentTextureSpecularInfoV1 {
  111275. /**
  111276. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111277. */
  111278. specularDataPosition?: number;
  111279. /**
  111280. * This contains all the images data needed to reconstruct the cubemap.
  111281. */
  111282. mipmaps: Array<BufferImageData>;
  111283. /**
  111284. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111285. */
  111286. lodGenerationScale: number;
  111287. }
  111288. /**
  111289. * Sets of helpers addressing the serialization and deserialization of environment texture
  111290. * stored in a BabylonJS env file.
  111291. * Those files are usually stored as .env files.
  111292. */
  111293. export class EnvironmentTextureTools {
  111294. /**
  111295. * Magic number identifying the env file.
  111296. */
  111297. private static _MagicBytes;
  111298. /**
  111299. * Gets the environment info from an env file.
  111300. * @param data The array buffer containing the .env bytes.
  111301. * @returns the environment file info (the json header) if successfully parsed.
  111302. */
  111303. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111304. /**
  111305. * Creates an environment texture from a loaded cube texture.
  111306. * @param texture defines the cube texture to convert in env file
  111307. * @return a promise containing the environment data if succesfull.
  111308. */
  111309. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111310. /**
  111311. * Creates a JSON representation of the spherical data.
  111312. * @param texture defines the texture containing the polynomials
  111313. * @return the JSON representation of the spherical info
  111314. */
  111315. private static _CreateEnvTextureIrradiance;
  111316. /**
  111317. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111318. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111319. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111320. * @return the views described by info providing access to the underlying buffer
  111321. */
  111322. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111323. /**
  111324. * Uploads the texture info contained in the env file to the GPU.
  111325. * @param texture defines the internal texture to upload to
  111326. * @param arrayBuffer defines the buffer cotaining the data to load
  111327. * @param info defines the texture info retrieved through the GetEnvInfo method
  111328. * @returns a promise
  111329. */
  111330. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111331. /**
  111332. * Uploads the levels of image data to the GPU.
  111333. * @param texture defines the internal texture to upload to
  111334. * @param imageData defines the array buffer views of image data [mipmap][face]
  111335. * @returns a promise
  111336. */
  111337. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111338. /**
  111339. * Uploads spherical polynomials information to the texture.
  111340. * @param texture defines the texture we are trying to upload the information to
  111341. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111342. */
  111343. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111344. /** @hidden */
  111345. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111346. }
  111347. }
  111348. declare module BABYLON {
  111349. /**
  111350. * Contains position and normal vectors for a vertex
  111351. */
  111352. export class PositionNormalVertex {
  111353. /** the position of the vertex (defaut: 0,0,0) */
  111354. position: Vector3;
  111355. /** the normal of the vertex (defaut: 0,1,0) */
  111356. normal: Vector3;
  111357. /**
  111358. * Creates a PositionNormalVertex
  111359. * @param position the position of the vertex (defaut: 0,0,0)
  111360. * @param normal the normal of the vertex (defaut: 0,1,0)
  111361. */
  111362. constructor(
  111363. /** the position of the vertex (defaut: 0,0,0) */
  111364. position?: Vector3,
  111365. /** the normal of the vertex (defaut: 0,1,0) */
  111366. normal?: Vector3);
  111367. /**
  111368. * Clones the PositionNormalVertex
  111369. * @returns the cloned PositionNormalVertex
  111370. */
  111371. clone(): PositionNormalVertex;
  111372. }
  111373. /**
  111374. * Contains position, normal and uv vectors for a vertex
  111375. */
  111376. export class PositionNormalTextureVertex {
  111377. /** the position of the vertex (defaut: 0,0,0) */
  111378. position: Vector3;
  111379. /** the normal of the vertex (defaut: 0,1,0) */
  111380. normal: Vector3;
  111381. /** the uv of the vertex (default: 0,0) */
  111382. uv: Vector2;
  111383. /**
  111384. * Creates a PositionNormalTextureVertex
  111385. * @param position the position of the vertex (defaut: 0,0,0)
  111386. * @param normal the normal of the vertex (defaut: 0,1,0)
  111387. * @param uv the uv of the vertex (default: 0,0)
  111388. */
  111389. constructor(
  111390. /** the position of the vertex (defaut: 0,0,0) */
  111391. position?: Vector3,
  111392. /** the normal of the vertex (defaut: 0,1,0) */
  111393. normal?: Vector3,
  111394. /** the uv of the vertex (default: 0,0) */
  111395. uv?: Vector2);
  111396. /**
  111397. * Clones the PositionNormalTextureVertex
  111398. * @returns the cloned PositionNormalTextureVertex
  111399. */
  111400. clone(): PositionNormalTextureVertex;
  111401. }
  111402. }
  111403. declare module BABYLON {
  111404. /** @hidden */
  111405. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111406. private _genericAttributeLocation;
  111407. private _varyingLocationCount;
  111408. private _varyingLocationMap;
  111409. private _replacements;
  111410. private _textureCount;
  111411. private _uniforms;
  111412. lineProcessor(line: string): string;
  111413. attributeProcessor(attribute: string): string;
  111414. varyingProcessor(varying: string, isFragment: boolean): string;
  111415. uniformProcessor(uniform: string): string;
  111416. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111417. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111418. }
  111419. }
  111420. declare module BABYLON {
  111421. /**
  111422. * Container for accessors for natively-stored mesh data buffers.
  111423. */
  111424. class NativeDataBuffer extends DataBuffer {
  111425. /**
  111426. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111427. */
  111428. nativeIndexBuffer?: any;
  111429. /**
  111430. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111431. */
  111432. nativeVertexBuffer?: any;
  111433. }
  111434. /** @hidden */
  111435. export class NativeEngine extends Engine {
  111436. private readonly _native;
  111437. getHardwareScalingLevel(): number;
  111438. constructor();
  111439. /**
  111440. * Can be used to override the current requestAnimationFrame requester.
  111441. * @hidden
  111442. */
  111443. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111444. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111445. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111446. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111447. recordVertexArrayObject(vertexBuffers: {
  111448. [key: string]: VertexBuffer;
  111449. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111450. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111451. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111452. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111453. /**
  111454. * Draw a list of indexed primitives
  111455. * @param fillMode defines the primitive to use
  111456. * @param indexStart defines the starting index
  111457. * @param indexCount defines the number of index to draw
  111458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111459. */
  111460. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111461. /**
  111462. * Draw a list of unindexed primitives
  111463. * @param fillMode defines the primitive to use
  111464. * @param verticesStart defines the index of first vertex to draw
  111465. * @param verticesCount defines the count of vertices to draw
  111466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111467. */
  111468. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111469. createPipelineContext(): IPipelineContext;
  111470. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111471. /** @hidden */
  111472. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111473. /** @hidden */
  111474. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111475. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111476. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111477. protected _setProgram(program: WebGLProgram): void;
  111478. _releaseEffect(effect: Effect): void;
  111479. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111480. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111481. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111482. bindSamplers(effect: Effect): void;
  111483. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111484. getRenderWidth(useScreen?: boolean): number;
  111485. getRenderHeight(useScreen?: boolean): number;
  111486. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111487. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111488. /**
  111489. * Set the z offset to apply to current rendering
  111490. * @param value defines the offset to apply
  111491. */
  111492. setZOffset(value: number): void;
  111493. /**
  111494. * Gets the current value of the zOffset
  111495. * @returns the current zOffset state
  111496. */
  111497. getZOffset(): number;
  111498. /**
  111499. * Enable or disable depth buffering
  111500. * @param enable defines the state to set
  111501. */
  111502. setDepthBuffer(enable: boolean): void;
  111503. /**
  111504. * Gets a boolean indicating if depth writing is enabled
  111505. * @returns the current depth writing state
  111506. */
  111507. getDepthWrite(): boolean;
  111508. /**
  111509. * Enable or disable depth writing
  111510. * @param enable defines the state to set
  111511. */
  111512. setDepthWrite(enable: boolean): void;
  111513. /**
  111514. * Enable or disable color writing
  111515. * @param enable defines the state to set
  111516. */
  111517. setColorWrite(enable: boolean): void;
  111518. /**
  111519. * Gets a boolean indicating if color writing is enabled
  111520. * @returns the current color writing state
  111521. */
  111522. getColorWrite(): boolean;
  111523. /**
  111524. * Sets alpha constants used by some alpha blending modes
  111525. * @param r defines the red component
  111526. * @param g defines the green component
  111527. * @param b defines the blue component
  111528. * @param a defines the alpha component
  111529. */
  111530. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111531. /**
  111532. * Sets the current alpha mode
  111533. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111534. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111535. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111536. */
  111537. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111538. /**
  111539. * Gets the current alpha mode
  111540. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111541. * @returns the current alpha mode
  111542. */
  111543. getAlphaMode(): number;
  111544. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111545. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111546. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111547. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111548. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111549. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111550. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111551. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111552. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111553. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111554. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111555. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111556. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111557. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111558. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111559. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111560. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111561. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111562. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111563. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111564. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111565. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111566. wipeCaches(bruteForce?: boolean): void;
  111567. _createTexture(): WebGLTexture;
  111568. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111569. /**
  111570. * Usually called from BABYLON.Texture.ts.
  111571. * Passed information to create a WebGLTexture
  111572. * @param urlArg defines a value which contains one of the following:
  111573. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111574. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111575. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111576. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111577. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111578. * @param scene needed for loading to the correct scene
  111579. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111580. * @param onLoad optional callback to be called upon successful completion
  111581. * @param onError optional callback to be called upon failure
  111582. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111583. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111584. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111585. * @param forcedExtension defines the extension to use to pick the right loader
  111586. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111587. */
  111588. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  111589. /**
  111590. * Creates a cube texture
  111591. * @param rootUrl defines the url where the files to load is located
  111592. * @param scene defines the current scene
  111593. * @param files defines the list of files to load (1 per face)
  111594. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111595. * @param onLoad defines an optional callback raised when the texture is loaded
  111596. * @param onError defines an optional callback raised if there is an issue to load the texture
  111597. * @param format defines the format of the data
  111598. * @param forcedExtension defines the extension to use to pick the right loader
  111599. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111600. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111601. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111602. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111603. * @returns the cube texture as an InternalTexture
  111604. */
  111605. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  111606. private _getSamplingFilter;
  111607. private static _GetNativeTextureFormat;
  111608. createRenderTargetTexture(size: number | {
  111609. width: number;
  111610. height: number;
  111611. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111612. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111613. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111614. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111615. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111616. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111617. /**
  111618. * Updates a dynamic vertex buffer.
  111619. * @param vertexBuffer the vertex buffer to update
  111620. * @param data the data used to update the vertex buffer
  111621. * @param byteOffset the byte offset of the data (optional)
  111622. * @param byteLength the byte length of the data (optional)
  111623. */
  111624. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111625. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111626. private _updateAnisotropicLevel;
  111627. private _getAddressMode;
  111628. /** @hidden */
  111629. _bindTexture(channel: number, texture: InternalTexture): void;
  111630. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111631. releaseEffects(): void;
  111632. /** @hidden */
  111633. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111634. /** @hidden */
  111635. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111636. /** @hidden */
  111637. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111638. /** @hidden */
  111639. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111640. }
  111641. }
  111642. declare module BABYLON {
  111643. /**
  111644. * Gather the list of clipboard event types as constants.
  111645. */
  111646. export class ClipboardEventTypes {
  111647. /**
  111648. * The clipboard event is fired when a copy command is active (pressed).
  111649. */
  111650. static readonly COPY: number;
  111651. /**
  111652. * The clipboard event is fired when a cut command is active (pressed).
  111653. */
  111654. static readonly CUT: number;
  111655. /**
  111656. * The clipboard event is fired when a paste command is active (pressed).
  111657. */
  111658. static readonly PASTE: number;
  111659. }
  111660. /**
  111661. * This class is used to store clipboard related info for the onClipboardObservable event.
  111662. */
  111663. export class ClipboardInfo {
  111664. /**
  111665. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111666. */
  111667. type: number;
  111668. /**
  111669. * Defines the related dom event
  111670. */
  111671. event: ClipboardEvent;
  111672. /**
  111673. *Creates an instance of ClipboardInfo.
  111674. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111675. * @param event Defines the related dom event
  111676. */
  111677. constructor(
  111678. /**
  111679. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111680. */
  111681. type: number,
  111682. /**
  111683. * Defines the related dom event
  111684. */
  111685. event: ClipboardEvent);
  111686. /**
  111687. * Get the clipboard event's type from the keycode.
  111688. * @param keyCode Defines the keyCode for the current keyboard event.
  111689. * @return {number}
  111690. */
  111691. static GetTypeFromCharacter(keyCode: number): number;
  111692. }
  111693. }
  111694. declare module BABYLON {
  111695. /**
  111696. * Google Daydream controller
  111697. */
  111698. export class DaydreamController extends WebVRController {
  111699. /**
  111700. * Base Url for the controller model.
  111701. */
  111702. static MODEL_BASE_URL: string;
  111703. /**
  111704. * File name for the controller model.
  111705. */
  111706. static MODEL_FILENAME: string;
  111707. /**
  111708. * Gamepad Id prefix used to identify Daydream Controller.
  111709. */
  111710. static readonly GAMEPAD_ID_PREFIX: string;
  111711. /**
  111712. * Creates a new DaydreamController from a gamepad
  111713. * @param vrGamepad the gamepad that the controller should be created from
  111714. */
  111715. constructor(vrGamepad: any);
  111716. /**
  111717. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111718. * @param scene scene in which to add meshes
  111719. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111720. */
  111721. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111722. /**
  111723. * Called once for each button that changed state since the last frame
  111724. * @param buttonIdx Which button index changed
  111725. * @param state New state of the button
  111726. * @param changes Which properties on the state changed since last frame
  111727. */
  111728. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111729. }
  111730. }
  111731. declare module BABYLON {
  111732. /**
  111733. * Gear VR Controller
  111734. */
  111735. export class GearVRController extends WebVRController {
  111736. /**
  111737. * Base Url for the controller model.
  111738. */
  111739. static MODEL_BASE_URL: string;
  111740. /**
  111741. * File name for the controller model.
  111742. */
  111743. static MODEL_FILENAME: string;
  111744. /**
  111745. * Gamepad Id prefix used to identify this controller.
  111746. */
  111747. static readonly GAMEPAD_ID_PREFIX: string;
  111748. private readonly _buttonIndexToObservableNameMap;
  111749. /**
  111750. * Creates a new GearVRController from a gamepad
  111751. * @param vrGamepad the gamepad that the controller should be created from
  111752. */
  111753. constructor(vrGamepad: any);
  111754. /**
  111755. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111756. * @param scene scene in which to add meshes
  111757. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111758. */
  111759. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111760. /**
  111761. * Called once for each button that changed state since the last frame
  111762. * @param buttonIdx Which button index changed
  111763. * @param state New state of the button
  111764. * @param changes Which properties on the state changed since last frame
  111765. */
  111766. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111767. }
  111768. }
  111769. declare module BABYLON {
  111770. /**
  111771. * Class containing static functions to help procedurally build meshes
  111772. */
  111773. export class PolyhedronBuilder {
  111774. /**
  111775. * Creates a polyhedron mesh
  111776. * * 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
  111777. * * The parameter `size` (positive float, default 1) sets the polygon size
  111778. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111779. * * 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`
  111780. * * 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
  111781. * * 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)`)
  111782. * * 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
  111783. * * 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
  111784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111787. * @param name defines the name of the mesh
  111788. * @param options defines the options used to create the mesh
  111789. * @param scene defines the hosting scene
  111790. * @returns the polyhedron mesh
  111791. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111792. */
  111793. static CreatePolyhedron(name: string, options: {
  111794. type?: number;
  111795. size?: number;
  111796. sizeX?: number;
  111797. sizeY?: number;
  111798. sizeZ?: number;
  111799. custom?: any;
  111800. faceUV?: Vector4[];
  111801. faceColors?: Color4[];
  111802. flat?: boolean;
  111803. updatable?: boolean;
  111804. sideOrientation?: number;
  111805. frontUVs?: Vector4;
  111806. backUVs?: Vector4;
  111807. }, scene?: Nullable<Scene>): Mesh;
  111808. }
  111809. }
  111810. declare module BABYLON {
  111811. /**
  111812. * Gizmo that enables scaling a mesh along 3 axis
  111813. */
  111814. export class ScaleGizmo extends Gizmo {
  111815. /**
  111816. * Internal gizmo used for interactions on the x axis
  111817. */
  111818. xGizmo: AxisScaleGizmo;
  111819. /**
  111820. * Internal gizmo used for interactions on the y axis
  111821. */
  111822. yGizmo: AxisScaleGizmo;
  111823. /**
  111824. * Internal gizmo used for interactions on the z axis
  111825. */
  111826. zGizmo: AxisScaleGizmo;
  111827. /**
  111828. * Internal gizmo used to scale all axis equally
  111829. */
  111830. uniformScaleGizmo: AxisScaleGizmo;
  111831. private _meshAttached;
  111832. private _updateGizmoRotationToMatchAttachedMesh;
  111833. private _snapDistance;
  111834. private _scaleRatio;
  111835. private _uniformScalingMesh;
  111836. private _octahedron;
  111837. /** Fires an event when any of it's sub gizmos are dragged */
  111838. onDragStartObservable: Observable<unknown>;
  111839. /** Fires an event when any of it's sub gizmos are released from dragging */
  111840. onDragEndObservable: Observable<unknown>;
  111841. attachedMesh: Nullable<AbstractMesh>;
  111842. /**
  111843. * Creates a ScaleGizmo
  111844. * @param gizmoLayer The utility layer the gizmo will be added to
  111845. */
  111846. constructor(gizmoLayer?: UtilityLayerRenderer);
  111847. updateGizmoRotationToMatchAttachedMesh: boolean;
  111848. /**
  111849. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111850. */
  111851. snapDistance: number;
  111852. /**
  111853. * Ratio for the scale of the gizmo (Default: 1)
  111854. */
  111855. scaleRatio: number;
  111856. /**
  111857. * Disposes of the gizmo
  111858. */
  111859. dispose(): void;
  111860. }
  111861. }
  111862. declare module BABYLON {
  111863. /**
  111864. * Single axis scale gizmo
  111865. */
  111866. export class AxisScaleGizmo extends Gizmo {
  111867. /**
  111868. * Drag behavior responsible for the gizmos dragging interactions
  111869. */
  111870. dragBehavior: PointerDragBehavior;
  111871. private _pointerObserver;
  111872. /**
  111873. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111874. */
  111875. snapDistance: number;
  111876. /**
  111877. * Event that fires each time the gizmo snaps to a new location.
  111878. * * snapDistance is the the change in distance
  111879. */
  111880. onSnapObservable: Observable<{
  111881. snapDistance: number;
  111882. }>;
  111883. /**
  111884. * If the scaling operation should be done on all axis (default: false)
  111885. */
  111886. uniformScaling: boolean;
  111887. private _isEnabled;
  111888. private _parent;
  111889. private _arrow;
  111890. private _coloredMaterial;
  111891. private _hoverMaterial;
  111892. /**
  111893. * Creates an AxisScaleGizmo
  111894. * @param gizmoLayer The utility layer the gizmo will be added to
  111895. * @param dragAxis The axis which the gizmo will be able to scale on
  111896. * @param color The color of the gizmo
  111897. */
  111898. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111899. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111900. /**
  111901. * If the gizmo is enabled
  111902. */
  111903. isEnabled: boolean;
  111904. /**
  111905. * Disposes of the gizmo
  111906. */
  111907. dispose(): void;
  111908. /**
  111909. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111910. * @param mesh The mesh to replace the default mesh of the gizmo
  111911. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111912. */
  111913. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111914. }
  111915. }
  111916. declare module BABYLON {
  111917. /**
  111918. * Bounding box gizmo
  111919. */
  111920. export class BoundingBoxGizmo extends Gizmo {
  111921. private _lineBoundingBox;
  111922. private _rotateSpheresParent;
  111923. private _scaleBoxesParent;
  111924. private _boundingDimensions;
  111925. private _renderObserver;
  111926. private _pointerObserver;
  111927. private _scaleDragSpeed;
  111928. private _tmpQuaternion;
  111929. private _tmpVector;
  111930. private _tmpRotationMatrix;
  111931. /**
  111932. * 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)
  111933. */
  111934. ignoreChildren: boolean;
  111935. /**
  111936. * 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)
  111937. */
  111938. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111939. /**
  111940. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111941. */
  111942. rotationSphereSize: number;
  111943. /**
  111944. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111945. */
  111946. scaleBoxSize: number;
  111947. /**
  111948. * 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)
  111949. */
  111950. fixedDragMeshScreenSize: boolean;
  111951. /**
  111952. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111953. */
  111954. fixedDragMeshScreenSizeDistanceFactor: number;
  111955. /**
  111956. * Fired when a rotation sphere or scale box is dragged
  111957. */
  111958. onDragStartObservable: Observable<{}>;
  111959. /**
  111960. * Fired when a scale box is dragged
  111961. */
  111962. onScaleBoxDragObservable: Observable<{}>;
  111963. /**
  111964. * Fired when a scale box drag is ended
  111965. */
  111966. onScaleBoxDragEndObservable: Observable<{}>;
  111967. /**
  111968. * Fired when a rotation sphere is dragged
  111969. */
  111970. onRotationSphereDragObservable: Observable<{}>;
  111971. /**
  111972. * Fired when a rotation sphere drag is ended
  111973. */
  111974. onRotationSphereDragEndObservable: Observable<{}>;
  111975. /**
  111976. * 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)
  111977. */
  111978. scalePivot: Nullable<Vector3>;
  111979. /**
  111980. * Mesh used as a pivot to rotate the attached mesh
  111981. */
  111982. private _anchorMesh;
  111983. private _existingMeshScale;
  111984. private _dragMesh;
  111985. private pointerDragBehavior;
  111986. private coloredMaterial;
  111987. private hoverColoredMaterial;
  111988. /**
  111989. * Sets the color of the bounding box gizmo
  111990. * @param color the color to set
  111991. */
  111992. setColor(color: Color3): void;
  111993. /**
  111994. * Creates an BoundingBoxGizmo
  111995. * @param gizmoLayer The utility layer the gizmo will be added to
  111996. * @param color The color of the gizmo
  111997. */
  111998. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111999. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112000. private _selectNode;
  112001. /**
  112002. * Updates the bounding box information for the Gizmo
  112003. */
  112004. updateBoundingBox(): void;
  112005. private _updateRotationSpheres;
  112006. private _updateScaleBoxes;
  112007. /**
  112008. * Enables rotation on the specified axis and disables rotation on the others
  112009. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112010. */
  112011. setEnabledRotationAxis(axis: string): void;
  112012. /**
  112013. * Enables/disables scaling
  112014. * @param enable if scaling should be enabled
  112015. */
  112016. setEnabledScaling(enable: boolean): void;
  112017. private _updateDummy;
  112018. /**
  112019. * Enables a pointer drag behavior on the bounding box of the gizmo
  112020. */
  112021. enableDragBehavior(): void;
  112022. /**
  112023. * Disposes of the gizmo
  112024. */
  112025. dispose(): void;
  112026. /**
  112027. * 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)
  112028. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112029. * @returns the bounding box mesh with the passed in mesh as a child
  112030. */
  112031. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112032. /**
  112033. * CustomMeshes are not supported by this gizmo
  112034. * @param mesh The mesh to replace the default mesh of the gizmo
  112035. */
  112036. setCustomMesh(mesh: Mesh): void;
  112037. }
  112038. }
  112039. declare module BABYLON {
  112040. /**
  112041. * Single plane rotation gizmo
  112042. */
  112043. export class PlaneRotationGizmo extends Gizmo {
  112044. /**
  112045. * Drag behavior responsible for the gizmos dragging interactions
  112046. */
  112047. dragBehavior: PointerDragBehavior;
  112048. private _pointerObserver;
  112049. /**
  112050. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112051. */
  112052. snapDistance: number;
  112053. /**
  112054. * Event that fires each time the gizmo snaps to a new location.
  112055. * * snapDistance is the the change in distance
  112056. */
  112057. onSnapObservable: Observable<{
  112058. snapDistance: number;
  112059. }>;
  112060. private _isEnabled;
  112061. private _parent;
  112062. /**
  112063. * Creates a PlaneRotationGizmo
  112064. * @param gizmoLayer The utility layer the gizmo will be added to
  112065. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112066. * @param color The color of the gizmo
  112067. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112068. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112069. */
  112070. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112071. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112072. /**
  112073. * If the gizmo is enabled
  112074. */
  112075. isEnabled: boolean;
  112076. /**
  112077. * Disposes of the gizmo
  112078. */
  112079. dispose(): void;
  112080. }
  112081. }
  112082. declare module BABYLON {
  112083. /**
  112084. * Gizmo that enables rotating a mesh along 3 axis
  112085. */
  112086. export class RotationGizmo extends Gizmo {
  112087. /**
  112088. * Internal gizmo used for interactions on the x axis
  112089. */
  112090. xGizmo: PlaneRotationGizmo;
  112091. /**
  112092. * Internal gizmo used for interactions on the y axis
  112093. */
  112094. yGizmo: PlaneRotationGizmo;
  112095. /**
  112096. * Internal gizmo used for interactions on the z axis
  112097. */
  112098. zGizmo: PlaneRotationGizmo;
  112099. /** Fires an event when any of it's sub gizmos are dragged */
  112100. onDragStartObservable: Observable<unknown>;
  112101. /** Fires an event when any of it's sub gizmos are released from dragging */
  112102. onDragEndObservable: Observable<unknown>;
  112103. private _meshAttached;
  112104. attachedMesh: Nullable<AbstractMesh>;
  112105. /**
  112106. * Creates a RotationGizmo
  112107. * @param gizmoLayer The utility layer the gizmo will be added to
  112108. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112109. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112110. */
  112111. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112112. updateGizmoRotationToMatchAttachedMesh: boolean;
  112113. /**
  112114. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112115. */
  112116. snapDistance: number;
  112117. /**
  112118. * Ratio for the scale of the gizmo (Default: 1)
  112119. */
  112120. scaleRatio: number;
  112121. /**
  112122. * Disposes of the gizmo
  112123. */
  112124. dispose(): void;
  112125. /**
  112126. * CustomMeshes are not supported by this gizmo
  112127. * @param mesh The mesh to replace the default mesh of the gizmo
  112128. */
  112129. setCustomMesh(mesh: Mesh): void;
  112130. }
  112131. }
  112132. declare module BABYLON {
  112133. /**
  112134. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112135. */
  112136. export class GizmoManager implements IDisposable {
  112137. private scene;
  112138. /**
  112139. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112140. */
  112141. gizmos: {
  112142. positionGizmo: Nullable<PositionGizmo>;
  112143. rotationGizmo: Nullable<RotationGizmo>;
  112144. scaleGizmo: Nullable<ScaleGizmo>;
  112145. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112146. };
  112147. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112148. clearGizmoOnEmptyPointerEvent: boolean;
  112149. /** Fires an event when the manager is attached to a mesh */
  112150. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112151. private _gizmosEnabled;
  112152. private _pointerObserver;
  112153. private _attachedMesh;
  112154. private _boundingBoxColor;
  112155. private _defaultUtilityLayer;
  112156. private _defaultKeepDepthUtilityLayer;
  112157. /**
  112158. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112159. */
  112160. boundingBoxDragBehavior: SixDofDragBehavior;
  112161. /**
  112162. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112163. */
  112164. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112165. /**
  112166. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112167. */
  112168. usePointerToAttachGizmos: boolean;
  112169. /**
  112170. * Utility layer that the bounding box gizmo belongs to
  112171. */
  112172. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112173. /**
  112174. * Utility layer that all gizmos besides bounding box belong to
  112175. */
  112176. readonly utilityLayer: UtilityLayerRenderer;
  112177. /**
  112178. * Instatiates a gizmo manager
  112179. * @param scene the scene to overlay the gizmos on top of
  112180. */
  112181. constructor(scene: Scene);
  112182. /**
  112183. * Attaches a set of gizmos to the specified mesh
  112184. * @param mesh The mesh the gizmo's should be attached to
  112185. */
  112186. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112187. /**
  112188. * If the position gizmo is enabled
  112189. */
  112190. positionGizmoEnabled: boolean;
  112191. /**
  112192. * If the rotation gizmo is enabled
  112193. */
  112194. rotationGizmoEnabled: boolean;
  112195. /**
  112196. * If the scale gizmo is enabled
  112197. */
  112198. scaleGizmoEnabled: boolean;
  112199. /**
  112200. * If the boundingBox gizmo is enabled
  112201. */
  112202. boundingBoxGizmoEnabled: boolean;
  112203. /**
  112204. * Disposes of the gizmo manager
  112205. */
  112206. dispose(): void;
  112207. }
  112208. }
  112209. declare module BABYLON {
  112210. /**
  112211. * A directional light is defined by a direction (what a surprise!).
  112212. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112213. * 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.
  112214. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112215. */
  112216. export class DirectionalLight extends ShadowLight {
  112217. private _shadowFrustumSize;
  112218. /**
  112219. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112220. */
  112221. /**
  112222. * Specifies a fix frustum size for the shadow generation.
  112223. */
  112224. shadowFrustumSize: number;
  112225. private _shadowOrthoScale;
  112226. /**
  112227. * Gets the shadow projection scale against the optimal computed one.
  112228. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112229. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112230. */
  112231. /**
  112232. * Sets the shadow projection scale against the optimal computed one.
  112233. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112234. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112235. */
  112236. shadowOrthoScale: number;
  112237. /**
  112238. * Automatically compute the projection matrix to best fit (including all the casters)
  112239. * on each frame.
  112240. */
  112241. autoUpdateExtends: boolean;
  112242. private _orthoLeft;
  112243. private _orthoRight;
  112244. private _orthoTop;
  112245. private _orthoBottom;
  112246. /**
  112247. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112248. * The directional light is emitted from everywhere in the given direction.
  112249. * It can cast shadows.
  112250. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112251. * @param name The friendly name of the light
  112252. * @param direction The direction of the light
  112253. * @param scene The scene the light belongs to
  112254. */
  112255. constructor(name: string, direction: Vector3, scene: Scene);
  112256. /**
  112257. * Returns the string "DirectionalLight".
  112258. * @return The class name
  112259. */
  112260. getClassName(): string;
  112261. /**
  112262. * Returns the integer 1.
  112263. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112264. */
  112265. getTypeID(): number;
  112266. /**
  112267. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112268. * Returns the DirectionalLight Shadow projection matrix.
  112269. */
  112270. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112271. /**
  112272. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112273. * Returns the DirectionalLight Shadow projection matrix.
  112274. */
  112275. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112276. /**
  112277. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112278. * Returns the DirectionalLight Shadow projection matrix.
  112279. */
  112280. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112281. protected _buildUniformLayout(): void;
  112282. /**
  112283. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112284. * @param effect The effect to update
  112285. * @param lightIndex The index of the light in the effect to update
  112286. * @returns The directional light
  112287. */
  112288. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112289. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112290. /**
  112291. * Gets the minZ used for shadow according to both the scene and the light.
  112292. *
  112293. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112294. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112295. * @param activeCamera The camera we are returning the min for
  112296. * @returns the depth min z
  112297. */
  112298. getDepthMinZ(activeCamera: Camera): number;
  112299. /**
  112300. * Gets the maxZ used for shadow according to both the scene and the light.
  112301. *
  112302. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112303. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112304. * @param activeCamera The camera we are returning the max for
  112305. * @returns the depth max z
  112306. */
  112307. getDepthMaxZ(activeCamera: Camera): number;
  112308. /**
  112309. * Prepares the list of defines specific to the light type.
  112310. * @param defines the list of defines
  112311. * @param lightIndex defines the index of the light for the effect
  112312. */
  112313. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112314. }
  112315. }
  112316. declare module BABYLON {
  112317. /**
  112318. * Class containing static functions to help procedurally build meshes
  112319. */
  112320. export class HemisphereBuilder {
  112321. /**
  112322. * Creates a hemisphere mesh
  112323. * @param name defines the name of the mesh
  112324. * @param options defines the options used to create the mesh
  112325. * @param scene defines the hosting scene
  112326. * @returns the hemisphere mesh
  112327. */
  112328. static CreateHemisphere(name: string, options: {
  112329. segments?: number;
  112330. diameter?: number;
  112331. sideOrientation?: number;
  112332. }, scene: any): Mesh;
  112333. }
  112334. }
  112335. declare module BABYLON {
  112336. /**
  112337. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112338. * These values define a cone of light starting from the position, emitting toward the direction.
  112339. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112340. * and the exponent defines the speed of the decay of the light with distance (reach).
  112341. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112342. */
  112343. export class SpotLight extends ShadowLight {
  112344. private _angle;
  112345. private _innerAngle;
  112346. private _cosHalfAngle;
  112347. private _lightAngleScale;
  112348. private _lightAngleOffset;
  112349. /**
  112350. * Gets the cone angle of the spot light in Radians.
  112351. */
  112352. /**
  112353. * Sets the cone angle of the spot light in Radians.
  112354. */
  112355. angle: number;
  112356. /**
  112357. * Only used in gltf falloff mode, this defines the angle where
  112358. * the directional falloff will start before cutting at angle which could be seen
  112359. * as outer angle.
  112360. */
  112361. /**
  112362. * Only used in gltf falloff mode, this defines the angle where
  112363. * the directional falloff will start before cutting at angle which could be seen
  112364. * as outer angle.
  112365. */
  112366. innerAngle: number;
  112367. private _shadowAngleScale;
  112368. /**
  112369. * Allows scaling the angle of the light for shadow generation only.
  112370. */
  112371. /**
  112372. * Allows scaling the angle of the light for shadow generation only.
  112373. */
  112374. shadowAngleScale: number;
  112375. /**
  112376. * The light decay speed with the distance from the emission spot.
  112377. */
  112378. exponent: number;
  112379. private _projectionTextureMatrix;
  112380. /**
  112381. * Allows reading the projecton texture
  112382. */
  112383. readonly projectionTextureMatrix: Matrix;
  112384. protected _projectionTextureLightNear: number;
  112385. /**
  112386. * Gets the near clip of the Spotlight for texture projection.
  112387. */
  112388. /**
  112389. * Sets the near clip of the Spotlight for texture projection.
  112390. */
  112391. projectionTextureLightNear: number;
  112392. protected _projectionTextureLightFar: number;
  112393. /**
  112394. * Gets the far clip of the Spotlight for texture projection.
  112395. */
  112396. /**
  112397. * Sets the far clip of the Spotlight for texture projection.
  112398. */
  112399. projectionTextureLightFar: number;
  112400. protected _projectionTextureUpDirection: Vector3;
  112401. /**
  112402. * Gets the Up vector of the Spotlight for texture projection.
  112403. */
  112404. /**
  112405. * Sets the Up vector of the Spotlight for texture projection.
  112406. */
  112407. projectionTextureUpDirection: Vector3;
  112408. private _projectionTexture;
  112409. /**
  112410. * Gets the projection texture of the light.
  112411. */
  112412. /**
  112413. * Sets the projection texture of the light.
  112414. */
  112415. projectionTexture: Nullable<BaseTexture>;
  112416. private _projectionTextureViewLightDirty;
  112417. private _projectionTextureProjectionLightDirty;
  112418. private _projectionTextureDirty;
  112419. private _projectionTextureViewTargetVector;
  112420. private _projectionTextureViewLightMatrix;
  112421. private _projectionTextureProjectionLightMatrix;
  112422. private _projectionTextureScalingMatrix;
  112423. /**
  112424. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112425. * It can cast shadows.
  112426. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112427. * @param name The light friendly name
  112428. * @param position The position of the spot light in the scene
  112429. * @param direction The direction of the light in the scene
  112430. * @param angle The cone angle of the light in Radians
  112431. * @param exponent The light decay speed with the distance from the emission spot
  112432. * @param scene The scene the lights belongs to
  112433. */
  112434. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112435. /**
  112436. * Returns the string "SpotLight".
  112437. * @returns the class name
  112438. */
  112439. getClassName(): string;
  112440. /**
  112441. * Returns the integer 2.
  112442. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112443. */
  112444. getTypeID(): number;
  112445. /**
  112446. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112447. */
  112448. protected _setDirection(value: Vector3): void;
  112449. /**
  112450. * Overrides the position setter to recompute the projection texture view light Matrix.
  112451. */
  112452. protected _setPosition(value: Vector3): void;
  112453. /**
  112454. * 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.
  112455. * Returns the SpotLight.
  112456. */
  112457. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112458. protected _computeProjectionTextureViewLightMatrix(): void;
  112459. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112460. /**
  112461. * Main function for light texture projection matrix computing.
  112462. */
  112463. protected _computeProjectionTextureMatrix(): void;
  112464. protected _buildUniformLayout(): void;
  112465. private _computeAngleValues;
  112466. /**
  112467. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112468. * @param effect The effect to update
  112469. * @param lightIndex The index of the light in the effect to update
  112470. * @returns The spot light
  112471. */
  112472. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112473. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112474. /**
  112475. * Disposes the light and the associated resources.
  112476. */
  112477. dispose(): void;
  112478. /**
  112479. * Prepares the list of defines specific to the light type.
  112480. * @param defines the list of defines
  112481. * @param lightIndex defines the index of the light for the effect
  112482. */
  112483. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112484. }
  112485. }
  112486. declare module BABYLON {
  112487. /**
  112488. * Gizmo that enables viewing a light
  112489. */
  112490. export class LightGizmo extends Gizmo {
  112491. private _lightMesh;
  112492. private _material;
  112493. private cachedPosition;
  112494. private cachedForward;
  112495. /**
  112496. * Creates a LightGizmo
  112497. * @param gizmoLayer The utility layer the gizmo will be added to
  112498. */
  112499. constructor(gizmoLayer?: UtilityLayerRenderer);
  112500. private _light;
  112501. /**
  112502. * The light that the gizmo is attached to
  112503. */
  112504. light: Nullable<Light>;
  112505. /**
  112506. * Gets the material used to render the light gizmo
  112507. */
  112508. readonly material: StandardMaterial;
  112509. /**
  112510. * @hidden
  112511. * Updates the gizmo to match the attached mesh's position/rotation
  112512. */
  112513. protected _update(): void;
  112514. private static _Scale;
  112515. /**
  112516. * Creates the lines for a light mesh
  112517. */
  112518. private static _createLightLines;
  112519. /**
  112520. * Disposes of the light gizmo
  112521. */
  112522. dispose(): void;
  112523. private static _CreateHemisphericLightMesh;
  112524. private static _CreatePointLightMesh;
  112525. private static _CreateSpotLightMesh;
  112526. private static _CreateDirectionalLightMesh;
  112527. }
  112528. }
  112529. declare module BABYLON {
  112530. /** @hidden */
  112531. export var backgroundFragmentDeclaration: {
  112532. name: string;
  112533. shader: string;
  112534. };
  112535. }
  112536. declare module BABYLON {
  112537. /** @hidden */
  112538. export var backgroundUboDeclaration: {
  112539. name: string;
  112540. shader: string;
  112541. };
  112542. }
  112543. declare module BABYLON {
  112544. /** @hidden */
  112545. export var backgroundPixelShader: {
  112546. name: string;
  112547. shader: string;
  112548. };
  112549. }
  112550. declare module BABYLON {
  112551. /** @hidden */
  112552. export var backgroundVertexDeclaration: {
  112553. name: string;
  112554. shader: string;
  112555. };
  112556. }
  112557. declare module BABYLON {
  112558. /** @hidden */
  112559. export var backgroundVertexShader: {
  112560. name: string;
  112561. shader: string;
  112562. };
  112563. }
  112564. declare module BABYLON {
  112565. /**
  112566. * Background material used to create an efficient environement around your scene.
  112567. */
  112568. export class BackgroundMaterial extends PushMaterial {
  112569. /**
  112570. * Standard reflectance value at parallel view angle.
  112571. */
  112572. static StandardReflectance0: number;
  112573. /**
  112574. * Standard reflectance value at grazing angle.
  112575. */
  112576. static StandardReflectance90: number;
  112577. protected _primaryColor: Color3;
  112578. /**
  112579. * Key light Color (multiply against the environement texture)
  112580. */
  112581. primaryColor: Color3;
  112582. protected __perceptualColor: Nullable<Color3>;
  112583. /**
  112584. * Experimental Internal Use Only.
  112585. *
  112586. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112587. * This acts as a helper to set the primary color to a more "human friendly" value.
  112588. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112589. * output color as close as possible from the chosen value.
  112590. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112591. * part of lighting setup.)
  112592. */
  112593. _perceptualColor: Nullable<Color3>;
  112594. protected _primaryColorShadowLevel: float;
  112595. /**
  112596. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112597. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112598. */
  112599. primaryColorShadowLevel: float;
  112600. protected _primaryColorHighlightLevel: float;
  112601. /**
  112602. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112603. * The primary color is used at the level chosen to define what the white area would look.
  112604. */
  112605. primaryColorHighlightLevel: float;
  112606. protected _reflectionTexture: Nullable<BaseTexture>;
  112607. /**
  112608. * Reflection Texture used in the material.
  112609. * Should be author in a specific way for the best result (refer to the documentation).
  112610. */
  112611. reflectionTexture: Nullable<BaseTexture>;
  112612. protected _reflectionBlur: float;
  112613. /**
  112614. * Reflection Texture level of blur.
  112615. *
  112616. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112617. * texture twice.
  112618. */
  112619. reflectionBlur: float;
  112620. protected _diffuseTexture: Nullable<BaseTexture>;
  112621. /**
  112622. * Diffuse Texture used in the material.
  112623. * Should be author in a specific way for the best result (refer to the documentation).
  112624. */
  112625. diffuseTexture: Nullable<BaseTexture>;
  112626. protected _shadowLights: Nullable<IShadowLight[]>;
  112627. /**
  112628. * Specify the list of lights casting shadow on the material.
  112629. * All scene shadow lights will be included if null.
  112630. */
  112631. shadowLights: Nullable<IShadowLight[]>;
  112632. protected _shadowLevel: float;
  112633. /**
  112634. * Helps adjusting the shadow to a softer level if required.
  112635. * 0 means black shadows and 1 means no shadows.
  112636. */
  112637. shadowLevel: float;
  112638. protected _sceneCenter: Vector3;
  112639. /**
  112640. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112641. * It is usually zero but might be interesting to modify according to your setup.
  112642. */
  112643. sceneCenter: Vector3;
  112644. protected _opacityFresnel: boolean;
  112645. /**
  112646. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112647. * This helps ensuring a nice transition when the camera goes under the ground.
  112648. */
  112649. opacityFresnel: boolean;
  112650. protected _reflectionFresnel: boolean;
  112651. /**
  112652. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112653. * This helps adding a mirror texture on the ground.
  112654. */
  112655. reflectionFresnel: boolean;
  112656. protected _reflectionFalloffDistance: number;
  112657. /**
  112658. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112659. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112660. */
  112661. reflectionFalloffDistance: number;
  112662. protected _reflectionAmount: number;
  112663. /**
  112664. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112665. */
  112666. reflectionAmount: number;
  112667. protected _reflectionReflectance0: number;
  112668. /**
  112669. * This specifies the weight of the reflection at grazing angle.
  112670. */
  112671. reflectionReflectance0: number;
  112672. protected _reflectionReflectance90: number;
  112673. /**
  112674. * This specifies the weight of the reflection at a perpendicular point of view.
  112675. */
  112676. reflectionReflectance90: number;
  112677. /**
  112678. * Sets the reflection reflectance fresnel values according to the default standard
  112679. * empirically know to work well :-)
  112680. */
  112681. reflectionStandardFresnelWeight: number;
  112682. protected _useRGBColor: boolean;
  112683. /**
  112684. * Helps to directly use the maps channels instead of their level.
  112685. */
  112686. useRGBColor: boolean;
  112687. protected _enableNoise: boolean;
  112688. /**
  112689. * This helps reducing the banding effect that could occur on the background.
  112690. */
  112691. enableNoise: boolean;
  112692. /**
  112693. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112694. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112695. * Recommended to be keep at 1.0 except for special cases.
  112696. */
  112697. fovMultiplier: number;
  112698. private _fovMultiplier;
  112699. /**
  112700. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112701. */
  112702. useEquirectangularFOV: boolean;
  112703. private _maxSimultaneousLights;
  112704. /**
  112705. * Number of Simultaneous lights allowed on the material.
  112706. */
  112707. maxSimultaneousLights: int;
  112708. /**
  112709. * Default configuration related to image processing available in the Background Material.
  112710. */
  112711. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112712. /**
  112713. * Keep track of the image processing observer to allow dispose and replace.
  112714. */
  112715. private _imageProcessingObserver;
  112716. /**
  112717. * Attaches a new image processing configuration to the PBR Material.
  112718. * @param configuration (if null the scene configuration will be use)
  112719. */
  112720. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112721. /**
  112722. * Gets the image processing configuration used either in this material.
  112723. */
  112724. /**
  112725. * Sets the Default image processing configuration used either in the this material.
  112726. *
  112727. * If sets to null, the scene one is in use.
  112728. */
  112729. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112730. /**
  112731. * Gets wether the color curves effect is enabled.
  112732. */
  112733. /**
  112734. * Sets wether the color curves effect is enabled.
  112735. */
  112736. cameraColorCurvesEnabled: boolean;
  112737. /**
  112738. * Gets wether the color grading effect is enabled.
  112739. */
  112740. /**
  112741. * Gets wether the color grading effect is enabled.
  112742. */
  112743. cameraColorGradingEnabled: boolean;
  112744. /**
  112745. * Gets wether tonemapping is enabled or not.
  112746. */
  112747. /**
  112748. * Sets wether tonemapping is enabled or not
  112749. */
  112750. cameraToneMappingEnabled: boolean;
  112751. /**
  112752. * The camera exposure used on this material.
  112753. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112754. * This corresponds to a photographic exposure.
  112755. */
  112756. /**
  112757. * The camera exposure used on this material.
  112758. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112759. * This corresponds to a photographic exposure.
  112760. */
  112761. cameraExposure: float;
  112762. /**
  112763. * Gets The camera contrast used on this material.
  112764. */
  112765. /**
  112766. * Sets The camera contrast used on this material.
  112767. */
  112768. cameraContrast: float;
  112769. /**
  112770. * Gets the Color Grading 2D Lookup Texture.
  112771. */
  112772. /**
  112773. * Sets the Color Grading 2D Lookup Texture.
  112774. */
  112775. cameraColorGradingTexture: Nullable<BaseTexture>;
  112776. /**
  112777. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112778. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112779. * 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;
  112780. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112781. */
  112782. /**
  112783. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112784. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112785. * 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;
  112786. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112787. */
  112788. cameraColorCurves: Nullable<ColorCurves>;
  112789. /**
  112790. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112791. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112792. */
  112793. switchToBGR: boolean;
  112794. private _renderTargets;
  112795. private _reflectionControls;
  112796. private _white;
  112797. private _primaryShadowColor;
  112798. private _primaryHighlightColor;
  112799. /**
  112800. * Instantiates a Background Material in the given scene
  112801. * @param name The friendly name of the material
  112802. * @param scene The scene to add the material to
  112803. */
  112804. constructor(name: string, scene: Scene);
  112805. /**
  112806. * Gets a boolean indicating that current material needs to register RTT
  112807. */
  112808. readonly hasRenderTargetTextures: boolean;
  112809. /**
  112810. * The entire material has been created in order to prevent overdraw.
  112811. * @returns false
  112812. */
  112813. needAlphaTesting(): boolean;
  112814. /**
  112815. * The entire material has been created in order to prevent overdraw.
  112816. * @returns true if blending is enable
  112817. */
  112818. needAlphaBlending(): boolean;
  112819. /**
  112820. * Checks wether the material is ready to be rendered for a given mesh.
  112821. * @param mesh The mesh to render
  112822. * @param subMesh The submesh to check against
  112823. * @param useInstances Specify wether or not the material is used with instances
  112824. * @returns true if all the dependencies are ready (Textures, Effects...)
  112825. */
  112826. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112827. /**
  112828. * Compute the primary color according to the chosen perceptual color.
  112829. */
  112830. private _computePrimaryColorFromPerceptualColor;
  112831. /**
  112832. * Compute the highlights and shadow colors according to their chosen levels.
  112833. */
  112834. private _computePrimaryColors;
  112835. /**
  112836. * Build the uniform buffer used in the material.
  112837. */
  112838. buildUniformLayout(): void;
  112839. /**
  112840. * Unbind the material.
  112841. */
  112842. unbind(): void;
  112843. /**
  112844. * Bind only the world matrix to the material.
  112845. * @param world The world matrix to bind.
  112846. */
  112847. bindOnlyWorldMatrix(world: Matrix): void;
  112848. /**
  112849. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112850. * @param world The world matrix to bind.
  112851. * @param subMesh The submesh to bind for.
  112852. */
  112853. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112854. /**
  112855. * Checks to see if a texture is used in the material.
  112856. * @param texture - Base texture to use.
  112857. * @returns - Boolean specifying if a texture is used in the material.
  112858. */
  112859. hasTexture(texture: BaseTexture): boolean;
  112860. /**
  112861. * Dispose the material.
  112862. * @param forceDisposeEffect Force disposal of the associated effect.
  112863. * @param forceDisposeTextures Force disposal of the associated textures.
  112864. */
  112865. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112866. /**
  112867. * Clones the material.
  112868. * @param name The cloned name.
  112869. * @returns The cloned material.
  112870. */
  112871. clone(name: string): BackgroundMaterial;
  112872. /**
  112873. * Serializes the current material to its JSON representation.
  112874. * @returns The JSON representation.
  112875. */
  112876. serialize(): any;
  112877. /**
  112878. * Gets the class name of the material
  112879. * @returns "BackgroundMaterial"
  112880. */
  112881. getClassName(): string;
  112882. /**
  112883. * Parse a JSON input to create back a background material.
  112884. * @param source The JSON data to parse
  112885. * @param scene The scene to create the parsed material in
  112886. * @param rootUrl The root url of the assets the material depends upon
  112887. * @returns the instantiated BackgroundMaterial.
  112888. */
  112889. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112890. }
  112891. }
  112892. declare module BABYLON {
  112893. /**
  112894. * Represents the different options available during the creation of
  112895. * a Environment helper.
  112896. *
  112897. * This can control the default ground, skybox and image processing setup of your scene.
  112898. */
  112899. export interface IEnvironmentHelperOptions {
  112900. /**
  112901. * Specifies wether or not to create a ground.
  112902. * True by default.
  112903. */
  112904. createGround: boolean;
  112905. /**
  112906. * Specifies the ground size.
  112907. * 15 by default.
  112908. */
  112909. groundSize: number;
  112910. /**
  112911. * The texture used on the ground for the main color.
  112912. * Comes from the BabylonJS CDN by default.
  112913. *
  112914. * Remarks: Can be either a texture or a url.
  112915. */
  112916. groundTexture: string | BaseTexture;
  112917. /**
  112918. * The color mixed in the ground texture by default.
  112919. * BabylonJS clearColor by default.
  112920. */
  112921. groundColor: Color3;
  112922. /**
  112923. * Specifies the ground opacity.
  112924. * 1 by default.
  112925. */
  112926. groundOpacity: number;
  112927. /**
  112928. * Enables the ground to receive shadows.
  112929. * True by default.
  112930. */
  112931. enableGroundShadow: boolean;
  112932. /**
  112933. * Helps preventing the shadow to be fully black on the ground.
  112934. * 0.5 by default.
  112935. */
  112936. groundShadowLevel: number;
  112937. /**
  112938. * Creates a mirror texture attach to the ground.
  112939. * false by default.
  112940. */
  112941. enableGroundMirror: boolean;
  112942. /**
  112943. * Specifies the ground mirror size ratio.
  112944. * 0.3 by default as the default kernel is 64.
  112945. */
  112946. groundMirrorSizeRatio: number;
  112947. /**
  112948. * Specifies the ground mirror blur kernel size.
  112949. * 64 by default.
  112950. */
  112951. groundMirrorBlurKernel: number;
  112952. /**
  112953. * Specifies the ground mirror visibility amount.
  112954. * 1 by default
  112955. */
  112956. groundMirrorAmount: number;
  112957. /**
  112958. * Specifies the ground mirror reflectance weight.
  112959. * This uses the standard weight of the background material to setup the fresnel effect
  112960. * of the mirror.
  112961. * 1 by default.
  112962. */
  112963. groundMirrorFresnelWeight: number;
  112964. /**
  112965. * Specifies the ground mirror Falloff distance.
  112966. * This can helps reducing the size of the reflection.
  112967. * 0 by Default.
  112968. */
  112969. groundMirrorFallOffDistance: number;
  112970. /**
  112971. * Specifies the ground mirror texture type.
  112972. * Unsigned Int by Default.
  112973. */
  112974. groundMirrorTextureType: number;
  112975. /**
  112976. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112977. * the shown objects.
  112978. */
  112979. groundYBias: number;
  112980. /**
  112981. * Specifies wether or not to create a skybox.
  112982. * True by default.
  112983. */
  112984. createSkybox: boolean;
  112985. /**
  112986. * Specifies the skybox size.
  112987. * 20 by default.
  112988. */
  112989. skyboxSize: number;
  112990. /**
  112991. * The texture used on the skybox for the main color.
  112992. * Comes from the BabylonJS CDN by default.
  112993. *
  112994. * Remarks: Can be either a texture or a url.
  112995. */
  112996. skyboxTexture: string | BaseTexture;
  112997. /**
  112998. * The color mixed in the skybox texture by default.
  112999. * BabylonJS clearColor by default.
  113000. */
  113001. skyboxColor: Color3;
  113002. /**
  113003. * The background rotation around the Y axis of the scene.
  113004. * This helps aligning the key lights of your scene with the background.
  113005. * 0 by default.
  113006. */
  113007. backgroundYRotation: number;
  113008. /**
  113009. * Compute automatically the size of the elements to best fit with the scene.
  113010. */
  113011. sizeAuto: boolean;
  113012. /**
  113013. * Default position of the rootMesh if autoSize is not true.
  113014. */
  113015. rootPosition: Vector3;
  113016. /**
  113017. * Sets up the image processing in the scene.
  113018. * true by default.
  113019. */
  113020. setupImageProcessing: boolean;
  113021. /**
  113022. * The texture used as your environment texture in the scene.
  113023. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113024. *
  113025. * Remarks: Can be either a texture or a url.
  113026. */
  113027. environmentTexture: string | BaseTexture;
  113028. /**
  113029. * The value of the exposure to apply to the scene.
  113030. * 0.6 by default if setupImageProcessing is true.
  113031. */
  113032. cameraExposure: number;
  113033. /**
  113034. * The value of the contrast to apply to the scene.
  113035. * 1.6 by default if setupImageProcessing is true.
  113036. */
  113037. cameraContrast: number;
  113038. /**
  113039. * Specifies wether or not tonemapping should be enabled in the scene.
  113040. * true by default if setupImageProcessing is true.
  113041. */
  113042. toneMappingEnabled: boolean;
  113043. }
  113044. /**
  113045. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113046. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113047. * It also helps with the default setup of your imageProcessing configuration.
  113048. */
  113049. export class EnvironmentHelper {
  113050. /**
  113051. * Default ground texture URL.
  113052. */
  113053. private static _groundTextureCDNUrl;
  113054. /**
  113055. * Default skybox texture URL.
  113056. */
  113057. private static _skyboxTextureCDNUrl;
  113058. /**
  113059. * Default environment texture URL.
  113060. */
  113061. private static _environmentTextureCDNUrl;
  113062. /**
  113063. * Creates the default options for the helper.
  113064. */
  113065. private static _getDefaultOptions;
  113066. private _rootMesh;
  113067. /**
  113068. * Gets the root mesh created by the helper.
  113069. */
  113070. readonly rootMesh: Mesh;
  113071. private _skybox;
  113072. /**
  113073. * Gets the skybox created by the helper.
  113074. */
  113075. readonly skybox: Nullable<Mesh>;
  113076. private _skyboxTexture;
  113077. /**
  113078. * Gets the skybox texture created by the helper.
  113079. */
  113080. readonly skyboxTexture: Nullable<BaseTexture>;
  113081. private _skyboxMaterial;
  113082. /**
  113083. * Gets the skybox material created by the helper.
  113084. */
  113085. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113086. private _ground;
  113087. /**
  113088. * Gets the ground mesh created by the helper.
  113089. */
  113090. readonly ground: Nullable<Mesh>;
  113091. private _groundTexture;
  113092. /**
  113093. * Gets the ground texture created by the helper.
  113094. */
  113095. readonly groundTexture: Nullable<BaseTexture>;
  113096. private _groundMirror;
  113097. /**
  113098. * Gets the ground mirror created by the helper.
  113099. */
  113100. readonly groundMirror: Nullable<MirrorTexture>;
  113101. /**
  113102. * Gets the ground mirror render list to helps pushing the meshes
  113103. * you wish in the ground reflection.
  113104. */
  113105. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113106. private _groundMaterial;
  113107. /**
  113108. * Gets the ground material created by the helper.
  113109. */
  113110. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113111. /**
  113112. * Stores the creation options.
  113113. */
  113114. private readonly _scene;
  113115. private _options;
  113116. /**
  113117. * This observable will be notified with any error during the creation of the environment,
  113118. * mainly texture creation errors.
  113119. */
  113120. onErrorObservable: Observable<{
  113121. message?: string;
  113122. exception?: any;
  113123. }>;
  113124. /**
  113125. * constructor
  113126. * @param options Defines the options we want to customize the helper
  113127. * @param scene The scene to add the material to
  113128. */
  113129. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113130. /**
  113131. * Updates the background according to the new options
  113132. * @param options
  113133. */
  113134. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113135. /**
  113136. * Sets the primary color of all the available elements.
  113137. * @param color the main color to affect to the ground and the background
  113138. */
  113139. setMainColor(color: Color3): void;
  113140. /**
  113141. * Setup the image processing according to the specified options.
  113142. */
  113143. private _setupImageProcessing;
  113144. /**
  113145. * Setup the environment texture according to the specified options.
  113146. */
  113147. private _setupEnvironmentTexture;
  113148. /**
  113149. * Setup the background according to the specified options.
  113150. */
  113151. private _setupBackground;
  113152. /**
  113153. * Get the scene sizes according to the setup.
  113154. */
  113155. private _getSceneSize;
  113156. /**
  113157. * Setup the ground according to the specified options.
  113158. */
  113159. private _setupGround;
  113160. /**
  113161. * Setup the ground material according to the specified options.
  113162. */
  113163. private _setupGroundMaterial;
  113164. /**
  113165. * Setup the ground diffuse texture according to the specified options.
  113166. */
  113167. private _setupGroundDiffuseTexture;
  113168. /**
  113169. * Setup the ground mirror texture according to the specified options.
  113170. */
  113171. private _setupGroundMirrorTexture;
  113172. /**
  113173. * Setup the ground to receive the mirror texture.
  113174. */
  113175. private _setupMirrorInGroundMaterial;
  113176. /**
  113177. * Setup the skybox according to the specified options.
  113178. */
  113179. private _setupSkybox;
  113180. /**
  113181. * Setup the skybox material according to the specified options.
  113182. */
  113183. private _setupSkyboxMaterial;
  113184. /**
  113185. * Setup the skybox reflection texture according to the specified options.
  113186. */
  113187. private _setupSkyboxReflectionTexture;
  113188. private _errorHandler;
  113189. /**
  113190. * Dispose all the elements created by the Helper.
  113191. */
  113192. dispose(): void;
  113193. }
  113194. }
  113195. declare module BABYLON {
  113196. /**
  113197. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113198. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113199. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113200. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113201. */
  113202. export class PhotoDome extends TransformNode {
  113203. /**
  113204. * Define the image as a Monoscopic panoramic 360 image.
  113205. */
  113206. static readonly MODE_MONOSCOPIC: number;
  113207. /**
  113208. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113209. */
  113210. static readonly MODE_TOPBOTTOM: number;
  113211. /**
  113212. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113213. */
  113214. static readonly MODE_SIDEBYSIDE: number;
  113215. private _useDirectMapping;
  113216. /**
  113217. * The texture being displayed on the sphere
  113218. */
  113219. protected _photoTexture: Texture;
  113220. /**
  113221. * Gets or sets the texture being displayed on the sphere
  113222. */
  113223. photoTexture: Texture;
  113224. /**
  113225. * Observable raised when an error occured while loading the 360 image
  113226. */
  113227. onLoadErrorObservable: Observable<string>;
  113228. /**
  113229. * The skybox material
  113230. */
  113231. protected _material: BackgroundMaterial;
  113232. /**
  113233. * The surface used for the skybox
  113234. */
  113235. protected _mesh: Mesh;
  113236. /**
  113237. * Gets the mesh used for the skybox.
  113238. */
  113239. readonly mesh: Mesh;
  113240. /**
  113241. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113242. * Also see the options.resolution property.
  113243. */
  113244. fovMultiplier: number;
  113245. private _imageMode;
  113246. /**
  113247. * Gets or set the current video mode for the video. It can be:
  113248. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113249. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113250. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113251. */
  113252. imageMode: number;
  113253. /**
  113254. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113255. * @param name Element's name, child elements will append suffixes for their own names.
  113256. * @param urlsOfPhoto defines the url of the photo to display
  113257. * @param options defines an object containing optional or exposed sub element properties
  113258. * @param onError defines a callback called when an error occured while loading the texture
  113259. */
  113260. constructor(name: string, urlOfPhoto: string, options: {
  113261. resolution?: number;
  113262. size?: number;
  113263. useDirectMapping?: boolean;
  113264. faceForward?: boolean;
  113265. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113266. private _onBeforeCameraRenderObserver;
  113267. private _changeImageMode;
  113268. /**
  113269. * Releases resources associated with this node.
  113270. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113271. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113272. */
  113273. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113274. }
  113275. }
  113276. declare module BABYLON {
  113277. /**
  113278. * Class used to host RGBD texture specific utilities
  113279. */
  113280. export class RGBDTextureTools {
  113281. /**
  113282. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113283. * @param texture the texture to expand.
  113284. */
  113285. static ExpandRGBDTexture(texture: Texture): void;
  113286. }
  113287. }
  113288. declare module BABYLON {
  113289. /**
  113290. * Class used to host texture specific utilities
  113291. */
  113292. export class BRDFTextureTools {
  113293. /**
  113294. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113295. * @param scene defines the hosting scene
  113296. * @returns the environment BRDF texture
  113297. */
  113298. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113299. private static _environmentBRDFBase64Texture;
  113300. }
  113301. }
  113302. declare module BABYLON {
  113303. /**
  113304. * @hidden
  113305. */
  113306. export interface IMaterialClearCoatDefines {
  113307. CLEARCOAT: boolean;
  113308. CLEARCOAT_DEFAULTIOR: boolean;
  113309. CLEARCOAT_TEXTURE: boolean;
  113310. CLEARCOAT_TEXTUREDIRECTUV: number;
  113311. CLEARCOAT_BUMP: boolean;
  113312. CLEARCOAT_BUMPDIRECTUV: number;
  113313. CLEARCOAT_TINT: boolean;
  113314. CLEARCOAT_TINT_TEXTURE: boolean;
  113315. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113316. /** @hidden */
  113317. _areTexturesDirty: boolean;
  113318. }
  113319. /**
  113320. * Define the code related to the clear coat parameters of the pbr material.
  113321. */
  113322. export class PBRClearCoatConfiguration {
  113323. /**
  113324. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113325. * The default fits with a polyurethane material.
  113326. */
  113327. private static readonly _DefaultIndexOfRefraction;
  113328. private _isEnabled;
  113329. /**
  113330. * Defines if the clear coat is enabled in the material.
  113331. */
  113332. isEnabled: boolean;
  113333. /**
  113334. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113335. */
  113336. intensity: number;
  113337. /**
  113338. * Defines the clear coat layer roughness.
  113339. */
  113340. roughness: number;
  113341. private _indexOfRefraction;
  113342. /**
  113343. * Defines the index of refraction of the clear coat.
  113344. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113345. * The default fits with a polyurethane material.
  113346. * Changing the default value is more performance intensive.
  113347. */
  113348. indexOfRefraction: number;
  113349. private _texture;
  113350. /**
  113351. * Stores the clear coat values in a texture.
  113352. */
  113353. texture: Nullable<BaseTexture>;
  113354. private _bumpTexture;
  113355. /**
  113356. * Define the clear coat specific bump texture.
  113357. */
  113358. bumpTexture: Nullable<BaseTexture>;
  113359. private _isTintEnabled;
  113360. /**
  113361. * Defines if the clear coat tint is enabled in the material.
  113362. */
  113363. isTintEnabled: boolean;
  113364. /**
  113365. * Defines the clear coat tint of the material.
  113366. * This is only use if tint is enabled
  113367. */
  113368. tintColor: Color3;
  113369. /**
  113370. * Defines the distance at which the tint color should be found in the
  113371. * clear coat media.
  113372. * This is only use if tint is enabled
  113373. */
  113374. tintColorAtDistance: number;
  113375. /**
  113376. * Defines the clear coat layer thickness.
  113377. * This is only use if tint is enabled
  113378. */
  113379. tintThickness: number;
  113380. private _tintTexture;
  113381. /**
  113382. * Stores the clear tint values in a texture.
  113383. * rgb is tint
  113384. * a is a thickness factor
  113385. */
  113386. tintTexture: Nullable<BaseTexture>;
  113387. /** @hidden */
  113388. private _internalMarkAllSubMeshesAsTexturesDirty;
  113389. /** @hidden */
  113390. _markAllSubMeshesAsTexturesDirty(): void;
  113391. /**
  113392. * Instantiate a new istance of clear coat configuration.
  113393. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113394. */
  113395. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113396. /**
  113397. * Gets wehter the submesh is ready to be used or not.
  113398. * @param defines the list of "defines" to update.
  113399. * @param scene defines the scene the material belongs to.
  113400. * @param engine defines the engine the material belongs to.
  113401. * @param disableBumpMap defines wether the material disables bump or not.
  113402. * @returns - boolean indicating that the submesh is ready or not.
  113403. */
  113404. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113405. /**
  113406. * Checks to see if a texture is used in the material.
  113407. * @param defines the list of "defines" to update.
  113408. * @param scene defines the scene to the material belongs to.
  113409. */
  113410. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113411. /**
  113412. * Binds the material data.
  113413. * @param uniformBuffer defines the Uniform buffer to fill in.
  113414. * @param scene defines the scene the material belongs to.
  113415. * @param engine defines the engine the material belongs to.
  113416. * @param disableBumpMap defines wether the material disables bump or not.
  113417. * @param isFrozen defines wether the material is frozen or not.
  113418. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113419. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113420. */
  113421. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113422. /**
  113423. * Checks to see if a texture is used in the material.
  113424. * @param texture - Base texture to use.
  113425. * @returns - Boolean specifying if a texture is used in the material.
  113426. */
  113427. hasTexture(texture: BaseTexture): boolean;
  113428. /**
  113429. * Returns an array of the actively used textures.
  113430. * @param activeTextures Array of BaseTextures
  113431. */
  113432. getActiveTextures(activeTextures: BaseTexture[]): void;
  113433. /**
  113434. * Returns the animatable textures.
  113435. * @param animatables Array of animatable textures.
  113436. */
  113437. getAnimatables(animatables: IAnimatable[]): void;
  113438. /**
  113439. * Disposes the resources of the material.
  113440. * @param forceDisposeTextures - Forces the disposal of all textures.
  113441. */
  113442. dispose(forceDisposeTextures?: boolean): void;
  113443. /**
  113444. * Get the current class name of the texture useful for serialization or dynamic coding.
  113445. * @returns "PBRClearCoatConfiguration"
  113446. */
  113447. getClassName(): string;
  113448. /**
  113449. * Add fallbacks to the effect fallbacks list.
  113450. * @param defines defines the Base texture to use.
  113451. * @param fallbacks defines the current fallback list.
  113452. * @param currentRank defines the current fallback rank.
  113453. * @returns the new fallback rank.
  113454. */
  113455. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113456. /**
  113457. * Add the required uniforms to the current list.
  113458. * @param uniforms defines the current uniform list.
  113459. */
  113460. static AddUniforms(uniforms: string[]): void;
  113461. /**
  113462. * Add the required samplers to the current list.
  113463. * @param samplers defines the current sampler list.
  113464. */
  113465. static AddSamplers(samplers: string[]): void;
  113466. /**
  113467. * Add the required uniforms to the current buffer.
  113468. * @param uniformBuffer defines the current uniform buffer.
  113469. */
  113470. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113471. /**
  113472. * Makes a duplicate of the current configuration into another one.
  113473. * @param clearCoatConfiguration define the config where to copy the info
  113474. */
  113475. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113476. /**
  113477. * Serializes this clear coat configuration.
  113478. * @returns - An object with the serialized config.
  113479. */
  113480. serialize(): any;
  113481. /**
  113482. * Parses a anisotropy Configuration from a serialized object.
  113483. * @param source - Serialized object.
  113484. * @param scene Defines the scene we are parsing for
  113485. * @param rootUrl Defines the rootUrl to load from
  113486. */
  113487. parse(source: any, scene: Scene, rootUrl: string): void;
  113488. }
  113489. }
  113490. declare module BABYLON {
  113491. /**
  113492. * @hidden
  113493. */
  113494. export interface IMaterialAnisotropicDefines {
  113495. ANISOTROPIC: boolean;
  113496. ANISOTROPIC_TEXTURE: boolean;
  113497. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113498. MAINUV1: boolean;
  113499. _areTexturesDirty: boolean;
  113500. _needUVs: boolean;
  113501. }
  113502. /**
  113503. * Define the code related to the anisotropic parameters of the pbr material.
  113504. */
  113505. export class PBRAnisotropicConfiguration {
  113506. private _isEnabled;
  113507. /**
  113508. * Defines if the anisotropy is enabled in the material.
  113509. */
  113510. isEnabled: boolean;
  113511. /**
  113512. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113513. */
  113514. intensity: number;
  113515. /**
  113516. * Defines if the effect is along the tangents, bitangents or in between.
  113517. * By default, the effect is "strectching" the highlights along the tangents.
  113518. */
  113519. direction: Vector2;
  113520. private _texture;
  113521. /**
  113522. * Stores the anisotropy values in a texture.
  113523. * rg is direction (like normal from -1 to 1)
  113524. * b is a intensity
  113525. */
  113526. texture: Nullable<BaseTexture>;
  113527. /** @hidden */
  113528. private _internalMarkAllSubMeshesAsTexturesDirty;
  113529. /** @hidden */
  113530. _markAllSubMeshesAsTexturesDirty(): void;
  113531. /**
  113532. * Instantiate a new istance of anisotropy configuration.
  113533. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113534. */
  113535. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113536. /**
  113537. * Specifies that the submesh is ready to be used.
  113538. * @param defines the list of "defines" to update.
  113539. * @param scene defines the scene the material belongs to.
  113540. * @returns - boolean indicating that the submesh is ready or not.
  113541. */
  113542. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113543. /**
  113544. * Checks to see if a texture is used in the material.
  113545. * @param defines the list of "defines" to update.
  113546. * @param mesh the mesh we are preparing the defines for.
  113547. * @param scene defines the scene the material belongs to.
  113548. */
  113549. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113550. /**
  113551. * Binds the material data.
  113552. * @param uniformBuffer defines the Uniform buffer to fill in.
  113553. * @param scene defines the scene the material belongs to.
  113554. * @param isFrozen defines wether the material is frozen or not.
  113555. */
  113556. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113557. /**
  113558. * Checks to see if a texture is used in the material.
  113559. * @param texture - Base texture to use.
  113560. * @returns - Boolean specifying if a texture is used in the material.
  113561. */
  113562. hasTexture(texture: BaseTexture): boolean;
  113563. /**
  113564. * Returns an array of the actively used textures.
  113565. * @param activeTextures Array of BaseTextures
  113566. */
  113567. getActiveTextures(activeTextures: BaseTexture[]): void;
  113568. /**
  113569. * Returns the animatable textures.
  113570. * @param animatables Array of animatable textures.
  113571. */
  113572. getAnimatables(animatables: IAnimatable[]): void;
  113573. /**
  113574. * Disposes the resources of the material.
  113575. * @param forceDisposeTextures - Forces the disposal of all textures.
  113576. */
  113577. dispose(forceDisposeTextures?: boolean): void;
  113578. /**
  113579. * Get the current class name of the texture useful for serialization or dynamic coding.
  113580. * @returns "PBRAnisotropicConfiguration"
  113581. */
  113582. getClassName(): string;
  113583. /**
  113584. * Add fallbacks to the effect fallbacks list.
  113585. * @param defines defines the Base texture to use.
  113586. * @param fallbacks defines the current fallback list.
  113587. * @param currentRank defines the current fallback rank.
  113588. * @returns the new fallback rank.
  113589. */
  113590. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113591. /**
  113592. * Add the required uniforms to the current list.
  113593. * @param uniforms defines the current uniform list.
  113594. */
  113595. static AddUniforms(uniforms: string[]): void;
  113596. /**
  113597. * Add the required uniforms to the current buffer.
  113598. * @param uniformBuffer defines the current uniform buffer.
  113599. */
  113600. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113601. /**
  113602. * Add the required samplers to the current list.
  113603. * @param samplers defines the current sampler list.
  113604. */
  113605. static AddSamplers(samplers: string[]): void;
  113606. /**
  113607. * Makes a duplicate of the current configuration into another one.
  113608. * @param anisotropicConfiguration define the config where to copy the info
  113609. */
  113610. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113611. /**
  113612. * Serializes this anisotropy configuration.
  113613. * @returns - An object with the serialized config.
  113614. */
  113615. serialize(): any;
  113616. /**
  113617. * Parses a anisotropy Configuration from a serialized object.
  113618. * @param source - Serialized object.
  113619. * @param scene Defines the scene we are parsing for
  113620. * @param rootUrl Defines the rootUrl to load from
  113621. */
  113622. parse(source: any, scene: Scene, rootUrl: string): void;
  113623. }
  113624. }
  113625. declare module BABYLON {
  113626. /**
  113627. * @hidden
  113628. */
  113629. export interface IMaterialBRDFDefines {
  113630. BRDF_V_HEIGHT_CORRELATED: boolean;
  113631. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113632. SPHERICAL_HARMONICS: boolean;
  113633. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113634. /** @hidden */
  113635. _areMiscDirty: boolean;
  113636. }
  113637. /**
  113638. * Define the code related to the BRDF parameters of the pbr material.
  113639. */
  113640. export class PBRBRDFConfiguration {
  113641. /**
  113642. * Default value used for the energy conservation.
  113643. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113644. */
  113645. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113646. /**
  113647. * Default value used for the Smith Visibility Height Correlated mode.
  113648. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113649. */
  113650. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113651. /**
  113652. * Default value used for the IBL diffuse part.
  113653. * This can help switching back to the polynomials mode globally which is a tiny bit
  113654. * less GPU intensive at the drawback of a lower quality.
  113655. */
  113656. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113657. /**
  113658. * Default value used for activating energy conservation for the specular workflow.
  113659. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113660. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113661. */
  113662. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113663. private _useEnergyConservation;
  113664. /**
  113665. * Defines if the material uses energy conservation.
  113666. */
  113667. useEnergyConservation: boolean;
  113668. private _useSmithVisibilityHeightCorrelated;
  113669. /**
  113670. * LEGACY Mode set to false
  113671. * Defines if the material uses height smith correlated visibility term.
  113672. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113673. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113674. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113675. * Not relying on height correlated will also disable energy conservation.
  113676. */
  113677. useSmithVisibilityHeightCorrelated: boolean;
  113678. private _useSphericalHarmonics;
  113679. /**
  113680. * LEGACY Mode set to false
  113681. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113682. * diffuse part of the IBL.
  113683. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113684. * to the ground truth.
  113685. */
  113686. useSphericalHarmonics: boolean;
  113687. private _useSpecularGlossinessInputEnergyConservation;
  113688. /**
  113689. * Defines if the material uses energy conservation, when the specular workflow is active.
  113690. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113691. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113692. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113693. */
  113694. useSpecularGlossinessInputEnergyConservation: boolean;
  113695. /** @hidden */
  113696. private _internalMarkAllSubMeshesAsMiscDirty;
  113697. /** @hidden */
  113698. _markAllSubMeshesAsMiscDirty(): void;
  113699. /**
  113700. * Instantiate a new istance of clear coat configuration.
  113701. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113702. */
  113703. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113704. /**
  113705. * Checks to see if a texture is used in the material.
  113706. * @param defines the list of "defines" to update.
  113707. */
  113708. prepareDefines(defines: IMaterialBRDFDefines): void;
  113709. /**
  113710. * Get the current class name of the texture useful for serialization or dynamic coding.
  113711. * @returns "PBRClearCoatConfiguration"
  113712. */
  113713. getClassName(): string;
  113714. /**
  113715. * Makes a duplicate of the current configuration into another one.
  113716. * @param brdfConfiguration define the config where to copy the info
  113717. */
  113718. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113719. /**
  113720. * Serializes this BRDF configuration.
  113721. * @returns - An object with the serialized config.
  113722. */
  113723. serialize(): any;
  113724. /**
  113725. * Parses a anisotropy Configuration from a serialized object.
  113726. * @param source - Serialized object.
  113727. * @param scene Defines the scene we are parsing for
  113728. * @param rootUrl Defines the rootUrl to load from
  113729. */
  113730. parse(source: any, scene: Scene, rootUrl: string): void;
  113731. }
  113732. }
  113733. declare module BABYLON {
  113734. /**
  113735. * @hidden
  113736. */
  113737. export interface IMaterialSheenDefines {
  113738. SHEEN: boolean;
  113739. SHEEN_TEXTURE: boolean;
  113740. SHEEN_TEXTUREDIRECTUV: number;
  113741. SHEEN_LINKWITHALBEDO: boolean;
  113742. /** @hidden */
  113743. _areTexturesDirty: boolean;
  113744. }
  113745. /**
  113746. * Define the code related to the Sheen parameters of the pbr material.
  113747. */
  113748. export class PBRSheenConfiguration {
  113749. private _isEnabled;
  113750. /**
  113751. * Defines if the material uses sheen.
  113752. */
  113753. isEnabled: boolean;
  113754. private _linkSheenWithAlbedo;
  113755. /**
  113756. * Defines if the sheen is linked to the sheen color.
  113757. */
  113758. linkSheenWithAlbedo: boolean;
  113759. /**
  113760. * Defines the sheen intensity.
  113761. */
  113762. intensity: number;
  113763. /**
  113764. * Defines the sheen color.
  113765. */
  113766. color: Color3;
  113767. private _texture;
  113768. /**
  113769. * Stores the sheen tint values in a texture.
  113770. * rgb is tint
  113771. * a is a intensity
  113772. */
  113773. texture: Nullable<BaseTexture>;
  113774. /** @hidden */
  113775. private _internalMarkAllSubMeshesAsTexturesDirty;
  113776. /** @hidden */
  113777. _markAllSubMeshesAsTexturesDirty(): void;
  113778. /**
  113779. * Instantiate a new istance of clear coat configuration.
  113780. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113781. */
  113782. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113783. /**
  113784. * Specifies that the submesh is ready to be used.
  113785. * @param defines the list of "defines" to update.
  113786. * @param scene defines the scene the material belongs to.
  113787. * @returns - boolean indicating that the submesh is ready or not.
  113788. */
  113789. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113790. /**
  113791. * Checks to see if a texture is used in the material.
  113792. * @param defines the list of "defines" to update.
  113793. * @param scene defines the scene the material belongs to.
  113794. */
  113795. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113796. /**
  113797. * Binds the material data.
  113798. * @param uniformBuffer defines the Uniform buffer to fill in.
  113799. * @param scene defines the scene the material belongs to.
  113800. * @param isFrozen defines wether the material is frozen or not.
  113801. */
  113802. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113803. /**
  113804. * Checks to see if a texture is used in the material.
  113805. * @param texture - Base texture to use.
  113806. * @returns - Boolean specifying if a texture is used in the material.
  113807. */
  113808. hasTexture(texture: BaseTexture): boolean;
  113809. /**
  113810. * Returns an array of the actively used textures.
  113811. * @param activeTextures Array of BaseTextures
  113812. */
  113813. getActiveTextures(activeTextures: BaseTexture[]): void;
  113814. /**
  113815. * Returns the animatable textures.
  113816. * @param animatables Array of animatable textures.
  113817. */
  113818. getAnimatables(animatables: IAnimatable[]): void;
  113819. /**
  113820. * Disposes the resources of the material.
  113821. * @param forceDisposeTextures - Forces the disposal of all textures.
  113822. */
  113823. dispose(forceDisposeTextures?: boolean): void;
  113824. /**
  113825. * Get the current class name of the texture useful for serialization or dynamic coding.
  113826. * @returns "PBRSheenConfiguration"
  113827. */
  113828. getClassName(): string;
  113829. /**
  113830. * Add fallbacks to the effect fallbacks list.
  113831. * @param defines defines the Base texture to use.
  113832. * @param fallbacks defines the current fallback list.
  113833. * @param currentRank defines the current fallback rank.
  113834. * @returns the new fallback rank.
  113835. */
  113836. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113837. /**
  113838. * Add the required uniforms to the current list.
  113839. * @param uniforms defines the current uniform list.
  113840. */
  113841. static AddUniforms(uniforms: string[]): void;
  113842. /**
  113843. * Add the required uniforms to the current buffer.
  113844. * @param uniformBuffer defines the current uniform buffer.
  113845. */
  113846. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113847. /**
  113848. * Add the required samplers to the current list.
  113849. * @param samplers defines the current sampler list.
  113850. */
  113851. static AddSamplers(samplers: string[]): void;
  113852. /**
  113853. * Makes a duplicate of the current configuration into another one.
  113854. * @param sheenConfiguration define the config where to copy the info
  113855. */
  113856. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113857. /**
  113858. * Serializes this BRDF configuration.
  113859. * @returns - An object with the serialized config.
  113860. */
  113861. serialize(): any;
  113862. /**
  113863. * Parses a anisotropy Configuration from a serialized object.
  113864. * @param source - Serialized object.
  113865. * @param scene Defines the scene we are parsing for
  113866. * @param rootUrl Defines the rootUrl to load from
  113867. */
  113868. parse(source: any, scene: Scene, rootUrl: string): void;
  113869. }
  113870. }
  113871. declare module BABYLON {
  113872. /**
  113873. * @hidden
  113874. */
  113875. export interface IMaterialSubSurfaceDefines {
  113876. SUBSURFACE: boolean;
  113877. SS_REFRACTION: boolean;
  113878. SS_TRANSLUCENCY: boolean;
  113879. SS_SCATERRING: boolean;
  113880. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113881. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113882. SS_REFRACTIONMAP_3D: boolean;
  113883. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113884. SS_LODINREFRACTIONALPHA: boolean;
  113885. SS_GAMMAREFRACTION: boolean;
  113886. SS_RGBDREFRACTION: boolean;
  113887. SS_LINEARSPECULARREFRACTION: boolean;
  113888. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113889. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113890. /** @hidden */
  113891. _areTexturesDirty: boolean;
  113892. }
  113893. /**
  113894. * Define the code related to the sub surface parameters of the pbr material.
  113895. */
  113896. export class PBRSubSurfaceConfiguration {
  113897. private _isRefractionEnabled;
  113898. /**
  113899. * Defines if the refraction is enabled in the material.
  113900. */
  113901. isRefractionEnabled: boolean;
  113902. private _isTranslucencyEnabled;
  113903. /**
  113904. * Defines if the translucency is enabled in the material.
  113905. */
  113906. isTranslucencyEnabled: boolean;
  113907. private _isScatteringEnabled;
  113908. /**
  113909. * Defines the refraction intensity of the material.
  113910. * The refraction when enabled replaces the Diffuse part of the material.
  113911. * The intensity helps transitionning between diffuse and refraction.
  113912. */
  113913. refractionIntensity: number;
  113914. /**
  113915. * Defines the translucency intensity of the material.
  113916. * When translucency has been enabled, this defines how much of the "translucency"
  113917. * is addded to the diffuse part of the material.
  113918. */
  113919. translucencyIntensity: number;
  113920. /**
  113921. * Defines the scattering intensity of the material.
  113922. * When scattering has been enabled, this defines how much of the "scattered light"
  113923. * is addded to the diffuse part of the material.
  113924. */
  113925. scatteringIntensity: number;
  113926. private _thicknessTexture;
  113927. /**
  113928. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113929. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113930. * 0 would mean minimumThickness
  113931. * 1 would mean maximumThickness
  113932. * The other channels might be use as a mask to vary the different effects intensity.
  113933. */
  113934. thicknessTexture: Nullable<BaseTexture>;
  113935. private _refractionTexture;
  113936. /**
  113937. * Defines the texture to use for refraction.
  113938. */
  113939. refractionTexture: Nullable<BaseTexture>;
  113940. private _indexOfRefraction;
  113941. /**
  113942. * Defines the index of refraction used in the material.
  113943. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113944. */
  113945. indexOfRefraction: number;
  113946. private _invertRefractionY;
  113947. /**
  113948. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113949. */
  113950. invertRefractionY: boolean;
  113951. private _linkRefractionWithTransparency;
  113952. /**
  113953. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113954. * Materials half opaque for instance using refraction could benefit from this control.
  113955. */
  113956. linkRefractionWithTransparency: boolean;
  113957. /**
  113958. * Defines the minimum thickness stored in the thickness map.
  113959. * If no thickness map is defined, this value will be used to simulate thickness.
  113960. */
  113961. minimumThickness: number;
  113962. /**
  113963. * Defines the maximum thickness stored in the thickness map.
  113964. */
  113965. maximumThickness: number;
  113966. /**
  113967. * Defines the volume tint of the material.
  113968. * This is used for both translucency and scattering.
  113969. */
  113970. tintColor: Color3;
  113971. /**
  113972. * Defines the distance at which the tint color should be found in the media.
  113973. * This is used for refraction only.
  113974. */
  113975. tintColorAtDistance: number;
  113976. /**
  113977. * Defines how far each channel transmit through the media.
  113978. * It is defined as a color to simplify it selection.
  113979. */
  113980. diffusionDistance: Color3;
  113981. private _useMaskFromThicknessTexture;
  113982. /**
  113983. * Stores the intensity of the different subsurface effects in the thickness texture.
  113984. * * the green channel is the translucency intensity.
  113985. * * the blue channel is the scattering intensity.
  113986. * * the alpha channel is the refraction intensity.
  113987. */
  113988. useMaskFromThicknessTexture: boolean;
  113989. /** @hidden */
  113990. private _internalMarkAllSubMeshesAsTexturesDirty;
  113991. /** @hidden */
  113992. _markAllSubMeshesAsTexturesDirty(): void;
  113993. /**
  113994. * Instantiate a new istance of sub surface configuration.
  113995. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113996. */
  113997. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113998. /**
  113999. * Gets wehter the submesh is ready to be used or not.
  114000. * @param defines the list of "defines" to update.
  114001. * @param scene defines the scene the material belongs to.
  114002. * @returns - boolean indicating that the submesh is ready or not.
  114003. */
  114004. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114005. /**
  114006. * Checks to see if a texture is used in the material.
  114007. * @param defines the list of "defines" to update.
  114008. * @param scene defines the scene to the material belongs to.
  114009. */
  114010. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114011. /**
  114012. * Binds the material data.
  114013. * @param uniformBuffer defines the Uniform buffer to fill in.
  114014. * @param scene defines the scene the material belongs to.
  114015. * @param engine defines the engine the material belongs to.
  114016. * @param isFrozen defines wether the material is frozen or not.
  114017. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114018. */
  114019. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114020. /**
  114021. * Unbinds the material from the mesh.
  114022. * @param activeEffect defines the effect that should be unbound from.
  114023. * @returns true if unbound, otherwise false
  114024. */
  114025. unbind(activeEffect: Effect): boolean;
  114026. /**
  114027. * Returns the texture used for refraction or null if none is used.
  114028. * @param scene defines the scene the material belongs to.
  114029. * @returns - Refraction texture if present. If no refraction texture and refraction
  114030. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114031. */
  114032. private _getRefractionTexture;
  114033. /**
  114034. * Returns true if alpha blending should be disabled.
  114035. */
  114036. readonly disableAlphaBlending: boolean;
  114037. /**
  114038. * Fills the list of render target textures.
  114039. * @param renderTargets the list of render targets to update
  114040. */
  114041. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114042. /**
  114043. * Checks to see if a texture is used in the material.
  114044. * @param texture - Base texture to use.
  114045. * @returns - Boolean specifying if a texture is used in the material.
  114046. */
  114047. hasTexture(texture: BaseTexture): boolean;
  114048. /**
  114049. * Gets a boolean indicating that current material needs to register RTT
  114050. * @returns true if this uses a render target otherwise false.
  114051. */
  114052. hasRenderTargetTextures(): boolean;
  114053. /**
  114054. * Returns an array of the actively used textures.
  114055. * @param activeTextures Array of BaseTextures
  114056. */
  114057. getActiveTextures(activeTextures: BaseTexture[]): void;
  114058. /**
  114059. * Returns the animatable textures.
  114060. * @param animatables Array of animatable textures.
  114061. */
  114062. getAnimatables(animatables: IAnimatable[]): void;
  114063. /**
  114064. * Disposes the resources of the material.
  114065. * @param forceDisposeTextures - Forces the disposal of all textures.
  114066. */
  114067. dispose(forceDisposeTextures?: boolean): void;
  114068. /**
  114069. * Get the current class name of the texture useful for serialization or dynamic coding.
  114070. * @returns "PBRSubSurfaceConfiguration"
  114071. */
  114072. getClassName(): string;
  114073. /**
  114074. * Add fallbacks to the effect fallbacks list.
  114075. * @param defines defines the Base texture to use.
  114076. * @param fallbacks defines the current fallback list.
  114077. * @param currentRank defines the current fallback rank.
  114078. * @returns the new fallback rank.
  114079. */
  114080. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114081. /**
  114082. * Add the required uniforms to the current list.
  114083. * @param uniforms defines the current uniform list.
  114084. */
  114085. static AddUniforms(uniforms: string[]): void;
  114086. /**
  114087. * Add the required samplers to the current list.
  114088. * @param samplers defines the current sampler list.
  114089. */
  114090. static AddSamplers(samplers: string[]): void;
  114091. /**
  114092. * Add the required uniforms to the current buffer.
  114093. * @param uniformBuffer defines the current uniform buffer.
  114094. */
  114095. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114096. /**
  114097. * Makes a duplicate of the current configuration into another one.
  114098. * @param configuration define the config where to copy the info
  114099. */
  114100. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114101. /**
  114102. * Serializes this Sub Surface configuration.
  114103. * @returns - An object with the serialized config.
  114104. */
  114105. serialize(): any;
  114106. /**
  114107. * Parses a anisotropy Configuration from a serialized object.
  114108. * @param source - Serialized object.
  114109. * @param scene Defines the scene we are parsing for
  114110. * @param rootUrl Defines the rootUrl to load from
  114111. */
  114112. parse(source: any, scene: Scene, rootUrl: string): void;
  114113. }
  114114. }
  114115. declare module BABYLON {
  114116. /** @hidden */
  114117. export var pbrFragmentDeclaration: {
  114118. name: string;
  114119. shader: string;
  114120. };
  114121. }
  114122. declare module BABYLON {
  114123. /** @hidden */
  114124. export var pbrUboDeclaration: {
  114125. name: string;
  114126. shader: string;
  114127. };
  114128. }
  114129. declare module BABYLON {
  114130. /** @hidden */
  114131. export var pbrFragmentExtraDeclaration: {
  114132. name: string;
  114133. shader: string;
  114134. };
  114135. }
  114136. declare module BABYLON {
  114137. /** @hidden */
  114138. export var pbrFragmentSamplersDeclaration: {
  114139. name: string;
  114140. shader: string;
  114141. };
  114142. }
  114143. declare module BABYLON {
  114144. /** @hidden */
  114145. export var pbrHelperFunctions: {
  114146. name: string;
  114147. shader: string;
  114148. };
  114149. }
  114150. declare module BABYLON {
  114151. /** @hidden */
  114152. export var harmonicsFunctions: {
  114153. name: string;
  114154. shader: string;
  114155. };
  114156. }
  114157. declare module BABYLON {
  114158. /** @hidden */
  114159. export var pbrDirectLightingSetupFunctions: {
  114160. name: string;
  114161. shader: string;
  114162. };
  114163. }
  114164. declare module BABYLON {
  114165. /** @hidden */
  114166. export var pbrDirectLightingFalloffFunctions: {
  114167. name: string;
  114168. shader: string;
  114169. };
  114170. }
  114171. declare module BABYLON {
  114172. /** @hidden */
  114173. export var pbrBRDFFunctions: {
  114174. name: string;
  114175. shader: string;
  114176. };
  114177. }
  114178. declare module BABYLON {
  114179. /** @hidden */
  114180. export var pbrDirectLightingFunctions: {
  114181. name: string;
  114182. shader: string;
  114183. };
  114184. }
  114185. declare module BABYLON {
  114186. /** @hidden */
  114187. export var pbrIBLFunctions: {
  114188. name: string;
  114189. shader: string;
  114190. };
  114191. }
  114192. declare module BABYLON {
  114193. /** @hidden */
  114194. export var pbrDebug: {
  114195. name: string;
  114196. shader: string;
  114197. };
  114198. }
  114199. declare module BABYLON {
  114200. /** @hidden */
  114201. export var pbrPixelShader: {
  114202. name: string;
  114203. shader: string;
  114204. };
  114205. }
  114206. declare module BABYLON {
  114207. /** @hidden */
  114208. export var pbrVertexDeclaration: {
  114209. name: string;
  114210. shader: string;
  114211. };
  114212. }
  114213. declare module BABYLON {
  114214. /** @hidden */
  114215. export var pbrVertexShader: {
  114216. name: string;
  114217. shader: string;
  114218. };
  114219. }
  114220. declare module BABYLON {
  114221. /**
  114222. * Manages the defines for the PBR Material.
  114223. * @hidden
  114224. */
  114225. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114226. PBR: boolean;
  114227. MAINUV1: boolean;
  114228. MAINUV2: boolean;
  114229. UV1: boolean;
  114230. UV2: boolean;
  114231. ALBEDO: boolean;
  114232. ALBEDODIRECTUV: number;
  114233. VERTEXCOLOR: boolean;
  114234. AMBIENT: boolean;
  114235. AMBIENTDIRECTUV: number;
  114236. AMBIENTINGRAYSCALE: boolean;
  114237. OPACITY: boolean;
  114238. VERTEXALPHA: boolean;
  114239. OPACITYDIRECTUV: number;
  114240. OPACITYRGB: boolean;
  114241. ALPHATEST: boolean;
  114242. DEPTHPREPASS: boolean;
  114243. ALPHABLEND: boolean;
  114244. ALPHAFROMALBEDO: boolean;
  114245. ALPHATESTVALUE: string;
  114246. SPECULAROVERALPHA: boolean;
  114247. RADIANCEOVERALPHA: boolean;
  114248. ALPHAFRESNEL: boolean;
  114249. LINEARALPHAFRESNEL: boolean;
  114250. PREMULTIPLYALPHA: boolean;
  114251. EMISSIVE: boolean;
  114252. EMISSIVEDIRECTUV: number;
  114253. REFLECTIVITY: boolean;
  114254. REFLECTIVITYDIRECTUV: number;
  114255. SPECULARTERM: boolean;
  114256. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114257. MICROSURFACEAUTOMATIC: boolean;
  114258. LODBASEDMICROSFURACE: boolean;
  114259. MICROSURFACEMAP: boolean;
  114260. MICROSURFACEMAPDIRECTUV: number;
  114261. METALLICWORKFLOW: boolean;
  114262. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114263. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114264. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114265. AOSTOREINMETALMAPRED: boolean;
  114266. ENVIRONMENTBRDF: boolean;
  114267. ENVIRONMENTBRDF_RGBD: boolean;
  114268. NORMAL: boolean;
  114269. TANGENT: boolean;
  114270. BUMP: boolean;
  114271. BUMPDIRECTUV: number;
  114272. OBJECTSPACE_NORMALMAP: boolean;
  114273. PARALLAX: boolean;
  114274. PARALLAXOCCLUSION: boolean;
  114275. NORMALXYSCALE: boolean;
  114276. LIGHTMAP: boolean;
  114277. LIGHTMAPDIRECTUV: number;
  114278. USELIGHTMAPASSHADOWMAP: boolean;
  114279. GAMMALIGHTMAP: boolean;
  114280. RGBDLIGHTMAP: boolean;
  114281. REFLECTION: boolean;
  114282. REFLECTIONMAP_3D: boolean;
  114283. REFLECTIONMAP_SPHERICAL: boolean;
  114284. REFLECTIONMAP_PLANAR: boolean;
  114285. REFLECTIONMAP_CUBIC: boolean;
  114286. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114287. REFLECTIONMAP_PROJECTION: boolean;
  114288. REFLECTIONMAP_SKYBOX: boolean;
  114289. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114290. REFLECTIONMAP_EXPLICIT: boolean;
  114291. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114292. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114293. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114294. INVERTCUBICMAP: boolean;
  114295. USESPHERICALFROMREFLECTIONMAP: boolean;
  114296. USEIRRADIANCEMAP: boolean;
  114297. SPHERICAL_HARMONICS: boolean;
  114298. USESPHERICALINVERTEX: boolean;
  114299. REFLECTIONMAP_OPPOSITEZ: boolean;
  114300. LODINREFLECTIONALPHA: boolean;
  114301. GAMMAREFLECTION: boolean;
  114302. RGBDREFLECTION: boolean;
  114303. LINEARSPECULARREFLECTION: boolean;
  114304. RADIANCEOCCLUSION: boolean;
  114305. HORIZONOCCLUSION: boolean;
  114306. INSTANCES: boolean;
  114307. NUM_BONE_INFLUENCERS: number;
  114308. BonesPerMesh: number;
  114309. BONETEXTURE: boolean;
  114310. NONUNIFORMSCALING: boolean;
  114311. MORPHTARGETS: boolean;
  114312. MORPHTARGETS_NORMAL: boolean;
  114313. MORPHTARGETS_TANGENT: boolean;
  114314. MORPHTARGETS_UV: boolean;
  114315. NUM_MORPH_INFLUENCERS: number;
  114316. IMAGEPROCESSING: boolean;
  114317. VIGNETTE: boolean;
  114318. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114319. VIGNETTEBLENDMODEOPAQUE: boolean;
  114320. TONEMAPPING: boolean;
  114321. TONEMAPPING_ACES: boolean;
  114322. CONTRAST: boolean;
  114323. COLORCURVES: boolean;
  114324. COLORGRADING: boolean;
  114325. COLORGRADING3D: boolean;
  114326. SAMPLER3DGREENDEPTH: boolean;
  114327. SAMPLER3DBGRMAP: boolean;
  114328. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114329. EXPOSURE: boolean;
  114330. MULTIVIEW: boolean;
  114331. USEPHYSICALLIGHTFALLOFF: boolean;
  114332. USEGLTFLIGHTFALLOFF: boolean;
  114333. TWOSIDEDLIGHTING: boolean;
  114334. SHADOWFLOAT: boolean;
  114335. CLIPPLANE: boolean;
  114336. CLIPPLANE2: boolean;
  114337. CLIPPLANE3: boolean;
  114338. CLIPPLANE4: boolean;
  114339. POINTSIZE: boolean;
  114340. FOG: boolean;
  114341. LOGARITHMICDEPTH: boolean;
  114342. FORCENORMALFORWARD: boolean;
  114343. SPECULARAA: boolean;
  114344. CLEARCOAT: boolean;
  114345. CLEARCOAT_DEFAULTIOR: boolean;
  114346. CLEARCOAT_TEXTURE: boolean;
  114347. CLEARCOAT_TEXTUREDIRECTUV: number;
  114348. CLEARCOAT_BUMP: boolean;
  114349. CLEARCOAT_BUMPDIRECTUV: number;
  114350. CLEARCOAT_TINT: boolean;
  114351. CLEARCOAT_TINT_TEXTURE: boolean;
  114352. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114353. ANISOTROPIC: boolean;
  114354. ANISOTROPIC_TEXTURE: boolean;
  114355. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114356. BRDF_V_HEIGHT_CORRELATED: boolean;
  114357. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114358. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114359. SHEEN: boolean;
  114360. SHEEN_TEXTURE: boolean;
  114361. SHEEN_TEXTUREDIRECTUV: number;
  114362. SHEEN_LINKWITHALBEDO: boolean;
  114363. SUBSURFACE: boolean;
  114364. SS_REFRACTION: boolean;
  114365. SS_TRANSLUCENCY: boolean;
  114366. SS_SCATERRING: boolean;
  114367. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114368. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114369. SS_REFRACTIONMAP_3D: boolean;
  114370. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114371. SS_LODINREFRACTIONALPHA: boolean;
  114372. SS_GAMMAREFRACTION: boolean;
  114373. SS_RGBDREFRACTION: boolean;
  114374. SS_LINEARSPECULARREFRACTION: boolean;
  114375. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114376. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114377. UNLIT: boolean;
  114378. DEBUGMODE: number;
  114379. /**
  114380. * Initializes the PBR Material defines.
  114381. */
  114382. constructor();
  114383. /**
  114384. * Resets the PBR Material defines.
  114385. */
  114386. reset(): void;
  114387. }
  114388. /**
  114389. * The Physically based material base class of BJS.
  114390. *
  114391. * This offers the main features of a standard PBR material.
  114392. * For more information, please refer to the documentation :
  114393. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114394. */
  114395. export abstract class PBRBaseMaterial extends PushMaterial {
  114396. /**
  114397. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114398. */
  114399. static readonly PBRMATERIAL_OPAQUE: number;
  114400. /**
  114401. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114402. */
  114403. static readonly PBRMATERIAL_ALPHATEST: number;
  114404. /**
  114405. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114406. */
  114407. static readonly PBRMATERIAL_ALPHABLEND: number;
  114408. /**
  114409. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114410. * They are also discarded below the alpha cutoff threshold to improve performances.
  114411. */
  114412. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114413. /**
  114414. * Defines the default value of how much AO map is occluding the analytical lights
  114415. * (point spot...).
  114416. */
  114417. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114418. /**
  114419. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114420. */
  114421. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114422. /**
  114423. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114424. * to enhance interoperability with other engines.
  114425. */
  114426. static readonly LIGHTFALLOFF_GLTF: number;
  114427. /**
  114428. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114429. * to enhance interoperability with other materials.
  114430. */
  114431. static readonly LIGHTFALLOFF_STANDARD: number;
  114432. /**
  114433. * Intensity of the direct lights e.g. the four lights available in your scene.
  114434. * This impacts both the direct diffuse and specular highlights.
  114435. */
  114436. protected _directIntensity: number;
  114437. /**
  114438. * Intensity of the emissive part of the material.
  114439. * This helps controlling the emissive effect without modifying the emissive color.
  114440. */
  114441. protected _emissiveIntensity: number;
  114442. /**
  114443. * Intensity of the environment e.g. how much the environment will light the object
  114444. * either through harmonics for rough material or through the refelction for shiny ones.
  114445. */
  114446. protected _environmentIntensity: number;
  114447. /**
  114448. * This is a special control allowing the reduction of the specular highlights coming from the
  114449. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114450. */
  114451. protected _specularIntensity: number;
  114452. /**
  114453. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114454. */
  114455. private _lightingInfos;
  114456. /**
  114457. * Debug Control allowing disabling the bump map on this material.
  114458. */
  114459. protected _disableBumpMap: boolean;
  114460. /**
  114461. * AKA Diffuse Texture in standard nomenclature.
  114462. */
  114463. protected _albedoTexture: Nullable<BaseTexture>;
  114464. /**
  114465. * AKA Occlusion Texture in other nomenclature.
  114466. */
  114467. protected _ambientTexture: Nullable<BaseTexture>;
  114468. /**
  114469. * AKA Occlusion Texture Intensity in other nomenclature.
  114470. */
  114471. protected _ambientTextureStrength: number;
  114472. /**
  114473. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114474. * 1 means it completely occludes it
  114475. * 0 mean it has no impact
  114476. */
  114477. protected _ambientTextureImpactOnAnalyticalLights: number;
  114478. /**
  114479. * Stores the alpha values in a texture.
  114480. */
  114481. protected _opacityTexture: Nullable<BaseTexture>;
  114482. /**
  114483. * Stores the reflection values in a texture.
  114484. */
  114485. protected _reflectionTexture: Nullable<BaseTexture>;
  114486. /**
  114487. * Stores the emissive values in a texture.
  114488. */
  114489. protected _emissiveTexture: Nullable<BaseTexture>;
  114490. /**
  114491. * AKA Specular texture in other nomenclature.
  114492. */
  114493. protected _reflectivityTexture: Nullable<BaseTexture>;
  114494. /**
  114495. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114496. */
  114497. protected _metallicTexture: Nullable<BaseTexture>;
  114498. /**
  114499. * Specifies the metallic scalar of the metallic/roughness workflow.
  114500. * Can also be used to scale the metalness values of the metallic texture.
  114501. */
  114502. protected _metallic: Nullable<number>;
  114503. /**
  114504. * Specifies the roughness scalar of the metallic/roughness workflow.
  114505. * Can also be used to scale the roughness values of the metallic texture.
  114506. */
  114507. protected _roughness: Nullable<number>;
  114508. /**
  114509. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114510. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114511. */
  114512. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114513. /**
  114514. * Stores surface normal data used to displace a mesh in a texture.
  114515. */
  114516. protected _bumpTexture: Nullable<BaseTexture>;
  114517. /**
  114518. * Stores the pre-calculated light information of a mesh in a texture.
  114519. */
  114520. protected _lightmapTexture: Nullable<BaseTexture>;
  114521. /**
  114522. * The color of a material in ambient lighting.
  114523. */
  114524. protected _ambientColor: Color3;
  114525. /**
  114526. * AKA Diffuse Color in other nomenclature.
  114527. */
  114528. protected _albedoColor: Color3;
  114529. /**
  114530. * AKA Specular Color in other nomenclature.
  114531. */
  114532. protected _reflectivityColor: Color3;
  114533. /**
  114534. * The color applied when light is reflected from a material.
  114535. */
  114536. protected _reflectionColor: Color3;
  114537. /**
  114538. * The color applied when light is emitted from a material.
  114539. */
  114540. protected _emissiveColor: Color3;
  114541. /**
  114542. * AKA Glossiness in other nomenclature.
  114543. */
  114544. protected _microSurface: number;
  114545. /**
  114546. * Specifies that the material will use the light map as a show map.
  114547. */
  114548. protected _useLightmapAsShadowmap: boolean;
  114549. /**
  114550. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114551. * makes the reflect vector face the model (under horizon).
  114552. */
  114553. protected _useHorizonOcclusion: boolean;
  114554. /**
  114555. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114556. * too much the area relying on ambient texture to define their ambient occlusion.
  114557. */
  114558. protected _useRadianceOcclusion: boolean;
  114559. /**
  114560. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114561. */
  114562. protected _useAlphaFromAlbedoTexture: boolean;
  114563. /**
  114564. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114565. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114566. */
  114567. protected _useSpecularOverAlpha: boolean;
  114568. /**
  114569. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114570. */
  114571. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114572. /**
  114573. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114574. */
  114575. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114576. /**
  114577. * Specifies if the metallic texture contains the roughness information in its green channel.
  114578. */
  114579. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114580. /**
  114581. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114582. */
  114583. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114584. /**
  114585. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114586. */
  114587. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114588. /**
  114589. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114590. */
  114591. protected _useAmbientInGrayScale: boolean;
  114592. /**
  114593. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114594. * The material will try to infer what glossiness each pixel should be.
  114595. */
  114596. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114597. /**
  114598. * Defines the falloff type used in this material.
  114599. * It by default is Physical.
  114600. */
  114601. protected _lightFalloff: number;
  114602. /**
  114603. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114604. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114605. */
  114606. protected _useRadianceOverAlpha: boolean;
  114607. /**
  114608. * Allows using an object space normal map (instead of tangent space).
  114609. */
  114610. protected _useObjectSpaceNormalMap: boolean;
  114611. /**
  114612. * Allows using the bump map in parallax mode.
  114613. */
  114614. protected _useParallax: boolean;
  114615. /**
  114616. * Allows using the bump map in parallax occlusion mode.
  114617. */
  114618. protected _useParallaxOcclusion: boolean;
  114619. /**
  114620. * Controls the scale bias of the parallax mode.
  114621. */
  114622. protected _parallaxScaleBias: number;
  114623. /**
  114624. * If sets to true, disables all the lights affecting the material.
  114625. */
  114626. protected _disableLighting: boolean;
  114627. /**
  114628. * Number of Simultaneous lights allowed on the material.
  114629. */
  114630. protected _maxSimultaneousLights: number;
  114631. /**
  114632. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114633. */
  114634. protected _invertNormalMapX: boolean;
  114635. /**
  114636. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114637. */
  114638. protected _invertNormalMapY: boolean;
  114639. /**
  114640. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114641. */
  114642. protected _twoSidedLighting: boolean;
  114643. /**
  114644. * Defines the alpha limits in alpha test mode.
  114645. */
  114646. protected _alphaCutOff: number;
  114647. /**
  114648. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114649. */
  114650. protected _forceAlphaTest: boolean;
  114651. /**
  114652. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114653. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114654. */
  114655. protected _useAlphaFresnel: boolean;
  114656. /**
  114657. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114658. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114659. */
  114660. protected _useLinearAlphaFresnel: boolean;
  114661. /**
  114662. * The transparency mode of the material.
  114663. */
  114664. protected _transparencyMode: Nullable<number>;
  114665. /**
  114666. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114667. * from cos thetav and roughness:
  114668. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114669. */
  114670. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114671. /**
  114672. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114673. */
  114674. protected _forceIrradianceInFragment: boolean;
  114675. /**
  114676. * Force normal to face away from face.
  114677. */
  114678. protected _forceNormalForward: boolean;
  114679. /**
  114680. * Enables specular anti aliasing in the PBR shader.
  114681. * It will both interacts on the Geometry for analytical and IBL lighting.
  114682. * It also prefilter the roughness map based on the bump values.
  114683. */
  114684. protected _enableSpecularAntiAliasing: boolean;
  114685. /**
  114686. * Default configuration related to image processing available in the PBR Material.
  114687. */
  114688. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114689. /**
  114690. * Keep track of the image processing observer to allow dispose and replace.
  114691. */
  114692. private _imageProcessingObserver;
  114693. /**
  114694. * Attaches a new image processing configuration to the PBR Material.
  114695. * @param configuration
  114696. */
  114697. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114698. /**
  114699. * Stores the available render targets.
  114700. */
  114701. private _renderTargets;
  114702. /**
  114703. * Sets the global ambient color for the material used in lighting calculations.
  114704. */
  114705. private _globalAmbientColor;
  114706. /**
  114707. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114708. */
  114709. private _useLogarithmicDepth;
  114710. /**
  114711. * If set to true, no lighting calculations will be applied.
  114712. */
  114713. private _unlit;
  114714. private _debugMode;
  114715. /**
  114716. * @hidden
  114717. * This is reserved for the inspector.
  114718. * Defines the material debug mode.
  114719. * It helps seeing only some components of the material while troubleshooting.
  114720. */
  114721. debugMode: number;
  114722. /**
  114723. * @hidden
  114724. * This is reserved for the inspector.
  114725. * Specify from where on screen the debug mode should start.
  114726. * The value goes from -1 (full screen) to 1 (not visible)
  114727. * It helps with side by side comparison against the final render
  114728. * This defaults to -1
  114729. */
  114730. private debugLimit;
  114731. /**
  114732. * @hidden
  114733. * This is reserved for the inspector.
  114734. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114735. * You can use the factor to better multiply the final value.
  114736. */
  114737. private debugFactor;
  114738. /**
  114739. * Defines the clear coat layer parameters for the material.
  114740. */
  114741. readonly clearCoat: PBRClearCoatConfiguration;
  114742. /**
  114743. * Defines the anisotropic parameters for the material.
  114744. */
  114745. readonly anisotropy: PBRAnisotropicConfiguration;
  114746. /**
  114747. * Defines the BRDF parameters for the material.
  114748. */
  114749. readonly brdf: PBRBRDFConfiguration;
  114750. /**
  114751. * Defines the Sheen parameters for the material.
  114752. */
  114753. readonly sheen: PBRSheenConfiguration;
  114754. /**
  114755. * Defines the SubSurface parameters for the material.
  114756. */
  114757. readonly subSurface: PBRSubSurfaceConfiguration;
  114758. /**
  114759. * Custom callback helping to override the default shader used in the material.
  114760. */
  114761. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114762. protected _rebuildInParallel: boolean;
  114763. /**
  114764. * Instantiates a new PBRMaterial instance.
  114765. *
  114766. * @param name The material name
  114767. * @param scene The scene the material will be use in.
  114768. */
  114769. constructor(name: string, scene: Scene);
  114770. /**
  114771. * Gets a boolean indicating that current material needs to register RTT
  114772. */
  114773. readonly hasRenderTargetTextures: boolean;
  114774. /**
  114775. * Gets the name of the material class.
  114776. */
  114777. getClassName(): string;
  114778. /**
  114779. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114780. */
  114781. /**
  114782. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114783. */
  114784. useLogarithmicDepth: boolean;
  114785. /**
  114786. * Gets the current transparency mode.
  114787. */
  114788. /**
  114789. * Sets the transparency mode of the material.
  114790. *
  114791. * | Value | Type | Description |
  114792. * | ----- | ----------------------------------- | ----------- |
  114793. * | 0 | OPAQUE | |
  114794. * | 1 | ALPHATEST | |
  114795. * | 2 | ALPHABLEND | |
  114796. * | 3 | ALPHATESTANDBLEND | |
  114797. *
  114798. */
  114799. transparencyMode: Nullable<number>;
  114800. /**
  114801. * Returns true if alpha blending should be disabled.
  114802. */
  114803. private readonly _disableAlphaBlending;
  114804. /**
  114805. * Specifies whether or not this material should be rendered in alpha blend mode.
  114806. */
  114807. needAlphaBlending(): boolean;
  114808. /**
  114809. * Specifies if the mesh will require alpha blending.
  114810. * @param mesh - BJS mesh.
  114811. */
  114812. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114813. /**
  114814. * Specifies whether or not this material should be rendered in alpha test mode.
  114815. */
  114816. needAlphaTesting(): boolean;
  114817. /**
  114818. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114819. */
  114820. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114821. /**
  114822. * Gets the texture used for the alpha test.
  114823. */
  114824. getAlphaTestTexture(): Nullable<BaseTexture>;
  114825. /**
  114826. * Specifies that the submesh is ready to be used.
  114827. * @param mesh - BJS mesh.
  114828. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114829. * @param useInstances - Specifies that instances should be used.
  114830. * @returns - boolean indicating that the submesh is ready or not.
  114831. */
  114832. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114833. /**
  114834. * Specifies if the material uses metallic roughness workflow.
  114835. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114836. */
  114837. isMetallicWorkflow(): boolean;
  114838. private _prepareEffect;
  114839. private _prepareDefines;
  114840. /**
  114841. * Force shader compilation
  114842. */
  114843. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114844. clipPlane: boolean;
  114845. }>): void;
  114846. /**
  114847. * Initializes the uniform buffer layout for the shader.
  114848. */
  114849. buildUniformLayout(): void;
  114850. /**
  114851. * Unbinds the material from the mesh
  114852. */
  114853. unbind(): void;
  114854. /**
  114855. * Binds the submesh data.
  114856. * @param world - The world matrix.
  114857. * @param mesh - The BJS mesh.
  114858. * @param subMesh - A submesh of the BJS mesh.
  114859. */
  114860. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114861. /**
  114862. * Returns the animatable textures.
  114863. * @returns - Array of animatable textures.
  114864. */
  114865. getAnimatables(): IAnimatable[];
  114866. /**
  114867. * Returns the texture used for reflections.
  114868. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114869. */
  114870. private _getReflectionTexture;
  114871. /**
  114872. * Returns an array of the actively used textures.
  114873. * @returns - Array of BaseTextures
  114874. */
  114875. getActiveTextures(): BaseTexture[];
  114876. /**
  114877. * Checks to see if a texture is used in the material.
  114878. * @param texture - Base texture to use.
  114879. * @returns - Boolean specifying if a texture is used in the material.
  114880. */
  114881. hasTexture(texture: BaseTexture): boolean;
  114882. /**
  114883. * Disposes the resources of the material.
  114884. * @param forceDisposeEffect - Forces the disposal of effects.
  114885. * @param forceDisposeTextures - Forces the disposal of all textures.
  114886. */
  114887. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114888. }
  114889. }
  114890. declare module BABYLON {
  114891. /**
  114892. * The Physically based material of BJS.
  114893. *
  114894. * This offers the main features of a standard PBR material.
  114895. * For more information, please refer to the documentation :
  114896. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114897. */
  114898. export class PBRMaterial extends PBRBaseMaterial {
  114899. /**
  114900. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114901. */
  114902. static readonly PBRMATERIAL_OPAQUE: number;
  114903. /**
  114904. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114905. */
  114906. static readonly PBRMATERIAL_ALPHATEST: number;
  114907. /**
  114908. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114909. */
  114910. static readonly PBRMATERIAL_ALPHABLEND: number;
  114911. /**
  114912. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114913. * They are also discarded below the alpha cutoff threshold to improve performances.
  114914. */
  114915. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114916. /**
  114917. * Defines the default value of how much AO map is occluding the analytical lights
  114918. * (point spot...).
  114919. */
  114920. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114921. /**
  114922. * Intensity of the direct lights e.g. the four lights available in your scene.
  114923. * This impacts both the direct diffuse and specular highlights.
  114924. */
  114925. directIntensity: number;
  114926. /**
  114927. * Intensity of the emissive part of the material.
  114928. * This helps controlling the emissive effect without modifying the emissive color.
  114929. */
  114930. emissiveIntensity: number;
  114931. /**
  114932. * Intensity of the environment e.g. how much the environment will light the object
  114933. * either through harmonics for rough material or through the refelction for shiny ones.
  114934. */
  114935. environmentIntensity: number;
  114936. /**
  114937. * This is a special control allowing the reduction of the specular highlights coming from the
  114938. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114939. */
  114940. specularIntensity: number;
  114941. /**
  114942. * Debug Control allowing disabling the bump map on this material.
  114943. */
  114944. disableBumpMap: boolean;
  114945. /**
  114946. * AKA Diffuse Texture in standard nomenclature.
  114947. */
  114948. albedoTexture: BaseTexture;
  114949. /**
  114950. * AKA Occlusion Texture in other nomenclature.
  114951. */
  114952. ambientTexture: BaseTexture;
  114953. /**
  114954. * AKA Occlusion Texture Intensity in other nomenclature.
  114955. */
  114956. ambientTextureStrength: number;
  114957. /**
  114958. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114959. * 1 means it completely occludes it
  114960. * 0 mean it has no impact
  114961. */
  114962. ambientTextureImpactOnAnalyticalLights: number;
  114963. /**
  114964. * Stores the alpha values in a texture.
  114965. */
  114966. opacityTexture: BaseTexture;
  114967. /**
  114968. * Stores the reflection values in a texture.
  114969. */
  114970. reflectionTexture: Nullable<BaseTexture>;
  114971. /**
  114972. * Stores the emissive values in a texture.
  114973. */
  114974. emissiveTexture: BaseTexture;
  114975. /**
  114976. * AKA Specular texture in other nomenclature.
  114977. */
  114978. reflectivityTexture: BaseTexture;
  114979. /**
  114980. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114981. */
  114982. metallicTexture: BaseTexture;
  114983. /**
  114984. * Specifies the metallic scalar of the metallic/roughness workflow.
  114985. * Can also be used to scale the metalness values of the metallic texture.
  114986. */
  114987. metallic: Nullable<number>;
  114988. /**
  114989. * Specifies the roughness scalar of the metallic/roughness workflow.
  114990. * Can also be used to scale the roughness values of the metallic texture.
  114991. */
  114992. roughness: Nullable<number>;
  114993. /**
  114994. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114995. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114996. */
  114997. microSurfaceTexture: BaseTexture;
  114998. /**
  114999. * Stores surface normal data used to displace a mesh in a texture.
  115000. */
  115001. bumpTexture: BaseTexture;
  115002. /**
  115003. * Stores the pre-calculated light information of a mesh in a texture.
  115004. */
  115005. lightmapTexture: BaseTexture;
  115006. /**
  115007. * Stores the refracted light information in a texture.
  115008. */
  115009. refractionTexture: Nullable<BaseTexture>;
  115010. /**
  115011. * The color of a material in ambient lighting.
  115012. */
  115013. ambientColor: Color3;
  115014. /**
  115015. * AKA Diffuse Color in other nomenclature.
  115016. */
  115017. albedoColor: Color3;
  115018. /**
  115019. * AKA Specular Color in other nomenclature.
  115020. */
  115021. reflectivityColor: Color3;
  115022. /**
  115023. * The color reflected from the material.
  115024. */
  115025. reflectionColor: Color3;
  115026. /**
  115027. * The color emitted from the material.
  115028. */
  115029. emissiveColor: Color3;
  115030. /**
  115031. * AKA Glossiness in other nomenclature.
  115032. */
  115033. microSurface: number;
  115034. /**
  115035. * source material index of refraction (IOR)' / 'destination material IOR.
  115036. */
  115037. indexOfRefraction: number;
  115038. /**
  115039. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115040. */
  115041. invertRefractionY: boolean;
  115042. /**
  115043. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115044. * Materials half opaque for instance using refraction could benefit from this control.
  115045. */
  115046. linkRefractionWithTransparency: boolean;
  115047. /**
  115048. * If true, the light map contains occlusion information instead of lighting info.
  115049. */
  115050. useLightmapAsShadowmap: boolean;
  115051. /**
  115052. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115053. */
  115054. useAlphaFromAlbedoTexture: boolean;
  115055. /**
  115056. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115057. */
  115058. forceAlphaTest: boolean;
  115059. /**
  115060. * Defines the alpha limits in alpha test mode.
  115061. */
  115062. alphaCutOff: number;
  115063. /**
  115064. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115065. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115066. */
  115067. useSpecularOverAlpha: boolean;
  115068. /**
  115069. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115070. */
  115071. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115072. /**
  115073. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115074. */
  115075. useRoughnessFromMetallicTextureAlpha: boolean;
  115076. /**
  115077. * Specifies if the metallic texture contains the roughness information in its green channel.
  115078. */
  115079. useRoughnessFromMetallicTextureGreen: boolean;
  115080. /**
  115081. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115082. */
  115083. useMetallnessFromMetallicTextureBlue: boolean;
  115084. /**
  115085. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115086. */
  115087. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115088. /**
  115089. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115090. */
  115091. useAmbientInGrayScale: boolean;
  115092. /**
  115093. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115094. * The material will try to infer what glossiness each pixel should be.
  115095. */
  115096. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115097. /**
  115098. * BJS is using an harcoded light falloff based on a manually sets up range.
  115099. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115100. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115101. */
  115102. /**
  115103. * BJS is using an harcoded light falloff based on a manually sets up range.
  115104. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115105. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115106. */
  115107. usePhysicalLightFalloff: boolean;
  115108. /**
  115109. * In order to support the falloff compatibility with gltf, a special mode has been added
  115110. * to reproduce the gltf light falloff.
  115111. */
  115112. /**
  115113. * In order to support the falloff compatibility with gltf, a special mode has been added
  115114. * to reproduce the gltf light falloff.
  115115. */
  115116. useGLTFLightFalloff: boolean;
  115117. /**
  115118. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115119. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115120. */
  115121. useRadianceOverAlpha: boolean;
  115122. /**
  115123. * Allows using an object space normal map (instead of tangent space).
  115124. */
  115125. useObjectSpaceNormalMap: boolean;
  115126. /**
  115127. * Allows using the bump map in parallax mode.
  115128. */
  115129. useParallax: boolean;
  115130. /**
  115131. * Allows using the bump map in parallax occlusion mode.
  115132. */
  115133. useParallaxOcclusion: boolean;
  115134. /**
  115135. * Controls the scale bias of the parallax mode.
  115136. */
  115137. parallaxScaleBias: number;
  115138. /**
  115139. * If sets to true, disables all the lights affecting the material.
  115140. */
  115141. disableLighting: boolean;
  115142. /**
  115143. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115144. */
  115145. forceIrradianceInFragment: boolean;
  115146. /**
  115147. * Number of Simultaneous lights allowed on the material.
  115148. */
  115149. maxSimultaneousLights: number;
  115150. /**
  115151. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115152. */
  115153. invertNormalMapX: boolean;
  115154. /**
  115155. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115156. */
  115157. invertNormalMapY: boolean;
  115158. /**
  115159. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115160. */
  115161. twoSidedLighting: boolean;
  115162. /**
  115163. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115164. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115165. */
  115166. useAlphaFresnel: boolean;
  115167. /**
  115168. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115169. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115170. */
  115171. useLinearAlphaFresnel: boolean;
  115172. /**
  115173. * Let user defines the brdf lookup texture used for IBL.
  115174. * A default 8bit version is embedded but you could point at :
  115175. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115176. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115177. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115178. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115179. */
  115180. environmentBRDFTexture: Nullable<BaseTexture>;
  115181. /**
  115182. * Force normal to face away from face.
  115183. */
  115184. forceNormalForward: boolean;
  115185. /**
  115186. * Enables specular anti aliasing in the PBR shader.
  115187. * It will both interacts on the Geometry for analytical and IBL lighting.
  115188. * It also prefilter the roughness map based on the bump values.
  115189. */
  115190. enableSpecularAntiAliasing: boolean;
  115191. /**
  115192. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115193. * makes the reflect vector face the model (under horizon).
  115194. */
  115195. useHorizonOcclusion: boolean;
  115196. /**
  115197. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115198. * too much the area relying on ambient texture to define their ambient occlusion.
  115199. */
  115200. useRadianceOcclusion: boolean;
  115201. /**
  115202. * If set to true, no lighting calculations will be applied.
  115203. */
  115204. unlit: boolean;
  115205. /**
  115206. * Gets the image processing configuration used either in this material.
  115207. */
  115208. /**
  115209. * Sets the Default image processing configuration used either in the this material.
  115210. *
  115211. * If sets to null, the scene one is in use.
  115212. */
  115213. imageProcessingConfiguration: ImageProcessingConfiguration;
  115214. /**
  115215. * Gets wether the color curves effect is enabled.
  115216. */
  115217. /**
  115218. * Sets wether the color curves effect is enabled.
  115219. */
  115220. cameraColorCurvesEnabled: boolean;
  115221. /**
  115222. * Gets wether the color grading effect is enabled.
  115223. */
  115224. /**
  115225. * Gets wether the color grading effect is enabled.
  115226. */
  115227. cameraColorGradingEnabled: boolean;
  115228. /**
  115229. * Gets wether tonemapping is enabled or not.
  115230. */
  115231. /**
  115232. * Sets wether tonemapping is enabled or not
  115233. */
  115234. cameraToneMappingEnabled: boolean;
  115235. /**
  115236. * The camera exposure used on this material.
  115237. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115238. * This corresponds to a photographic exposure.
  115239. */
  115240. /**
  115241. * The camera exposure used on this material.
  115242. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115243. * This corresponds to a photographic exposure.
  115244. */
  115245. cameraExposure: number;
  115246. /**
  115247. * Gets The camera contrast used on this material.
  115248. */
  115249. /**
  115250. * Sets The camera contrast used on this material.
  115251. */
  115252. cameraContrast: number;
  115253. /**
  115254. * Gets the Color Grading 2D Lookup Texture.
  115255. */
  115256. /**
  115257. * Sets the Color Grading 2D Lookup Texture.
  115258. */
  115259. cameraColorGradingTexture: Nullable<BaseTexture>;
  115260. /**
  115261. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115262. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115263. * 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;
  115264. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115265. */
  115266. /**
  115267. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115268. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115269. * 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;
  115270. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115271. */
  115272. cameraColorCurves: Nullable<ColorCurves>;
  115273. /**
  115274. * Instantiates a new PBRMaterial instance.
  115275. *
  115276. * @param name The material name
  115277. * @param scene The scene the material will be use in.
  115278. */
  115279. constructor(name: string, scene: Scene);
  115280. /**
  115281. * Returns the name of this material class.
  115282. */
  115283. getClassName(): string;
  115284. /**
  115285. * Makes a duplicate of the current material.
  115286. * @param name - name to use for the new material.
  115287. */
  115288. clone(name: string): PBRMaterial;
  115289. /**
  115290. * Serializes this PBR Material.
  115291. * @returns - An object with the serialized material.
  115292. */
  115293. serialize(): any;
  115294. /**
  115295. * Parses a PBR Material from a serialized object.
  115296. * @param source - Serialized object.
  115297. * @param scene - BJS scene instance.
  115298. * @param rootUrl - url for the scene object
  115299. * @returns - PBRMaterial
  115300. */
  115301. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115302. }
  115303. }
  115304. declare module BABYLON {
  115305. /**
  115306. * Direct draw surface info
  115307. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115308. */
  115309. export interface DDSInfo {
  115310. /**
  115311. * Width of the texture
  115312. */
  115313. width: number;
  115314. /**
  115315. * Width of the texture
  115316. */
  115317. height: number;
  115318. /**
  115319. * Number of Mipmaps for the texture
  115320. * @see https://en.wikipedia.org/wiki/Mipmap
  115321. */
  115322. mipmapCount: number;
  115323. /**
  115324. * If the textures format is a known fourCC format
  115325. * @see https://www.fourcc.org/
  115326. */
  115327. isFourCC: boolean;
  115328. /**
  115329. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115330. */
  115331. isRGB: boolean;
  115332. /**
  115333. * If the texture is a lumincance format
  115334. */
  115335. isLuminance: boolean;
  115336. /**
  115337. * If this is a cube texture
  115338. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115339. */
  115340. isCube: boolean;
  115341. /**
  115342. * If the texture is a compressed format eg. FOURCC_DXT1
  115343. */
  115344. isCompressed: boolean;
  115345. /**
  115346. * The dxgiFormat of the texture
  115347. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115348. */
  115349. dxgiFormat: number;
  115350. /**
  115351. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115352. */
  115353. textureType: number;
  115354. /**
  115355. * Sphericle polynomial created for the dds texture
  115356. */
  115357. sphericalPolynomial?: SphericalPolynomial;
  115358. }
  115359. /**
  115360. * Class used to provide DDS decompression tools
  115361. */
  115362. export class DDSTools {
  115363. /**
  115364. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115365. */
  115366. static StoreLODInAlphaChannel: boolean;
  115367. /**
  115368. * Gets DDS information from an array buffer
  115369. * @param arrayBuffer defines the array buffer to read data from
  115370. * @returns the DDS information
  115371. */
  115372. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115373. private static _FloatView;
  115374. private static _Int32View;
  115375. private static _ToHalfFloat;
  115376. private static _FromHalfFloat;
  115377. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115378. private static _GetHalfFloatRGBAArrayBuffer;
  115379. private static _GetFloatRGBAArrayBuffer;
  115380. private static _GetFloatAsUIntRGBAArrayBuffer;
  115381. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115382. private static _GetRGBAArrayBuffer;
  115383. private static _ExtractLongWordOrder;
  115384. private static _GetRGBArrayBuffer;
  115385. private static _GetLuminanceArrayBuffer;
  115386. /**
  115387. * Uploads DDS Levels to a Babylon Texture
  115388. * @hidden
  115389. */
  115390. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115391. }
  115392. interface ThinEngine {
  115393. /**
  115394. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115395. * @param rootUrl defines the url where the file to load is located
  115396. * @param scene defines the current scene
  115397. * @param lodScale defines scale to apply to the mip map selection
  115398. * @param lodOffset defines offset to apply to the mip map selection
  115399. * @param onLoad defines an optional callback raised when the texture is loaded
  115400. * @param onError defines an optional callback raised if there is an issue to load the texture
  115401. * @param format defines the format of the data
  115402. * @param forcedExtension defines the extension to use to pick the right loader
  115403. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115404. * @returns the cube texture as an InternalTexture
  115405. */
  115406. 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;
  115407. }
  115408. }
  115409. declare module BABYLON {
  115410. /**
  115411. * Implementation of the DDS Texture Loader.
  115412. * @hidden
  115413. */
  115414. export class _DDSTextureLoader implements IInternalTextureLoader {
  115415. /**
  115416. * Defines wether the loader supports cascade loading the different faces.
  115417. */
  115418. readonly supportCascades: boolean;
  115419. /**
  115420. * This returns if the loader support the current file information.
  115421. * @param extension defines the file extension of the file being loaded
  115422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115423. * @param fallback defines the fallback internal texture if any
  115424. * @param isBase64 defines whether the texture is encoded as a base64
  115425. * @param isBuffer defines whether the texture data are stored as a buffer
  115426. * @returns true if the loader can load the specified file
  115427. */
  115428. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115429. /**
  115430. * Transform the url before loading if required.
  115431. * @param rootUrl the url of the texture
  115432. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115433. * @returns the transformed texture
  115434. */
  115435. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115436. /**
  115437. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115438. * @param rootUrl the url of the texture
  115439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115440. * @returns the fallback texture
  115441. */
  115442. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115443. /**
  115444. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115445. * @param data contains the texture data
  115446. * @param texture defines the BabylonJS internal texture
  115447. * @param createPolynomials will be true if polynomials have been requested
  115448. * @param onLoad defines the callback to trigger once the texture is ready
  115449. * @param onError defines the callback to trigger in case of error
  115450. */
  115451. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115452. /**
  115453. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115454. * @param data contains the texture data
  115455. * @param texture defines the BabylonJS internal texture
  115456. * @param callback defines the method to call once ready to upload
  115457. */
  115458. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115459. }
  115460. }
  115461. declare module BABYLON {
  115462. /**
  115463. * Implementation of the ENV Texture Loader.
  115464. * @hidden
  115465. */
  115466. export class _ENVTextureLoader implements IInternalTextureLoader {
  115467. /**
  115468. * Defines wether the loader supports cascade loading the different faces.
  115469. */
  115470. readonly supportCascades: boolean;
  115471. /**
  115472. * This returns if the loader support the current file information.
  115473. * @param extension defines the file extension of the file being loaded
  115474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115475. * @param fallback defines the fallback internal texture if any
  115476. * @param isBase64 defines whether the texture is encoded as a base64
  115477. * @param isBuffer defines whether the texture data are stored as a buffer
  115478. * @returns true if the loader can load the specified file
  115479. */
  115480. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115481. /**
  115482. * Transform the url before loading if required.
  115483. * @param rootUrl the url of the texture
  115484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115485. * @returns the transformed texture
  115486. */
  115487. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115488. /**
  115489. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115490. * @param rootUrl the url of the texture
  115491. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115492. * @returns the fallback texture
  115493. */
  115494. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115495. /**
  115496. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115497. * @param data contains the texture data
  115498. * @param texture defines the BabylonJS internal texture
  115499. * @param createPolynomials will be true if polynomials have been requested
  115500. * @param onLoad defines the callback to trigger once the texture is ready
  115501. * @param onError defines the callback to trigger in case of error
  115502. */
  115503. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115504. /**
  115505. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115506. * @param data contains the texture data
  115507. * @param texture defines the BabylonJS internal texture
  115508. * @param callback defines the method to call once ready to upload
  115509. */
  115510. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115511. }
  115512. }
  115513. declare module BABYLON {
  115514. /**
  115515. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115516. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115517. */
  115518. export class KhronosTextureContainer {
  115519. /** contents of the KTX container file */
  115520. arrayBuffer: any;
  115521. private static HEADER_LEN;
  115522. private static COMPRESSED_2D;
  115523. private static COMPRESSED_3D;
  115524. private static TEX_2D;
  115525. private static TEX_3D;
  115526. /**
  115527. * Gets the openGL type
  115528. */
  115529. glType: number;
  115530. /**
  115531. * Gets the openGL type size
  115532. */
  115533. glTypeSize: number;
  115534. /**
  115535. * Gets the openGL format
  115536. */
  115537. glFormat: number;
  115538. /**
  115539. * Gets the openGL internal format
  115540. */
  115541. glInternalFormat: number;
  115542. /**
  115543. * Gets the base internal format
  115544. */
  115545. glBaseInternalFormat: number;
  115546. /**
  115547. * Gets image width in pixel
  115548. */
  115549. pixelWidth: number;
  115550. /**
  115551. * Gets image height in pixel
  115552. */
  115553. pixelHeight: number;
  115554. /**
  115555. * Gets image depth in pixels
  115556. */
  115557. pixelDepth: number;
  115558. /**
  115559. * Gets the number of array elements
  115560. */
  115561. numberOfArrayElements: number;
  115562. /**
  115563. * Gets the number of faces
  115564. */
  115565. numberOfFaces: number;
  115566. /**
  115567. * Gets the number of mipmap levels
  115568. */
  115569. numberOfMipmapLevels: number;
  115570. /**
  115571. * Gets the bytes of key value data
  115572. */
  115573. bytesOfKeyValueData: number;
  115574. /**
  115575. * Gets the load type
  115576. */
  115577. loadType: number;
  115578. /**
  115579. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115580. */
  115581. isInvalid: boolean;
  115582. /**
  115583. * Creates a new KhronosTextureContainer
  115584. * @param arrayBuffer contents of the KTX container file
  115585. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115586. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115587. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115588. */
  115589. constructor(
  115590. /** contents of the KTX container file */
  115591. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115592. /**
  115593. * Uploads KTX content to a Babylon Texture.
  115594. * It is assumed that the texture has already been created & is currently bound
  115595. * @hidden
  115596. */
  115597. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115598. private _upload2DCompressedLevels;
  115599. }
  115600. }
  115601. declare module BABYLON {
  115602. /**
  115603. * Implementation of the KTX Texture Loader.
  115604. * @hidden
  115605. */
  115606. export class _KTXTextureLoader implements IInternalTextureLoader {
  115607. /**
  115608. * Defines wether the loader supports cascade loading the different faces.
  115609. */
  115610. readonly supportCascades: boolean;
  115611. /**
  115612. * This returns if the loader support the current file information.
  115613. * @param extension defines the file extension of the file being loaded
  115614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115615. * @param fallback defines the fallback internal texture if any
  115616. * @param isBase64 defines whether the texture is encoded as a base64
  115617. * @param isBuffer defines whether the texture data are stored as a buffer
  115618. * @returns true if the loader can load the specified file
  115619. */
  115620. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115621. /**
  115622. * Transform the url before loading if required.
  115623. * @param rootUrl the url of the texture
  115624. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115625. * @returns the transformed texture
  115626. */
  115627. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115628. /**
  115629. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115630. * @param rootUrl the url of the texture
  115631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115632. * @returns the fallback texture
  115633. */
  115634. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115635. /**
  115636. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115637. * @param data contains the texture data
  115638. * @param texture defines the BabylonJS internal texture
  115639. * @param createPolynomials will be true if polynomials have been requested
  115640. * @param onLoad defines the callback to trigger once the texture is ready
  115641. * @param onError defines the callback to trigger in case of error
  115642. */
  115643. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115644. /**
  115645. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115646. * @param data contains the texture data
  115647. * @param texture defines the BabylonJS internal texture
  115648. * @param callback defines the method to call once ready to upload
  115649. */
  115650. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115651. }
  115652. }
  115653. declare module BABYLON {
  115654. /**
  115655. * Options for the default xr helper
  115656. */
  115657. export class WebXRDefaultExperienceOptions {
  115658. /**
  115659. * Floor meshes that should be used for teleporting
  115660. */
  115661. floorMeshes: Array<AbstractMesh>;
  115662. }
  115663. /**
  115664. * Default experience which provides a similar setup to the previous webVRExperience
  115665. */
  115666. export class WebXRDefaultExperience {
  115667. /**
  115668. * Base experience
  115669. */
  115670. baseExperience: WebXRExperienceHelper;
  115671. /**
  115672. * Input experience extension
  115673. */
  115674. input: WebXRInput;
  115675. /**
  115676. * Loads the controller models
  115677. */
  115678. controllerModelLoader: WebXRControllerModelLoader;
  115679. /**
  115680. * Enables laser pointer and selection
  115681. */
  115682. pointerSelection: WebXRControllerPointerSelection;
  115683. /**
  115684. * Enables teleportation
  115685. */
  115686. teleportation: WebXRControllerTeleportation;
  115687. /**
  115688. * Enables ui for enetering/exiting xr
  115689. */
  115690. enterExitUI: WebXREnterExitUI;
  115691. /**
  115692. * Default output canvas xr should render to
  115693. */
  115694. outputCanvas: WebXRManagedOutputCanvas;
  115695. /**
  115696. * Creates the default xr experience
  115697. * @param scene scene
  115698. * @param options options for basic configuration
  115699. * @returns resulting WebXRDefaultExperience
  115700. */
  115701. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115702. private constructor();
  115703. /**
  115704. * DIsposes of the experience helper
  115705. */
  115706. dispose(): void;
  115707. }
  115708. }
  115709. declare module BABYLON {
  115710. /** @hidden */
  115711. export var _forceSceneHelpersToBundle: boolean;
  115712. interface Scene {
  115713. /**
  115714. * Creates a default light for the scene.
  115715. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115716. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115717. */
  115718. createDefaultLight(replace?: boolean): void;
  115719. /**
  115720. * Creates a default camera for the scene.
  115721. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115722. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115723. * @param replace has default false, when true replaces the active camera in the scene
  115724. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115725. */
  115726. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115727. /**
  115728. * Creates a default camera and a default light.
  115729. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115730. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115731. * @param replace has the default false, when true replaces the active camera/light in the scene
  115732. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115733. */
  115734. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115735. /**
  115736. * Creates a new sky box
  115737. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115738. * @param environmentTexture defines the texture to use as environment texture
  115739. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115740. * @param scale defines the overall scale of the skybox
  115741. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115742. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115743. * @returns a new mesh holding the sky box
  115744. */
  115745. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115746. /**
  115747. * Creates a new environment
  115748. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115749. * @param options defines the options you can use to configure the environment
  115750. * @returns the new EnvironmentHelper
  115751. */
  115752. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115753. /**
  115754. * Creates a new VREXperienceHelper
  115755. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115756. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115757. * @returns a new VREXperienceHelper
  115758. */
  115759. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115760. /**
  115761. * Creates a new WebXRDefaultExperience
  115762. * @see http://doc.babylonjs.com/how_to/webxr
  115763. * @param options experience options
  115764. * @returns a promise for a new WebXRDefaultExperience
  115765. */
  115766. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115767. }
  115768. }
  115769. declare module BABYLON {
  115770. /**
  115771. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115772. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115773. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115774. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115775. */
  115776. export class VideoDome extends TransformNode {
  115777. /**
  115778. * Define the video source as a Monoscopic panoramic 360 video.
  115779. */
  115780. static readonly MODE_MONOSCOPIC: number;
  115781. /**
  115782. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115783. */
  115784. static readonly MODE_TOPBOTTOM: number;
  115785. /**
  115786. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115787. */
  115788. static readonly MODE_SIDEBYSIDE: number;
  115789. private _halfDome;
  115790. private _useDirectMapping;
  115791. /**
  115792. * The video texture being displayed on the sphere
  115793. */
  115794. protected _videoTexture: VideoTexture;
  115795. /**
  115796. * Gets the video texture being displayed on the sphere
  115797. */
  115798. readonly videoTexture: VideoTexture;
  115799. /**
  115800. * The skybox material
  115801. */
  115802. protected _material: BackgroundMaterial;
  115803. /**
  115804. * The surface used for the skybox
  115805. */
  115806. protected _mesh: Mesh;
  115807. /**
  115808. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115809. */
  115810. private _halfDomeMask;
  115811. /**
  115812. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115813. * Also see the options.resolution property.
  115814. */
  115815. fovMultiplier: number;
  115816. private _videoMode;
  115817. /**
  115818. * Gets or set the current video mode for the video. It can be:
  115819. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115820. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115821. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115822. */
  115823. videoMode: number;
  115824. /**
  115825. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115826. *
  115827. */
  115828. /**
  115829. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115830. */
  115831. halfDome: boolean;
  115832. /**
  115833. * Oberserver used in Stereoscopic VR Mode.
  115834. */
  115835. private _onBeforeCameraRenderObserver;
  115836. /**
  115837. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115838. * @param name Element's name, child elements will append suffixes for their own names.
  115839. * @param urlsOrVideo defines the url(s) or the video element to use
  115840. * @param options An object containing optional or exposed sub element properties
  115841. */
  115842. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115843. resolution?: number;
  115844. clickToPlay?: boolean;
  115845. autoPlay?: boolean;
  115846. loop?: boolean;
  115847. size?: number;
  115848. poster?: string;
  115849. faceForward?: boolean;
  115850. useDirectMapping?: boolean;
  115851. halfDomeMode?: boolean;
  115852. }, scene: Scene);
  115853. private _changeVideoMode;
  115854. /**
  115855. * Releases resources associated with this node.
  115856. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115857. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115858. */
  115859. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115860. }
  115861. }
  115862. declare module BABYLON {
  115863. /**
  115864. * This class can be used to get instrumentation data from a Babylon engine
  115865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115866. */
  115867. export class EngineInstrumentation implements IDisposable {
  115868. /**
  115869. * Define the instrumented engine.
  115870. */
  115871. engine: Engine;
  115872. private _captureGPUFrameTime;
  115873. private _gpuFrameTimeToken;
  115874. private _gpuFrameTime;
  115875. private _captureShaderCompilationTime;
  115876. private _shaderCompilationTime;
  115877. private _onBeginFrameObserver;
  115878. private _onEndFrameObserver;
  115879. private _onBeforeShaderCompilationObserver;
  115880. private _onAfterShaderCompilationObserver;
  115881. /**
  115882. * Gets the perf counter used for GPU frame time
  115883. */
  115884. readonly gpuFrameTimeCounter: PerfCounter;
  115885. /**
  115886. * Gets the GPU frame time capture status
  115887. */
  115888. /**
  115889. * Enable or disable the GPU frame time capture
  115890. */
  115891. captureGPUFrameTime: boolean;
  115892. /**
  115893. * Gets the perf counter used for shader compilation time
  115894. */
  115895. readonly shaderCompilationTimeCounter: PerfCounter;
  115896. /**
  115897. * Gets the shader compilation time capture status
  115898. */
  115899. /**
  115900. * Enable or disable the shader compilation time capture
  115901. */
  115902. captureShaderCompilationTime: boolean;
  115903. /**
  115904. * Instantiates a new engine instrumentation.
  115905. * This class can be used to get instrumentation data from a Babylon engine
  115906. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115907. * @param engine Defines the engine to instrument
  115908. */
  115909. constructor(
  115910. /**
  115911. * Define the instrumented engine.
  115912. */
  115913. engine: Engine);
  115914. /**
  115915. * Dispose and release associated resources.
  115916. */
  115917. dispose(): void;
  115918. }
  115919. }
  115920. declare module BABYLON {
  115921. /**
  115922. * This class can be used to get instrumentation data from a Babylon engine
  115923. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115924. */
  115925. export class SceneInstrumentation implements IDisposable {
  115926. /**
  115927. * Defines the scene to instrument
  115928. */
  115929. scene: Scene;
  115930. private _captureActiveMeshesEvaluationTime;
  115931. private _activeMeshesEvaluationTime;
  115932. private _captureRenderTargetsRenderTime;
  115933. private _renderTargetsRenderTime;
  115934. private _captureFrameTime;
  115935. private _frameTime;
  115936. private _captureRenderTime;
  115937. private _renderTime;
  115938. private _captureInterFrameTime;
  115939. private _interFrameTime;
  115940. private _captureParticlesRenderTime;
  115941. private _particlesRenderTime;
  115942. private _captureSpritesRenderTime;
  115943. private _spritesRenderTime;
  115944. private _capturePhysicsTime;
  115945. private _physicsTime;
  115946. private _captureAnimationsTime;
  115947. private _animationsTime;
  115948. private _captureCameraRenderTime;
  115949. private _cameraRenderTime;
  115950. private _onBeforeActiveMeshesEvaluationObserver;
  115951. private _onAfterActiveMeshesEvaluationObserver;
  115952. private _onBeforeRenderTargetsRenderObserver;
  115953. private _onAfterRenderTargetsRenderObserver;
  115954. private _onAfterRenderObserver;
  115955. private _onBeforeDrawPhaseObserver;
  115956. private _onAfterDrawPhaseObserver;
  115957. private _onBeforeAnimationsObserver;
  115958. private _onBeforeParticlesRenderingObserver;
  115959. private _onAfterParticlesRenderingObserver;
  115960. private _onBeforeSpritesRenderingObserver;
  115961. private _onAfterSpritesRenderingObserver;
  115962. private _onBeforePhysicsObserver;
  115963. private _onAfterPhysicsObserver;
  115964. private _onAfterAnimationsObserver;
  115965. private _onBeforeCameraRenderObserver;
  115966. private _onAfterCameraRenderObserver;
  115967. /**
  115968. * Gets the perf counter used for active meshes evaluation time
  115969. */
  115970. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115971. /**
  115972. * Gets the active meshes evaluation time capture status
  115973. */
  115974. /**
  115975. * Enable or disable the active meshes evaluation time capture
  115976. */
  115977. captureActiveMeshesEvaluationTime: boolean;
  115978. /**
  115979. * Gets the perf counter used for render targets render time
  115980. */
  115981. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115982. /**
  115983. * Gets the render targets render time capture status
  115984. */
  115985. /**
  115986. * Enable or disable the render targets render time capture
  115987. */
  115988. captureRenderTargetsRenderTime: boolean;
  115989. /**
  115990. * Gets the perf counter used for particles render time
  115991. */
  115992. readonly particlesRenderTimeCounter: PerfCounter;
  115993. /**
  115994. * Gets the particles render time capture status
  115995. */
  115996. /**
  115997. * Enable or disable the particles render time capture
  115998. */
  115999. captureParticlesRenderTime: boolean;
  116000. /**
  116001. * Gets the perf counter used for sprites render time
  116002. */
  116003. readonly spritesRenderTimeCounter: PerfCounter;
  116004. /**
  116005. * Gets the sprites render time capture status
  116006. */
  116007. /**
  116008. * Enable or disable the sprites render time capture
  116009. */
  116010. captureSpritesRenderTime: boolean;
  116011. /**
  116012. * Gets the perf counter used for physics time
  116013. */
  116014. readonly physicsTimeCounter: PerfCounter;
  116015. /**
  116016. * Gets the physics time capture status
  116017. */
  116018. /**
  116019. * Enable or disable the physics time capture
  116020. */
  116021. capturePhysicsTime: boolean;
  116022. /**
  116023. * Gets the perf counter used for animations time
  116024. */
  116025. readonly animationsTimeCounter: PerfCounter;
  116026. /**
  116027. * Gets the animations time capture status
  116028. */
  116029. /**
  116030. * Enable or disable the animations time capture
  116031. */
  116032. captureAnimationsTime: boolean;
  116033. /**
  116034. * Gets the perf counter used for frame time capture
  116035. */
  116036. readonly frameTimeCounter: PerfCounter;
  116037. /**
  116038. * Gets the frame time capture status
  116039. */
  116040. /**
  116041. * Enable or disable the frame time capture
  116042. */
  116043. captureFrameTime: boolean;
  116044. /**
  116045. * Gets the perf counter used for inter-frames time capture
  116046. */
  116047. readonly interFrameTimeCounter: PerfCounter;
  116048. /**
  116049. * Gets the inter-frames time capture status
  116050. */
  116051. /**
  116052. * Enable or disable the inter-frames time capture
  116053. */
  116054. captureInterFrameTime: boolean;
  116055. /**
  116056. * Gets the perf counter used for render time capture
  116057. */
  116058. readonly renderTimeCounter: PerfCounter;
  116059. /**
  116060. * Gets the render time capture status
  116061. */
  116062. /**
  116063. * Enable or disable the render time capture
  116064. */
  116065. captureRenderTime: boolean;
  116066. /**
  116067. * Gets the perf counter used for camera render time capture
  116068. */
  116069. readonly cameraRenderTimeCounter: PerfCounter;
  116070. /**
  116071. * Gets the camera render time capture status
  116072. */
  116073. /**
  116074. * Enable or disable the camera render time capture
  116075. */
  116076. captureCameraRenderTime: boolean;
  116077. /**
  116078. * Gets the perf counter used for draw calls
  116079. */
  116080. readonly drawCallsCounter: PerfCounter;
  116081. /**
  116082. * Instantiates a new scene instrumentation.
  116083. * This class can be used to get instrumentation data from a Babylon engine
  116084. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116085. * @param scene Defines the scene to instrument
  116086. */
  116087. constructor(
  116088. /**
  116089. * Defines the scene to instrument
  116090. */
  116091. scene: Scene);
  116092. /**
  116093. * Dispose and release associated resources.
  116094. */
  116095. dispose(): void;
  116096. }
  116097. }
  116098. declare module BABYLON {
  116099. /** @hidden */
  116100. export var glowMapGenerationPixelShader: {
  116101. name: string;
  116102. shader: string;
  116103. };
  116104. }
  116105. declare module BABYLON {
  116106. /** @hidden */
  116107. export var glowMapGenerationVertexShader: {
  116108. name: string;
  116109. shader: string;
  116110. };
  116111. }
  116112. declare module BABYLON {
  116113. /**
  116114. * Effect layer options. This helps customizing the behaviour
  116115. * of the effect layer.
  116116. */
  116117. export interface IEffectLayerOptions {
  116118. /**
  116119. * Multiplication factor apply to the canvas size to compute the render target size
  116120. * used to generated the objects (the smaller the faster).
  116121. */
  116122. mainTextureRatio: number;
  116123. /**
  116124. * Enforces a fixed size texture to ensure effect stability across devices.
  116125. */
  116126. mainTextureFixedSize?: number;
  116127. /**
  116128. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116129. */
  116130. alphaBlendingMode: number;
  116131. /**
  116132. * The camera attached to the layer.
  116133. */
  116134. camera: Nullable<Camera>;
  116135. /**
  116136. * The rendering group to draw the layer in.
  116137. */
  116138. renderingGroupId: number;
  116139. }
  116140. /**
  116141. * The effect layer Helps adding post process effect blended with the main pass.
  116142. *
  116143. * This can be for instance use to generate glow or higlight effects on the scene.
  116144. *
  116145. * The effect layer class can not be used directly and is intented to inherited from to be
  116146. * customized per effects.
  116147. */
  116148. export abstract class EffectLayer {
  116149. private _vertexBuffers;
  116150. private _indexBuffer;
  116151. private _cachedDefines;
  116152. private _effectLayerMapGenerationEffect;
  116153. private _effectLayerOptions;
  116154. private _mergeEffect;
  116155. protected _scene: Scene;
  116156. protected _engine: Engine;
  116157. protected _maxSize: number;
  116158. protected _mainTextureDesiredSize: ISize;
  116159. protected _mainTexture: RenderTargetTexture;
  116160. protected _shouldRender: boolean;
  116161. protected _postProcesses: PostProcess[];
  116162. protected _textures: BaseTexture[];
  116163. protected _emissiveTextureAndColor: {
  116164. texture: Nullable<BaseTexture>;
  116165. color: Color4;
  116166. };
  116167. /**
  116168. * The name of the layer
  116169. */
  116170. name: string;
  116171. /**
  116172. * The clear color of the texture used to generate the glow map.
  116173. */
  116174. neutralColor: Color4;
  116175. /**
  116176. * Specifies wether the highlight layer is enabled or not.
  116177. */
  116178. isEnabled: boolean;
  116179. /**
  116180. * Gets the camera attached to the layer.
  116181. */
  116182. readonly camera: Nullable<Camera>;
  116183. /**
  116184. * Gets the rendering group id the layer should render in.
  116185. */
  116186. renderingGroupId: number;
  116187. /**
  116188. * An event triggered when the effect layer has been disposed.
  116189. */
  116190. onDisposeObservable: Observable<EffectLayer>;
  116191. /**
  116192. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116193. */
  116194. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116195. /**
  116196. * An event triggered when the generated texture is being merged in the scene.
  116197. */
  116198. onBeforeComposeObservable: Observable<EffectLayer>;
  116199. /**
  116200. * An event triggered when the generated texture has been merged in the scene.
  116201. */
  116202. onAfterComposeObservable: Observable<EffectLayer>;
  116203. /**
  116204. * An event triggered when the efffect layer changes its size.
  116205. */
  116206. onSizeChangedObservable: Observable<EffectLayer>;
  116207. /** @hidden */
  116208. static _SceneComponentInitialization: (scene: Scene) => void;
  116209. /**
  116210. * Instantiates a new effect Layer and references it in the scene.
  116211. * @param name The name of the layer
  116212. * @param scene The scene to use the layer in
  116213. */
  116214. constructor(
  116215. /** The Friendly of the effect in the scene */
  116216. name: string, scene: Scene);
  116217. /**
  116218. * Get the effect name of the layer.
  116219. * @return The effect name
  116220. */
  116221. abstract getEffectName(): string;
  116222. /**
  116223. * Checks for the readiness of the element composing the layer.
  116224. * @param subMesh the mesh to check for
  116225. * @param useInstances specify wether or not to use instances to render the mesh
  116226. * @return true if ready otherwise, false
  116227. */
  116228. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116229. /**
  116230. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116231. * @returns true if the effect requires stencil during the main canvas render pass.
  116232. */
  116233. abstract needStencil(): boolean;
  116234. /**
  116235. * Create the merge effect. This is the shader use to blit the information back
  116236. * to the main canvas at the end of the scene rendering.
  116237. * @returns The effect containing the shader used to merge the effect on the main canvas
  116238. */
  116239. protected abstract _createMergeEffect(): Effect;
  116240. /**
  116241. * Creates the render target textures and post processes used in the effect layer.
  116242. */
  116243. protected abstract _createTextureAndPostProcesses(): void;
  116244. /**
  116245. * Implementation specific of rendering the generating effect on the main canvas.
  116246. * @param effect The effect used to render through
  116247. */
  116248. protected abstract _internalRender(effect: Effect): void;
  116249. /**
  116250. * Sets the required values for both the emissive texture and and the main color.
  116251. */
  116252. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116253. /**
  116254. * Free any resources and references associated to a mesh.
  116255. * Internal use
  116256. * @param mesh The mesh to free.
  116257. */
  116258. abstract _disposeMesh(mesh: Mesh): void;
  116259. /**
  116260. * Serializes this layer (Glow or Highlight for example)
  116261. * @returns a serialized layer object
  116262. */
  116263. abstract serialize?(): any;
  116264. /**
  116265. * Initializes the effect layer with the required options.
  116266. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116267. */
  116268. protected _init(options: Partial<IEffectLayerOptions>): void;
  116269. /**
  116270. * Generates the index buffer of the full screen quad blending to the main canvas.
  116271. */
  116272. private _generateIndexBuffer;
  116273. /**
  116274. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116275. */
  116276. private _generateVertexBuffer;
  116277. /**
  116278. * Sets the main texture desired size which is the closest power of two
  116279. * of the engine canvas size.
  116280. */
  116281. private _setMainTextureSize;
  116282. /**
  116283. * Creates the main texture for the effect layer.
  116284. */
  116285. protected _createMainTexture(): void;
  116286. /**
  116287. * Adds specific effects defines.
  116288. * @param defines The defines to add specifics to.
  116289. */
  116290. protected _addCustomEffectDefines(defines: string[]): void;
  116291. /**
  116292. * Checks for the readiness of the element composing the layer.
  116293. * @param subMesh the mesh to check for
  116294. * @param useInstances specify wether or not to use instances to render the mesh
  116295. * @param emissiveTexture the associated emissive texture used to generate the glow
  116296. * @return true if ready otherwise, false
  116297. */
  116298. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116299. /**
  116300. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116301. */
  116302. render(): void;
  116303. /**
  116304. * Determine if a given mesh will be used in the current effect.
  116305. * @param mesh mesh to test
  116306. * @returns true if the mesh will be used
  116307. */
  116308. hasMesh(mesh: AbstractMesh): boolean;
  116309. /**
  116310. * Returns true if the layer contains information to display, otherwise false.
  116311. * @returns true if the glow layer should be rendered
  116312. */
  116313. shouldRender(): boolean;
  116314. /**
  116315. * Returns true if the mesh should render, otherwise false.
  116316. * @param mesh The mesh to render
  116317. * @returns true if it should render otherwise false
  116318. */
  116319. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116320. /**
  116321. * Returns true if the mesh can be rendered, otherwise false.
  116322. * @param mesh The mesh to render
  116323. * @param material The material used on the mesh
  116324. * @returns true if it can be rendered otherwise false
  116325. */
  116326. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116327. /**
  116328. * Returns true if the mesh should render, otherwise false.
  116329. * @param mesh The mesh to render
  116330. * @returns true if it should render otherwise false
  116331. */
  116332. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116333. /**
  116334. * Renders the submesh passed in parameter to the generation map.
  116335. */
  116336. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116337. /**
  116338. * Rebuild the required buffers.
  116339. * @hidden Internal use only.
  116340. */
  116341. _rebuild(): void;
  116342. /**
  116343. * Dispose only the render target textures and post process.
  116344. */
  116345. private _disposeTextureAndPostProcesses;
  116346. /**
  116347. * Dispose the highlight layer and free resources.
  116348. */
  116349. dispose(): void;
  116350. /**
  116351. * Gets the class name of the effect layer
  116352. * @returns the string with the class name of the effect layer
  116353. */
  116354. getClassName(): string;
  116355. /**
  116356. * Creates an effect layer from parsed effect layer data
  116357. * @param parsedEffectLayer defines effect layer data
  116358. * @param scene defines the current scene
  116359. * @param rootUrl defines the root URL containing the effect layer information
  116360. * @returns a parsed effect Layer
  116361. */
  116362. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116363. }
  116364. }
  116365. declare module BABYLON {
  116366. interface AbstractScene {
  116367. /**
  116368. * The list of effect layers (highlights/glow) added to the scene
  116369. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116370. * @see http://doc.babylonjs.com/how_to/glow_layer
  116371. */
  116372. effectLayers: Array<EffectLayer>;
  116373. /**
  116374. * Removes the given effect layer from this scene.
  116375. * @param toRemove defines the effect layer to remove
  116376. * @returns the index of the removed effect layer
  116377. */
  116378. removeEffectLayer(toRemove: EffectLayer): number;
  116379. /**
  116380. * Adds the given effect layer to this scene
  116381. * @param newEffectLayer defines the effect layer to add
  116382. */
  116383. addEffectLayer(newEffectLayer: EffectLayer): void;
  116384. }
  116385. /**
  116386. * Defines the layer scene component responsible to manage any effect layers
  116387. * in a given scene.
  116388. */
  116389. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116390. /**
  116391. * The component name helpfull to identify the component in the list of scene components.
  116392. */
  116393. readonly name: string;
  116394. /**
  116395. * The scene the component belongs to.
  116396. */
  116397. scene: Scene;
  116398. private _engine;
  116399. private _renderEffects;
  116400. private _needStencil;
  116401. private _previousStencilState;
  116402. /**
  116403. * Creates a new instance of the component for the given scene
  116404. * @param scene Defines the scene to register the component in
  116405. */
  116406. constructor(scene: Scene);
  116407. /**
  116408. * Registers the component in a given scene
  116409. */
  116410. register(): void;
  116411. /**
  116412. * Rebuilds the elements related to this component in case of
  116413. * context lost for instance.
  116414. */
  116415. rebuild(): void;
  116416. /**
  116417. * Serializes the component data to the specified json object
  116418. * @param serializationObject The object to serialize to
  116419. */
  116420. serialize(serializationObject: any): void;
  116421. /**
  116422. * Adds all the elements from the container to the scene
  116423. * @param container the container holding the elements
  116424. */
  116425. addFromContainer(container: AbstractScene): void;
  116426. /**
  116427. * Removes all the elements in the container from the scene
  116428. * @param container contains the elements to remove
  116429. * @param dispose if the removed element should be disposed (default: false)
  116430. */
  116431. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116432. /**
  116433. * Disposes the component and the associated ressources.
  116434. */
  116435. dispose(): void;
  116436. private _isReadyForMesh;
  116437. private _renderMainTexture;
  116438. private _setStencil;
  116439. private _setStencilBack;
  116440. private _draw;
  116441. private _drawCamera;
  116442. private _drawRenderingGroup;
  116443. }
  116444. }
  116445. declare module BABYLON {
  116446. /** @hidden */
  116447. export var glowMapMergePixelShader: {
  116448. name: string;
  116449. shader: string;
  116450. };
  116451. }
  116452. declare module BABYLON {
  116453. /** @hidden */
  116454. export var glowMapMergeVertexShader: {
  116455. name: string;
  116456. shader: string;
  116457. };
  116458. }
  116459. declare module BABYLON {
  116460. interface AbstractScene {
  116461. /**
  116462. * Return a the first highlight layer of the scene with a given name.
  116463. * @param name The name of the highlight layer to look for.
  116464. * @return The highlight layer if found otherwise null.
  116465. */
  116466. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116467. }
  116468. /**
  116469. * Glow layer options. This helps customizing the behaviour
  116470. * of the glow layer.
  116471. */
  116472. export interface IGlowLayerOptions {
  116473. /**
  116474. * Multiplication factor apply to the canvas size to compute the render target size
  116475. * used to generated the glowing objects (the smaller the faster).
  116476. */
  116477. mainTextureRatio: number;
  116478. /**
  116479. * Enforces a fixed size texture to ensure resize independant blur.
  116480. */
  116481. mainTextureFixedSize?: number;
  116482. /**
  116483. * How big is the kernel of the blur texture.
  116484. */
  116485. blurKernelSize: number;
  116486. /**
  116487. * The camera attached to the layer.
  116488. */
  116489. camera: Nullable<Camera>;
  116490. /**
  116491. * Enable MSAA by chosing the number of samples.
  116492. */
  116493. mainTextureSamples?: number;
  116494. /**
  116495. * The rendering group to draw the layer in.
  116496. */
  116497. renderingGroupId: number;
  116498. }
  116499. /**
  116500. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116501. *
  116502. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116503. * glowy meshes to your scene.
  116504. *
  116505. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116506. */
  116507. export class GlowLayer extends EffectLayer {
  116508. /**
  116509. * Effect Name of the layer.
  116510. */
  116511. static readonly EffectName: string;
  116512. /**
  116513. * The default blur kernel size used for the glow.
  116514. */
  116515. static DefaultBlurKernelSize: number;
  116516. /**
  116517. * The default texture size ratio used for the glow.
  116518. */
  116519. static DefaultTextureRatio: number;
  116520. /**
  116521. * Sets the kernel size of the blur.
  116522. */
  116523. /**
  116524. * Gets the kernel size of the blur.
  116525. */
  116526. blurKernelSize: number;
  116527. /**
  116528. * Sets the glow intensity.
  116529. */
  116530. /**
  116531. * Gets the glow intensity.
  116532. */
  116533. intensity: number;
  116534. private _options;
  116535. private _intensity;
  116536. private _horizontalBlurPostprocess1;
  116537. private _verticalBlurPostprocess1;
  116538. private _horizontalBlurPostprocess2;
  116539. private _verticalBlurPostprocess2;
  116540. private _blurTexture1;
  116541. private _blurTexture2;
  116542. private _postProcesses1;
  116543. private _postProcesses2;
  116544. private _includedOnlyMeshes;
  116545. private _excludedMeshes;
  116546. /**
  116547. * Callback used to let the user override the color selection on a per mesh basis
  116548. */
  116549. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116550. /**
  116551. * Callback used to let the user override the texture selection on a per mesh basis
  116552. */
  116553. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116554. /**
  116555. * Instantiates a new glow Layer and references it to the scene.
  116556. * @param name The name of the layer
  116557. * @param scene The scene to use the layer in
  116558. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116559. */
  116560. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116561. /**
  116562. * Get the effect name of the layer.
  116563. * @return The effect name
  116564. */
  116565. getEffectName(): string;
  116566. /**
  116567. * Create the merge effect. This is the shader use to blit the information back
  116568. * to the main canvas at the end of the scene rendering.
  116569. */
  116570. protected _createMergeEffect(): Effect;
  116571. /**
  116572. * Creates the render target textures and post processes used in the glow layer.
  116573. */
  116574. protected _createTextureAndPostProcesses(): void;
  116575. /**
  116576. * Checks for the readiness of the element composing the layer.
  116577. * @param subMesh the mesh to check for
  116578. * @param useInstances specify wether or not to use instances to render the mesh
  116579. * @param emissiveTexture the associated emissive texture used to generate the glow
  116580. * @return true if ready otherwise, false
  116581. */
  116582. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116583. /**
  116584. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116585. */
  116586. needStencil(): boolean;
  116587. /**
  116588. * Returns true if the mesh can be rendered, otherwise false.
  116589. * @param mesh The mesh to render
  116590. * @param material The material used on the mesh
  116591. * @returns true if it can be rendered otherwise false
  116592. */
  116593. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116594. /**
  116595. * Implementation specific of rendering the generating effect on the main canvas.
  116596. * @param effect The effect used to render through
  116597. */
  116598. protected _internalRender(effect: Effect): void;
  116599. /**
  116600. * Sets the required values for both the emissive texture and and the main color.
  116601. */
  116602. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116603. /**
  116604. * Returns true if the mesh should render, otherwise false.
  116605. * @param mesh The mesh to render
  116606. * @returns true if it should render otherwise false
  116607. */
  116608. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116609. /**
  116610. * Adds specific effects defines.
  116611. * @param defines The defines to add specifics to.
  116612. */
  116613. protected _addCustomEffectDefines(defines: string[]): void;
  116614. /**
  116615. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116616. * @param mesh The mesh to exclude from the glow layer
  116617. */
  116618. addExcludedMesh(mesh: Mesh): void;
  116619. /**
  116620. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116621. * @param mesh The mesh to remove
  116622. */
  116623. removeExcludedMesh(mesh: Mesh): void;
  116624. /**
  116625. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116626. * @param mesh The mesh to include in the glow layer
  116627. */
  116628. addIncludedOnlyMesh(mesh: Mesh): void;
  116629. /**
  116630. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116631. * @param mesh The mesh to remove
  116632. */
  116633. removeIncludedOnlyMesh(mesh: Mesh): void;
  116634. /**
  116635. * Determine if a given mesh will be used in the glow layer
  116636. * @param mesh The mesh to test
  116637. * @returns true if the mesh will be highlighted by the current glow layer
  116638. */
  116639. hasMesh(mesh: AbstractMesh): boolean;
  116640. /**
  116641. * Free any resources and references associated to a mesh.
  116642. * Internal use
  116643. * @param mesh The mesh to free.
  116644. * @hidden
  116645. */
  116646. _disposeMesh(mesh: Mesh): void;
  116647. /**
  116648. * Gets the class name of the effect layer
  116649. * @returns the string with the class name of the effect layer
  116650. */
  116651. getClassName(): string;
  116652. /**
  116653. * Serializes this glow layer
  116654. * @returns a serialized glow layer object
  116655. */
  116656. serialize(): any;
  116657. /**
  116658. * Creates a Glow Layer from parsed glow layer data
  116659. * @param parsedGlowLayer defines glow layer data
  116660. * @param scene defines the current scene
  116661. * @param rootUrl defines the root URL containing the glow layer information
  116662. * @returns a parsed Glow Layer
  116663. */
  116664. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116665. }
  116666. }
  116667. declare module BABYLON {
  116668. /** @hidden */
  116669. export var glowBlurPostProcessPixelShader: {
  116670. name: string;
  116671. shader: string;
  116672. };
  116673. }
  116674. declare module BABYLON {
  116675. interface AbstractScene {
  116676. /**
  116677. * Return a the first highlight layer of the scene with a given name.
  116678. * @param name The name of the highlight layer to look for.
  116679. * @return The highlight layer if found otherwise null.
  116680. */
  116681. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116682. }
  116683. /**
  116684. * Highlight layer options. This helps customizing the behaviour
  116685. * of the highlight layer.
  116686. */
  116687. export interface IHighlightLayerOptions {
  116688. /**
  116689. * Multiplication factor apply to the canvas size to compute the render target size
  116690. * used to generated the glowing objects (the smaller the faster).
  116691. */
  116692. mainTextureRatio: number;
  116693. /**
  116694. * Enforces a fixed size texture to ensure resize independant blur.
  116695. */
  116696. mainTextureFixedSize?: number;
  116697. /**
  116698. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116699. * of the picture to blur (the smaller the faster).
  116700. */
  116701. blurTextureSizeRatio: number;
  116702. /**
  116703. * How big in texel of the blur texture is the vertical blur.
  116704. */
  116705. blurVerticalSize: number;
  116706. /**
  116707. * How big in texel of the blur texture is the horizontal blur.
  116708. */
  116709. blurHorizontalSize: number;
  116710. /**
  116711. * Alpha blending mode used to apply the blur. Default is combine.
  116712. */
  116713. alphaBlendingMode: number;
  116714. /**
  116715. * The camera attached to the layer.
  116716. */
  116717. camera: Nullable<Camera>;
  116718. /**
  116719. * Should we display highlight as a solid stroke?
  116720. */
  116721. isStroke?: boolean;
  116722. /**
  116723. * The rendering group to draw the layer in.
  116724. */
  116725. renderingGroupId: number;
  116726. }
  116727. /**
  116728. * The highlight layer Helps adding a glow effect around a mesh.
  116729. *
  116730. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116731. * glowy meshes to your scene.
  116732. *
  116733. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116734. */
  116735. export class HighlightLayer extends EffectLayer {
  116736. name: string;
  116737. /**
  116738. * Effect Name of the highlight layer.
  116739. */
  116740. static readonly EffectName: string;
  116741. /**
  116742. * The neutral color used during the preparation of the glow effect.
  116743. * This is black by default as the blend operation is a blend operation.
  116744. */
  116745. static NeutralColor: Color4;
  116746. /**
  116747. * Stencil value used for glowing meshes.
  116748. */
  116749. static GlowingMeshStencilReference: number;
  116750. /**
  116751. * Stencil value used for the other meshes in the scene.
  116752. */
  116753. static NormalMeshStencilReference: number;
  116754. /**
  116755. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116756. */
  116757. innerGlow: boolean;
  116758. /**
  116759. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116760. */
  116761. outerGlow: boolean;
  116762. /**
  116763. * Specifies the horizontal size of the blur.
  116764. */
  116765. /**
  116766. * Gets the horizontal size of the blur.
  116767. */
  116768. blurHorizontalSize: number;
  116769. /**
  116770. * Specifies the vertical size of the blur.
  116771. */
  116772. /**
  116773. * Gets the vertical size of the blur.
  116774. */
  116775. blurVerticalSize: number;
  116776. /**
  116777. * An event triggered when the highlight layer is being blurred.
  116778. */
  116779. onBeforeBlurObservable: Observable<HighlightLayer>;
  116780. /**
  116781. * An event triggered when the highlight layer has been blurred.
  116782. */
  116783. onAfterBlurObservable: Observable<HighlightLayer>;
  116784. private _instanceGlowingMeshStencilReference;
  116785. private _options;
  116786. private _downSamplePostprocess;
  116787. private _horizontalBlurPostprocess;
  116788. private _verticalBlurPostprocess;
  116789. private _blurTexture;
  116790. private _meshes;
  116791. private _excludedMeshes;
  116792. /**
  116793. * Instantiates a new highlight Layer and references it to the scene..
  116794. * @param name The name of the layer
  116795. * @param scene The scene to use the layer in
  116796. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116797. */
  116798. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116799. /**
  116800. * Get the effect name of the layer.
  116801. * @return The effect name
  116802. */
  116803. getEffectName(): string;
  116804. /**
  116805. * Create the merge effect. This is the shader use to blit the information back
  116806. * to the main canvas at the end of the scene rendering.
  116807. */
  116808. protected _createMergeEffect(): Effect;
  116809. /**
  116810. * Creates the render target textures and post processes used in the highlight layer.
  116811. */
  116812. protected _createTextureAndPostProcesses(): void;
  116813. /**
  116814. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116815. */
  116816. needStencil(): boolean;
  116817. /**
  116818. * Checks for the readiness of the element composing the layer.
  116819. * @param subMesh the mesh to check for
  116820. * @param useInstances specify wether or not to use instances to render the mesh
  116821. * @param emissiveTexture the associated emissive texture used to generate the glow
  116822. * @return true if ready otherwise, false
  116823. */
  116824. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116825. /**
  116826. * Implementation specific of rendering the generating effect on the main canvas.
  116827. * @param effect The effect used to render through
  116828. */
  116829. protected _internalRender(effect: Effect): void;
  116830. /**
  116831. * Returns true if the layer contains information to display, otherwise false.
  116832. */
  116833. shouldRender(): boolean;
  116834. /**
  116835. * Returns true if the mesh should render, otherwise false.
  116836. * @param mesh The mesh to render
  116837. * @returns true if it should render otherwise false
  116838. */
  116839. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116840. /**
  116841. * Sets the required values for both the emissive texture and and the main color.
  116842. */
  116843. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116844. /**
  116845. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116846. * @param mesh The mesh to exclude from the highlight layer
  116847. */
  116848. addExcludedMesh(mesh: Mesh): void;
  116849. /**
  116850. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116851. * @param mesh The mesh to highlight
  116852. */
  116853. removeExcludedMesh(mesh: Mesh): void;
  116854. /**
  116855. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116856. * @param mesh mesh to test
  116857. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116858. */
  116859. hasMesh(mesh: AbstractMesh): boolean;
  116860. /**
  116861. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116862. * @param mesh The mesh to highlight
  116863. * @param color The color of the highlight
  116864. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116865. */
  116866. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116867. /**
  116868. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116869. * @param mesh The mesh to highlight
  116870. */
  116871. removeMesh(mesh: Mesh): void;
  116872. /**
  116873. * Force the stencil to the normal expected value for none glowing parts
  116874. */
  116875. private _defaultStencilReference;
  116876. /**
  116877. * Free any resources and references associated to a mesh.
  116878. * Internal use
  116879. * @param mesh The mesh to free.
  116880. * @hidden
  116881. */
  116882. _disposeMesh(mesh: Mesh): void;
  116883. /**
  116884. * Dispose the highlight layer and free resources.
  116885. */
  116886. dispose(): void;
  116887. /**
  116888. * Gets the class name of the effect layer
  116889. * @returns the string with the class name of the effect layer
  116890. */
  116891. getClassName(): string;
  116892. /**
  116893. * Serializes this Highlight layer
  116894. * @returns a serialized Highlight layer object
  116895. */
  116896. serialize(): any;
  116897. /**
  116898. * Creates a Highlight layer from parsed Highlight layer data
  116899. * @param parsedHightlightLayer defines the Highlight layer data
  116900. * @param scene defines the current scene
  116901. * @param rootUrl defines the root URL containing the Highlight layer information
  116902. * @returns a parsed Highlight layer
  116903. */
  116904. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116905. }
  116906. }
  116907. declare module BABYLON {
  116908. interface AbstractScene {
  116909. /**
  116910. * The list of layers (background and foreground) of the scene
  116911. */
  116912. layers: Array<Layer>;
  116913. }
  116914. /**
  116915. * Defines the layer scene component responsible to manage any layers
  116916. * in a given scene.
  116917. */
  116918. export class LayerSceneComponent implements ISceneComponent {
  116919. /**
  116920. * The component name helpfull to identify the component in the list of scene components.
  116921. */
  116922. readonly name: string;
  116923. /**
  116924. * The scene the component belongs to.
  116925. */
  116926. scene: Scene;
  116927. private _engine;
  116928. /**
  116929. * Creates a new instance of the component for the given scene
  116930. * @param scene Defines the scene to register the component in
  116931. */
  116932. constructor(scene: Scene);
  116933. /**
  116934. * Registers the component in a given scene
  116935. */
  116936. register(): void;
  116937. /**
  116938. * Rebuilds the elements related to this component in case of
  116939. * context lost for instance.
  116940. */
  116941. rebuild(): void;
  116942. /**
  116943. * Disposes the component and the associated ressources.
  116944. */
  116945. dispose(): void;
  116946. private _draw;
  116947. private _drawCameraPredicate;
  116948. private _drawCameraBackground;
  116949. private _drawCameraForeground;
  116950. private _drawRenderTargetPredicate;
  116951. private _drawRenderTargetBackground;
  116952. private _drawRenderTargetForeground;
  116953. /**
  116954. * Adds all the elements from the container to the scene
  116955. * @param container the container holding the elements
  116956. */
  116957. addFromContainer(container: AbstractScene): void;
  116958. /**
  116959. * Removes all the elements in the container from the scene
  116960. * @param container contains the elements to remove
  116961. * @param dispose if the removed element should be disposed (default: false)
  116962. */
  116963. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116964. }
  116965. }
  116966. declare module BABYLON {
  116967. /** @hidden */
  116968. export var layerPixelShader: {
  116969. name: string;
  116970. shader: string;
  116971. };
  116972. }
  116973. declare module BABYLON {
  116974. /** @hidden */
  116975. export var layerVertexShader: {
  116976. name: string;
  116977. shader: string;
  116978. };
  116979. }
  116980. declare module BABYLON {
  116981. /**
  116982. * This represents a full screen 2d layer.
  116983. * This can be useful to display a picture in the background of your scene for instance.
  116984. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116985. */
  116986. export class Layer {
  116987. /**
  116988. * Define the name of the layer.
  116989. */
  116990. name: string;
  116991. /**
  116992. * Define the texture the layer should display.
  116993. */
  116994. texture: Nullable<Texture>;
  116995. /**
  116996. * Is the layer in background or foreground.
  116997. */
  116998. isBackground: boolean;
  116999. /**
  117000. * Define the color of the layer (instead of texture).
  117001. */
  117002. color: Color4;
  117003. /**
  117004. * Define the scale of the layer in order to zoom in out of the texture.
  117005. */
  117006. scale: Vector2;
  117007. /**
  117008. * Define an offset for the layer in order to shift the texture.
  117009. */
  117010. offset: Vector2;
  117011. /**
  117012. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117013. */
  117014. alphaBlendingMode: number;
  117015. /**
  117016. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117017. * Alpha test will not mix with the background color in case of transparency.
  117018. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117019. */
  117020. alphaTest: boolean;
  117021. /**
  117022. * Define a mask to restrict the layer to only some of the scene cameras.
  117023. */
  117024. layerMask: number;
  117025. /**
  117026. * Define the list of render target the layer is visible into.
  117027. */
  117028. renderTargetTextures: RenderTargetTexture[];
  117029. /**
  117030. * Define if the layer is only used in renderTarget or if it also
  117031. * renders in the main frame buffer of the canvas.
  117032. */
  117033. renderOnlyInRenderTargetTextures: boolean;
  117034. private _scene;
  117035. private _vertexBuffers;
  117036. private _indexBuffer;
  117037. private _effect;
  117038. private _alphaTestEffect;
  117039. /**
  117040. * An event triggered when the layer is disposed.
  117041. */
  117042. onDisposeObservable: Observable<Layer>;
  117043. private _onDisposeObserver;
  117044. /**
  117045. * Back compatibility with callback before the onDisposeObservable existed.
  117046. * The set callback will be triggered when the layer has been disposed.
  117047. */
  117048. onDispose: () => void;
  117049. /**
  117050. * An event triggered before rendering the scene
  117051. */
  117052. onBeforeRenderObservable: Observable<Layer>;
  117053. private _onBeforeRenderObserver;
  117054. /**
  117055. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117056. * The set callback will be triggered just before rendering the layer.
  117057. */
  117058. onBeforeRender: () => void;
  117059. /**
  117060. * An event triggered after rendering the scene
  117061. */
  117062. onAfterRenderObservable: Observable<Layer>;
  117063. private _onAfterRenderObserver;
  117064. /**
  117065. * Back compatibility with callback before the onAfterRenderObservable existed.
  117066. * The set callback will be triggered just after rendering the layer.
  117067. */
  117068. onAfterRender: () => void;
  117069. /**
  117070. * Instantiates a new layer.
  117071. * This represents a full screen 2d layer.
  117072. * This can be useful to display a picture in the background of your scene for instance.
  117073. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117074. * @param name Define the name of the layer in the scene
  117075. * @param imgUrl Define the url of the texture to display in the layer
  117076. * @param scene Define the scene the layer belongs to
  117077. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117078. * @param color Defines a color for the layer
  117079. */
  117080. constructor(
  117081. /**
  117082. * Define the name of the layer.
  117083. */
  117084. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117085. private _createIndexBuffer;
  117086. /** @hidden */
  117087. _rebuild(): void;
  117088. /**
  117089. * Renders the layer in the scene.
  117090. */
  117091. render(): void;
  117092. /**
  117093. * Disposes and releases the associated ressources.
  117094. */
  117095. dispose(): void;
  117096. }
  117097. }
  117098. declare module BABYLON {
  117099. /** @hidden */
  117100. export var lensFlarePixelShader: {
  117101. name: string;
  117102. shader: string;
  117103. };
  117104. }
  117105. declare module BABYLON {
  117106. /** @hidden */
  117107. export var lensFlareVertexShader: {
  117108. name: string;
  117109. shader: string;
  117110. };
  117111. }
  117112. declare module BABYLON {
  117113. /**
  117114. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117115. * It is usually composed of several `lensFlare`.
  117116. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117117. */
  117118. export class LensFlareSystem {
  117119. /**
  117120. * Define the name of the lens flare system
  117121. */
  117122. name: string;
  117123. /**
  117124. * List of lens flares used in this system.
  117125. */
  117126. lensFlares: LensFlare[];
  117127. /**
  117128. * Define a limit from the border the lens flare can be visible.
  117129. */
  117130. borderLimit: number;
  117131. /**
  117132. * Define a viewport border we do not want to see the lens flare in.
  117133. */
  117134. viewportBorder: number;
  117135. /**
  117136. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117137. */
  117138. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117139. /**
  117140. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117141. */
  117142. layerMask: number;
  117143. /**
  117144. * Define the id of the lens flare system in the scene.
  117145. * (equal to name by default)
  117146. */
  117147. id: string;
  117148. private _scene;
  117149. private _emitter;
  117150. private _vertexBuffers;
  117151. private _indexBuffer;
  117152. private _effect;
  117153. private _positionX;
  117154. private _positionY;
  117155. private _isEnabled;
  117156. /** @hidden */
  117157. static _SceneComponentInitialization: (scene: Scene) => void;
  117158. /**
  117159. * Instantiates a lens flare system.
  117160. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117161. * It is usually composed of several `lensFlare`.
  117162. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117163. * @param name Define the name of the lens flare system in the scene
  117164. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117165. * @param scene Define the scene the lens flare system belongs to
  117166. */
  117167. constructor(
  117168. /**
  117169. * Define the name of the lens flare system
  117170. */
  117171. name: string, emitter: any, scene: Scene);
  117172. /**
  117173. * Define if the lens flare system is enabled.
  117174. */
  117175. isEnabled: boolean;
  117176. /**
  117177. * Get the scene the effects belongs to.
  117178. * @returns the scene holding the lens flare system
  117179. */
  117180. getScene(): Scene;
  117181. /**
  117182. * Get the emitter of the lens flare system.
  117183. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117184. * @returns the emitter of the lens flare system
  117185. */
  117186. getEmitter(): any;
  117187. /**
  117188. * Set the emitter of the lens flare system.
  117189. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117190. * @param newEmitter Define the new emitter of the system
  117191. */
  117192. setEmitter(newEmitter: any): void;
  117193. /**
  117194. * Get the lens flare system emitter position.
  117195. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117196. * @returns the position
  117197. */
  117198. getEmitterPosition(): Vector3;
  117199. /**
  117200. * @hidden
  117201. */
  117202. computeEffectivePosition(globalViewport: Viewport): boolean;
  117203. /** @hidden */
  117204. _isVisible(): boolean;
  117205. /**
  117206. * @hidden
  117207. */
  117208. render(): boolean;
  117209. /**
  117210. * Dispose and release the lens flare with its associated resources.
  117211. */
  117212. dispose(): void;
  117213. /**
  117214. * Parse a lens flare system from a JSON repressentation
  117215. * @param parsedLensFlareSystem Define the JSON to parse
  117216. * @param scene Define the scene the parsed system should be instantiated in
  117217. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117218. * @returns the parsed system
  117219. */
  117220. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117221. /**
  117222. * Serialize the current Lens Flare System into a JSON representation.
  117223. * @returns the serialized JSON
  117224. */
  117225. serialize(): any;
  117226. }
  117227. }
  117228. declare module BABYLON {
  117229. /**
  117230. * This represents one of the lens effect in a `lensFlareSystem`.
  117231. * It controls one of the indiviual texture used in the effect.
  117232. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117233. */
  117234. export class LensFlare {
  117235. /**
  117236. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117237. */
  117238. size: number;
  117239. /**
  117240. * 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.
  117241. */
  117242. position: number;
  117243. /**
  117244. * Define the lens color.
  117245. */
  117246. color: Color3;
  117247. /**
  117248. * Define the lens texture.
  117249. */
  117250. texture: Nullable<Texture>;
  117251. /**
  117252. * Define the alpha mode to render this particular lens.
  117253. */
  117254. alphaMode: number;
  117255. private _system;
  117256. /**
  117257. * Creates a new Lens Flare.
  117258. * This represents one of the lens effect in a `lensFlareSystem`.
  117259. * It controls one of the indiviual texture used in the effect.
  117260. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117261. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117262. * @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.
  117263. * @param color Define the lens color
  117264. * @param imgUrl Define the lens texture url
  117265. * @param system Define the `lensFlareSystem` this flare is part of
  117266. * @returns The newly created Lens Flare
  117267. */
  117268. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117269. /**
  117270. * Instantiates a new Lens Flare.
  117271. * This represents one of the lens effect in a `lensFlareSystem`.
  117272. * It controls one of the indiviual texture used in the effect.
  117273. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117274. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117275. * @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.
  117276. * @param color Define the lens color
  117277. * @param imgUrl Define the lens texture url
  117278. * @param system Define the `lensFlareSystem` this flare is part of
  117279. */
  117280. constructor(
  117281. /**
  117282. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117283. */
  117284. size: number,
  117285. /**
  117286. * 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.
  117287. */
  117288. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117289. /**
  117290. * Dispose and release the lens flare with its associated resources.
  117291. */
  117292. dispose(): void;
  117293. }
  117294. }
  117295. declare module BABYLON {
  117296. interface AbstractScene {
  117297. /**
  117298. * The list of lens flare system added to the scene
  117299. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117300. */
  117301. lensFlareSystems: Array<LensFlareSystem>;
  117302. /**
  117303. * Removes the given lens flare system from this scene.
  117304. * @param toRemove The lens flare system to remove
  117305. * @returns The index of the removed lens flare system
  117306. */
  117307. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117308. /**
  117309. * Adds the given lens flare system to this scene
  117310. * @param newLensFlareSystem The lens flare system to add
  117311. */
  117312. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117313. /**
  117314. * Gets a lens flare system using its name
  117315. * @param name defines the name to look for
  117316. * @returns the lens flare system or null if not found
  117317. */
  117318. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117319. /**
  117320. * Gets a lens flare system using its id
  117321. * @param id defines the id to look for
  117322. * @returns the lens flare system or null if not found
  117323. */
  117324. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117325. }
  117326. /**
  117327. * Defines the lens flare scene component responsible to manage any lens flares
  117328. * in a given scene.
  117329. */
  117330. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117331. /**
  117332. * The component name helpfull to identify the component in the list of scene components.
  117333. */
  117334. readonly name: string;
  117335. /**
  117336. * The scene the component belongs to.
  117337. */
  117338. scene: Scene;
  117339. /**
  117340. * Creates a new instance of the component for the given scene
  117341. * @param scene Defines the scene to register the component in
  117342. */
  117343. constructor(scene: Scene);
  117344. /**
  117345. * Registers the component in a given scene
  117346. */
  117347. register(): void;
  117348. /**
  117349. * Rebuilds the elements related to this component in case of
  117350. * context lost for instance.
  117351. */
  117352. rebuild(): void;
  117353. /**
  117354. * Adds all the elements from the container to the scene
  117355. * @param container the container holding the elements
  117356. */
  117357. addFromContainer(container: AbstractScene): void;
  117358. /**
  117359. * Removes all the elements in the container from the scene
  117360. * @param container contains the elements to remove
  117361. * @param dispose if the removed element should be disposed (default: false)
  117362. */
  117363. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117364. /**
  117365. * Serializes the component data to the specified json object
  117366. * @param serializationObject The object to serialize to
  117367. */
  117368. serialize(serializationObject: any): void;
  117369. /**
  117370. * Disposes the component and the associated ressources.
  117371. */
  117372. dispose(): void;
  117373. private _draw;
  117374. }
  117375. }
  117376. declare module BABYLON {
  117377. /**
  117378. * Defines the shadow generator component responsible to manage any shadow generators
  117379. * in a given scene.
  117380. */
  117381. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117382. /**
  117383. * The component name helpfull to identify the component in the list of scene components.
  117384. */
  117385. readonly name: string;
  117386. /**
  117387. * The scene the component belongs to.
  117388. */
  117389. scene: Scene;
  117390. /**
  117391. * Creates a new instance of the component for the given scene
  117392. * @param scene Defines the scene to register the component in
  117393. */
  117394. constructor(scene: Scene);
  117395. /**
  117396. * Registers the component in a given scene
  117397. */
  117398. register(): void;
  117399. /**
  117400. * Rebuilds the elements related to this component in case of
  117401. * context lost for instance.
  117402. */
  117403. rebuild(): void;
  117404. /**
  117405. * Serializes the component data to the specified json object
  117406. * @param serializationObject The object to serialize to
  117407. */
  117408. serialize(serializationObject: any): void;
  117409. /**
  117410. * Adds all the elements from the container to the scene
  117411. * @param container the container holding the elements
  117412. */
  117413. addFromContainer(container: AbstractScene): void;
  117414. /**
  117415. * Removes all the elements in the container from the scene
  117416. * @param container contains the elements to remove
  117417. * @param dispose if the removed element should be disposed (default: false)
  117418. */
  117419. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117420. /**
  117421. * Rebuilds the elements related to this component in case of
  117422. * context lost for instance.
  117423. */
  117424. dispose(): void;
  117425. private _gatherRenderTargets;
  117426. }
  117427. }
  117428. declare module BABYLON {
  117429. /**
  117430. * A point light is a light defined by an unique point in world space.
  117431. * The light is emitted in every direction from this point.
  117432. * A good example of a point light is a standard light bulb.
  117433. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117434. */
  117435. export class PointLight extends ShadowLight {
  117436. private _shadowAngle;
  117437. /**
  117438. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117439. * This specifies what angle the shadow will use to be created.
  117440. *
  117441. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117442. */
  117443. /**
  117444. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117445. * This specifies what angle the shadow will use to be created.
  117446. *
  117447. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117448. */
  117449. shadowAngle: number;
  117450. /**
  117451. * Gets the direction if it has been set.
  117452. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117453. */
  117454. /**
  117455. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117456. */
  117457. direction: Vector3;
  117458. /**
  117459. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117460. * A PointLight emits the light in every direction.
  117461. * It can cast shadows.
  117462. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117463. * ```javascript
  117464. * var pointLight = new PointLight("pl", camera.position, scene);
  117465. * ```
  117466. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117467. * @param name The light friendly name
  117468. * @param position The position of the point light in the scene
  117469. * @param scene The scene the lights belongs to
  117470. */
  117471. constructor(name: string, position: Vector3, scene: Scene);
  117472. /**
  117473. * Returns the string "PointLight"
  117474. * @returns the class name
  117475. */
  117476. getClassName(): string;
  117477. /**
  117478. * Returns the integer 0.
  117479. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117480. */
  117481. getTypeID(): number;
  117482. /**
  117483. * Specifies wether or not the shadowmap should be a cube texture.
  117484. * @returns true if the shadowmap needs to be a cube texture.
  117485. */
  117486. needCube(): boolean;
  117487. /**
  117488. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117489. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117490. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117491. */
  117492. getShadowDirection(faceIndex?: number): Vector3;
  117493. /**
  117494. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117495. * - fov = PI / 2
  117496. * - aspect ratio : 1.0
  117497. * - z-near and far equal to the active camera minZ and maxZ.
  117498. * Returns the PointLight.
  117499. */
  117500. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117501. protected _buildUniformLayout(): void;
  117502. /**
  117503. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117504. * @param effect The effect to update
  117505. * @param lightIndex The index of the light in the effect to update
  117506. * @returns The point light
  117507. */
  117508. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117509. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117510. /**
  117511. * Prepares the list of defines specific to the light type.
  117512. * @param defines the list of defines
  117513. * @param lightIndex defines the index of the light for the effect
  117514. */
  117515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117516. }
  117517. }
  117518. declare module BABYLON {
  117519. /**
  117520. * Header information of HDR texture files.
  117521. */
  117522. export interface HDRInfo {
  117523. /**
  117524. * The height of the texture in pixels.
  117525. */
  117526. height: number;
  117527. /**
  117528. * The width of the texture in pixels.
  117529. */
  117530. width: number;
  117531. /**
  117532. * The index of the beginning of the data in the binary file.
  117533. */
  117534. dataPosition: number;
  117535. }
  117536. /**
  117537. * This groups tools to convert HDR texture to native colors array.
  117538. */
  117539. export class HDRTools {
  117540. private static Ldexp;
  117541. private static Rgbe2float;
  117542. private static readStringLine;
  117543. /**
  117544. * Reads header information from an RGBE texture stored in a native array.
  117545. * More information on this format are available here:
  117546. * https://en.wikipedia.org/wiki/RGBE_image_format
  117547. *
  117548. * @param uint8array The binary file stored in native array.
  117549. * @return The header information.
  117550. */
  117551. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117552. /**
  117553. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117554. * This RGBE texture needs to store the information as a panorama.
  117555. *
  117556. * More information on this format are available here:
  117557. * https://en.wikipedia.org/wiki/RGBE_image_format
  117558. *
  117559. * @param buffer The binary file stored in an array buffer.
  117560. * @param size The expected size of the extracted cubemap.
  117561. * @return The Cube Map information.
  117562. */
  117563. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117564. /**
  117565. * Returns the pixels data extracted from an RGBE texture.
  117566. * This pixels will be stored left to right up to down in the R G B order in one array.
  117567. *
  117568. * More information on this format are available here:
  117569. * https://en.wikipedia.org/wiki/RGBE_image_format
  117570. *
  117571. * @param uint8array The binary file stored in an array buffer.
  117572. * @param hdrInfo The header information of the file.
  117573. * @return The pixels data in RGB right to left up to down order.
  117574. */
  117575. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117576. private static RGBE_ReadPixels_RLE;
  117577. }
  117578. }
  117579. declare module BABYLON {
  117580. /**
  117581. * This represents a texture coming from an HDR input.
  117582. *
  117583. * The only supported format is currently panorama picture stored in RGBE format.
  117584. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117585. */
  117586. export class HDRCubeTexture extends BaseTexture {
  117587. private static _facesMapping;
  117588. private _generateHarmonics;
  117589. private _noMipmap;
  117590. private _textureMatrix;
  117591. private _size;
  117592. private _onLoad;
  117593. private _onError;
  117594. /**
  117595. * The texture URL.
  117596. */
  117597. url: string;
  117598. /**
  117599. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117600. */
  117601. coordinatesMode: number;
  117602. protected _isBlocking: boolean;
  117603. /**
  117604. * Sets wether or not the texture is blocking during loading.
  117605. */
  117606. /**
  117607. * Gets wether or not the texture is blocking during loading.
  117608. */
  117609. isBlocking: boolean;
  117610. protected _rotationY: number;
  117611. /**
  117612. * Sets texture matrix rotation angle around Y axis in radians.
  117613. */
  117614. /**
  117615. * Gets texture matrix rotation angle around Y axis radians.
  117616. */
  117617. rotationY: number;
  117618. /**
  117619. * Gets or sets the center of the bounding box associated with the cube texture
  117620. * It must define where the camera used to render the texture was set
  117621. */
  117622. boundingBoxPosition: Vector3;
  117623. private _boundingBoxSize;
  117624. /**
  117625. * Gets or sets the size of the bounding box associated with the cube texture
  117626. * When defined, the cubemap will switch to local mode
  117627. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117628. * @example https://www.babylonjs-playground.com/#RNASML
  117629. */
  117630. boundingBoxSize: Vector3;
  117631. /**
  117632. * Instantiates an HDRTexture from the following parameters.
  117633. *
  117634. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117635. * @param scene The scene the texture will be used in
  117636. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117637. * @param noMipmap Forces to not generate the mipmap if true
  117638. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117639. * @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)
  117640. * @param reserved Reserved flag for internal use.
  117641. */
  117642. 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>);
  117643. /**
  117644. * Get the current class name of the texture useful for serialization or dynamic coding.
  117645. * @returns "HDRCubeTexture"
  117646. */
  117647. getClassName(): string;
  117648. /**
  117649. * Occurs when the file is raw .hdr file.
  117650. */
  117651. private loadTexture;
  117652. clone(): HDRCubeTexture;
  117653. delayLoad(): void;
  117654. /**
  117655. * Get the texture reflection matrix used to rotate/transform the reflection.
  117656. * @returns the reflection matrix
  117657. */
  117658. getReflectionTextureMatrix(): Matrix;
  117659. /**
  117660. * Set the texture reflection matrix used to rotate/transform the reflection.
  117661. * @param value Define the reflection matrix to set
  117662. */
  117663. setReflectionTextureMatrix(value: Matrix): void;
  117664. /**
  117665. * Parses a JSON representation of an HDR Texture in order to create the texture
  117666. * @param parsedTexture Define the JSON representation
  117667. * @param scene Define the scene the texture should be created in
  117668. * @param rootUrl Define the root url in case we need to load relative dependencies
  117669. * @returns the newly created texture after parsing
  117670. */
  117671. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117672. serialize(): any;
  117673. }
  117674. }
  117675. declare module BABYLON {
  117676. /**
  117677. * Class used to control physics engine
  117678. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117679. */
  117680. export class PhysicsEngine implements IPhysicsEngine {
  117681. private _physicsPlugin;
  117682. /**
  117683. * Global value used to control the smallest number supported by the simulation
  117684. */
  117685. static Epsilon: number;
  117686. private _impostors;
  117687. private _joints;
  117688. /**
  117689. * Gets the gravity vector used by the simulation
  117690. */
  117691. gravity: Vector3;
  117692. /**
  117693. * Factory used to create the default physics plugin.
  117694. * @returns The default physics plugin
  117695. */
  117696. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117697. /**
  117698. * Creates a new Physics Engine
  117699. * @param gravity defines the gravity vector used by the simulation
  117700. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117701. */
  117702. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117703. /**
  117704. * Sets the gravity vector used by the simulation
  117705. * @param gravity defines the gravity vector to use
  117706. */
  117707. setGravity(gravity: Vector3): void;
  117708. /**
  117709. * Set the time step of the physics engine.
  117710. * Default is 1/60.
  117711. * To slow it down, enter 1/600 for example.
  117712. * To speed it up, 1/30
  117713. * @param newTimeStep defines the new timestep to apply to this world.
  117714. */
  117715. setTimeStep(newTimeStep?: number): void;
  117716. /**
  117717. * Get the time step of the physics engine.
  117718. * @returns the current time step
  117719. */
  117720. getTimeStep(): number;
  117721. /**
  117722. * Release all resources
  117723. */
  117724. dispose(): void;
  117725. /**
  117726. * Gets the name of the current physics plugin
  117727. * @returns the name of the plugin
  117728. */
  117729. getPhysicsPluginName(): string;
  117730. /**
  117731. * Adding a new impostor for the impostor tracking.
  117732. * This will be done by the impostor itself.
  117733. * @param impostor the impostor to add
  117734. */
  117735. addImpostor(impostor: PhysicsImpostor): void;
  117736. /**
  117737. * Remove an impostor from the engine.
  117738. * This impostor and its mesh will not longer be updated by the physics engine.
  117739. * @param impostor the impostor to remove
  117740. */
  117741. removeImpostor(impostor: PhysicsImpostor): void;
  117742. /**
  117743. * Add a joint to the physics engine
  117744. * @param mainImpostor defines the main impostor to which the joint is added.
  117745. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117746. * @param joint defines the joint that will connect both impostors.
  117747. */
  117748. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117749. /**
  117750. * Removes a joint from the simulation
  117751. * @param mainImpostor defines the impostor used with the joint
  117752. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117753. * @param joint defines the joint to remove
  117754. */
  117755. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117756. /**
  117757. * Called by the scene. No need to call it.
  117758. * @param delta defines the timespam between frames
  117759. */
  117760. _step(delta: number): void;
  117761. /**
  117762. * Gets the current plugin used to run the simulation
  117763. * @returns current plugin
  117764. */
  117765. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117766. /**
  117767. * Gets the list of physic impostors
  117768. * @returns an array of PhysicsImpostor
  117769. */
  117770. getImpostors(): Array<PhysicsImpostor>;
  117771. /**
  117772. * Gets the impostor for a physics enabled object
  117773. * @param object defines the object impersonated by the impostor
  117774. * @returns the PhysicsImpostor or null if not found
  117775. */
  117776. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117777. /**
  117778. * Gets the impostor for a physics body object
  117779. * @param body defines physics body used by the impostor
  117780. * @returns the PhysicsImpostor or null if not found
  117781. */
  117782. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117783. /**
  117784. * Does a raycast in the physics world
  117785. * @param from when should the ray start?
  117786. * @param to when should the ray end?
  117787. * @returns PhysicsRaycastResult
  117788. */
  117789. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117790. }
  117791. }
  117792. declare module BABYLON {
  117793. /** @hidden */
  117794. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117795. private _useDeltaForWorldStep;
  117796. world: any;
  117797. name: string;
  117798. private _physicsMaterials;
  117799. private _fixedTimeStep;
  117800. private _cannonRaycastResult;
  117801. private _raycastResult;
  117802. private _physicsBodysToRemoveAfterStep;
  117803. BJSCANNON: any;
  117804. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117805. setGravity(gravity: Vector3): void;
  117806. setTimeStep(timeStep: number): void;
  117807. getTimeStep(): number;
  117808. executeStep(delta: number): void;
  117809. private _removeMarkedPhysicsBodiesFromWorld;
  117810. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117811. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117812. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117813. private _processChildMeshes;
  117814. removePhysicsBody(impostor: PhysicsImpostor): void;
  117815. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117816. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117817. private _addMaterial;
  117818. private _checkWithEpsilon;
  117819. private _createShape;
  117820. private _createHeightmap;
  117821. private _minus90X;
  117822. private _plus90X;
  117823. private _tmpPosition;
  117824. private _tmpDeltaPosition;
  117825. private _tmpUnityRotation;
  117826. private _updatePhysicsBodyTransformation;
  117827. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117828. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117829. isSupported(): boolean;
  117830. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117831. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117832. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117833. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117834. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117835. getBodyMass(impostor: PhysicsImpostor): number;
  117836. getBodyFriction(impostor: PhysicsImpostor): number;
  117837. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117838. getBodyRestitution(impostor: PhysicsImpostor): number;
  117839. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117840. sleepBody(impostor: PhysicsImpostor): void;
  117841. wakeUpBody(impostor: PhysicsImpostor): void;
  117842. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117843. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117844. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117845. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117846. getRadius(impostor: PhysicsImpostor): number;
  117847. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117848. dispose(): void;
  117849. private _extendNamespace;
  117850. /**
  117851. * Does a raycast in the physics world
  117852. * @param from when should the ray start?
  117853. * @param to when should the ray end?
  117854. * @returns PhysicsRaycastResult
  117855. */
  117856. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117857. }
  117858. }
  117859. declare module BABYLON {
  117860. /** @hidden */
  117861. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117862. world: any;
  117863. name: string;
  117864. BJSOIMO: any;
  117865. private _raycastResult;
  117866. constructor(iterations?: number, oimoInjection?: any);
  117867. setGravity(gravity: Vector3): void;
  117868. setTimeStep(timeStep: number): void;
  117869. getTimeStep(): number;
  117870. private _tmpImpostorsArray;
  117871. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117872. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117873. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117874. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117875. private _tmpPositionVector;
  117876. removePhysicsBody(impostor: PhysicsImpostor): void;
  117877. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117878. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117879. isSupported(): boolean;
  117880. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117881. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117882. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117883. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117884. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117885. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117886. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117887. getBodyMass(impostor: PhysicsImpostor): number;
  117888. getBodyFriction(impostor: PhysicsImpostor): number;
  117889. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117890. getBodyRestitution(impostor: PhysicsImpostor): number;
  117891. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117892. sleepBody(impostor: PhysicsImpostor): void;
  117893. wakeUpBody(impostor: PhysicsImpostor): void;
  117894. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117895. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117896. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117897. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117898. getRadius(impostor: PhysicsImpostor): number;
  117899. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117900. dispose(): void;
  117901. /**
  117902. * Does a raycast in the physics world
  117903. * @param from when should the ray start?
  117904. * @param to when should the ray end?
  117905. * @returns PhysicsRaycastResult
  117906. */
  117907. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117908. }
  117909. }
  117910. declare module BABYLON {
  117911. /**
  117912. * Class containing static functions to help procedurally build meshes
  117913. */
  117914. export class RibbonBuilder {
  117915. /**
  117916. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117917. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117918. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117919. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117920. * * 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
  117921. * * 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
  117922. * * 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
  117923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117925. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117926. * * 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
  117927. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117928. * * 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
  117929. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117931. * @param name defines the name of the mesh
  117932. * @param options defines the options used to create the mesh
  117933. * @param scene defines the hosting scene
  117934. * @returns the ribbon mesh
  117935. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117936. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117937. */
  117938. static CreateRibbon(name: string, options: {
  117939. pathArray: Vector3[][];
  117940. closeArray?: boolean;
  117941. closePath?: boolean;
  117942. offset?: number;
  117943. updatable?: boolean;
  117944. sideOrientation?: number;
  117945. frontUVs?: Vector4;
  117946. backUVs?: Vector4;
  117947. instance?: Mesh;
  117948. invertUV?: boolean;
  117949. uvs?: Vector2[];
  117950. colors?: Color4[];
  117951. }, scene?: Nullable<Scene>): Mesh;
  117952. }
  117953. }
  117954. declare module BABYLON {
  117955. /**
  117956. * Class containing static functions to help procedurally build meshes
  117957. */
  117958. export class ShapeBuilder {
  117959. /**
  117960. * 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.
  117961. * * 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.
  117962. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117963. * * 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.
  117964. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117965. * * 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
  117966. * * 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
  117967. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117970. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117972. * @param name defines the name of the mesh
  117973. * @param options defines the options used to create the mesh
  117974. * @param scene defines the hosting scene
  117975. * @returns the extruded shape mesh
  117976. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117977. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117978. */
  117979. static ExtrudeShape(name: string, options: {
  117980. shape: Vector3[];
  117981. path: Vector3[];
  117982. scale?: number;
  117983. rotation?: number;
  117984. cap?: number;
  117985. updatable?: boolean;
  117986. sideOrientation?: number;
  117987. frontUVs?: Vector4;
  117988. backUVs?: Vector4;
  117989. instance?: Mesh;
  117990. invertUV?: boolean;
  117991. }, scene?: Nullable<Scene>): Mesh;
  117992. /**
  117993. * Creates an custom extruded shape mesh.
  117994. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117995. * * 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.
  117996. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117997. * * 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
  117998. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117999. * * 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
  118000. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118001. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118002. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118003. * * 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
  118004. * * 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
  118005. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118008. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118009. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118010. * @param name defines the name of the mesh
  118011. * @param options defines the options used to create the mesh
  118012. * @param scene defines the hosting scene
  118013. * @returns the custom extruded shape mesh
  118014. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118015. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118016. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118017. */
  118018. static ExtrudeShapeCustom(name: string, options: {
  118019. shape: Vector3[];
  118020. path: Vector3[];
  118021. scaleFunction?: any;
  118022. rotationFunction?: any;
  118023. ribbonCloseArray?: boolean;
  118024. ribbonClosePath?: boolean;
  118025. cap?: number;
  118026. updatable?: boolean;
  118027. sideOrientation?: number;
  118028. frontUVs?: Vector4;
  118029. backUVs?: Vector4;
  118030. instance?: Mesh;
  118031. invertUV?: boolean;
  118032. }, scene?: Nullable<Scene>): Mesh;
  118033. private static _ExtrudeShapeGeneric;
  118034. }
  118035. }
  118036. declare module BABYLON {
  118037. /**
  118038. * AmmoJS Physics plugin
  118039. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118040. * @see https://github.com/kripken/ammo.js/
  118041. */
  118042. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118043. private _useDeltaForWorldStep;
  118044. /**
  118045. * Reference to the Ammo library
  118046. */
  118047. bjsAMMO: any;
  118048. /**
  118049. * Created ammoJS world which physics bodies are added to
  118050. */
  118051. world: any;
  118052. /**
  118053. * Name of the plugin
  118054. */
  118055. name: string;
  118056. private _timeStep;
  118057. private _fixedTimeStep;
  118058. private _maxSteps;
  118059. private _tmpQuaternion;
  118060. private _tmpAmmoTransform;
  118061. private _tmpAmmoQuaternion;
  118062. private _tmpAmmoConcreteContactResultCallback;
  118063. private _collisionConfiguration;
  118064. private _dispatcher;
  118065. private _overlappingPairCache;
  118066. private _solver;
  118067. private _softBodySolver;
  118068. private _tmpAmmoVectorA;
  118069. private _tmpAmmoVectorB;
  118070. private _tmpAmmoVectorC;
  118071. private _tmpAmmoVectorD;
  118072. private _tmpContactCallbackResult;
  118073. private _tmpAmmoVectorRCA;
  118074. private _tmpAmmoVectorRCB;
  118075. private _raycastResult;
  118076. private static readonly DISABLE_COLLISION_FLAG;
  118077. private static readonly KINEMATIC_FLAG;
  118078. private static readonly DISABLE_DEACTIVATION_FLAG;
  118079. /**
  118080. * Initializes the ammoJS plugin
  118081. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118082. * @param ammoInjection can be used to inject your own ammo reference
  118083. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118084. */
  118085. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118086. /**
  118087. * Sets the gravity of the physics world (m/(s^2))
  118088. * @param gravity Gravity to set
  118089. */
  118090. setGravity(gravity: Vector3): void;
  118091. /**
  118092. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118093. * @param timeStep timestep to use in seconds
  118094. */
  118095. setTimeStep(timeStep: number): void;
  118096. /**
  118097. * 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)
  118098. * @param fixedTimeStep fixedTimeStep to use in seconds
  118099. */
  118100. setFixedTimeStep(fixedTimeStep: number): void;
  118101. /**
  118102. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118103. * @param maxSteps the maximum number of steps by the physics engine per frame
  118104. */
  118105. setMaxSteps(maxSteps: number): void;
  118106. /**
  118107. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118108. * @returns the current timestep in seconds
  118109. */
  118110. getTimeStep(): number;
  118111. private _isImpostorInContact;
  118112. private _isImpostorPairInContact;
  118113. private _stepSimulation;
  118114. /**
  118115. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118116. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118117. * After the step the babylon meshes are set to the position of the physics imposters
  118118. * @param delta amount of time to step forward
  118119. * @param impostors array of imposters to update before/after the step
  118120. */
  118121. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118122. /**
  118123. * Update babylon mesh to match physics world object
  118124. * @param impostor imposter to match
  118125. */
  118126. private _afterSoftStep;
  118127. /**
  118128. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118129. * @param impostor imposter to match
  118130. */
  118131. private _ropeStep;
  118132. /**
  118133. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118134. * @param impostor imposter to match
  118135. */
  118136. private _softbodyOrClothStep;
  118137. private _tmpVector;
  118138. private _tmpMatrix;
  118139. /**
  118140. * Applies an impulse on the imposter
  118141. * @param impostor imposter to apply impulse to
  118142. * @param force amount of force to be applied to the imposter
  118143. * @param contactPoint the location to apply the impulse on the imposter
  118144. */
  118145. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118146. /**
  118147. * Applies a force on the imposter
  118148. * @param impostor imposter to apply force
  118149. * @param force amount of force to be applied to the imposter
  118150. * @param contactPoint the location to apply the force on the imposter
  118151. */
  118152. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118153. /**
  118154. * Creates a physics body using the plugin
  118155. * @param impostor the imposter to create the physics body on
  118156. */
  118157. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118158. /**
  118159. * Removes the physics body from the imposter and disposes of the body's memory
  118160. * @param impostor imposter to remove the physics body from
  118161. */
  118162. removePhysicsBody(impostor: PhysicsImpostor): void;
  118163. /**
  118164. * Generates a joint
  118165. * @param impostorJoint the imposter joint to create the joint with
  118166. */
  118167. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118168. /**
  118169. * Removes a joint
  118170. * @param impostorJoint the imposter joint to remove the joint from
  118171. */
  118172. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118173. private _addMeshVerts;
  118174. /**
  118175. * Initialise the soft body vertices to match its object's (mesh) vertices
  118176. * Softbody vertices (nodes) are in world space and to match this
  118177. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118178. * @param impostor to create the softbody for
  118179. */
  118180. private _softVertexData;
  118181. /**
  118182. * Create an impostor's soft body
  118183. * @param impostor to create the softbody for
  118184. */
  118185. private _createSoftbody;
  118186. /**
  118187. * Create cloth for an impostor
  118188. * @param impostor to create the softbody for
  118189. */
  118190. private _createCloth;
  118191. /**
  118192. * Create rope for an impostor
  118193. * @param impostor to create the softbody for
  118194. */
  118195. private _createRope;
  118196. private _addHullVerts;
  118197. private _createShape;
  118198. /**
  118199. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118200. * @param impostor imposter containing the physics body and babylon object
  118201. */
  118202. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118203. /**
  118204. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118205. * @param impostor imposter containing the physics body and babylon object
  118206. * @param newPosition new position
  118207. * @param newRotation new rotation
  118208. */
  118209. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118210. /**
  118211. * If this plugin is supported
  118212. * @returns true if its supported
  118213. */
  118214. isSupported(): boolean;
  118215. /**
  118216. * Sets the linear velocity of the physics body
  118217. * @param impostor imposter to set the velocity on
  118218. * @param velocity velocity to set
  118219. */
  118220. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118221. /**
  118222. * Sets the angular velocity of the physics body
  118223. * @param impostor imposter to set the velocity on
  118224. * @param velocity velocity to set
  118225. */
  118226. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118227. /**
  118228. * gets the linear velocity
  118229. * @param impostor imposter to get linear velocity from
  118230. * @returns linear velocity
  118231. */
  118232. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118233. /**
  118234. * gets the angular velocity
  118235. * @param impostor imposter to get angular velocity from
  118236. * @returns angular velocity
  118237. */
  118238. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118239. /**
  118240. * Sets the mass of physics body
  118241. * @param impostor imposter to set the mass on
  118242. * @param mass mass to set
  118243. */
  118244. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118245. /**
  118246. * Gets the mass of the physics body
  118247. * @param impostor imposter to get the mass from
  118248. * @returns mass
  118249. */
  118250. getBodyMass(impostor: PhysicsImpostor): number;
  118251. /**
  118252. * Gets friction of the impostor
  118253. * @param impostor impostor to get friction from
  118254. * @returns friction value
  118255. */
  118256. getBodyFriction(impostor: PhysicsImpostor): number;
  118257. /**
  118258. * Sets friction of the impostor
  118259. * @param impostor impostor to set friction on
  118260. * @param friction friction value
  118261. */
  118262. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118263. /**
  118264. * Gets restitution of the impostor
  118265. * @param impostor impostor to get restitution from
  118266. * @returns restitution value
  118267. */
  118268. getBodyRestitution(impostor: PhysicsImpostor): number;
  118269. /**
  118270. * Sets resitution of the impostor
  118271. * @param impostor impostor to set resitution on
  118272. * @param restitution resitution value
  118273. */
  118274. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118275. /**
  118276. * Gets pressure inside the impostor
  118277. * @param impostor impostor to get pressure from
  118278. * @returns pressure value
  118279. */
  118280. getBodyPressure(impostor: PhysicsImpostor): number;
  118281. /**
  118282. * Sets pressure inside a soft body impostor
  118283. * Cloth and rope must remain 0 pressure
  118284. * @param impostor impostor to set pressure on
  118285. * @param pressure pressure value
  118286. */
  118287. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118288. /**
  118289. * Gets stiffness of the impostor
  118290. * @param impostor impostor to get stiffness from
  118291. * @returns pressure value
  118292. */
  118293. getBodyStiffness(impostor: PhysicsImpostor): number;
  118294. /**
  118295. * Sets stiffness of the impostor
  118296. * @param impostor impostor to set stiffness on
  118297. * @param stiffness stiffness value from 0 to 1
  118298. */
  118299. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118300. /**
  118301. * Gets velocityIterations of the impostor
  118302. * @param impostor impostor to get velocity iterations from
  118303. * @returns velocityIterations value
  118304. */
  118305. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118306. /**
  118307. * Sets velocityIterations of the impostor
  118308. * @param impostor impostor to set velocity iterations on
  118309. * @param velocityIterations velocityIterations value
  118310. */
  118311. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118312. /**
  118313. * Gets positionIterations of the impostor
  118314. * @param impostor impostor to get position iterations from
  118315. * @returns positionIterations value
  118316. */
  118317. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118318. /**
  118319. * Sets positionIterations of the impostor
  118320. * @param impostor impostor to set position on
  118321. * @param positionIterations positionIterations value
  118322. */
  118323. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118324. /**
  118325. * Append an anchor to a cloth object
  118326. * @param impostor is the cloth impostor to add anchor to
  118327. * @param otherImpostor is the rigid impostor to anchor to
  118328. * @param width ratio across width from 0 to 1
  118329. * @param height ratio up height from 0 to 1
  118330. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118331. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118332. */
  118333. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118334. /**
  118335. * Append an hook to a rope object
  118336. * @param impostor is the rope impostor to add hook to
  118337. * @param otherImpostor is the rigid impostor to hook to
  118338. * @param length ratio along the rope from 0 to 1
  118339. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118340. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118341. */
  118342. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118343. /**
  118344. * Sleeps the physics body and stops it from being active
  118345. * @param impostor impostor to sleep
  118346. */
  118347. sleepBody(impostor: PhysicsImpostor): void;
  118348. /**
  118349. * Activates the physics body
  118350. * @param impostor impostor to activate
  118351. */
  118352. wakeUpBody(impostor: PhysicsImpostor): void;
  118353. /**
  118354. * Updates the distance parameters of the joint
  118355. * @param joint joint to update
  118356. * @param maxDistance maximum distance of the joint
  118357. * @param minDistance minimum distance of the joint
  118358. */
  118359. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118360. /**
  118361. * Sets a motor on the joint
  118362. * @param joint joint to set motor on
  118363. * @param speed speed of the motor
  118364. * @param maxForce maximum force of the motor
  118365. * @param motorIndex index of the motor
  118366. */
  118367. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118368. /**
  118369. * Sets the motors limit
  118370. * @param joint joint to set limit on
  118371. * @param upperLimit upper limit
  118372. * @param lowerLimit lower limit
  118373. */
  118374. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118375. /**
  118376. * Syncs the position and rotation of a mesh with the impostor
  118377. * @param mesh mesh to sync
  118378. * @param impostor impostor to update the mesh with
  118379. */
  118380. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118381. /**
  118382. * Gets the radius of the impostor
  118383. * @param impostor impostor to get radius from
  118384. * @returns the radius
  118385. */
  118386. getRadius(impostor: PhysicsImpostor): number;
  118387. /**
  118388. * Gets the box size of the impostor
  118389. * @param impostor impostor to get box size from
  118390. * @param result the resulting box size
  118391. */
  118392. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118393. /**
  118394. * Disposes of the impostor
  118395. */
  118396. dispose(): void;
  118397. /**
  118398. * Does a raycast in the physics world
  118399. * @param from when should the ray start?
  118400. * @param to when should the ray end?
  118401. * @returns PhysicsRaycastResult
  118402. */
  118403. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118404. }
  118405. }
  118406. declare module BABYLON {
  118407. interface AbstractScene {
  118408. /**
  118409. * The list of reflection probes added to the scene
  118410. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118411. */
  118412. reflectionProbes: Array<ReflectionProbe>;
  118413. /**
  118414. * Removes the given reflection probe from this scene.
  118415. * @param toRemove The reflection probe to remove
  118416. * @returns The index of the removed reflection probe
  118417. */
  118418. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118419. /**
  118420. * Adds the given reflection probe to this scene.
  118421. * @param newReflectionProbe The reflection probe to add
  118422. */
  118423. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118424. }
  118425. /**
  118426. * Class used to generate realtime reflection / refraction cube textures
  118427. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118428. */
  118429. export class ReflectionProbe {
  118430. /** defines the name of the probe */
  118431. name: string;
  118432. private _scene;
  118433. private _renderTargetTexture;
  118434. private _projectionMatrix;
  118435. private _viewMatrix;
  118436. private _target;
  118437. private _add;
  118438. private _attachedMesh;
  118439. private _invertYAxis;
  118440. /** Gets or sets probe position (center of the cube map) */
  118441. position: Vector3;
  118442. /**
  118443. * Creates a new reflection probe
  118444. * @param name defines the name of the probe
  118445. * @param size defines the texture resolution (for each face)
  118446. * @param scene defines the hosting scene
  118447. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118448. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118449. */
  118450. constructor(
  118451. /** defines the name of the probe */
  118452. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118453. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118454. samples: number;
  118455. /** Gets or sets the refresh rate to use (on every frame by default) */
  118456. refreshRate: number;
  118457. /**
  118458. * Gets the hosting scene
  118459. * @returns a Scene
  118460. */
  118461. getScene(): Scene;
  118462. /** Gets the internal CubeTexture used to render to */
  118463. readonly cubeTexture: RenderTargetTexture;
  118464. /** Gets the list of meshes to render */
  118465. readonly renderList: Nullable<AbstractMesh[]>;
  118466. /**
  118467. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118468. * @param mesh defines the mesh to attach to
  118469. */
  118470. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118471. /**
  118472. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118473. * @param renderingGroupId The rendering group id corresponding to its index
  118474. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118475. */
  118476. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118477. /**
  118478. * Clean all associated resources
  118479. */
  118480. dispose(): void;
  118481. /**
  118482. * Converts the reflection probe information to a readable string for debug purpose.
  118483. * @param fullDetails Supports for multiple levels of logging within scene loading
  118484. * @returns the human readable reflection probe info
  118485. */
  118486. toString(fullDetails?: boolean): string;
  118487. /**
  118488. * Get the class name of the relfection probe.
  118489. * @returns "ReflectionProbe"
  118490. */
  118491. getClassName(): string;
  118492. /**
  118493. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118494. * @returns The JSON representation of the texture
  118495. */
  118496. serialize(): any;
  118497. /**
  118498. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118499. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118500. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118501. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118502. * @returns The parsed reflection probe if successful
  118503. */
  118504. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118505. }
  118506. }
  118507. declare module BABYLON {
  118508. /** @hidden */
  118509. export var _BabylonLoaderRegistered: boolean;
  118510. }
  118511. declare module BABYLON {
  118512. /**
  118513. * The Physically based simple base material of BJS.
  118514. *
  118515. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118516. * It is used as the base class for both the specGloss and metalRough conventions.
  118517. */
  118518. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118519. /**
  118520. * Number of Simultaneous lights allowed on the material.
  118521. */
  118522. maxSimultaneousLights: number;
  118523. /**
  118524. * If sets to true, disables all the lights affecting the material.
  118525. */
  118526. disableLighting: boolean;
  118527. /**
  118528. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118529. */
  118530. environmentTexture: BaseTexture;
  118531. /**
  118532. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118533. */
  118534. invertNormalMapX: boolean;
  118535. /**
  118536. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118537. */
  118538. invertNormalMapY: boolean;
  118539. /**
  118540. * Normal map used in the model.
  118541. */
  118542. normalTexture: BaseTexture;
  118543. /**
  118544. * Emissivie color used to self-illuminate the model.
  118545. */
  118546. emissiveColor: Color3;
  118547. /**
  118548. * Emissivie texture used to self-illuminate the model.
  118549. */
  118550. emissiveTexture: BaseTexture;
  118551. /**
  118552. * Occlusion Channel Strenght.
  118553. */
  118554. occlusionStrength: number;
  118555. /**
  118556. * Occlusion Texture of the material (adding extra occlusion effects).
  118557. */
  118558. occlusionTexture: BaseTexture;
  118559. /**
  118560. * Defines the alpha limits in alpha test mode.
  118561. */
  118562. alphaCutOff: number;
  118563. /**
  118564. * Gets the current double sided mode.
  118565. */
  118566. /**
  118567. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118568. */
  118569. doubleSided: boolean;
  118570. /**
  118571. * Stores the pre-calculated light information of a mesh in a texture.
  118572. */
  118573. lightmapTexture: BaseTexture;
  118574. /**
  118575. * If true, the light map contains occlusion information instead of lighting info.
  118576. */
  118577. useLightmapAsShadowmap: boolean;
  118578. /**
  118579. * Instantiates a new PBRMaterial instance.
  118580. *
  118581. * @param name The material name
  118582. * @param scene The scene the material will be use in.
  118583. */
  118584. constructor(name: string, scene: Scene);
  118585. getClassName(): string;
  118586. }
  118587. }
  118588. declare module BABYLON {
  118589. /**
  118590. * The PBR material of BJS following the metal roughness convention.
  118591. *
  118592. * This fits to the PBR convention in the GLTF definition:
  118593. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118594. */
  118595. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118596. /**
  118597. * The base color has two different interpretations depending on the value of metalness.
  118598. * When the material is a metal, the base color is the specific measured reflectance value
  118599. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118600. * of the material.
  118601. */
  118602. baseColor: Color3;
  118603. /**
  118604. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118605. * well as opacity information in the alpha channel.
  118606. */
  118607. baseTexture: BaseTexture;
  118608. /**
  118609. * Specifies the metallic scalar value of the material.
  118610. * Can also be used to scale the metalness values of the metallic texture.
  118611. */
  118612. metallic: number;
  118613. /**
  118614. * Specifies the roughness scalar value of the material.
  118615. * Can also be used to scale the roughness values of the metallic texture.
  118616. */
  118617. roughness: number;
  118618. /**
  118619. * Texture containing both the metallic value in the B channel and the
  118620. * roughness value in the G channel to keep better precision.
  118621. */
  118622. metallicRoughnessTexture: BaseTexture;
  118623. /**
  118624. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118625. *
  118626. * @param name The material name
  118627. * @param scene The scene the material will be use in.
  118628. */
  118629. constructor(name: string, scene: Scene);
  118630. /**
  118631. * Return the currrent class name of the material.
  118632. */
  118633. getClassName(): string;
  118634. /**
  118635. * Makes a duplicate of the current material.
  118636. * @param name - name to use for the new material.
  118637. */
  118638. clone(name: string): PBRMetallicRoughnessMaterial;
  118639. /**
  118640. * Serialize the material to a parsable JSON object.
  118641. */
  118642. serialize(): any;
  118643. /**
  118644. * Parses a JSON object correponding to the serialize function.
  118645. */
  118646. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118647. }
  118648. }
  118649. declare module BABYLON {
  118650. /**
  118651. * The PBR material of BJS following the specular glossiness convention.
  118652. *
  118653. * This fits to the PBR convention in the GLTF definition:
  118654. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118655. */
  118656. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118657. /**
  118658. * Specifies the diffuse color of the material.
  118659. */
  118660. diffuseColor: Color3;
  118661. /**
  118662. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118663. * channel.
  118664. */
  118665. diffuseTexture: BaseTexture;
  118666. /**
  118667. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118668. */
  118669. specularColor: Color3;
  118670. /**
  118671. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118672. */
  118673. glossiness: number;
  118674. /**
  118675. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118676. */
  118677. specularGlossinessTexture: BaseTexture;
  118678. /**
  118679. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118680. *
  118681. * @param name The material name
  118682. * @param scene The scene the material will be use in.
  118683. */
  118684. constructor(name: string, scene: Scene);
  118685. /**
  118686. * Return the currrent class name of the material.
  118687. */
  118688. getClassName(): string;
  118689. /**
  118690. * Makes a duplicate of the current material.
  118691. * @param name - name to use for the new material.
  118692. */
  118693. clone(name: string): PBRSpecularGlossinessMaterial;
  118694. /**
  118695. * Serialize the material to a parsable JSON object.
  118696. */
  118697. serialize(): any;
  118698. /**
  118699. * Parses a JSON object correponding to the serialize function.
  118700. */
  118701. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118702. }
  118703. }
  118704. declare module BABYLON {
  118705. /**
  118706. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118707. * It can help converting any input color in a desired output one. This can then be used to create effects
  118708. * from sepia, black and white to sixties or futuristic rendering...
  118709. *
  118710. * The only supported format is currently 3dl.
  118711. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118712. */
  118713. export class ColorGradingTexture extends BaseTexture {
  118714. /**
  118715. * The current texture matrix. (will always be identity in color grading texture)
  118716. */
  118717. private _textureMatrix;
  118718. /**
  118719. * The texture URL.
  118720. */
  118721. url: string;
  118722. /**
  118723. * Empty line regex stored for GC.
  118724. */
  118725. private static _noneEmptyLineRegex;
  118726. private _engine;
  118727. /**
  118728. * Instantiates a ColorGradingTexture from the following parameters.
  118729. *
  118730. * @param url The location of the color gradind data (currently only supporting 3dl)
  118731. * @param scene The scene the texture will be used in
  118732. */
  118733. constructor(url: string, scene: Scene);
  118734. /**
  118735. * Returns the texture matrix used in most of the material.
  118736. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118737. */
  118738. getTextureMatrix(): Matrix;
  118739. /**
  118740. * Occurs when the file being loaded is a .3dl LUT file.
  118741. */
  118742. private load3dlTexture;
  118743. /**
  118744. * Starts the loading process of the texture.
  118745. */
  118746. private loadTexture;
  118747. /**
  118748. * Clones the color gradind texture.
  118749. */
  118750. clone(): ColorGradingTexture;
  118751. /**
  118752. * Called during delayed load for textures.
  118753. */
  118754. delayLoad(): void;
  118755. /**
  118756. * Parses a color grading texture serialized by Babylon.
  118757. * @param parsedTexture The texture information being parsedTexture
  118758. * @param scene The scene to load the texture in
  118759. * @param rootUrl The root url of the data assets to load
  118760. * @return A color gradind texture
  118761. */
  118762. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118763. /**
  118764. * Serializes the LUT texture to json format.
  118765. */
  118766. serialize(): any;
  118767. }
  118768. }
  118769. declare module BABYLON {
  118770. /**
  118771. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118772. */
  118773. export class EquiRectangularCubeTexture extends BaseTexture {
  118774. /** The six faces of the cube. */
  118775. private static _FacesMapping;
  118776. private _noMipmap;
  118777. private _onLoad;
  118778. private _onError;
  118779. /** The size of the cubemap. */
  118780. private _size;
  118781. /** The buffer of the image. */
  118782. private _buffer;
  118783. /** The width of the input image. */
  118784. private _width;
  118785. /** The height of the input image. */
  118786. private _height;
  118787. /** The URL to the image. */
  118788. url: string;
  118789. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118790. coordinatesMode: number;
  118791. /**
  118792. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118793. * @param url The location of the image
  118794. * @param scene The scene the texture will be used in
  118795. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118796. * @param noMipmap Forces to not generate the mipmap if true
  118797. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118798. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118799. * @param onLoad — defines a callback called when texture is loaded
  118800. * @param onError — defines a callback called if there is an error
  118801. */
  118802. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118803. /**
  118804. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118805. */
  118806. private loadImage;
  118807. /**
  118808. * Convert the image buffer into a cubemap and create a CubeTexture.
  118809. */
  118810. private loadTexture;
  118811. /**
  118812. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118813. * @param buffer The ArrayBuffer that should be converted.
  118814. * @returns The buffer as Float32Array.
  118815. */
  118816. private getFloat32ArrayFromArrayBuffer;
  118817. /**
  118818. * Get the current class name of the texture useful for serialization or dynamic coding.
  118819. * @returns "EquiRectangularCubeTexture"
  118820. */
  118821. getClassName(): string;
  118822. /**
  118823. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118824. * @returns A clone of the current EquiRectangularCubeTexture.
  118825. */
  118826. clone(): EquiRectangularCubeTexture;
  118827. }
  118828. }
  118829. declare module BABYLON {
  118830. /**
  118831. * Based on jsTGALoader - Javascript loader for TGA file
  118832. * By Vincent Thibault
  118833. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118834. */
  118835. export class TGATools {
  118836. private static _TYPE_INDEXED;
  118837. private static _TYPE_RGB;
  118838. private static _TYPE_GREY;
  118839. private static _TYPE_RLE_INDEXED;
  118840. private static _TYPE_RLE_RGB;
  118841. private static _TYPE_RLE_GREY;
  118842. private static _ORIGIN_MASK;
  118843. private static _ORIGIN_SHIFT;
  118844. private static _ORIGIN_BL;
  118845. private static _ORIGIN_BR;
  118846. private static _ORIGIN_UL;
  118847. private static _ORIGIN_UR;
  118848. /**
  118849. * Gets the header of a TGA file
  118850. * @param data defines the TGA data
  118851. * @returns the header
  118852. */
  118853. static GetTGAHeader(data: Uint8Array): any;
  118854. /**
  118855. * Uploads TGA content to a Babylon Texture
  118856. * @hidden
  118857. */
  118858. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118859. /** @hidden */
  118860. 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;
  118861. /** @hidden */
  118862. 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;
  118863. /** @hidden */
  118864. 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;
  118865. /** @hidden */
  118866. 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;
  118867. /** @hidden */
  118868. 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;
  118869. /** @hidden */
  118870. 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;
  118871. }
  118872. }
  118873. declare module BABYLON {
  118874. /**
  118875. * Implementation of the TGA Texture Loader.
  118876. * @hidden
  118877. */
  118878. export class _TGATextureLoader implements IInternalTextureLoader {
  118879. /**
  118880. * Defines wether the loader supports cascade loading the different faces.
  118881. */
  118882. readonly supportCascades: boolean;
  118883. /**
  118884. * This returns if the loader support the current file information.
  118885. * @param extension defines the file extension of the file being loaded
  118886. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118887. * @param fallback defines the fallback internal texture if any
  118888. * @param isBase64 defines whether the texture is encoded as a base64
  118889. * @param isBuffer defines whether the texture data are stored as a buffer
  118890. * @returns true if the loader can load the specified file
  118891. */
  118892. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118893. /**
  118894. * Transform the url before loading if required.
  118895. * @param rootUrl the url of the texture
  118896. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118897. * @returns the transformed texture
  118898. */
  118899. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118900. /**
  118901. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118902. * @param rootUrl the url of the texture
  118903. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118904. * @returns the fallback texture
  118905. */
  118906. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118907. /**
  118908. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118909. * @param data contains the texture data
  118910. * @param texture defines the BabylonJS internal texture
  118911. * @param createPolynomials will be true if polynomials have been requested
  118912. * @param onLoad defines the callback to trigger once the texture is ready
  118913. * @param onError defines the callback to trigger in case of error
  118914. */
  118915. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118916. /**
  118917. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118918. * @param data contains the texture data
  118919. * @param texture defines the BabylonJS internal texture
  118920. * @param callback defines the method to call once ready to upload
  118921. */
  118922. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118923. }
  118924. }
  118925. declare module BABYLON {
  118926. /**
  118927. * Info about the .basis files
  118928. */
  118929. class BasisFileInfo {
  118930. /**
  118931. * If the file has alpha
  118932. */
  118933. hasAlpha: boolean;
  118934. /**
  118935. * Info about each image of the basis file
  118936. */
  118937. images: Array<{
  118938. levels: Array<{
  118939. width: number;
  118940. height: number;
  118941. transcodedPixels: ArrayBufferView;
  118942. }>;
  118943. }>;
  118944. }
  118945. /**
  118946. * Result of transcoding a basis file
  118947. */
  118948. class TranscodeResult {
  118949. /**
  118950. * Info about the .basis file
  118951. */
  118952. fileInfo: BasisFileInfo;
  118953. /**
  118954. * Format to use when loading the file
  118955. */
  118956. format: number;
  118957. }
  118958. /**
  118959. * Configuration options for the Basis transcoder
  118960. */
  118961. export class BasisTranscodeConfiguration {
  118962. /**
  118963. * Supported compression formats used to determine the supported output format of the transcoder
  118964. */
  118965. supportedCompressionFormats?: {
  118966. /**
  118967. * etc1 compression format
  118968. */
  118969. etc1?: boolean;
  118970. /**
  118971. * s3tc compression format
  118972. */
  118973. s3tc?: boolean;
  118974. /**
  118975. * pvrtc compression format
  118976. */
  118977. pvrtc?: boolean;
  118978. /**
  118979. * etc2 compression format
  118980. */
  118981. etc2?: boolean;
  118982. };
  118983. /**
  118984. * If mipmap levels should be loaded for transcoded images (Default: true)
  118985. */
  118986. loadMipmapLevels?: boolean;
  118987. /**
  118988. * Index of a single image to load (Default: all images)
  118989. */
  118990. loadSingleImage?: number;
  118991. }
  118992. /**
  118993. * Used to load .Basis files
  118994. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118995. */
  118996. export class BasisTools {
  118997. private static _IgnoreSupportedFormats;
  118998. /**
  118999. * URL to use when loading the basis transcoder
  119000. */
  119001. static JSModuleURL: string;
  119002. /**
  119003. * URL to use when loading the wasm module for the transcoder
  119004. */
  119005. static WasmModuleURL: string;
  119006. /**
  119007. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119008. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119009. * @returns internal format corresponding to the Basis format
  119010. */
  119011. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119012. private static _WorkerPromise;
  119013. private static _Worker;
  119014. private static _actionId;
  119015. private static _CreateWorkerAsync;
  119016. /**
  119017. * Transcodes a loaded image file to compressed pixel data
  119018. * @param imageData image data to transcode
  119019. * @param config configuration options for the transcoding
  119020. * @returns a promise resulting in the transcoded image
  119021. */
  119022. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119023. /**
  119024. * Loads a texture from the transcode result
  119025. * @param texture texture load to
  119026. * @param transcodeResult the result of transcoding the basis file to load from
  119027. */
  119028. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119029. }
  119030. }
  119031. declare module BABYLON {
  119032. /**
  119033. * Loader for .basis file format
  119034. */
  119035. export class _BasisTextureLoader implements IInternalTextureLoader {
  119036. /**
  119037. * Defines whether the loader supports cascade loading the different faces.
  119038. */
  119039. readonly supportCascades: boolean;
  119040. /**
  119041. * This returns if the loader support the current file information.
  119042. * @param extension defines the file extension of the file being loaded
  119043. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119044. * @param fallback defines the fallback internal texture if any
  119045. * @param isBase64 defines whether the texture is encoded as a base64
  119046. * @param isBuffer defines whether the texture data are stored as a buffer
  119047. * @returns true if the loader can load the specified file
  119048. */
  119049. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119050. /**
  119051. * Transform the url before loading if required.
  119052. * @param rootUrl the url of the texture
  119053. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119054. * @returns the transformed texture
  119055. */
  119056. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119057. /**
  119058. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119059. * @param rootUrl the url of the texture
  119060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119061. * @returns the fallback texture
  119062. */
  119063. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119064. /**
  119065. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119066. * @param data contains the texture data
  119067. * @param texture defines the BabylonJS internal texture
  119068. * @param createPolynomials will be true if polynomials have been requested
  119069. * @param onLoad defines the callback to trigger once the texture is ready
  119070. * @param onError defines the callback to trigger in case of error
  119071. */
  119072. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119073. /**
  119074. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119075. * @param data contains the texture data
  119076. * @param texture defines the BabylonJS internal texture
  119077. * @param callback defines the method to call once ready to upload
  119078. */
  119079. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119080. }
  119081. }
  119082. declare module BABYLON {
  119083. /**
  119084. * 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.
  119085. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119086. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119087. */
  119088. export class CustomProceduralTexture extends ProceduralTexture {
  119089. private _animate;
  119090. private _time;
  119091. private _config;
  119092. private _texturePath;
  119093. /**
  119094. * Instantiates a new Custom Procedural Texture.
  119095. * 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.
  119096. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119097. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119098. * @param name Define the name of the texture
  119099. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119100. * @param size Define the size of the texture to create
  119101. * @param scene Define the scene the texture belongs to
  119102. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119103. * @param generateMipMaps Define if the texture should creates mip maps or not
  119104. */
  119105. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119106. private _loadJson;
  119107. /**
  119108. * Is the texture ready to be used ? (rendered at least once)
  119109. * @returns true if ready, otherwise, false.
  119110. */
  119111. isReady(): boolean;
  119112. /**
  119113. * Render the texture to its associated render target.
  119114. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119115. */
  119116. render(useCameraPostProcess?: boolean): void;
  119117. /**
  119118. * Update the list of dependant textures samplers in the shader.
  119119. */
  119120. updateTextures(): void;
  119121. /**
  119122. * Update the uniform values of the procedural texture in the shader.
  119123. */
  119124. updateShaderUniforms(): void;
  119125. /**
  119126. * Define if the texture animates or not.
  119127. */
  119128. animate: boolean;
  119129. }
  119130. }
  119131. declare module BABYLON {
  119132. /** @hidden */
  119133. export var noisePixelShader: {
  119134. name: string;
  119135. shader: string;
  119136. };
  119137. }
  119138. declare module BABYLON {
  119139. /**
  119140. * Class used to generate noise procedural textures
  119141. */
  119142. export class NoiseProceduralTexture extends ProceduralTexture {
  119143. private _time;
  119144. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119145. brightness: number;
  119146. /** Defines the number of octaves to process */
  119147. octaves: number;
  119148. /** Defines the level of persistence (0.8 by default) */
  119149. persistence: number;
  119150. /** Gets or sets animation speed factor (default is 1) */
  119151. animationSpeedFactor: number;
  119152. /**
  119153. * Creates a new NoiseProceduralTexture
  119154. * @param name defines the name fo the texture
  119155. * @param size defines the size of the texture (default is 256)
  119156. * @param scene defines the hosting scene
  119157. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119158. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119159. */
  119160. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119161. private _updateShaderUniforms;
  119162. protected _getDefines(): string;
  119163. /** Generate the current state of the procedural texture */
  119164. render(useCameraPostProcess?: boolean): void;
  119165. /**
  119166. * Serializes this noise procedural texture
  119167. * @returns a serialized noise procedural texture object
  119168. */
  119169. serialize(): any;
  119170. /**
  119171. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119172. * @param parsedTexture defines parsed texture data
  119173. * @param scene defines the current scene
  119174. * @param rootUrl defines the root URL containing noise procedural texture information
  119175. * @returns a parsed NoiseProceduralTexture
  119176. */
  119177. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119178. }
  119179. }
  119180. declare module BABYLON {
  119181. /**
  119182. * Raw cube texture where the raw buffers are passed in
  119183. */
  119184. export class RawCubeTexture extends CubeTexture {
  119185. /**
  119186. * Creates a cube texture where the raw buffers are passed in.
  119187. * @param scene defines the scene the texture is attached to
  119188. * @param data defines the array of data to use to create each face
  119189. * @param size defines the size of the textures
  119190. * @param format defines the format of the data
  119191. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119192. * @param generateMipMaps defines if the engine should generate the mip levels
  119193. * @param invertY defines if data must be stored with Y axis inverted
  119194. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119195. * @param compression defines the compression used (null by default)
  119196. */
  119197. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119198. /**
  119199. * Updates the raw cube texture.
  119200. * @param data defines the data to store
  119201. * @param format defines the data format
  119202. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119203. * @param invertY defines if data must be stored with Y axis inverted
  119204. * @param compression defines the compression used (null by default)
  119205. * @param level defines which level of the texture to update
  119206. */
  119207. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119208. /**
  119209. * Updates a raw cube texture with RGBD encoded data.
  119210. * @param data defines the array of data [mipmap][face] to use to create each face
  119211. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119212. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119213. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119214. * @returns a promsie that resolves when the operation is complete
  119215. */
  119216. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119217. /**
  119218. * Clones the raw cube texture.
  119219. * @return a new cube texture
  119220. */
  119221. clone(): CubeTexture;
  119222. /** @hidden */
  119223. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119224. }
  119225. }
  119226. declare module BABYLON {
  119227. /**
  119228. * Class used to store 3D textures containing user data
  119229. */
  119230. export class RawTexture3D extends Texture {
  119231. /** Gets or sets the texture format to use */
  119232. format: number;
  119233. private _engine;
  119234. /**
  119235. * Create a new RawTexture3D
  119236. * @param data defines the data of the texture
  119237. * @param width defines the width of the texture
  119238. * @param height defines the height of the texture
  119239. * @param depth defines the depth of the texture
  119240. * @param format defines the texture format to use
  119241. * @param scene defines the hosting scene
  119242. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119243. * @param invertY defines if texture must be stored with Y axis inverted
  119244. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119245. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119246. */
  119247. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119248. /** Gets or sets the texture format to use */
  119249. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119250. /**
  119251. * Update the texture with new data
  119252. * @param data defines the data to store in the texture
  119253. */
  119254. update(data: ArrayBufferView): void;
  119255. }
  119256. }
  119257. declare module BABYLON {
  119258. /**
  119259. * Creates a refraction texture used by refraction channel of the standard material.
  119260. * It is like a mirror but to see through a material.
  119261. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119262. */
  119263. export class RefractionTexture extends RenderTargetTexture {
  119264. /**
  119265. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119266. * 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.
  119267. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119268. */
  119269. refractionPlane: Plane;
  119270. /**
  119271. * Define how deep under the surface we should see.
  119272. */
  119273. depth: number;
  119274. /**
  119275. * Creates a refraction texture used by refraction channel of the standard material.
  119276. * It is like a mirror but to see through a material.
  119277. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119278. * @param name Define the texture name
  119279. * @param size Define the size of the underlying texture
  119280. * @param scene Define the scene the refraction belongs to
  119281. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119282. */
  119283. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119284. /**
  119285. * Clone the refraction texture.
  119286. * @returns the cloned texture
  119287. */
  119288. clone(): RefractionTexture;
  119289. /**
  119290. * Serialize the texture to a JSON representation you could use in Parse later on
  119291. * @returns the serialized JSON representation
  119292. */
  119293. serialize(): any;
  119294. }
  119295. }
  119296. declare module BABYLON {
  119297. /**
  119298. * Defines the options related to the creation of an HtmlElementTexture
  119299. */
  119300. export interface IHtmlElementTextureOptions {
  119301. /**
  119302. * Defines wether mip maps should be created or not.
  119303. */
  119304. generateMipMaps?: boolean;
  119305. /**
  119306. * Defines the sampling mode of the texture.
  119307. */
  119308. samplingMode?: number;
  119309. /**
  119310. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119311. */
  119312. engine: Nullable<ThinEngine>;
  119313. /**
  119314. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119315. */
  119316. scene: Nullable<Scene>;
  119317. }
  119318. /**
  119319. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119320. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119321. * is automatically managed.
  119322. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119323. * in your application.
  119324. *
  119325. * As the update is not automatic, you need to call them manually.
  119326. */
  119327. export class HtmlElementTexture extends BaseTexture {
  119328. /**
  119329. * The texture URL.
  119330. */
  119331. element: HTMLVideoElement | HTMLCanvasElement;
  119332. private static readonly DefaultOptions;
  119333. private _textureMatrix;
  119334. private _engine;
  119335. private _isVideo;
  119336. private _generateMipMaps;
  119337. private _samplingMode;
  119338. /**
  119339. * Instantiates a HtmlElementTexture from the following parameters.
  119340. *
  119341. * @param name Defines the name of the texture
  119342. * @param element Defines the video or canvas the texture is filled with
  119343. * @param options Defines the other none mandatory texture creation options
  119344. */
  119345. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119346. private _createInternalTexture;
  119347. /**
  119348. * Returns the texture matrix used in most of the material.
  119349. */
  119350. getTextureMatrix(): Matrix;
  119351. /**
  119352. * Updates the content of the texture.
  119353. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119354. */
  119355. update(invertY?: Nullable<boolean>): void;
  119356. }
  119357. }
  119358. declare module BABYLON {
  119359. /**
  119360. * Enum used to define the target of a block
  119361. */
  119362. export enum NodeMaterialBlockTargets {
  119363. /** Vertex shader */
  119364. Vertex = 1,
  119365. /** Fragment shader */
  119366. Fragment = 2,
  119367. /** Neutral */
  119368. Neutral = 4,
  119369. /** Vertex and Fragment */
  119370. VertexAndFragment = 3
  119371. }
  119372. }
  119373. declare module BABYLON {
  119374. /**
  119375. * Defines the kind of connection point for node based material
  119376. */
  119377. export enum NodeMaterialBlockConnectionPointTypes {
  119378. /** Float */
  119379. Float = 1,
  119380. /** Int */
  119381. Int = 2,
  119382. /** Vector2 */
  119383. Vector2 = 4,
  119384. /** Vector3 */
  119385. Vector3 = 8,
  119386. /** Vector4 */
  119387. Vector4 = 16,
  119388. /** Color3 */
  119389. Color3 = 32,
  119390. /** Color4 */
  119391. Color4 = 64,
  119392. /** Matrix */
  119393. Matrix = 128,
  119394. /** Detect type based on connection */
  119395. AutoDetect = 1024,
  119396. /** Output type that will be defined by input type */
  119397. BasedOnInput = 2048
  119398. }
  119399. }
  119400. declare module BABYLON {
  119401. /**
  119402. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119403. */
  119404. export enum NodeMaterialBlockConnectionPointMode {
  119405. /** Value is an uniform */
  119406. Uniform = 0,
  119407. /** Value is a mesh attribute */
  119408. Attribute = 1,
  119409. /** Value is a varying between vertex and fragment shaders */
  119410. Varying = 2,
  119411. /** Mode is undefined */
  119412. Undefined = 3
  119413. }
  119414. }
  119415. declare module BABYLON {
  119416. /**
  119417. * Enum used to define system values e.g. values automatically provided by the system
  119418. */
  119419. export enum NodeMaterialSystemValues {
  119420. /** World */
  119421. World = 1,
  119422. /** View */
  119423. View = 2,
  119424. /** Projection */
  119425. Projection = 3,
  119426. /** ViewProjection */
  119427. ViewProjection = 4,
  119428. /** WorldView */
  119429. WorldView = 5,
  119430. /** WorldViewProjection */
  119431. WorldViewProjection = 6,
  119432. /** CameraPosition */
  119433. CameraPosition = 7,
  119434. /** Fog Color */
  119435. FogColor = 8,
  119436. /** Delta time */
  119437. DeltaTime = 9
  119438. }
  119439. }
  119440. declare module BABYLON {
  119441. /**
  119442. * Root class for all node material optimizers
  119443. */
  119444. export class NodeMaterialOptimizer {
  119445. /**
  119446. * Function used to optimize a NodeMaterial graph
  119447. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119448. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119449. */
  119450. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119451. }
  119452. }
  119453. declare module BABYLON {
  119454. /**
  119455. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119456. */
  119457. export class TransformBlock extends NodeMaterialBlock {
  119458. /**
  119459. * Defines the value to use to complement W value to transform it to a Vector4
  119460. */
  119461. complementW: number;
  119462. /**
  119463. * Defines the value to use to complement z value to transform it to a Vector4
  119464. */
  119465. complementZ: number;
  119466. /**
  119467. * Creates a new TransformBlock
  119468. * @param name defines the block name
  119469. */
  119470. constructor(name: string);
  119471. /**
  119472. * Gets the current class name
  119473. * @returns the class name
  119474. */
  119475. getClassName(): string;
  119476. /**
  119477. * Gets the vector input
  119478. */
  119479. readonly vector: NodeMaterialConnectionPoint;
  119480. /**
  119481. * Gets the output component
  119482. */
  119483. readonly output: NodeMaterialConnectionPoint;
  119484. /**
  119485. * Gets the matrix transform input
  119486. */
  119487. readonly transform: NodeMaterialConnectionPoint;
  119488. protected _buildBlock(state: NodeMaterialBuildState): this;
  119489. serialize(): any;
  119490. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119491. protected _dumpPropertiesCode(): string;
  119492. }
  119493. }
  119494. declare module BABYLON {
  119495. /**
  119496. * Block used to output the vertex position
  119497. */
  119498. export class VertexOutputBlock extends NodeMaterialBlock {
  119499. /**
  119500. * Creates a new VertexOutputBlock
  119501. * @param name defines the block name
  119502. */
  119503. constructor(name: string);
  119504. /**
  119505. * Gets the current class name
  119506. * @returns the class name
  119507. */
  119508. getClassName(): string;
  119509. /**
  119510. * Gets the vector input component
  119511. */
  119512. readonly vector: NodeMaterialConnectionPoint;
  119513. protected _buildBlock(state: NodeMaterialBuildState): this;
  119514. }
  119515. }
  119516. declare module BABYLON {
  119517. /**
  119518. * Block used to output the final color
  119519. */
  119520. export class FragmentOutputBlock extends NodeMaterialBlock {
  119521. /**
  119522. * Create a new FragmentOutputBlock
  119523. * @param name defines the block name
  119524. */
  119525. constructor(name: string);
  119526. /**
  119527. * Gets the current class name
  119528. * @returns the class name
  119529. */
  119530. getClassName(): string;
  119531. /**
  119532. * Gets the rgba input component
  119533. */
  119534. readonly rgba: NodeMaterialConnectionPoint;
  119535. /**
  119536. * Gets the rgb input component
  119537. */
  119538. readonly rgb: NodeMaterialConnectionPoint;
  119539. /**
  119540. * Gets the a input component
  119541. */
  119542. readonly a: NodeMaterialConnectionPoint;
  119543. protected _buildBlock(state: NodeMaterialBuildState): this;
  119544. }
  119545. }
  119546. declare module BABYLON {
  119547. /**
  119548. * Block used to read a reflection texture from a sampler
  119549. */
  119550. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119551. private _define3DName;
  119552. private _defineCubicName;
  119553. private _defineExplicitName;
  119554. private _defineProjectionName;
  119555. private _defineLocalCubicName;
  119556. private _defineSphericalName;
  119557. private _definePlanarName;
  119558. private _defineEquirectangularName;
  119559. private _defineMirroredEquirectangularFixedName;
  119560. private _defineEquirectangularFixedName;
  119561. private _defineSkyboxName;
  119562. private _cubeSamplerName;
  119563. private _2DSamplerName;
  119564. private _positionUVWName;
  119565. private _directionWName;
  119566. private _reflectionCoordsName;
  119567. private _reflection2DCoordsName;
  119568. private _reflectionColorName;
  119569. private _reflectionMatrixName;
  119570. /**
  119571. * Gets or sets the texture associated with the node
  119572. */
  119573. texture: Nullable<BaseTexture>;
  119574. /**
  119575. * Create a new TextureBlock
  119576. * @param name defines the block name
  119577. */
  119578. constructor(name: string);
  119579. /**
  119580. * Gets the current class name
  119581. * @returns the class name
  119582. */
  119583. getClassName(): string;
  119584. /**
  119585. * Gets the world position input component
  119586. */
  119587. readonly position: NodeMaterialConnectionPoint;
  119588. /**
  119589. * Gets the world position input component
  119590. */
  119591. readonly worldPosition: NodeMaterialConnectionPoint;
  119592. /**
  119593. * Gets the world normal input component
  119594. */
  119595. readonly worldNormal: NodeMaterialConnectionPoint;
  119596. /**
  119597. * Gets the world input component
  119598. */
  119599. readonly world: NodeMaterialConnectionPoint;
  119600. /**
  119601. * Gets the camera (or eye) position component
  119602. */
  119603. readonly cameraPosition: NodeMaterialConnectionPoint;
  119604. /**
  119605. * Gets the view input component
  119606. */
  119607. readonly view: NodeMaterialConnectionPoint;
  119608. /**
  119609. * Gets the rgb output component
  119610. */
  119611. readonly rgb: NodeMaterialConnectionPoint;
  119612. /**
  119613. * Gets the r output component
  119614. */
  119615. readonly r: NodeMaterialConnectionPoint;
  119616. /**
  119617. * Gets the g output component
  119618. */
  119619. readonly g: NodeMaterialConnectionPoint;
  119620. /**
  119621. * Gets the b output component
  119622. */
  119623. readonly b: NodeMaterialConnectionPoint;
  119624. autoConfigure(material: NodeMaterial): void;
  119625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119626. isReady(): boolean;
  119627. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119628. private _injectVertexCode;
  119629. private _writeOutput;
  119630. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119631. serialize(): any;
  119632. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119633. }
  119634. }
  119635. declare module BABYLON {
  119636. /**
  119637. * Interface used to configure the node material editor
  119638. */
  119639. export interface INodeMaterialEditorOptions {
  119640. /** Define the URl to load node editor script */
  119641. editorURL?: string;
  119642. }
  119643. /** @hidden */
  119644. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119645. /** BONES */
  119646. NUM_BONE_INFLUENCERS: number;
  119647. BonesPerMesh: number;
  119648. BONETEXTURE: boolean;
  119649. /** MORPH TARGETS */
  119650. MORPHTARGETS: boolean;
  119651. MORPHTARGETS_NORMAL: boolean;
  119652. MORPHTARGETS_TANGENT: boolean;
  119653. MORPHTARGETS_UV: boolean;
  119654. NUM_MORPH_INFLUENCERS: number;
  119655. /** IMAGE PROCESSING */
  119656. IMAGEPROCESSING: boolean;
  119657. VIGNETTE: boolean;
  119658. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119659. VIGNETTEBLENDMODEOPAQUE: boolean;
  119660. TONEMAPPING: boolean;
  119661. TONEMAPPING_ACES: boolean;
  119662. CONTRAST: boolean;
  119663. EXPOSURE: boolean;
  119664. COLORCURVES: boolean;
  119665. COLORGRADING: boolean;
  119666. COLORGRADING3D: boolean;
  119667. SAMPLER3DGREENDEPTH: boolean;
  119668. SAMPLER3DBGRMAP: boolean;
  119669. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119670. /** MISC. */
  119671. BUMPDIRECTUV: number;
  119672. constructor();
  119673. setValue(name: string, value: boolean): void;
  119674. }
  119675. /**
  119676. * Class used to configure NodeMaterial
  119677. */
  119678. export interface INodeMaterialOptions {
  119679. /**
  119680. * Defines if blocks should emit comments
  119681. */
  119682. emitComments: boolean;
  119683. }
  119684. /**
  119685. * Class used to create a node based material built by assembling shader blocks
  119686. */
  119687. export class NodeMaterial extends PushMaterial {
  119688. private static _BuildIdGenerator;
  119689. private _options;
  119690. private _vertexCompilationState;
  119691. private _fragmentCompilationState;
  119692. private _sharedData;
  119693. private _buildId;
  119694. private _buildWasSuccessful;
  119695. private _cachedWorldViewMatrix;
  119696. private _cachedWorldViewProjectionMatrix;
  119697. private _optimizers;
  119698. private _animationFrame;
  119699. /** Define the URl to load node editor script */
  119700. static EditorURL: string;
  119701. private BJSNODEMATERIALEDITOR;
  119702. /** Get the inspector from bundle or global */
  119703. private _getGlobalNodeMaterialEditor;
  119704. /**
  119705. * 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)
  119706. */
  119707. ignoreAlpha: boolean;
  119708. /**
  119709. * Defines the maximum number of lights that can be used in the material
  119710. */
  119711. maxSimultaneousLights: number;
  119712. /**
  119713. * Observable raised when the material is built
  119714. */
  119715. onBuildObservable: Observable<NodeMaterial>;
  119716. /**
  119717. * Gets or sets the root nodes of the material vertex shader
  119718. */
  119719. _vertexOutputNodes: NodeMaterialBlock[];
  119720. /**
  119721. * Gets or sets the root nodes of the material fragment (pixel) shader
  119722. */
  119723. _fragmentOutputNodes: NodeMaterialBlock[];
  119724. /** Gets or sets options to control the node material overall behavior */
  119725. options: INodeMaterialOptions;
  119726. /**
  119727. * Default configuration related to image processing available in the standard Material.
  119728. */
  119729. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119730. /**
  119731. * Gets the image processing configuration used either in this material.
  119732. */
  119733. /**
  119734. * Sets the Default image processing configuration used either in the this material.
  119735. *
  119736. * If sets to null, the scene one is in use.
  119737. */
  119738. imageProcessingConfiguration: ImageProcessingConfiguration;
  119739. /**
  119740. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119741. */
  119742. attachedBlocks: NodeMaterialBlock[];
  119743. /**
  119744. * Create a new node based material
  119745. * @param name defines the material name
  119746. * @param scene defines the hosting scene
  119747. * @param options defines creation option
  119748. */
  119749. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119750. /**
  119751. * Gets the current class name of the material e.g. "NodeMaterial"
  119752. * @returns the class name
  119753. */
  119754. getClassName(): string;
  119755. /**
  119756. * Keep track of the image processing observer to allow dispose and replace.
  119757. */
  119758. private _imageProcessingObserver;
  119759. /**
  119760. * Attaches a new image processing configuration to the Standard Material.
  119761. * @param configuration
  119762. */
  119763. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119764. /**
  119765. * Get a block by its name
  119766. * @param name defines the name of the block to retrieve
  119767. * @returns the required block or null if not found
  119768. */
  119769. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119770. /**
  119771. * Get a block by its name
  119772. * @param predicate defines the predicate used to find the good candidate
  119773. * @returns the required block or null if not found
  119774. */
  119775. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119776. /**
  119777. * Get an input block by its name
  119778. * @param predicate defines the predicate used to find the good candidate
  119779. * @returns the required input block or null if not found
  119780. */
  119781. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119782. /**
  119783. * Gets the list of input blocks attached to this material
  119784. * @returns an array of InputBlocks
  119785. */
  119786. getInputBlocks(): InputBlock[];
  119787. /**
  119788. * Adds a new optimizer to the list of optimizers
  119789. * @param optimizer defines the optimizers to add
  119790. * @returns the current material
  119791. */
  119792. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119793. /**
  119794. * Remove an optimizer from the list of optimizers
  119795. * @param optimizer defines the optimizers to remove
  119796. * @returns the current material
  119797. */
  119798. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119799. /**
  119800. * Add a new block to the list of output nodes
  119801. * @param node defines the node to add
  119802. * @returns the current material
  119803. */
  119804. addOutputNode(node: NodeMaterialBlock): this;
  119805. /**
  119806. * Remove a block from the list of root nodes
  119807. * @param node defines the node to remove
  119808. * @returns the current material
  119809. */
  119810. removeOutputNode(node: NodeMaterialBlock): this;
  119811. private _addVertexOutputNode;
  119812. private _removeVertexOutputNode;
  119813. private _addFragmentOutputNode;
  119814. private _removeFragmentOutputNode;
  119815. /**
  119816. * Specifies if the material will require alpha blending
  119817. * @returns a boolean specifying if alpha blending is needed
  119818. */
  119819. needAlphaBlending(): boolean;
  119820. /**
  119821. * Specifies if this material should be rendered in alpha test mode
  119822. * @returns a boolean specifying if an alpha test is needed.
  119823. */
  119824. needAlphaTesting(): boolean;
  119825. private _initializeBlock;
  119826. private _resetDualBlocks;
  119827. /**
  119828. * Build the material and generates the inner effect
  119829. * @param verbose defines if the build should log activity
  119830. */
  119831. build(verbose?: boolean): void;
  119832. /**
  119833. * Runs an otpimization phase to try to improve the shader code
  119834. */
  119835. optimize(): void;
  119836. private _prepareDefinesForAttributes;
  119837. /**
  119838. * Get if the submesh is ready to be used and all its information available.
  119839. * Child classes can use it to update shaders
  119840. * @param mesh defines the mesh to check
  119841. * @param subMesh defines which submesh to check
  119842. * @param useInstances specifies that instances should be used
  119843. * @returns a boolean indicating that the submesh is ready or not
  119844. */
  119845. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119846. /**
  119847. * Get a string representing the shaders built by the current node graph
  119848. */
  119849. readonly compiledShaders: string;
  119850. /**
  119851. * Binds the world matrix to the material
  119852. * @param world defines the world transformation matrix
  119853. */
  119854. bindOnlyWorldMatrix(world: Matrix): void;
  119855. /**
  119856. * Binds the submesh to this material by preparing the effect and shader to draw
  119857. * @param world defines the world transformation matrix
  119858. * @param mesh defines the mesh containing the submesh
  119859. * @param subMesh defines the submesh to bind the material to
  119860. */
  119861. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119862. /**
  119863. * Gets the active textures from the material
  119864. * @returns an array of textures
  119865. */
  119866. getActiveTextures(): BaseTexture[];
  119867. /**
  119868. * Gets the list of texture blocks
  119869. * @returns an array of texture blocks
  119870. */
  119871. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119872. /**
  119873. * Specifies if the material uses a texture
  119874. * @param texture defines the texture to check against the material
  119875. * @returns a boolean specifying if the material uses the texture
  119876. */
  119877. hasTexture(texture: BaseTexture): boolean;
  119878. /**
  119879. * Disposes the material
  119880. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119881. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119882. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119883. */
  119884. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119885. /** Creates the node editor window. */
  119886. private _createNodeEditor;
  119887. /**
  119888. * Launch the node material editor
  119889. * @param config Define the configuration of the editor
  119890. * @return a promise fulfilled when the node editor is visible
  119891. */
  119892. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119893. /**
  119894. * Clear the current material
  119895. */
  119896. clear(): void;
  119897. /**
  119898. * Clear the current material and set it to a default state
  119899. */
  119900. setToDefault(): void;
  119901. /**
  119902. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119903. * @param url defines the url to load from
  119904. * @returns a promise that will fullfil when the material is fully loaded
  119905. */
  119906. loadAsync(url: string): Promise<unknown>;
  119907. private _gatherBlocks;
  119908. /**
  119909. * Generate a string containing the code declaration required to create an equivalent of this material
  119910. * @returns a string
  119911. */
  119912. generateCode(): string;
  119913. /**
  119914. * Serializes this material in a JSON representation
  119915. * @returns the serialized material object
  119916. */
  119917. serialize(): any;
  119918. private _restoreConnections;
  119919. /**
  119920. * Clear the current graph and load a new one from a serialization object
  119921. * @param source defines the JSON representation of the material
  119922. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119923. */
  119924. loadFromSerialization(source: any, rootUrl?: string): void;
  119925. /**
  119926. * Creates a node material from parsed material data
  119927. * @param source defines the JSON representation of the material
  119928. * @param scene defines the hosting scene
  119929. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119930. * @returns a new node material
  119931. */
  119932. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119933. /**
  119934. * Creates a new node material set to default basic configuration
  119935. * @param name defines the name of the material
  119936. * @param scene defines the hosting scene
  119937. * @returns a new NodeMaterial
  119938. */
  119939. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119940. }
  119941. }
  119942. declare module BABYLON {
  119943. /**
  119944. * Block used to read a texture from a sampler
  119945. */
  119946. export class TextureBlock extends NodeMaterialBlock {
  119947. private _defineName;
  119948. private _linearDefineName;
  119949. private _samplerName;
  119950. private _transformedUVName;
  119951. private _textureTransformName;
  119952. private _textureInfoName;
  119953. private _mainUVName;
  119954. private _mainUVDefineName;
  119955. /**
  119956. * Gets or sets the texture associated with the node
  119957. */
  119958. texture: Nullable<Texture>;
  119959. /**
  119960. * Create a new TextureBlock
  119961. * @param name defines the block name
  119962. */
  119963. constructor(name: string);
  119964. /**
  119965. * Gets the current class name
  119966. * @returns the class name
  119967. */
  119968. getClassName(): string;
  119969. /**
  119970. * Gets the uv input component
  119971. */
  119972. readonly uv: NodeMaterialConnectionPoint;
  119973. /**
  119974. * Gets the rgba output component
  119975. */
  119976. readonly rgba: NodeMaterialConnectionPoint;
  119977. /**
  119978. * Gets the rgb output component
  119979. */
  119980. readonly rgb: NodeMaterialConnectionPoint;
  119981. /**
  119982. * Gets the r output component
  119983. */
  119984. readonly r: NodeMaterialConnectionPoint;
  119985. /**
  119986. * Gets the g output component
  119987. */
  119988. readonly g: NodeMaterialConnectionPoint;
  119989. /**
  119990. * Gets the b output component
  119991. */
  119992. readonly b: NodeMaterialConnectionPoint;
  119993. /**
  119994. * Gets the a output component
  119995. */
  119996. readonly a: NodeMaterialConnectionPoint;
  119997. readonly target: NodeMaterialBlockTargets;
  119998. autoConfigure(material: NodeMaterial): void;
  119999. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120001. isReady(): boolean;
  120002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120003. private readonly _isMixed;
  120004. private _injectVertexCode;
  120005. private _writeOutput;
  120006. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120007. protected _dumpPropertiesCode(): string;
  120008. serialize(): any;
  120009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120010. }
  120011. }
  120012. declare module BABYLON {
  120013. /**
  120014. * Class used to store shared data between 2 NodeMaterialBuildState
  120015. */
  120016. export class NodeMaterialBuildStateSharedData {
  120017. /**
  120018. * Gets the list of emitted varyings
  120019. */
  120020. temps: string[];
  120021. /**
  120022. * Gets the list of emitted varyings
  120023. */
  120024. varyings: string[];
  120025. /**
  120026. * Gets the varying declaration string
  120027. */
  120028. varyingDeclaration: string;
  120029. /**
  120030. * Input blocks
  120031. */
  120032. inputBlocks: InputBlock[];
  120033. /**
  120034. * Input blocks
  120035. */
  120036. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120037. /**
  120038. * Bindable blocks (Blocks that need to set data to the effect)
  120039. */
  120040. bindableBlocks: NodeMaterialBlock[];
  120041. /**
  120042. * List of blocks that can provide a compilation fallback
  120043. */
  120044. blocksWithFallbacks: NodeMaterialBlock[];
  120045. /**
  120046. * List of blocks that can provide a define update
  120047. */
  120048. blocksWithDefines: NodeMaterialBlock[];
  120049. /**
  120050. * List of blocks that can provide a repeatable content
  120051. */
  120052. repeatableContentBlocks: NodeMaterialBlock[];
  120053. /**
  120054. * List of blocks that can provide a dynamic list of uniforms
  120055. */
  120056. dynamicUniformBlocks: NodeMaterialBlock[];
  120057. /**
  120058. * List of blocks that can block the isReady function for the material
  120059. */
  120060. blockingBlocks: NodeMaterialBlock[];
  120061. /**
  120062. * Gets the list of animated inputs
  120063. */
  120064. animatedInputs: InputBlock[];
  120065. /**
  120066. * Build Id used to avoid multiple recompilations
  120067. */
  120068. buildId: number;
  120069. /** List of emitted variables */
  120070. variableNames: {
  120071. [key: string]: number;
  120072. };
  120073. /** List of emitted defines */
  120074. defineNames: {
  120075. [key: string]: number;
  120076. };
  120077. /** Should emit comments? */
  120078. emitComments: boolean;
  120079. /** Emit build activity */
  120080. verbose: boolean;
  120081. /** Gets or sets the hosting scene */
  120082. scene: Scene;
  120083. /**
  120084. * Gets the compilation hints emitted at compilation time
  120085. */
  120086. hints: {
  120087. needWorldViewMatrix: boolean;
  120088. needWorldViewProjectionMatrix: boolean;
  120089. needAlphaBlending: boolean;
  120090. needAlphaTesting: boolean;
  120091. };
  120092. /**
  120093. * List of compilation checks
  120094. */
  120095. checks: {
  120096. emitVertex: boolean;
  120097. emitFragment: boolean;
  120098. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120099. };
  120100. /** Creates a new shared data */
  120101. constructor();
  120102. /**
  120103. * Emits console errors and exceptions if there is a failing check
  120104. */
  120105. emitErrors(): void;
  120106. }
  120107. }
  120108. declare module BABYLON {
  120109. /**
  120110. * Class used to store node based material build state
  120111. */
  120112. export class NodeMaterialBuildState {
  120113. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120114. supportUniformBuffers: boolean;
  120115. /**
  120116. * Gets the list of emitted attributes
  120117. */
  120118. attributes: string[];
  120119. /**
  120120. * Gets the list of emitted uniforms
  120121. */
  120122. uniforms: string[];
  120123. /**
  120124. * Gets the list of emitted constants
  120125. */
  120126. constants: string[];
  120127. /**
  120128. * Gets the list of emitted uniform buffers
  120129. */
  120130. uniformBuffers: string[];
  120131. /**
  120132. * Gets the list of emitted samplers
  120133. */
  120134. samplers: string[];
  120135. /**
  120136. * Gets the list of emitted functions
  120137. */
  120138. functions: {
  120139. [key: string]: string;
  120140. };
  120141. /**
  120142. * Gets the list of emitted extensions
  120143. */
  120144. extensions: {
  120145. [key: string]: string;
  120146. };
  120147. /**
  120148. * Gets the target of the compilation state
  120149. */
  120150. target: NodeMaterialBlockTargets;
  120151. /**
  120152. * Gets the list of emitted counters
  120153. */
  120154. counters: {
  120155. [key: string]: number;
  120156. };
  120157. /**
  120158. * Shared data between multiple NodeMaterialBuildState instances
  120159. */
  120160. sharedData: NodeMaterialBuildStateSharedData;
  120161. /** @hidden */
  120162. _vertexState: NodeMaterialBuildState;
  120163. /** @hidden */
  120164. _attributeDeclaration: string;
  120165. /** @hidden */
  120166. _uniformDeclaration: string;
  120167. /** @hidden */
  120168. _constantDeclaration: string;
  120169. /** @hidden */
  120170. _samplerDeclaration: string;
  120171. /** @hidden */
  120172. _varyingTransfer: string;
  120173. private _repeatableContentAnchorIndex;
  120174. /** @hidden */
  120175. _builtCompilationString: string;
  120176. /**
  120177. * Gets the emitted compilation strings
  120178. */
  120179. compilationString: string;
  120180. /**
  120181. * Finalize the compilation strings
  120182. * @param state defines the current compilation state
  120183. */
  120184. finalize(state: NodeMaterialBuildState): void;
  120185. /** @hidden */
  120186. readonly _repeatableContentAnchor: string;
  120187. /** @hidden */
  120188. _getFreeVariableName(prefix: string): string;
  120189. /** @hidden */
  120190. _getFreeDefineName(prefix: string): string;
  120191. /** @hidden */
  120192. _excludeVariableName(name: string): void;
  120193. /** @hidden */
  120194. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120195. /** @hidden */
  120196. _emitExtension(name: string, extension: string): void;
  120197. /** @hidden */
  120198. _emitFunction(name: string, code: string, comments: string): void;
  120199. /** @hidden */
  120200. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120201. replaceStrings?: {
  120202. search: RegExp;
  120203. replace: string;
  120204. }[];
  120205. repeatKey?: string;
  120206. }): string;
  120207. /** @hidden */
  120208. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120209. repeatKey?: string;
  120210. removeAttributes?: boolean;
  120211. removeUniforms?: boolean;
  120212. removeVaryings?: boolean;
  120213. removeIfDef?: boolean;
  120214. replaceStrings?: {
  120215. search: RegExp;
  120216. replace: string;
  120217. }[];
  120218. }, storeKey?: string): void;
  120219. /** @hidden */
  120220. _registerTempVariable(name: string): boolean;
  120221. /** @hidden */
  120222. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120223. /** @hidden */
  120224. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120225. /** @hidden */
  120226. _emitFloat(value: number): string;
  120227. }
  120228. }
  120229. declare module BABYLON {
  120230. /**
  120231. * Defines a block that can be used inside a node based material
  120232. */
  120233. export class NodeMaterialBlock {
  120234. private _buildId;
  120235. private _buildTarget;
  120236. private _target;
  120237. private _isFinalMerger;
  120238. private _isInput;
  120239. /** @hidden */
  120240. _codeVariableName: string;
  120241. /** @hidden */
  120242. _inputs: NodeMaterialConnectionPoint[];
  120243. /** @hidden */
  120244. _outputs: NodeMaterialConnectionPoint[];
  120245. /** @hidden */
  120246. _preparationId: number;
  120247. /**
  120248. * Gets or sets the name of the block
  120249. */
  120250. name: string;
  120251. /**
  120252. * Gets or sets the unique id of the node
  120253. */
  120254. uniqueId: number;
  120255. /**
  120256. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120257. */
  120258. readonly isFinalMerger: boolean;
  120259. /**
  120260. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120261. */
  120262. readonly isInput: boolean;
  120263. /**
  120264. * Gets or sets the build Id
  120265. */
  120266. buildId: number;
  120267. /**
  120268. * Gets or sets the target of the block
  120269. */
  120270. target: NodeMaterialBlockTargets;
  120271. /**
  120272. * Gets the list of input points
  120273. */
  120274. readonly inputs: NodeMaterialConnectionPoint[];
  120275. /** Gets the list of output points */
  120276. readonly outputs: NodeMaterialConnectionPoint[];
  120277. /**
  120278. * Find an input by its name
  120279. * @param name defines the name of the input to look for
  120280. * @returns the input or null if not found
  120281. */
  120282. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120283. /**
  120284. * Find an output by its name
  120285. * @param name defines the name of the outputto look for
  120286. * @returns the output or null if not found
  120287. */
  120288. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120289. /**
  120290. * Creates a new NodeMaterialBlock
  120291. * @param name defines the block name
  120292. * @param target defines the target of that block (Vertex by default)
  120293. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120294. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120295. */
  120296. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120297. /**
  120298. * Initialize the block and prepare the context for build
  120299. * @param state defines the state that will be used for the build
  120300. */
  120301. initialize(state: NodeMaterialBuildState): void;
  120302. /**
  120303. * Bind data to effect. Will only be called for blocks with isBindable === true
  120304. * @param effect defines the effect to bind data to
  120305. * @param nodeMaterial defines the hosting NodeMaterial
  120306. * @param mesh defines the mesh that will be rendered
  120307. */
  120308. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120309. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120310. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120311. protected _writeFloat(value: number): string;
  120312. /**
  120313. * Gets the current class name e.g. "NodeMaterialBlock"
  120314. * @returns the class name
  120315. */
  120316. getClassName(): string;
  120317. /**
  120318. * Register a new input. Must be called inside a block constructor
  120319. * @param name defines the connection point name
  120320. * @param type defines the connection point type
  120321. * @param isOptional defines a boolean indicating that this input can be omitted
  120322. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120323. * @returns the current block
  120324. */
  120325. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120326. /**
  120327. * Register a new output. Must be called inside a block constructor
  120328. * @param name defines the connection point name
  120329. * @param type defines the connection point type
  120330. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120331. * @returns the current block
  120332. */
  120333. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120334. /**
  120335. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120336. * @param forOutput defines an optional connection point to check compatibility with
  120337. * @returns the first available input or null
  120338. */
  120339. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120340. /**
  120341. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120342. * @param forBlock defines an optional block to check compatibility with
  120343. * @returns the first available input or null
  120344. */
  120345. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120346. /**
  120347. * Gets the sibling of the given output
  120348. * @param current defines the current output
  120349. * @returns the next output in the list or null
  120350. */
  120351. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120352. /**
  120353. * Connect current block with another block
  120354. * @param other defines the block to connect with
  120355. * @param options define the various options to help pick the right connections
  120356. * @returns the current block
  120357. */
  120358. connectTo(other: NodeMaterialBlock, options?: {
  120359. input?: string;
  120360. output?: string;
  120361. outputSwizzle?: string;
  120362. }): this | undefined;
  120363. protected _buildBlock(state: NodeMaterialBuildState): void;
  120364. /**
  120365. * Add uniforms, samplers and uniform buffers at compilation time
  120366. * @param state defines the state to update
  120367. * @param nodeMaterial defines the node material requesting the update
  120368. * @param defines defines the material defines to update
  120369. */
  120370. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120371. /**
  120372. * Add potential fallbacks if shader compilation fails
  120373. * @param mesh defines the mesh to be rendered
  120374. * @param fallbacks defines the current prioritized list of fallbacks
  120375. */
  120376. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120377. /**
  120378. * Initialize defines for shader compilation
  120379. * @param mesh defines the mesh to be rendered
  120380. * @param nodeMaterial defines the node material requesting the update
  120381. * @param defines defines the material defines to update
  120382. * @param useInstances specifies that instances should be used
  120383. */
  120384. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120385. /**
  120386. * Update defines for shader compilation
  120387. * @param mesh defines the mesh to be rendered
  120388. * @param nodeMaterial defines the node material requesting the update
  120389. * @param defines defines the material defines to update
  120390. * @param useInstances specifies that instances should be used
  120391. */
  120392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120393. /**
  120394. * Lets the block try to connect some inputs automatically
  120395. * @param material defines the hosting NodeMaterial
  120396. */
  120397. autoConfigure(material: NodeMaterial): void;
  120398. /**
  120399. * Function called when a block is declared as repeatable content generator
  120400. * @param vertexShaderState defines the current compilation state for the vertex shader
  120401. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120402. * @param mesh defines the mesh to be rendered
  120403. * @param defines defines the material defines to update
  120404. */
  120405. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120406. /**
  120407. * Checks if the block is ready
  120408. * @param mesh defines the mesh to be rendered
  120409. * @param nodeMaterial defines the node material requesting the update
  120410. * @param defines defines the material defines to update
  120411. * @param useInstances specifies that instances should be used
  120412. * @returns true if the block is ready
  120413. */
  120414. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120415. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120416. private _processBuild;
  120417. /**
  120418. * Compile the current node and generate the shader code
  120419. * @param state defines the current compilation state (uniforms, samplers, current string)
  120420. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120421. * @returns true if already built
  120422. */
  120423. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120424. protected _inputRename(name: string): string;
  120425. protected _outputRename(name: string): string;
  120426. protected _dumpPropertiesCode(): string;
  120427. /** @hidden */
  120428. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120429. /**
  120430. * Clone the current block to a new identical block
  120431. * @param scene defines the hosting scene
  120432. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120433. * @returns a copy of the current block
  120434. */
  120435. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120436. /**
  120437. * Serializes this block in a JSON representation
  120438. * @returns the serialized block object
  120439. */
  120440. serialize(): any;
  120441. /** @hidden */
  120442. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120443. }
  120444. }
  120445. declare module BABYLON {
  120446. /**
  120447. * Enum defining the type of animations supported by InputBlock
  120448. */
  120449. export enum AnimatedInputBlockTypes {
  120450. /** No animation */
  120451. None = 0,
  120452. /** Time based animation. Will only work for floats */
  120453. Time = 1
  120454. }
  120455. }
  120456. declare module BABYLON {
  120457. /**
  120458. * Block used to expose an input value
  120459. */
  120460. export class InputBlock extends NodeMaterialBlock {
  120461. private _mode;
  120462. private _associatedVariableName;
  120463. private _storedValue;
  120464. private _valueCallback;
  120465. private _type;
  120466. private _animationType;
  120467. /** Gets or set a value used to limit the range of float values */
  120468. min: number;
  120469. /** Gets or set a value used to limit the range of float values */
  120470. max: number;
  120471. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120472. matrixMode: number;
  120473. /** @hidden */
  120474. _systemValue: Nullable<NodeMaterialSystemValues>;
  120475. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120476. visibleInInspector: boolean;
  120477. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120478. isConstant: boolean;
  120479. /**
  120480. * Gets or sets the connection point type (default is float)
  120481. */
  120482. readonly type: NodeMaterialBlockConnectionPointTypes;
  120483. /**
  120484. * Creates a new InputBlock
  120485. * @param name defines the block name
  120486. * @param target defines the target of that block (Vertex by default)
  120487. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120488. */
  120489. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120490. /**
  120491. * Gets the output component
  120492. */
  120493. readonly output: NodeMaterialConnectionPoint;
  120494. /**
  120495. * Set the source of this connection point to a vertex attribute
  120496. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120497. * @returns the current connection point
  120498. */
  120499. setAsAttribute(attributeName?: string): InputBlock;
  120500. /**
  120501. * Set the source of this connection point to a system value
  120502. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120503. * @returns the current connection point
  120504. */
  120505. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120506. /**
  120507. * Gets or sets the value of that point.
  120508. * Please note that this value will be ignored if valueCallback is defined
  120509. */
  120510. value: any;
  120511. /**
  120512. * Gets or sets a callback used to get the value of that point.
  120513. * Please note that setting this value will force the connection point to ignore the value property
  120514. */
  120515. valueCallback: () => any;
  120516. /**
  120517. * Gets or sets the associated variable name in the shader
  120518. */
  120519. associatedVariableName: string;
  120520. /** Gets or sets the type of animation applied to the input */
  120521. animationType: AnimatedInputBlockTypes;
  120522. /**
  120523. * Gets a boolean indicating that this connection point not defined yet
  120524. */
  120525. readonly isUndefined: boolean;
  120526. /**
  120527. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120528. * In this case the connection point name must be the name of the uniform to use.
  120529. * Can only be set on inputs
  120530. */
  120531. isUniform: boolean;
  120532. /**
  120533. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120534. * In this case the connection point name must be the name of the attribute to use
  120535. * Can only be set on inputs
  120536. */
  120537. isAttribute: boolean;
  120538. /**
  120539. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120540. * Can only be set on exit points
  120541. */
  120542. isVarying: boolean;
  120543. /**
  120544. * Gets a boolean indicating that the current connection point is a system value
  120545. */
  120546. readonly isSystemValue: boolean;
  120547. /**
  120548. * Gets or sets the current well known value or null if not defined as a system value
  120549. */
  120550. systemValue: Nullable<NodeMaterialSystemValues>;
  120551. /**
  120552. * Gets the current class name
  120553. * @returns the class name
  120554. */
  120555. getClassName(): string;
  120556. /**
  120557. * Animate the input if animationType !== None
  120558. * @param scene defines the rendering scene
  120559. */
  120560. animate(scene: Scene): void;
  120561. private _emitDefine;
  120562. initialize(state: NodeMaterialBuildState): void;
  120563. /**
  120564. * Set the input block to its default value (based on its type)
  120565. */
  120566. setDefaultValue(): void;
  120567. private _emitConstant;
  120568. private _emit;
  120569. /** @hidden */
  120570. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120571. /** @hidden */
  120572. _transmit(effect: Effect, scene: Scene): void;
  120573. protected _buildBlock(state: NodeMaterialBuildState): void;
  120574. protected _dumpPropertiesCode(): string;
  120575. serialize(): any;
  120576. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120577. }
  120578. }
  120579. declare module BABYLON {
  120580. /**
  120581. * Defines a connection point for a block
  120582. */
  120583. export class NodeMaterialConnectionPoint {
  120584. /** @hidden */
  120585. _ownerBlock: NodeMaterialBlock;
  120586. /** @hidden */
  120587. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120588. private _endpoints;
  120589. private _associatedVariableName;
  120590. /** @hidden */
  120591. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120592. /** @hidden */
  120593. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120594. private _type;
  120595. /** @hidden */
  120596. _enforceAssociatedVariableName: boolean;
  120597. /**
  120598. * Gets or sets the additional types supported by this connection point
  120599. */
  120600. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120601. /**
  120602. * Gets or sets the additional types excluded by this connection point
  120603. */
  120604. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120605. /**
  120606. * Gets or sets the associated variable name in the shader
  120607. */
  120608. associatedVariableName: string;
  120609. /**
  120610. * Gets or sets the connection point type (default is float)
  120611. */
  120612. type: NodeMaterialBlockConnectionPointTypes;
  120613. /**
  120614. * Gets or sets the connection point name
  120615. */
  120616. name: string;
  120617. /**
  120618. * Gets or sets a boolean indicating that this connection point can be omitted
  120619. */
  120620. isOptional: boolean;
  120621. /**
  120622. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120623. */
  120624. define: string;
  120625. /** Gets or sets the target of that connection point */
  120626. target: NodeMaterialBlockTargets;
  120627. /**
  120628. * Gets a boolean indicating that the current point is connected
  120629. */
  120630. readonly isConnected: boolean;
  120631. /**
  120632. * Gets a boolean indicating that the current point is connected to an input block
  120633. */
  120634. readonly isConnectedToInputBlock: boolean;
  120635. /**
  120636. * Gets a the connected input block (if any)
  120637. */
  120638. readonly connectInputBlock: Nullable<InputBlock>;
  120639. /** Get the other side of the connection (if any) */
  120640. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120641. /** Get the block that owns this connection point */
  120642. readonly ownerBlock: NodeMaterialBlock;
  120643. /** Get the block connected on the other side of this connection (if any) */
  120644. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120645. /** Get the block connected on the endpoints of this connection (if any) */
  120646. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120647. /** Gets the list of connected endpoints */
  120648. readonly endpoints: NodeMaterialConnectionPoint[];
  120649. /** Gets a boolean indicating if that output point is connected to at least one input */
  120650. readonly hasEndpoints: boolean;
  120651. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  120652. readonly isConnectedInVertexShader: boolean;
  120653. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  120654. readonly isConnectedInFragmentShader: boolean;
  120655. /**
  120656. * Creates a new connection point
  120657. * @param name defines the connection point name
  120658. * @param ownerBlock defines the block hosting this connection point
  120659. */
  120660. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120661. /**
  120662. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120663. * @returns the class name
  120664. */
  120665. getClassName(): string;
  120666. /**
  120667. * Gets an boolean indicating if the current point can be connected to another point
  120668. * @param connectionPoint defines the other connection point
  120669. * @returns true if the connection is possible
  120670. */
  120671. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120672. /**
  120673. * Connect this point to another connection point
  120674. * @param connectionPoint defines the other connection point
  120675. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120676. * @returns the current connection point
  120677. */
  120678. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120679. /**
  120680. * Disconnect this point from one of his endpoint
  120681. * @param endpoint defines the other connection point
  120682. * @returns the current connection point
  120683. */
  120684. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120685. /**
  120686. * Serializes this point in a JSON representation
  120687. * @returns the serialized point object
  120688. */
  120689. serialize(): any;
  120690. }
  120691. }
  120692. declare module BABYLON {
  120693. /**
  120694. * Block used to add support for vertex skinning (bones)
  120695. */
  120696. export class BonesBlock extends NodeMaterialBlock {
  120697. /**
  120698. * Creates a new BonesBlock
  120699. * @param name defines the block name
  120700. */
  120701. constructor(name: string);
  120702. /**
  120703. * Initialize the block and prepare the context for build
  120704. * @param state defines the state that will be used for the build
  120705. */
  120706. initialize(state: NodeMaterialBuildState): void;
  120707. /**
  120708. * Gets the current class name
  120709. * @returns the class name
  120710. */
  120711. getClassName(): string;
  120712. /**
  120713. * Gets the matrix indices input component
  120714. */
  120715. readonly matricesIndices: NodeMaterialConnectionPoint;
  120716. /**
  120717. * Gets the matrix weights input component
  120718. */
  120719. readonly matricesWeights: NodeMaterialConnectionPoint;
  120720. /**
  120721. * Gets the extra matrix indices input component
  120722. */
  120723. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120724. /**
  120725. * Gets the extra matrix weights input component
  120726. */
  120727. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120728. /**
  120729. * Gets the world input component
  120730. */
  120731. readonly world: NodeMaterialConnectionPoint;
  120732. /**
  120733. * Gets the output component
  120734. */
  120735. readonly output: NodeMaterialConnectionPoint;
  120736. autoConfigure(material: NodeMaterial): void;
  120737. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120738. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120740. protected _buildBlock(state: NodeMaterialBuildState): this;
  120741. }
  120742. }
  120743. declare module BABYLON {
  120744. /**
  120745. * Block used to add support for instances
  120746. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120747. */
  120748. export class InstancesBlock extends NodeMaterialBlock {
  120749. /**
  120750. * Creates a new InstancesBlock
  120751. * @param name defines the block name
  120752. */
  120753. constructor(name: string);
  120754. /**
  120755. * Gets the current class name
  120756. * @returns the class name
  120757. */
  120758. getClassName(): string;
  120759. /**
  120760. * Gets the first world row input component
  120761. */
  120762. readonly world0: NodeMaterialConnectionPoint;
  120763. /**
  120764. * Gets the second world row input component
  120765. */
  120766. readonly world1: NodeMaterialConnectionPoint;
  120767. /**
  120768. * Gets the third world row input component
  120769. */
  120770. readonly world2: NodeMaterialConnectionPoint;
  120771. /**
  120772. * Gets the forth world row input component
  120773. */
  120774. readonly world3: NodeMaterialConnectionPoint;
  120775. /**
  120776. * Gets the world input component
  120777. */
  120778. readonly world: NodeMaterialConnectionPoint;
  120779. /**
  120780. * Gets the output component
  120781. */
  120782. readonly output: NodeMaterialConnectionPoint;
  120783. autoConfigure(material: NodeMaterial): void;
  120784. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120785. protected _buildBlock(state: NodeMaterialBuildState): this;
  120786. }
  120787. }
  120788. declare module BABYLON {
  120789. /**
  120790. * Block used to add morph targets support to vertex shader
  120791. */
  120792. export class MorphTargetsBlock extends NodeMaterialBlock {
  120793. private _repeatableContentAnchor;
  120794. private _repeatebleContentGenerated;
  120795. /**
  120796. * Create a new MorphTargetsBlock
  120797. * @param name defines the block name
  120798. */
  120799. constructor(name: string);
  120800. /**
  120801. * Gets the current class name
  120802. * @returns the class name
  120803. */
  120804. getClassName(): string;
  120805. /**
  120806. * Gets the position input component
  120807. */
  120808. readonly position: NodeMaterialConnectionPoint;
  120809. /**
  120810. * Gets the normal input component
  120811. */
  120812. readonly normal: NodeMaterialConnectionPoint;
  120813. /**
  120814. * Gets the tangent input component
  120815. */
  120816. readonly tangent: NodeMaterialConnectionPoint;
  120817. /**
  120818. * Gets the tangent input component
  120819. */
  120820. readonly uv: NodeMaterialConnectionPoint;
  120821. /**
  120822. * Gets the position output component
  120823. */
  120824. readonly positionOutput: NodeMaterialConnectionPoint;
  120825. /**
  120826. * Gets the normal output component
  120827. */
  120828. readonly normalOutput: NodeMaterialConnectionPoint;
  120829. /**
  120830. * Gets the tangent output component
  120831. */
  120832. readonly tangentOutput: NodeMaterialConnectionPoint;
  120833. /**
  120834. * Gets the tangent output component
  120835. */
  120836. readonly uvOutput: NodeMaterialConnectionPoint;
  120837. initialize(state: NodeMaterialBuildState): void;
  120838. autoConfigure(material: NodeMaterial): void;
  120839. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120840. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120841. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120842. protected _buildBlock(state: NodeMaterialBuildState): this;
  120843. }
  120844. }
  120845. declare module BABYLON {
  120846. /**
  120847. * Block used to get data information from a light
  120848. */
  120849. export class LightInformationBlock extends NodeMaterialBlock {
  120850. private _lightDataUniformName;
  120851. private _lightColorUniformName;
  120852. private _lightTypeDefineName;
  120853. /**
  120854. * Gets or sets the light associated with this block
  120855. */
  120856. light: Nullable<Light>;
  120857. /**
  120858. * Creates a new LightInformationBlock
  120859. * @param name defines the block name
  120860. */
  120861. constructor(name: string);
  120862. /**
  120863. * Gets the current class name
  120864. * @returns the class name
  120865. */
  120866. getClassName(): string;
  120867. /**
  120868. * Gets the world position input component
  120869. */
  120870. readonly worldPosition: NodeMaterialConnectionPoint;
  120871. /**
  120872. * Gets the direction output component
  120873. */
  120874. readonly direction: NodeMaterialConnectionPoint;
  120875. /**
  120876. * Gets the direction output component
  120877. */
  120878. readonly color: NodeMaterialConnectionPoint;
  120879. /**
  120880. * Gets the direction output component
  120881. */
  120882. readonly intensity: NodeMaterialConnectionPoint;
  120883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120884. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120885. protected _buildBlock(state: NodeMaterialBuildState): this;
  120886. serialize(): any;
  120887. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120888. }
  120889. }
  120890. declare module BABYLON {
  120891. /**
  120892. * Block used to add image processing support to fragment shader
  120893. */
  120894. export class ImageProcessingBlock extends NodeMaterialBlock {
  120895. /**
  120896. * Create a new ImageProcessingBlock
  120897. * @param name defines the block name
  120898. */
  120899. constructor(name: string);
  120900. /**
  120901. * Gets the current class name
  120902. * @returns the class name
  120903. */
  120904. getClassName(): string;
  120905. /**
  120906. * Gets the color input component
  120907. */
  120908. readonly color: NodeMaterialConnectionPoint;
  120909. /**
  120910. * Gets the output component
  120911. */
  120912. readonly output: NodeMaterialConnectionPoint;
  120913. /**
  120914. * Initialize the block and prepare the context for build
  120915. * @param state defines the state that will be used for the build
  120916. */
  120917. initialize(state: NodeMaterialBuildState): void;
  120918. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120919. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120920. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120921. protected _buildBlock(state: NodeMaterialBuildState): this;
  120922. }
  120923. }
  120924. declare module BABYLON {
  120925. /**
  120926. * Block used to pertub normals based on a normal map
  120927. */
  120928. export class PerturbNormalBlock extends NodeMaterialBlock {
  120929. private _tangentSpaceParameterName;
  120930. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120931. invertX: boolean;
  120932. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120933. invertY: boolean;
  120934. /**
  120935. * Create a new PerturbNormalBlock
  120936. * @param name defines the block name
  120937. */
  120938. constructor(name: string);
  120939. /**
  120940. * Gets the current class name
  120941. * @returns the class name
  120942. */
  120943. getClassName(): string;
  120944. /**
  120945. * Gets the world position input component
  120946. */
  120947. readonly worldPosition: NodeMaterialConnectionPoint;
  120948. /**
  120949. * Gets the world normal input component
  120950. */
  120951. readonly worldNormal: NodeMaterialConnectionPoint;
  120952. /**
  120953. * Gets the uv input component
  120954. */
  120955. readonly uv: NodeMaterialConnectionPoint;
  120956. /**
  120957. * Gets the normal map color input component
  120958. */
  120959. readonly normalMapColor: NodeMaterialConnectionPoint;
  120960. /**
  120961. * Gets the strength input component
  120962. */
  120963. readonly strength: NodeMaterialConnectionPoint;
  120964. /**
  120965. * Gets the output component
  120966. */
  120967. readonly output: NodeMaterialConnectionPoint;
  120968. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120969. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120970. autoConfigure(material: NodeMaterial): void;
  120971. protected _buildBlock(state: NodeMaterialBuildState): this;
  120972. protected _dumpPropertiesCode(): string;
  120973. serialize(): any;
  120974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120975. }
  120976. }
  120977. declare module BABYLON {
  120978. /**
  120979. * Block used to discard a pixel if a value is smaller than a cutoff
  120980. */
  120981. export class DiscardBlock extends NodeMaterialBlock {
  120982. /**
  120983. * Create a new DiscardBlock
  120984. * @param name defines the block name
  120985. */
  120986. constructor(name: string);
  120987. /**
  120988. * Gets the current class name
  120989. * @returns the class name
  120990. */
  120991. getClassName(): string;
  120992. /**
  120993. * Gets the color input component
  120994. */
  120995. readonly value: NodeMaterialConnectionPoint;
  120996. /**
  120997. * Gets the cutoff input component
  120998. */
  120999. readonly cutoff: NodeMaterialConnectionPoint;
  121000. protected _buildBlock(state: NodeMaterialBuildState): this;
  121001. }
  121002. }
  121003. declare module BABYLON {
  121004. /**
  121005. * Block used to add support for scene fog
  121006. */
  121007. export class FogBlock extends NodeMaterialBlock {
  121008. private _fogDistanceName;
  121009. private _fogParameters;
  121010. /**
  121011. * Create a new FogBlock
  121012. * @param name defines the block name
  121013. */
  121014. constructor(name: string);
  121015. /**
  121016. * Gets the current class name
  121017. * @returns the class name
  121018. */
  121019. getClassName(): string;
  121020. /**
  121021. * Gets the world position input component
  121022. */
  121023. readonly worldPosition: NodeMaterialConnectionPoint;
  121024. /**
  121025. * Gets the view input component
  121026. */
  121027. readonly view: NodeMaterialConnectionPoint;
  121028. /**
  121029. * Gets the color input component
  121030. */
  121031. readonly input: NodeMaterialConnectionPoint;
  121032. /**
  121033. * Gets the fog color input component
  121034. */
  121035. readonly fogColor: NodeMaterialConnectionPoint;
  121036. /**
  121037. * Gets the output component
  121038. */
  121039. readonly output: NodeMaterialConnectionPoint;
  121040. autoConfigure(material: NodeMaterial): void;
  121041. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121042. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121043. protected _buildBlock(state: NodeMaterialBuildState): this;
  121044. }
  121045. }
  121046. declare module BABYLON {
  121047. /**
  121048. * Block used to add light in the fragment shader
  121049. */
  121050. export class LightBlock extends NodeMaterialBlock {
  121051. private _lightId;
  121052. /**
  121053. * Gets or sets the light associated with this block
  121054. */
  121055. light: Nullable<Light>;
  121056. /**
  121057. * Create a new LightBlock
  121058. * @param name defines the block name
  121059. */
  121060. constructor(name: string);
  121061. /**
  121062. * Gets the current class name
  121063. * @returns the class name
  121064. */
  121065. getClassName(): string;
  121066. /**
  121067. * Gets the world position input component
  121068. */
  121069. readonly worldPosition: NodeMaterialConnectionPoint;
  121070. /**
  121071. * Gets the world normal input component
  121072. */
  121073. readonly worldNormal: NodeMaterialConnectionPoint;
  121074. /**
  121075. * Gets the camera (or eye) position component
  121076. */
  121077. readonly cameraPosition: NodeMaterialConnectionPoint;
  121078. /**
  121079. * Gets the glossiness component
  121080. */
  121081. readonly glossiness: NodeMaterialConnectionPoint;
  121082. /**
  121083. * Gets the glossinness power component
  121084. */
  121085. readonly glossPower: NodeMaterialConnectionPoint;
  121086. /**
  121087. * Gets the diffuse color component
  121088. */
  121089. readonly diffuseColor: NodeMaterialConnectionPoint;
  121090. /**
  121091. * Gets the specular color component
  121092. */
  121093. readonly specularColor: NodeMaterialConnectionPoint;
  121094. /**
  121095. * Gets the diffuse output component
  121096. */
  121097. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121098. /**
  121099. * Gets the specular output component
  121100. */
  121101. readonly specularOutput: NodeMaterialConnectionPoint;
  121102. autoConfigure(material: NodeMaterial): void;
  121103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121104. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121105. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121106. private _injectVertexCode;
  121107. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121108. serialize(): any;
  121109. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121110. }
  121111. }
  121112. declare module BABYLON {
  121113. /**
  121114. * Block used to multiply 2 values
  121115. */
  121116. export class MultiplyBlock extends NodeMaterialBlock {
  121117. /**
  121118. * Creates a new MultiplyBlock
  121119. * @param name defines the block name
  121120. */
  121121. constructor(name: string);
  121122. /**
  121123. * Gets the current class name
  121124. * @returns the class name
  121125. */
  121126. getClassName(): string;
  121127. /**
  121128. * Gets the left operand input component
  121129. */
  121130. readonly left: NodeMaterialConnectionPoint;
  121131. /**
  121132. * Gets the right operand input component
  121133. */
  121134. readonly right: NodeMaterialConnectionPoint;
  121135. /**
  121136. * Gets the output component
  121137. */
  121138. readonly output: NodeMaterialConnectionPoint;
  121139. protected _buildBlock(state: NodeMaterialBuildState): this;
  121140. }
  121141. }
  121142. declare module BABYLON {
  121143. /**
  121144. * Block used to add 2 vectors
  121145. */
  121146. export class AddBlock extends NodeMaterialBlock {
  121147. /**
  121148. * Creates a new AddBlock
  121149. * @param name defines the block name
  121150. */
  121151. constructor(name: string);
  121152. /**
  121153. * Gets the current class name
  121154. * @returns the class name
  121155. */
  121156. getClassName(): string;
  121157. /**
  121158. * Gets the left operand input component
  121159. */
  121160. readonly left: NodeMaterialConnectionPoint;
  121161. /**
  121162. * Gets the right operand input component
  121163. */
  121164. readonly right: NodeMaterialConnectionPoint;
  121165. /**
  121166. * Gets the output component
  121167. */
  121168. readonly output: NodeMaterialConnectionPoint;
  121169. protected _buildBlock(state: NodeMaterialBuildState): this;
  121170. }
  121171. }
  121172. declare module BABYLON {
  121173. /**
  121174. * Block used to scale a vector by a float
  121175. */
  121176. export class ScaleBlock extends NodeMaterialBlock {
  121177. /**
  121178. * Creates a new ScaleBlock
  121179. * @param name defines the block name
  121180. */
  121181. constructor(name: string);
  121182. /**
  121183. * Gets the current class name
  121184. * @returns the class name
  121185. */
  121186. getClassName(): string;
  121187. /**
  121188. * Gets the input component
  121189. */
  121190. readonly input: NodeMaterialConnectionPoint;
  121191. /**
  121192. * Gets the factor input component
  121193. */
  121194. readonly factor: NodeMaterialConnectionPoint;
  121195. /**
  121196. * Gets the output component
  121197. */
  121198. readonly output: NodeMaterialConnectionPoint;
  121199. protected _buildBlock(state: NodeMaterialBuildState): this;
  121200. }
  121201. }
  121202. declare module BABYLON {
  121203. /**
  121204. * Block used to clamp a float
  121205. */
  121206. export class ClampBlock extends NodeMaterialBlock {
  121207. /** Gets or sets the minimum range */
  121208. minimum: number;
  121209. /** Gets or sets the maximum range */
  121210. maximum: number;
  121211. /**
  121212. * Creates a new ClampBlock
  121213. * @param name defines the block name
  121214. */
  121215. constructor(name: string);
  121216. /**
  121217. * Gets the current class name
  121218. * @returns the class name
  121219. */
  121220. getClassName(): string;
  121221. /**
  121222. * Gets the value input component
  121223. */
  121224. readonly value: NodeMaterialConnectionPoint;
  121225. /**
  121226. * Gets the output component
  121227. */
  121228. readonly output: NodeMaterialConnectionPoint;
  121229. protected _buildBlock(state: NodeMaterialBuildState): this;
  121230. protected _dumpPropertiesCode(): string;
  121231. serialize(): any;
  121232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121233. }
  121234. }
  121235. declare module BABYLON {
  121236. /**
  121237. * Block used to apply a cross product between 2 vectors
  121238. */
  121239. export class CrossBlock extends NodeMaterialBlock {
  121240. /**
  121241. * Creates a new CrossBlock
  121242. * @param name defines the block name
  121243. */
  121244. constructor(name: string);
  121245. /**
  121246. * Gets the current class name
  121247. * @returns the class name
  121248. */
  121249. getClassName(): string;
  121250. /**
  121251. * Gets the left operand input component
  121252. */
  121253. readonly left: NodeMaterialConnectionPoint;
  121254. /**
  121255. * Gets the right operand input component
  121256. */
  121257. readonly right: NodeMaterialConnectionPoint;
  121258. /**
  121259. * Gets the output component
  121260. */
  121261. readonly output: NodeMaterialConnectionPoint;
  121262. protected _buildBlock(state: NodeMaterialBuildState): this;
  121263. }
  121264. }
  121265. declare module BABYLON {
  121266. /**
  121267. * Block used to apply a dot product between 2 vectors
  121268. */
  121269. export class DotBlock extends NodeMaterialBlock {
  121270. /**
  121271. * Creates a new DotBlock
  121272. * @param name defines the block name
  121273. */
  121274. constructor(name: string);
  121275. /**
  121276. * Gets the current class name
  121277. * @returns the class name
  121278. */
  121279. getClassName(): string;
  121280. /**
  121281. * Gets the left operand input component
  121282. */
  121283. readonly left: NodeMaterialConnectionPoint;
  121284. /**
  121285. * Gets the right operand input component
  121286. */
  121287. readonly right: NodeMaterialConnectionPoint;
  121288. /**
  121289. * Gets the output component
  121290. */
  121291. readonly output: NodeMaterialConnectionPoint;
  121292. protected _buildBlock(state: NodeMaterialBuildState): this;
  121293. }
  121294. }
  121295. declare module BABYLON {
  121296. /**
  121297. * Block used to remap a float from a range to a new one
  121298. */
  121299. export class RemapBlock extends NodeMaterialBlock {
  121300. /**
  121301. * Gets or sets the source range
  121302. */
  121303. sourceRange: Vector2;
  121304. /**
  121305. * Gets or sets the target range
  121306. */
  121307. targetRange: Vector2;
  121308. /**
  121309. * Creates a new RemapBlock
  121310. * @param name defines the block name
  121311. */
  121312. constructor(name: string);
  121313. /**
  121314. * Gets the current class name
  121315. * @returns the class name
  121316. */
  121317. getClassName(): string;
  121318. /**
  121319. * Gets the input component
  121320. */
  121321. readonly input: NodeMaterialConnectionPoint;
  121322. /**
  121323. * Gets the source min input component
  121324. */
  121325. readonly sourceMin: NodeMaterialConnectionPoint;
  121326. /**
  121327. * Gets the source max input component
  121328. */
  121329. readonly sourceMax: NodeMaterialConnectionPoint;
  121330. /**
  121331. * Gets the target min input component
  121332. */
  121333. readonly targetMin: NodeMaterialConnectionPoint;
  121334. /**
  121335. * Gets the target max input component
  121336. */
  121337. readonly targetMax: NodeMaterialConnectionPoint;
  121338. /**
  121339. * Gets the output component
  121340. */
  121341. readonly output: NodeMaterialConnectionPoint;
  121342. protected _buildBlock(state: NodeMaterialBuildState): this;
  121343. protected _dumpPropertiesCode(): string;
  121344. serialize(): any;
  121345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121346. }
  121347. }
  121348. declare module BABYLON {
  121349. /**
  121350. * Block used to normalize a vector
  121351. */
  121352. export class NormalizeBlock extends NodeMaterialBlock {
  121353. /**
  121354. * Creates a new NormalizeBlock
  121355. * @param name defines the block name
  121356. */
  121357. constructor(name: string);
  121358. /**
  121359. * Gets the current class name
  121360. * @returns the class name
  121361. */
  121362. getClassName(): string;
  121363. /**
  121364. * Gets the input component
  121365. */
  121366. readonly input: NodeMaterialConnectionPoint;
  121367. /**
  121368. * Gets the output component
  121369. */
  121370. readonly output: NodeMaterialConnectionPoint;
  121371. protected _buildBlock(state: NodeMaterialBuildState): this;
  121372. }
  121373. }
  121374. declare module BABYLON {
  121375. /**
  121376. * Operations supported by the Trigonometry block
  121377. */
  121378. export enum TrigonometryBlockOperations {
  121379. /** Cos */
  121380. Cos = 0,
  121381. /** Sin */
  121382. Sin = 1,
  121383. /** Abs */
  121384. Abs = 2,
  121385. /** Exp */
  121386. Exp = 3,
  121387. /** Exp2 */
  121388. Exp2 = 4,
  121389. /** Round */
  121390. Round = 5,
  121391. /** Floor */
  121392. Floor = 6,
  121393. /** Ceiling */
  121394. Ceiling = 7,
  121395. /** Square root */
  121396. Sqrt = 8,
  121397. /** Log */
  121398. Log = 9,
  121399. /** Tangent */
  121400. Tan = 10,
  121401. /** Arc tangent */
  121402. ArcTan = 11,
  121403. /** Arc cosinus */
  121404. ArcCos = 12,
  121405. /** Arc sinus */
  121406. ArcSin = 13,
  121407. /** Fraction */
  121408. Fract = 14,
  121409. /** Sign */
  121410. Sign = 15,
  121411. /** To radians (from degrees) */
  121412. Radians = 16,
  121413. /** To degrees (from radians) */
  121414. Degrees = 17
  121415. }
  121416. /**
  121417. * Block used to apply trigonometry operation to floats
  121418. */
  121419. export class TrigonometryBlock extends NodeMaterialBlock {
  121420. /**
  121421. * Gets or sets the operation applied by the block
  121422. */
  121423. operation: TrigonometryBlockOperations;
  121424. /**
  121425. * Creates a new TrigonometryBlock
  121426. * @param name defines the block name
  121427. */
  121428. constructor(name: string);
  121429. /**
  121430. * Gets the current class name
  121431. * @returns the class name
  121432. */
  121433. getClassName(): string;
  121434. /**
  121435. * Gets the input component
  121436. */
  121437. readonly input: NodeMaterialConnectionPoint;
  121438. /**
  121439. * Gets the output component
  121440. */
  121441. readonly output: NodeMaterialConnectionPoint;
  121442. protected _buildBlock(state: NodeMaterialBuildState): this;
  121443. serialize(): any;
  121444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121445. }
  121446. }
  121447. declare module BABYLON {
  121448. /**
  121449. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121450. */
  121451. export class ColorMergerBlock extends NodeMaterialBlock {
  121452. /**
  121453. * Create a new ColorMergerBlock
  121454. * @param name defines the block name
  121455. */
  121456. constructor(name: string);
  121457. /**
  121458. * Gets the current class name
  121459. * @returns the class name
  121460. */
  121461. getClassName(): string;
  121462. /**
  121463. * Gets the r component (input)
  121464. */
  121465. readonly r: NodeMaterialConnectionPoint;
  121466. /**
  121467. * Gets the g component (input)
  121468. */
  121469. readonly g: NodeMaterialConnectionPoint;
  121470. /**
  121471. * Gets the b component (input)
  121472. */
  121473. readonly b: NodeMaterialConnectionPoint;
  121474. /**
  121475. * Gets the a component (input)
  121476. */
  121477. readonly a: NodeMaterialConnectionPoint;
  121478. /**
  121479. * Gets the rgba component (output)
  121480. */
  121481. readonly rgba: NodeMaterialConnectionPoint;
  121482. /**
  121483. * Gets the rgb component (output)
  121484. */
  121485. readonly rgb: NodeMaterialConnectionPoint;
  121486. protected _buildBlock(state: NodeMaterialBuildState): this;
  121487. }
  121488. }
  121489. declare module BABYLON {
  121490. /**
  121491. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121492. */
  121493. export class VectorMergerBlock extends NodeMaterialBlock {
  121494. /**
  121495. * Create a new VectorMergerBlock
  121496. * @param name defines the block name
  121497. */
  121498. constructor(name: string);
  121499. /**
  121500. * Gets the current class name
  121501. * @returns the class name
  121502. */
  121503. getClassName(): string;
  121504. /**
  121505. * Gets the x component (input)
  121506. */
  121507. readonly x: NodeMaterialConnectionPoint;
  121508. /**
  121509. * Gets the y component (input)
  121510. */
  121511. readonly y: NodeMaterialConnectionPoint;
  121512. /**
  121513. * Gets the z component (input)
  121514. */
  121515. readonly z: NodeMaterialConnectionPoint;
  121516. /**
  121517. * Gets the w component (input)
  121518. */
  121519. readonly w: NodeMaterialConnectionPoint;
  121520. /**
  121521. * Gets the xyzw component (output)
  121522. */
  121523. readonly xyzw: NodeMaterialConnectionPoint;
  121524. /**
  121525. * Gets the xyz component (output)
  121526. */
  121527. readonly xyz: NodeMaterialConnectionPoint;
  121528. /**
  121529. * Gets the xy component (output)
  121530. */
  121531. readonly xy: NodeMaterialConnectionPoint;
  121532. protected _buildBlock(state: NodeMaterialBuildState): this;
  121533. }
  121534. }
  121535. declare module BABYLON {
  121536. /**
  121537. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121538. */
  121539. export class ColorSplitterBlock extends NodeMaterialBlock {
  121540. /**
  121541. * Create a new ColorSplitterBlock
  121542. * @param name defines the block name
  121543. */
  121544. constructor(name: string);
  121545. /**
  121546. * Gets the current class name
  121547. * @returns the class name
  121548. */
  121549. getClassName(): string;
  121550. /**
  121551. * Gets the rgba component (input)
  121552. */
  121553. readonly rgba: NodeMaterialConnectionPoint;
  121554. /**
  121555. * Gets the rgb component (input)
  121556. */
  121557. readonly rgbIn: NodeMaterialConnectionPoint;
  121558. /**
  121559. * Gets the rgb component (output)
  121560. */
  121561. readonly rgbOut: NodeMaterialConnectionPoint;
  121562. /**
  121563. * Gets the r component (output)
  121564. */
  121565. readonly r: NodeMaterialConnectionPoint;
  121566. /**
  121567. * Gets the g component (output)
  121568. */
  121569. readonly g: NodeMaterialConnectionPoint;
  121570. /**
  121571. * Gets the b component (output)
  121572. */
  121573. readonly b: NodeMaterialConnectionPoint;
  121574. /**
  121575. * Gets the a component (output)
  121576. */
  121577. readonly a: NodeMaterialConnectionPoint;
  121578. protected _inputRename(name: string): string;
  121579. protected _outputRename(name: string): string;
  121580. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121581. }
  121582. }
  121583. declare module BABYLON {
  121584. /**
  121585. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121586. */
  121587. export class VectorSplitterBlock extends NodeMaterialBlock {
  121588. /**
  121589. * Create a new VectorSplitterBlock
  121590. * @param name defines the block name
  121591. */
  121592. constructor(name: string);
  121593. /**
  121594. * Gets the current class name
  121595. * @returns the class name
  121596. */
  121597. getClassName(): string;
  121598. /**
  121599. * Gets the xyzw component (input)
  121600. */
  121601. readonly xyzw: NodeMaterialConnectionPoint;
  121602. /**
  121603. * Gets the xyz component (input)
  121604. */
  121605. readonly xyzIn: NodeMaterialConnectionPoint;
  121606. /**
  121607. * Gets the xy component (input)
  121608. */
  121609. readonly xyIn: NodeMaterialConnectionPoint;
  121610. /**
  121611. * Gets the xyz component (output)
  121612. */
  121613. readonly xyzOut: NodeMaterialConnectionPoint;
  121614. /**
  121615. * Gets the xy component (output)
  121616. */
  121617. readonly xyOut: NodeMaterialConnectionPoint;
  121618. /**
  121619. * Gets the x component (output)
  121620. */
  121621. readonly x: NodeMaterialConnectionPoint;
  121622. /**
  121623. * Gets the y component (output)
  121624. */
  121625. readonly y: NodeMaterialConnectionPoint;
  121626. /**
  121627. * Gets the z component (output)
  121628. */
  121629. readonly z: NodeMaterialConnectionPoint;
  121630. /**
  121631. * Gets the w component (output)
  121632. */
  121633. readonly w: NodeMaterialConnectionPoint;
  121634. protected _inputRename(name: string): string;
  121635. protected _outputRename(name: string): string;
  121636. protected _buildBlock(state: NodeMaterialBuildState): this;
  121637. }
  121638. }
  121639. declare module BABYLON {
  121640. /**
  121641. * Block used to lerp between 2 values
  121642. */
  121643. export class LerpBlock extends NodeMaterialBlock {
  121644. /**
  121645. * Creates a new LerpBlock
  121646. * @param name defines the block name
  121647. */
  121648. constructor(name: string);
  121649. /**
  121650. * Gets the current class name
  121651. * @returns the class name
  121652. */
  121653. getClassName(): string;
  121654. /**
  121655. * Gets the left operand input component
  121656. */
  121657. readonly left: NodeMaterialConnectionPoint;
  121658. /**
  121659. * Gets the right operand input component
  121660. */
  121661. readonly right: NodeMaterialConnectionPoint;
  121662. /**
  121663. * Gets the gradient operand input component
  121664. */
  121665. readonly gradient: NodeMaterialConnectionPoint;
  121666. /**
  121667. * Gets the output component
  121668. */
  121669. readonly output: NodeMaterialConnectionPoint;
  121670. protected _buildBlock(state: NodeMaterialBuildState): this;
  121671. }
  121672. }
  121673. declare module BABYLON {
  121674. /**
  121675. * Block used to divide 2 vectors
  121676. */
  121677. export class DivideBlock extends NodeMaterialBlock {
  121678. /**
  121679. * Creates a new DivideBlock
  121680. * @param name defines the block name
  121681. */
  121682. constructor(name: string);
  121683. /**
  121684. * Gets the current class name
  121685. * @returns the class name
  121686. */
  121687. getClassName(): string;
  121688. /**
  121689. * Gets the left operand input component
  121690. */
  121691. readonly left: NodeMaterialConnectionPoint;
  121692. /**
  121693. * Gets the right operand input component
  121694. */
  121695. readonly right: NodeMaterialConnectionPoint;
  121696. /**
  121697. * Gets the output component
  121698. */
  121699. readonly output: NodeMaterialConnectionPoint;
  121700. protected _buildBlock(state: NodeMaterialBuildState): this;
  121701. }
  121702. }
  121703. declare module BABYLON {
  121704. /**
  121705. * Block used to subtract 2 vectors
  121706. */
  121707. export class SubtractBlock extends NodeMaterialBlock {
  121708. /**
  121709. * Creates a new SubtractBlock
  121710. * @param name defines the block name
  121711. */
  121712. constructor(name: string);
  121713. /**
  121714. * Gets the current class name
  121715. * @returns the class name
  121716. */
  121717. getClassName(): string;
  121718. /**
  121719. * Gets the left operand input component
  121720. */
  121721. readonly left: NodeMaterialConnectionPoint;
  121722. /**
  121723. * Gets the right operand input component
  121724. */
  121725. readonly right: NodeMaterialConnectionPoint;
  121726. /**
  121727. * Gets the output component
  121728. */
  121729. readonly output: NodeMaterialConnectionPoint;
  121730. protected _buildBlock(state: NodeMaterialBuildState): this;
  121731. }
  121732. }
  121733. declare module BABYLON {
  121734. /**
  121735. * Block used to step a value
  121736. */
  121737. export class StepBlock extends NodeMaterialBlock {
  121738. /**
  121739. * Creates a new StepBlock
  121740. * @param name defines the block name
  121741. */
  121742. constructor(name: string);
  121743. /**
  121744. * Gets the current class name
  121745. * @returns the class name
  121746. */
  121747. getClassName(): string;
  121748. /**
  121749. * Gets the value operand input component
  121750. */
  121751. readonly value: NodeMaterialConnectionPoint;
  121752. /**
  121753. * Gets the edge operand input component
  121754. */
  121755. readonly edge: NodeMaterialConnectionPoint;
  121756. /**
  121757. * Gets the output component
  121758. */
  121759. readonly output: NodeMaterialConnectionPoint;
  121760. protected _buildBlock(state: NodeMaterialBuildState): this;
  121761. }
  121762. }
  121763. declare module BABYLON {
  121764. /**
  121765. * Block used to get the opposite (1 - x) of a value
  121766. */
  121767. export class OneMinusBlock extends NodeMaterialBlock {
  121768. /**
  121769. * Creates a new OneMinusBlock
  121770. * @param name defines the block name
  121771. */
  121772. constructor(name: string);
  121773. /**
  121774. * Gets the current class name
  121775. * @returns the class name
  121776. */
  121777. getClassName(): string;
  121778. /**
  121779. * Gets the input component
  121780. */
  121781. readonly input: NodeMaterialConnectionPoint;
  121782. /**
  121783. * Gets the output component
  121784. */
  121785. readonly output: NodeMaterialConnectionPoint;
  121786. protected _buildBlock(state: NodeMaterialBuildState): this;
  121787. }
  121788. }
  121789. declare module BABYLON {
  121790. /**
  121791. * Block used to get the view direction
  121792. */
  121793. export class ViewDirectionBlock extends NodeMaterialBlock {
  121794. /**
  121795. * Creates a new ViewDirectionBlock
  121796. * @param name defines the block name
  121797. */
  121798. constructor(name: string);
  121799. /**
  121800. * Gets the current class name
  121801. * @returns the class name
  121802. */
  121803. getClassName(): string;
  121804. /**
  121805. * Gets the world position component
  121806. */
  121807. readonly worldPosition: NodeMaterialConnectionPoint;
  121808. /**
  121809. * Gets the camera position component
  121810. */
  121811. readonly cameraPosition: NodeMaterialConnectionPoint;
  121812. /**
  121813. * Gets the output component
  121814. */
  121815. readonly output: NodeMaterialConnectionPoint;
  121816. autoConfigure(material: NodeMaterial): void;
  121817. protected _buildBlock(state: NodeMaterialBuildState): this;
  121818. }
  121819. }
  121820. declare module BABYLON {
  121821. /**
  121822. * Block used to compute fresnel value
  121823. */
  121824. export class FresnelBlock extends NodeMaterialBlock {
  121825. /**
  121826. * Create a new FresnelBlock
  121827. * @param name defines the block name
  121828. */
  121829. constructor(name: string);
  121830. /**
  121831. * Gets the current class name
  121832. * @returns the class name
  121833. */
  121834. getClassName(): string;
  121835. /**
  121836. * Gets the world normal input component
  121837. */
  121838. readonly worldNormal: NodeMaterialConnectionPoint;
  121839. /**
  121840. * Gets the view direction input component
  121841. */
  121842. readonly viewDirection: NodeMaterialConnectionPoint;
  121843. /**
  121844. * Gets the bias input component
  121845. */
  121846. readonly bias: NodeMaterialConnectionPoint;
  121847. /**
  121848. * Gets the camera (or eye) position component
  121849. */
  121850. readonly power: NodeMaterialConnectionPoint;
  121851. /**
  121852. * Gets the fresnel output component
  121853. */
  121854. readonly fresnel: NodeMaterialConnectionPoint;
  121855. autoConfigure(material: NodeMaterial): void;
  121856. protected _buildBlock(state: NodeMaterialBuildState): this;
  121857. }
  121858. }
  121859. declare module BABYLON {
  121860. /**
  121861. * Block used to get the max of 2 values
  121862. */
  121863. export class MaxBlock extends NodeMaterialBlock {
  121864. /**
  121865. * Creates a new MaxBlock
  121866. * @param name defines the block name
  121867. */
  121868. constructor(name: string);
  121869. /**
  121870. * Gets the current class name
  121871. * @returns the class name
  121872. */
  121873. getClassName(): string;
  121874. /**
  121875. * Gets the left operand input component
  121876. */
  121877. readonly left: NodeMaterialConnectionPoint;
  121878. /**
  121879. * Gets the right operand input component
  121880. */
  121881. readonly right: NodeMaterialConnectionPoint;
  121882. /**
  121883. * Gets the output component
  121884. */
  121885. readonly output: NodeMaterialConnectionPoint;
  121886. protected _buildBlock(state: NodeMaterialBuildState): this;
  121887. }
  121888. }
  121889. declare module BABYLON {
  121890. /**
  121891. * Block used to get the min of 2 values
  121892. */
  121893. export class MinBlock extends NodeMaterialBlock {
  121894. /**
  121895. * Creates a new MinBlock
  121896. * @param name defines the block name
  121897. */
  121898. constructor(name: string);
  121899. /**
  121900. * Gets the current class name
  121901. * @returns the class name
  121902. */
  121903. getClassName(): string;
  121904. /**
  121905. * Gets the left operand input component
  121906. */
  121907. readonly left: NodeMaterialConnectionPoint;
  121908. /**
  121909. * Gets the right operand input component
  121910. */
  121911. readonly right: NodeMaterialConnectionPoint;
  121912. /**
  121913. * Gets the output component
  121914. */
  121915. readonly output: NodeMaterialConnectionPoint;
  121916. protected _buildBlock(state: NodeMaterialBuildState): this;
  121917. }
  121918. }
  121919. declare module BABYLON {
  121920. /**
  121921. * Block used to get the distance between 2 values
  121922. */
  121923. export class DistanceBlock extends NodeMaterialBlock {
  121924. /**
  121925. * Creates a new DistanceBlock
  121926. * @param name defines the block name
  121927. */
  121928. constructor(name: string);
  121929. /**
  121930. * Gets the current class name
  121931. * @returns the class name
  121932. */
  121933. getClassName(): string;
  121934. /**
  121935. * Gets the left operand input component
  121936. */
  121937. readonly left: NodeMaterialConnectionPoint;
  121938. /**
  121939. * Gets the right operand input component
  121940. */
  121941. readonly right: NodeMaterialConnectionPoint;
  121942. /**
  121943. * Gets the output component
  121944. */
  121945. readonly output: NodeMaterialConnectionPoint;
  121946. protected _buildBlock(state: NodeMaterialBuildState): this;
  121947. }
  121948. }
  121949. declare module BABYLON {
  121950. /**
  121951. * Block used to get the length of a vector
  121952. */
  121953. export class LengthBlock extends NodeMaterialBlock {
  121954. /**
  121955. * Creates a new LengthBlock
  121956. * @param name defines the block name
  121957. */
  121958. constructor(name: string);
  121959. /**
  121960. * Gets the current class name
  121961. * @returns the class name
  121962. */
  121963. getClassName(): string;
  121964. /**
  121965. * Gets the value input component
  121966. */
  121967. readonly value: NodeMaterialConnectionPoint;
  121968. /**
  121969. * Gets the output component
  121970. */
  121971. readonly output: NodeMaterialConnectionPoint;
  121972. protected _buildBlock(state: NodeMaterialBuildState): this;
  121973. }
  121974. }
  121975. declare module BABYLON {
  121976. /**
  121977. * Block used to get negative version of a value (i.e. x * -1)
  121978. */
  121979. export class NegateBlock extends NodeMaterialBlock {
  121980. /**
  121981. * Creates a new NegateBlock
  121982. * @param name defines the block name
  121983. */
  121984. constructor(name: string);
  121985. /**
  121986. * Gets the current class name
  121987. * @returns the class name
  121988. */
  121989. getClassName(): string;
  121990. /**
  121991. * Gets the value input component
  121992. */
  121993. readonly value: NodeMaterialConnectionPoint;
  121994. /**
  121995. * Gets the output component
  121996. */
  121997. readonly output: NodeMaterialConnectionPoint;
  121998. protected _buildBlock(state: NodeMaterialBuildState): this;
  121999. }
  122000. }
  122001. declare module BABYLON {
  122002. /**
  122003. * Block used to get the value of the first parameter raised to the power of the second
  122004. */
  122005. export class PowBlock extends NodeMaterialBlock {
  122006. /**
  122007. * Creates a new PowBlock
  122008. * @param name defines the block name
  122009. */
  122010. constructor(name: string);
  122011. /**
  122012. * Gets the current class name
  122013. * @returns the class name
  122014. */
  122015. getClassName(): string;
  122016. /**
  122017. * Gets the value operand input component
  122018. */
  122019. readonly value: NodeMaterialConnectionPoint;
  122020. /**
  122021. * Gets the power operand input component
  122022. */
  122023. readonly power: NodeMaterialConnectionPoint;
  122024. /**
  122025. * Gets the output component
  122026. */
  122027. readonly output: NodeMaterialConnectionPoint;
  122028. protected _buildBlock(state: NodeMaterialBuildState): this;
  122029. }
  122030. }
  122031. declare module BABYLON {
  122032. /**
  122033. * Block used to get a random number
  122034. */
  122035. export class RandomNumberBlock extends NodeMaterialBlock {
  122036. /**
  122037. * Creates a new RandomNumberBlock
  122038. * @param name defines the block name
  122039. */
  122040. constructor(name: string);
  122041. /**
  122042. * Gets the current class name
  122043. * @returns the class name
  122044. */
  122045. getClassName(): string;
  122046. /**
  122047. * Gets the seed input component
  122048. */
  122049. readonly seed: NodeMaterialConnectionPoint;
  122050. /**
  122051. * Gets the output component
  122052. */
  122053. readonly output: NodeMaterialConnectionPoint;
  122054. protected _buildBlock(state: NodeMaterialBuildState): this;
  122055. }
  122056. }
  122057. declare module BABYLON {
  122058. /**
  122059. * Block used to compute arc tangent of 2 values
  122060. */
  122061. export class ArcTan2Block extends NodeMaterialBlock {
  122062. /**
  122063. * Creates a new ArcTan2Block
  122064. * @param name defines the block name
  122065. */
  122066. constructor(name: string);
  122067. /**
  122068. * Gets the current class name
  122069. * @returns the class name
  122070. */
  122071. getClassName(): string;
  122072. /**
  122073. * Gets the x operand input component
  122074. */
  122075. readonly x: NodeMaterialConnectionPoint;
  122076. /**
  122077. * Gets the y operand input component
  122078. */
  122079. readonly y: NodeMaterialConnectionPoint;
  122080. /**
  122081. * Gets the output component
  122082. */
  122083. readonly output: NodeMaterialConnectionPoint;
  122084. protected _buildBlock(state: NodeMaterialBuildState): this;
  122085. }
  122086. }
  122087. declare module BABYLON {
  122088. /**
  122089. * Block used to smooth step a value
  122090. */
  122091. export class SmoothStepBlock extends NodeMaterialBlock {
  122092. /**
  122093. * Creates a new SmoothStepBlock
  122094. * @param name defines the block name
  122095. */
  122096. constructor(name: string);
  122097. /**
  122098. * Gets the current class name
  122099. * @returns the class name
  122100. */
  122101. getClassName(): string;
  122102. /**
  122103. * Gets the value operand input component
  122104. */
  122105. readonly value: NodeMaterialConnectionPoint;
  122106. /**
  122107. * Gets the first edge operand input component
  122108. */
  122109. readonly edge0: NodeMaterialConnectionPoint;
  122110. /**
  122111. * Gets the second edge operand input component
  122112. */
  122113. readonly edge1: NodeMaterialConnectionPoint;
  122114. /**
  122115. * Gets the output component
  122116. */
  122117. readonly output: NodeMaterialConnectionPoint;
  122118. protected _buildBlock(state: NodeMaterialBuildState): this;
  122119. }
  122120. }
  122121. declare module BABYLON {
  122122. /**
  122123. * Block used to get the reciprocal (1 / x) of a value
  122124. */
  122125. export class ReciprocalBlock extends NodeMaterialBlock {
  122126. /**
  122127. * Creates a new ReciprocalBlock
  122128. * @param name defines the block name
  122129. */
  122130. constructor(name: string);
  122131. /**
  122132. * Gets the current class name
  122133. * @returns the class name
  122134. */
  122135. getClassName(): string;
  122136. /**
  122137. * Gets the input component
  122138. */
  122139. readonly input: NodeMaterialConnectionPoint;
  122140. /**
  122141. * Gets the output component
  122142. */
  122143. readonly output: NodeMaterialConnectionPoint;
  122144. protected _buildBlock(state: NodeMaterialBuildState): this;
  122145. }
  122146. }
  122147. declare module BABYLON {
  122148. /**
  122149. * Block used to replace a color by another one
  122150. */
  122151. export class ReplaceColorBlock extends NodeMaterialBlock {
  122152. /**
  122153. * Creates a new ReplaceColorBlock
  122154. * @param name defines the block name
  122155. */
  122156. constructor(name: string);
  122157. /**
  122158. * Gets the current class name
  122159. * @returns the class name
  122160. */
  122161. getClassName(): string;
  122162. /**
  122163. * Gets the value input component
  122164. */
  122165. readonly value: NodeMaterialConnectionPoint;
  122166. /**
  122167. * Gets the reference input component
  122168. */
  122169. readonly reference: NodeMaterialConnectionPoint;
  122170. /**
  122171. * Gets the distance input component
  122172. */
  122173. readonly distance: NodeMaterialConnectionPoint;
  122174. /**
  122175. * Gets the replacement input component
  122176. */
  122177. readonly replacement: NodeMaterialConnectionPoint;
  122178. /**
  122179. * Gets the output component
  122180. */
  122181. readonly output: NodeMaterialConnectionPoint;
  122182. protected _buildBlock(state: NodeMaterialBuildState): this;
  122183. }
  122184. }
  122185. declare module BABYLON {
  122186. /**
  122187. * Block used to posterize a value
  122188. * @see https://en.wikipedia.org/wiki/Posterization
  122189. */
  122190. export class PosterizeBlock extends NodeMaterialBlock {
  122191. /**
  122192. * Creates a new PosterizeBlock
  122193. * @param name defines the block name
  122194. */
  122195. constructor(name: string);
  122196. /**
  122197. * Gets the current class name
  122198. * @returns the class name
  122199. */
  122200. getClassName(): string;
  122201. /**
  122202. * Gets the value input component
  122203. */
  122204. readonly value: NodeMaterialConnectionPoint;
  122205. /**
  122206. * Gets the steps input component
  122207. */
  122208. readonly steps: NodeMaterialConnectionPoint;
  122209. /**
  122210. * Gets the output component
  122211. */
  122212. readonly output: NodeMaterialConnectionPoint;
  122213. protected _buildBlock(state: NodeMaterialBuildState): this;
  122214. }
  122215. }
  122216. declare module BABYLON {
  122217. /**
  122218. * Operations supported by the Wave block
  122219. */
  122220. export enum WaveBlockKind {
  122221. /** SawTooth */
  122222. SawTooth = 0,
  122223. /** Square */
  122224. Square = 1,
  122225. /** Triangle */
  122226. Triangle = 2
  122227. }
  122228. /**
  122229. * Block used to apply wave operation to floats
  122230. */
  122231. export class WaveBlock extends NodeMaterialBlock {
  122232. /**
  122233. * Gets or sets the kibnd of wave to be applied by the block
  122234. */
  122235. kind: WaveBlockKind;
  122236. /**
  122237. * Creates a new WaveBlock
  122238. * @param name defines the block name
  122239. */
  122240. constructor(name: string);
  122241. /**
  122242. * Gets the current class name
  122243. * @returns the class name
  122244. */
  122245. getClassName(): string;
  122246. /**
  122247. * Gets the input component
  122248. */
  122249. readonly input: NodeMaterialConnectionPoint;
  122250. /**
  122251. * Gets the output component
  122252. */
  122253. readonly output: NodeMaterialConnectionPoint;
  122254. protected _buildBlock(state: NodeMaterialBuildState): this;
  122255. serialize(): any;
  122256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122257. }
  122258. }
  122259. declare module BABYLON {
  122260. /**
  122261. * Class used to store a color step for the GradientBlock
  122262. */
  122263. export class GradientBlockColorStep {
  122264. /**
  122265. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122266. */
  122267. step: number;
  122268. /**
  122269. * Gets or sets the color associated with this step
  122270. */
  122271. color: Color3;
  122272. /**
  122273. * Creates a new GradientBlockColorStep
  122274. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122275. * @param color defines the color associated with this step
  122276. */
  122277. constructor(
  122278. /**
  122279. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122280. */
  122281. step: number,
  122282. /**
  122283. * Gets or sets the color associated with this step
  122284. */
  122285. color: Color3);
  122286. }
  122287. /**
  122288. * Block used to return a color from a gradient based on an input value between 0 and 1
  122289. */
  122290. export class GradientBlock extends NodeMaterialBlock {
  122291. /**
  122292. * Gets or sets the list of color steps
  122293. */
  122294. colorSteps: GradientBlockColorStep[];
  122295. /**
  122296. * Creates a new GradientBlock
  122297. * @param name defines the block name
  122298. */
  122299. constructor(name: string);
  122300. /**
  122301. * Gets the current class name
  122302. * @returns the class name
  122303. */
  122304. getClassName(): string;
  122305. /**
  122306. * Gets the gradient input component
  122307. */
  122308. readonly gradient: NodeMaterialConnectionPoint;
  122309. /**
  122310. * Gets the output component
  122311. */
  122312. readonly output: NodeMaterialConnectionPoint;
  122313. private _writeColorConstant;
  122314. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122315. serialize(): any;
  122316. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122317. protected _dumpPropertiesCode(): string;
  122318. }
  122319. }
  122320. declare module BABYLON {
  122321. /**
  122322. * Block used to normalize lerp between 2 values
  122323. */
  122324. export class NLerpBlock extends NodeMaterialBlock {
  122325. /**
  122326. * Creates a new NLerpBlock
  122327. * @param name defines the block name
  122328. */
  122329. constructor(name: string);
  122330. /**
  122331. * Gets the current class name
  122332. * @returns the class name
  122333. */
  122334. getClassName(): string;
  122335. /**
  122336. * Gets the left operand input component
  122337. */
  122338. readonly left: NodeMaterialConnectionPoint;
  122339. /**
  122340. * Gets the right operand input component
  122341. */
  122342. readonly right: NodeMaterialConnectionPoint;
  122343. /**
  122344. * Gets the gradient operand input component
  122345. */
  122346. readonly gradient: NodeMaterialConnectionPoint;
  122347. /**
  122348. * Gets the output component
  122349. */
  122350. readonly output: NodeMaterialConnectionPoint;
  122351. protected _buildBlock(state: NodeMaterialBuildState): this;
  122352. }
  122353. }
  122354. declare module BABYLON {
  122355. /**
  122356. * Effect Render Options
  122357. */
  122358. export interface IEffectRendererOptions {
  122359. /**
  122360. * Defines the vertices positions.
  122361. */
  122362. positions?: number[];
  122363. /**
  122364. * Defines the indices.
  122365. */
  122366. indices?: number[];
  122367. }
  122368. /**
  122369. * Helper class to render one or more effects
  122370. */
  122371. export class EffectRenderer {
  122372. private engine;
  122373. private static _DefaultOptions;
  122374. private _vertexBuffers;
  122375. private _indexBuffer;
  122376. private _ringBufferIndex;
  122377. private _ringScreenBuffer;
  122378. private _fullscreenViewport;
  122379. private _getNextFrameBuffer;
  122380. /**
  122381. * Creates an effect renderer
  122382. * @param engine the engine to use for rendering
  122383. * @param options defines the options of the effect renderer
  122384. */
  122385. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  122386. /**
  122387. * Sets the current viewport in normalized coordinates 0-1
  122388. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122389. */
  122390. setViewport(viewport?: Viewport): void;
  122391. /**
  122392. * Binds the embedded attributes buffer to the effect.
  122393. * @param effect Defines the effect to bind the attributes for
  122394. */
  122395. bindBuffers(effect: Effect): void;
  122396. /**
  122397. * Sets the current effect wrapper to use during draw.
  122398. * The effect needs to be ready before calling this api.
  122399. * This also sets the default full screen position attribute.
  122400. * @param effectWrapper Defines the effect to draw with
  122401. */
  122402. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122403. /**
  122404. * Draws a full screen quad.
  122405. */
  122406. draw(): void;
  122407. /**
  122408. * renders one or more effects to a specified texture
  122409. * @param effectWrappers list of effects to renderer
  122410. * @param outputTexture texture to draw to, if null it will render to the screen
  122411. */
  122412. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122413. /**
  122414. * Disposes of the effect renderer
  122415. */
  122416. dispose(): void;
  122417. }
  122418. /**
  122419. * Options to create an EffectWrapper
  122420. */
  122421. interface EffectWrapperCreationOptions {
  122422. /**
  122423. * Engine to use to create the effect
  122424. */
  122425. engine: ThinEngine;
  122426. /**
  122427. * Fragment shader for the effect
  122428. */
  122429. fragmentShader: string;
  122430. /**
  122431. * Vertex shader for the effect
  122432. */
  122433. vertexShader?: string;
  122434. /**
  122435. * Attributes to use in the shader
  122436. */
  122437. attributeNames?: Array<string>;
  122438. /**
  122439. * Uniforms to use in the shader
  122440. */
  122441. uniformNames?: Array<string>;
  122442. /**
  122443. * Texture sampler names to use in the shader
  122444. */
  122445. samplerNames?: Array<string>;
  122446. /**
  122447. * The friendly name of the effect displayed in Spector.
  122448. */
  122449. name?: string;
  122450. }
  122451. /**
  122452. * Wraps an effect to be used for rendering
  122453. */
  122454. export class EffectWrapper {
  122455. /**
  122456. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122457. */
  122458. onApplyObservable: Observable<{}>;
  122459. /**
  122460. * The underlying effect
  122461. */
  122462. effect: Effect;
  122463. /**
  122464. * Creates an effect to be renderer
  122465. * @param creationOptions options to create the effect
  122466. */
  122467. constructor(creationOptions: EffectWrapperCreationOptions);
  122468. /**
  122469. * Disposes of the effect wrapper
  122470. */
  122471. dispose(): void;
  122472. }
  122473. }
  122474. declare module BABYLON {
  122475. /**
  122476. * Helper class to push actions to a pool of workers.
  122477. */
  122478. export class WorkerPool implements IDisposable {
  122479. private _workerInfos;
  122480. private _pendingActions;
  122481. /**
  122482. * Constructor
  122483. * @param workers Array of workers to use for actions
  122484. */
  122485. constructor(workers: Array<Worker>);
  122486. /**
  122487. * Terminates all workers and clears any pending actions.
  122488. */
  122489. dispose(): void;
  122490. /**
  122491. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122492. * pended until a worker has completed its action.
  122493. * @param action The action to perform. Call onComplete when the action is complete.
  122494. */
  122495. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122496. private _execute;
  122497. }
  122498. }
  122499. declare module BABYLON {
  122500. /**
  122501. * Configuration for Draco compression
  122502. */
  122503. export interface IDracoCompressionConfiguration {
  122504. /**
  122505. * Configuration for the decoder.
  122506. */
  122507. decoder: {
  122508. /**
  122509. * The url to the WebAssembly module.
  122510. */
  122511. wasmUrl?: string;
  122512. /**
  122513. * The url to the WebAssembly binary.
  122514. */
  122515. wasmBinaryUrl?: string;
  122516. /**
  122517. * The url to the fallback JavaScript module.
  122518. */
  122519. fallbackUrl?: string;
  122520. };
  122521. }
  122522. /**
  122523. * Draco compression (https://google.github.io/draco/)
  122524. *
  122525. * This class wraps the Draco module.
  122526. *
  122527. * **Encoder**
  122528. *
  122529. * The encoder is not currently implemented.
  122530. *
  122531. * **Decoder**
  122532. *
  122533. * 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.
  122534. *
  122535. * To update the configuration, use the following code:
  122536. * ```javascript
  122537. * DracoCompression.Configuration = {
  122538. * decoder: {
  122539. * wasmUrl: "<url to the WebAssembly library>",
  122540. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122541. * fallbackUrl: "<url to the fallback JavaScript library>",
  122542. * }
  122543. * };
  122544. * ```
  122545. *
  122546. * 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.
  122547. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122548. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122549. *
  122550. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122551. * ```javascript
  122552. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122553. * ```
  122554. *
  122555. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122556. */
  122557. export class DracoCompression implements IDisposable {
  122558. private _workerPoolPromise?;
  122559. private _decoderModulePromise?;
  122560. /**
  122561. * The configuration. Defaults to the following urls:
  122562. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122563. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122564. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122565. */
  122566. static Configuration: IDracoCompressionConfiguration;
  122567. /**
  122568. * Returns true if the decoder configuration is available.
  122569. */
  122570. static readonly DecoderAvailable: boolean;
  122571. /**
  122572. * Default number of workers to create when creating the draco compression object.
  122573. */
  122574. static DefaultNumWorkers: number;
  122575. private static GetDefaultNumWorkers;
  122576. private static _Default;
  122577. /**
  122578. * Default instance for the draco compression object.
  122579. */
  122580. static readonly Default: DracoCompression;
  122581. /**
  122582. * Constructor
  122583. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122584. */
  122585. constructor(numWorkers?: number);
  122586. /**
  122587. * Stop all async operations and release resources.
  122588. */
  122589. dispose(): void;
  122590. /**
  122591. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122592. * @returns a promise that resolves when ready
  122593. */
  122594. whenReadyAsync(): Promise<void>;
  122595. /**
  122596. * Decode Draco compressed mesh data to vertex data.
  122597. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122598. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122599. * @returns A promise that resolves with the decoded vertex data
  122600. */
  122601. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122602. [kind: string]: number;
  122603. }): Promise<VertexData>;
  122604. }
  122605. }
  122606. declare module BABYLON {
  122607. /**
  122608. * Class for building Constructive Solid Geometry
  122609. */
  122610. export class CSG {
  122611. private polygons;
  122612. /**
  122613. * The world matrix
  122614. */
  122615. matrix: Matrix;
  122616. /**
  122617. * Stores the position
  122618. */
  122619. position: Vector3;
  122620. /**
  122621. * Stores the rotation
  122622. */
  122623. rotation: Vector3;
  122624. /**
  122625. * Stores the rotation quaternion
  122626. */
  122627. rotationQuaternion: Nullable<Quaternion>;
  122628. /**
  122629. * Stores the scaling vector
  122630. */
  122631. scaling: Vector3;
  122632. /**
  122633. * Convert the Mesh to CSG
  122634. * @param mesh The Mesh to convert to CSG
  122635. * @returns A new CSG from the Mesh
  122636. */
  122637. static FromMesh(mesh: Mesh): CSG;
  122638. /**
  122639. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122640. * @param polygons Polygons used to construct a CSG solid
  122641. */
  122642. private static FromPolygons;
  122643. /**
  122644. * Clones, or makes a deep copy, of the CSG
  122645. * @returns A new CSG
  122646. */
  122647. clone(): CSG;
  122648. /**
  122649. * Unions this CSG with another CSG
  122650. * @param csg The CSG to union against this CSG
  122651. * @returns The unioned CSG
  122652. */
  122653. union(csg: CSG): CSG;
  122654. /**
  122655. * Unions this CSG with another CSG in place
  122656. * @param csg The CSG to union against this CSG
  122657. */
  122658. unionInPlace(csg: CSG): void;
  122659. /**
  122660. * Subtracts this CSG with another CSG
  122661. * @param csg The CSG to subtract against this CSG
  122662. * @returns A new CSG
  122663. */
  122664. subtract(csg: CSG): CSG;
  122665. /**
  122666. * Subtracts this CSG with another CSG in place
  122667. * @param csg The CSG to subtact against this CSG
  122668. */
  122669. subtractInPlace(csg: CSG): void;
  122670. /**
  122671. * Intersect this CSG with another CSG
  122672. * @param csg The CSG to intersect against this CSG
  122673. * @returns A new CSG
  122674. */
  122675. intersect(csg: CSG): CSG;
  122676. /**
  122677. * Intersects this CSG with another CSG in place
  122678. * @param csg The CSG to intersect against this CSG
  122679. */
  122680. intersectInPlace(csg: CSG): void;
  122681. /**
  122682. * Return a new CSG solid with solid and empty space switched. This solid is
  122683. * not modified.
  122684. * @returns A new CSG solid with solid and empty space switched
  122685. */
  122686. inverse(): CSG;
  122687. /**
  122688. * Inverses the CSG in place
  122689. */
  122690. inverseInPlace(): void;
  122691. /**
  122692. * This is used to keep meshes transformations so they can be restored
  122693. * when we build back a Babylon Mesh
  122694. * NB : All CSG operations are performed in world coordinates
  122695. * @param csg The CSG to copy the transform attributes from
  122696. * @returns This CSG
  122697. */
  122698. copyTransformAttributes(csg: CSG): CSG;
  122699. /**
  122700. * Build Raw mesh from CSG
  122701. * Coordinates here are in world space
  122702. * @param name The name of the mesh geometry
  122703. * @param scene The Scene
  122704. * @param keepSubMeshes Specifies if the submeshes should be kept
  122705. * @returns A new Mesh
  122706. */
  122707. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122708. /**
  122709. * Build Mesh from CSG taking material and transforms into account
  122710. * @param name The name of the Mesh
  122711. * @param material The material of the Mesh
  122712. * @param scene The Scene
  122713. * @param keepSubMeshes Specifies if submeshes should be kept
  122714. * @returns The new Mesh
  122715. */
  122716. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122717. }
  122718. }
  122719. declare module BABYLON {
  122720. /**
  122721. * Class used to create a trail following a mesh
  122722. */
  122723. export class TrailMesh extends Mesh {
  122724. private _generator;
  122725. private _autoStart;
  122726. private _running;
  122727. private _diameter;
  122728. private _length;
  122729. private _sectionPolygonPointsCount;
  122730. private _sectionVectors;
  122731. private _sectionNormalVectors;
  122732. private _beforeRenderObserver;
  122733. /**
  122734. * @constructor
  122735. * @param name The value used by scene.getMeshByName() to do a lookup.
  122736. * @param generator The mesh to generate a trail.
  122737. * @param scene The scene to add this mesh to.
  122738. * @param diameter Diameter of trailing mesh. Default is 1.
  122739. * @param length Length of trailing mesh. Default is 60.
  122740. * @param autoStart Automatically start trailing mesh. Default true.
  122741. */
  122742. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122743. /**
  122744. * "TrailMesh"
  122745. * @returns "TrailMesh"
  122746. */
  122747. getClassName(): string;
  122748. private _createMesh;
  122749. /**
  122750. * Start trailing mesh.
  122751. */
  122752. start(): void;
  122753. /**
  122754. * Stop trailing mesh.
  122755. */
  122756. stop(): void;
  122757. /**
  122758. * Update trailing mesh geometry.
  122759. */
  122760. update(): void;
  122761. /**
  122762. * Returns a new TrailMesh object.
  122763. * @param name is a string, the name given to the new mesh
  122764. * @param newGenerator use new generator object for cloned trail mesh
  122765. * @returns a new mesh
  122766. */
  122767. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122768. /**
  122769. * Serializes this trail mesh
  122770. * @param serializationObject object to write serialization to
  122771. */
  122772. serialize(serializationObject: any): void;
  122773. /**
  122774. * Parses a serialized trail mesh
  122775. * @param parsedMesh the serialized mesh
  122776. * @param scene the scene to create the trail mesh in
  122777. * @returns the created trail mesh
  122778. */
  122779. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122780. }
  122781. }
  122782. declare module BABYLON {
  122783. /**
  122784. * Class containing static functions to help procedurally build meshes
  122785. */
  122786. export class TiledBoxBuilder {
  122787. /**
  122788. * Creates a box mesh
  122789. * 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)
  122790. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122794. * @param name defines the name of the mesh
  122795. * @param options defines the options used to create the mesh
  122796. * @param scene defines the hosting scene
  122797. * @returns the box mesh
  122798. */
  122799. static CreateTiledBox(name: string, options: {
  122800. pattern?: number;
  122801. width?: number;
  122802. height?: number;
  122803. depth?: number;
  122804. tileSize?: number;
  122805. tileWidth?: number;
  122806. tileHeight?: number;
  122807. alignHorizontal?: number;
  122808. alignVertical?: number;
  122809. faceUV?: Vector4[];
  122810. faceColors?: Color4[];
  122811. sideOrientation?: number;
  122812. updatable?: boolean;
  122813. }, scene?: Nullable<Scene>): Mesh;
  122814. }
  122815. }
  122816. declare module BABYLON {
  122817. /**
  122818. * Class containing static functions to help procedurally build meshes
  122819. */
  122820. export class TorusKnotBuilder {
  122821. /**
  122822. * Creates a torus knot mesh
  122823. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122824. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122825. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122826. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122830. * @param name defines the name of the mesh
  122831. * @param options defines the options used to create the mesh
  122832. * @param scene defines the hosting scene
  122833. * @returns the torus knot mesh
  122834. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122835. */
  122836. static CreateTorusKnot(name: string, options: {
  122837. radius?: number;
  122838. tube?: number;
  122839. radialSegments?: number;
  122840. tubularSegments?: number;
  122841. p?: number;
  122842. q?: number;
  122843. updatable?: boolean;
  122844. sideOrientation?: number;
  122845. frontUVs?: Vector4;
  122846. backUVs?: Vector4;
  122847. }, scene: any): Mesh;
  122848. }
  122849. }
  122850. declare module BABYLON {
  122851. /**
  122852. * Polygon
  122853. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122854. */
  122855. export class Polygon {
  122856. /**
  122857. * Creates a rectangle
  122858. * @param xmin bottom X coord
  122859. * @param ymin bottom Y coord
  122860. * @param xmax top X coord
  122861. * @param ymax top Y coord
  122862. * @returns points that make the resulting rectation
  122863. */
  122864. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122865. /**
  122866. * Creates a circle
  122867. * @param radius radius of circle
  122868. * @param cx scale in x
  122869. * @param cy scale in y
  122870. * @param numberOfSides number of sides that make up the circle
  122871. * @returns points that make the resulting circle
  122872. */
  122873. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122874. /**
  122875. * Creates a polygon from input string
  122876. * @param input Input polygon data
  122877. * @returns the parsed points
  122878. */
  122879. static Parse(input: string): Vector2[];
  122880. /**
  122881. * Starts building a polygon from x and y coordinates
  122882. * @param x x coordinate
  122883. * @param y y coordinate
  122884. * @returns the started path2
  122885. */
  122886. static StartingAt(x: number, y: number): Path2;
  122887. }
  122888. /**
  122889. * Builds a polygon
  122890. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122891. */
  122892. export class PolygonMeshBuilder {
  122893. private _points;
  122894. private _outlinepoints;
  122895. private _holes;
  122896. private _name;
  122897. private _scene;
  122898. private _epoints;
  122899. private _eholes;
  122900. private _addToepoint;
  122901. /**
  122902. * Babylon reference to the earcut plugin.
  122903. */
  122904. bjsEarcut: any;
  122905. /**
  122906. * Creates a PolygonMeshBuilder
  122907. * @param name name of the builder
  122908. * @param contours Path of the polygon
  122909. * @param scene scene to add to when creating the mesh
  122910. * @param earcutInjection can be used to inject your own earcut reference
  122911. */
  122912. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122913. /**
  122914. * Adds a whole within the polygon
  122915. * @param hole Array of points defining the hole
  122916. * @returns this
  122917. */
  122918. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122919. /**
  122920. * Creates the polygon
  122921. * @param updatable If the mesh should be updatable
  122922. * @param depth The depth of the mesh created
  122923. * @returns the created mesh
  122924. */
  122925. build(updatable?: boolean, depth?: number): Mesh;
  122926. /**
  122927. * Creates the polygon
  122928. * @param depth The depth of the mesh created
  122929. * @returns the created VertexData
  122930. */
  122931. buildVertexData(depth?: number): VertexData;
  122932. /**
  122933. * Adds a side to the polygon
  122934. * @param positions points that make the polygon
  122935. * @param normals normals of the polygon
  122936. * @param uvs uvs of the polygon
  122937. * @param indices indices of the polygon
  122938. * @param bounds bounds of the polygon
  122939. * @param points points of the polygon
  122940. * @param depth depth of the polygon
  122941. * @param flip flip of the polygon
  122942. */
  122943. private addSide;
  122944. }
  122945. }
  122946. declare module BABYLON {
  122947. /**
  122948. * Class containing static functions to help procedurally build meshes
  122949. */
  122950. export class PolygonBuilder {
  122951. /**
  122952. * Creates a polygon mesh
  122953. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122954. * * 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
  122955. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122958. * * Remember you can only change the shape positions, not their number when updating a polygon
  122959. * @param name defines the name of the mesh
  122960. * @param options defines the options used to create the mesh
  122961. * @param scene defines the hosting scene
  122962. * @param earcutInjection can be used to inject your own earcut reference
  122963. * @returns the polygon mesh
  122964. */
  122965. static CreatePolygon(name: string, options: {
  122966. shape: Vector3[];
  122967. holes?: Vector3[][];
  122968. depth?: number;
  122969. faceUV?: Vector4[];
  122970. faceColors?: Color4[];
  122971. updatable?: boolean;
  122972. sideOrientation?: number;
  122973. frontUVs?: Vector4;
  122974. backUVs?: Vector4;
  122975. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122976. /**
  122977. * Creates an extruded polygon mesh, with depth in the Y direction.
  122978. * * 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)
  122979. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122980. * @param name defines the name of the mesh
  122981. * @param options defines the options used to create the mesh
  122982. * @param scene defines the hosting scene
  122983. * @param earcutInjection can be used to inject your own earcut reference
  122984. * @returns the polygon mesh
  122985. */
  122986. static ExtrudePolygon(name: string, options: {
  122987. shape: Vector3[];
  122988. holes?: Vector3[][];
  122989. depth?: number;
  122990. faceUV?: Vector4[];
  122991. faceColors?: Color4[];
  122992. updatable?: boolean;
  122993. sideOrientation?: number;
  122994. frontUVs?: Vector4;
  122995. backUVs?: Vector4;
  122996. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122997. }
  122998. }
  122999. declare module BABYLON {
  123000. /**
  123001. * Class containing static functions to help procedurally build meshes
  123002. */
  123003. export class LatheBuilder {
  123004. /**
  123005. * Creates lathe mesh.
  123006. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123007. * * 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
  123008. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123009. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123010. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123011. * * 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
  123012. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123013. * * 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
  123014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123018. * @param name defines the name of the mesh
  123019. * @param options defines the options used to create the mesh
  123020. * @param scene defines the hosting scene
  123021. * @returns the lathe mesh
  123022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123023. */
  123024. static CreateLathe(name: string, options: {
  123025. shape: Vector3[];
  123026. radius?: number;
  123027. tessellation?: number;
  123028. clip?: number;
  123029. arc?: number;
  123030. closed?: boolean;
  123031. updatable?: boolean;
  123032. sideOrientation?: number;
  123033. frontUVs?: Vector4;
  123034. backUVs?: Vector4;
  123035. cap?: number;
  123036. invertUV?: boolean;
  123037. }, scene?: Nullable<Scene>): Mesh;
  123038. }
  123039. }
  123040. declare module BABYLON {
  123041. /**
  123042. * Class containing static functions to help procedurally build meshes
  123043. */
  123044. export class TiledPlaneBuilder {
  123045. /**
  123046. * Creates a tiled plane mesh
  123047. * * The parameter `pattern` will, depending on value, do nothing or
  123048. * * * flip (reflect about central vertical) alternate tiles across and up
  123049. * * * flip every tile on alternate rows
  123050. * * * rotate (180 degs) alternate tiles across and up
  123051. * * * rotate every tile on alternate rows
  123052. * * * flip and rotate alternate tiles across and up
  123053. * * * flip and rotate every tile on alternate rows
  123054. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123055. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123057. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123058. * * 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)
  123059. * * 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)
  123060. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123061. * @param name defines the name of the mesh
  123062. * @param options defines the options used to create the mesh
  123063. * @param scene defines the hosting scene
  123064. * @returns the box mesh
  123065. */
  123066. static CreateTiledPlane(name: string, options: {
  123067. pattern?: number;
  123068. tileSize?: number;
  123069. tileWidth?: number;
  123070. tileHeight?: number;
  123071. size?: number;
  123072. width?: number;
  123073. height?: number;
  123074. alignHorizontal?: number;
  123075. alignVertical?: number;
  123076. sideOrientation?: number;
  123077. frontUVs?: Vector4;
  123078. backUVs?: Vector4;
  123079. updatable?: boolean;
  123080. }, scene?: Nullable<Scene>): Mesh;
  123081. }
  123082. }
  123083. declare module BABYLON {
  123084. /**
  123085. * Class containing static functions to help procedurally build meshes
  123086. */
  123087. export class TubeBuilder {
  123088. /**
  123089. * Creates a tube mesh.
  123090. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123091. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123092. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123093. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123094. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123095. * * 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)
  123096. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123097. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  123098. * * 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
  123099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123103. * @param name defines the name of the mesh
  123104. * @param options defines the options used to create the mesh
  123105. * @param scene defines the hosting scene
  123106. * @returns the tube mesh
  123107. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123108. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123109. */
  123110. static CreateTube(name: string, options: {
  123111. path: Vector3[];
  123112. radius?: number;
  123113. tessellation?: number;
  123114. radiusFunction?: {
  123115. (i: number, distance: number): number;
  123116. };
  123117. cap?: number;
  123118. arc?: number;
  123119. updatable?: boolean;
  123120. sideOrientation?: number;
  123121. frontUVs?: Vector4;
  123122. backUVs?: Vector4;
  123123. instance?: Mesh;
  123124. invertUV?: boolean;
  123125. }, scene?: Nullable<Scene>): Mesh;
  123126. }
  123127. }
  123128. declare module BABYLON {
  123129. /**
  123130. * Class containing static functions to help procedurally build meshes
  123131. */
  123132. export class IcoSphereBuilder {
  123133. /**
  123134. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123135. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123136. * * 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`)
  123137. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123138. * * 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
  123139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123142. * @param name defines the name of the mesh
  123143. * @param options defines the options used to create the mesh
  123144. * @param scene defines the hosting scene
  123145. * @returns the icosahedron mesh
  123146. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123147. */
  123148. static CreateIcoSphere(name: string, options: {
  123149. radius?: number;
  123150. radiusX?: number;
  123151. radiusY?: number;
  123152. radiusZ?: number;
  123153. flat?: boolean;
  123154. subdivisions?: number;
  123155. sideOrientation?: number;
  123156. frontUVs?: Vector4;
  123157. backUVs?: Vector4;
  123158. updatable?: boolean;
  123159. }, scene?: Nullable<Scene>): Mesh;
  123160. }
  123161. }
  123162. declare module BABYLON {
  123163. /**
  123164. * Class containing static functions to help procedurally build meshes
  123165. */
  123166. export class DecalBuilder {
  123167. /**
  123168. * Creates a decal mesh.
  123169. * 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
  123170. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123171. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123172. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123173. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123174. * @param name defines the name of the mesh
  123175. * @param sourceMesh defines the mesh where the decal must be applied
  123176. * @param options defines the options used to create the mesh
  123177. * @param scene defines the hosting scene
  123178. * @returns the decal mesh
  123179. * @see https://doc.babylonjs.com/how_to/decals
  123180. */
  123181. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123182. position?: Vector3;
  123183. normal?: Vector3;
  123184. size?: Vector3;
  123185. angle?: number;
  123186. }): Mesh;
  123187. }
  123188. }
  123189. declare module BABYLON {
  123190. /**
  123191. * Class containing static functions to help procedurally build meshes
  123192. */
  123193. export class MeshBuilder {
  123194. /**
  123195. * Creates a box mesh
  123196. * * The parameter `size` sets the size (float) of each box side (default 1)
  123197. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123198. * * 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)
  123199. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123200. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123201. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123203. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123204. * @param name defines the name of the mesh
  123205. * @param options defines the options used to create the mesh
  123206. * @param scene defines the hosting scene
  123207. * @returns the box mesh
  123208. */
  123209. static CreateBox(name: string, options: {
  123210. size?: number;
  123211. width?: number;
  123212. height?: number;
  123213. depth?: number;
  123214. faceUV?: Vector4[];
  123215. faceColors?: Color4[];
  123216. sideOrientation?: number;
  123217. frontUVs?: Vector4;
  123218. backUVs?: Vector4;
  123219. updatable?: boolean;
  123220. }, scene?: Nullable<Scene>): Mesh;
  123221. /**
  123222. * Creates a tiled box mesh
  123223. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123225. * @param name defines the name of the mesh
  123226. * @param options defines the options used to create the mesh
  123227. * @param scene defines the hosting scene
  123228. * @returns the tiled box mesh
  123229. */
  123230. static CreateTiledBox(name: string, options: {
  123231. pattern?: number;
  123232. size?: number;
  123233. width?: number;
  123234. height?: number;
  123235. depth: number;
  123236. tileSize?: number;
  123237. tileWidth?: number;
  123238. tileHeight?: number;
  123239. faceUV?: Vector4[];
  123240. faceColors?: Color4[];
  123241. alignHorizontal?: number;
  123242. alignVertical?: number;
  123243. sideOrientation?: number;
  123244. updatable?: boolean;
  123245. }, scene?: Nullable<Scene>): Mesh;
  123246. /**
  123247. * Creates a sphere mesh
  123248. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123249. * * 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`)
  123250. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123251. * * 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
  123252. * * 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)
  123253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123256. * @param name defines the name of the mesh
  123257. * @param options defines the options used to create the mesh
  123258. * @param scene defines the hosting scene
  123259. * @returns the sphere mesh
  123260. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123261. */
  123262. static CreateSphere(name: string, options: {
  123263. segments?: number;
  123264. diameter?: number;
  123265. diameterX?: number;
  123266. diameterY?: number;
  123267. diameterZ?: number;
  123268. arc?: number;
  123269. slice?: number;
  123270. sideOrientation?: number;
  123271. frontUVs?: Vector4;
  123272. backUVs?: Vector4;
  123273. updatable?: boolean;
  123274. }, scene?: Nullable<Scene>): Mesh;
  123275. /**
  123276. * Creates a plane polygonal mesh. By default, this is a disc
  123277. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123278. * * 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
  123279. * * 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
  123280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123283. * @param name defines the name of the mesh
  123284. * @param options defines the options used to create the mesh
  123285. * @param scene defines the hosting scene
  123286. * @returns the plane polygonal mesh
  123287. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123288. */
  123289. static CreateDisc(name: string, options: {
  123290. radius?: number;
  123291. tessellation?: number;
  123292. arc?: number;
  123293. updatable?: boolean;
  123294. sideOrientation?: number;
  123295. frontUVs?: Vector4;
  123296. backUVs?: Vector4;
  123297. }, scene?: Nullable<Scene>): Mesh;
  123298. /**
  123299. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123300. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123301. * * 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`)
  123302. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123303. * * 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
  123304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123307. * @param name defines the name of the mesh
  123308. * @param options defines the options used to create the mesh
  123309. * @param scene defines the hosting scene
  123310. * @returns the icosahedron mesh
  123311. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123312. */
  123313. static CreateIcoSphere(name: string, options: {
  123314. radius?: number;
  123315. radiusX?: number;
  123316. radiusY?: number;
  123317. radiusZ?: number;
  123318. flat?: boolean;
  123319. subdivisions?: number;
  123320. sideOrientation?: number;
  123321. frontUVs?: Vector4;
  123322. backUVs?: Vector4;
  123323. updatable?: boolean;
  123324. }, scene?: Nullable<Scene>): Mesh;
  123325. /**
  123326. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123327. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123328. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123329. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123330. * * 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
  123331. * * 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
  123332. * * 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
  123333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123336. * * 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
  123337. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123338. * * 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
  123339. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123341. * @param name defines the name of the mesh
  123342. * @param options defines the options used to create the mesh
  123343. * @param scene defines the hosting scene
  123344. * @returns the ribbon mesh
  123345. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123346. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123347. */
  123348. static CreateRibbon(name: string, options: {
  123349. pathArray: Vector3[][];
  123350. closeArray?: boolean;
  123351. closePath?: boolean;
  123352. offset?: number;
  123353. updatable?: boolean;
  123354. sideOrientation?: number;
  123355. frontUVs?: Vector4;
  123356. backUVs?: Vector4;
  123357. instance?: Mesh;
  123358. invertUV?: boolean;
  123359. uvs?: Vector2[];
  123360. colors?: Color4[];
  123361. }, scene?: Nullable<Scene>): Mesh;
  123362. /**
  123363. * Creates a cylinder or a cone mesh
  123364. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123365. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123366. * * 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.
  123367. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123368. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123369. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123370. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123371. * * 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).
  123372. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123373. * * 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).
  123374. * * 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
  123375. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123376. * * 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
  123377. * * 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.
  123378. * * If `enclose` is false, a ring surface is one element.
  123379. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123380. * * 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
  123381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123382. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123384. * @param name defines the name of the mesh
  123385. * @param options defines the options used to create the mesh
  123386. * @param scene defines the hosting scene
  123387. * @returns the cylinder mesh
  123388. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123389. */
  123390. static CreateCylinder(name: string, options: {
  123391. height?: number;
  123392. diameterTop?: number;
  123393. diameterBottom?: number;
  123394. diameter?: number;
  123395. tessellation?: number;
  123396. subdivisions?: number;
  123397. arc?: number;
  123398. faceColors?: Color4[];
  123399. faceUV?: Vector4[];
  123400. updatable?: boolean;
  123401. hasRings?: boolean;
  123402. enclose?: boolean;
  123403. cap?: number;
  123404. sideOrientation?: number;
  123405. frontUVs?: Vector4;
  123406. backUVs?: Vector4;
  123407. }, scene?: Nullable<Scene>): Mesh;
  123408. /**
  123409. * Creates a torus mesh
  123410. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123411. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123412. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123413. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123414. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123416. * @param name defines the name of the mesh
  123417. * @param options defines the options used to create the mesh
  123418. * @param scene defines the hosting scene
  123419. * @returns the torus mesh
  123420. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123421. */
  123422. static CreateTorus(name: string, options: {
  123423. diameter?: number;
  123424. thickness?: number;
  123425. tessellation?: number;
  123426. updatable?: boolean;
  123427. sideOrientation?: number;
  123428. frontUVs?: Vector4;
  123429. backUVs?: Vector4;
  123430. }, scene?: Nullable<Scene>): Mesh;
  123431. /**
  123432. * Creates a torus knot mesh
  123433. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123434. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123435. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123436. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123438. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123440. * @param name defines the name of the mesh
  123441. * @param options defines the options used to create the mesh
  123442. * @param scene defines the hosting scene
  123443. * @returns the torus knot mesh
  123444. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123445. */
  123446. static CreateTorusKnot(name: string, options: {
  123447. radius?: number;
  123448. tube?: number;
  123449. radialSegments?: number;
  123450. tubularSegments?: number;
  123451. p?: number;
  123452. q?: number;
  123453. updatable?: boolean;
  123454. sideOrientation?: number;
  123455. frontUVs?: Vector4;
  123456. backUVs?: Vector4;
  123457. }, scene?: Nullable<Scene>): Mesh;
  123458. /**
  123459. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123460. * * 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
  123461. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123462. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123463. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123464. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123465. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123466. * * 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
  123467. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123469. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123470. * @param name defines the name of the new line system
  123471. * @param options defines the options used to create the line system
  123472. * @param scene defines the hosting scene
  123473. * @returns a new line system mesh
  123474. */
  123475. static CreateLineSystem(name: string, options: {
  123476. lines: Vector3[][];
  123477. updatable?: boolean;
  123478. instance?: Nullable<LinesMesh>;
  123479. colors?: Nullable<Color4[][]>;
  123480. useVertexAlpha?: boolean;
  123481. }, scene: Nullable<Scene>): LinesMesh;
  123482. /**
  123483. * Creates a line mesh
  123484. * 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
  123485. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123486. * * The parameter `points` is an array successive Vector3
  123487. * * 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
  123488. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123489. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123490. * * When updating an instance, remember that only point positions can change, not the number of points
  123491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123493. * @param name defines the name of the new line system
  123494. * @param options defines the options used to create the line system
  123495. * @param scene defines the hosting scene
  123496. * @returns a new line mesh
  123497. */
  123498. static CreateLines(name: string, options: {
  123499. points: Vector3[];
  123500. updatable?: boolean;
  123501. instance?: Nullable<LinesMesh>;
  123502. colors?: Color4[];
  123503. useVertexAlpha?: boolean;
  123504. }, scene?: Nullable<Scene>): LinesMesh;
  123505. /**
  123506. * Creates a dashed line mesh
  123507. * * 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
  123508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123509. * * The parameter `points` is an array successive Vector3
  123510. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123511. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123512. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123513. * * 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
  123514. * * When updating an instance, remember that only point positions can change, not the number of points
  123515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123516. * @param name defines the name of the mesh
  123517. * @param options defines the options used to create the mesh
  123518. * @param scene defines the hosting scene
  123519. * @returns the dashed line mesh
  123520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123521. */
  123522. static CreateDashedLines(name: string, options: {
  123523. points: Vector3[];
  123524. dashSize?: number;
  123525. gapSize?: number;
  123526. dashNb?: number;
  123527. updatable?: boolean;
  123528. instance?: LinesMesh;
  123529. }, scene?: Nullable<Scene>): LinesMesh;
  123530. /**
  123531. * 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.
  123532. * * 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.
  123533. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123534. * * 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.
  123535. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123536. * * 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
  123537. * * 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
  123538. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123543. * @param name defines the name of the mesh
  123544. * @param options defines the options used to create the mesh
  123545. * @param scene defines the hosting scene
  123546. * @returns the extruded shape mesh
  123547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123549. */
  123550. static ExtrudeShape(name: string, options: {
  123551. shape: Vector3[];
  123552. path: Vector3[];
  123553. scale?: number;
  123554. rotation?: number;
  123555. cap?: number;
  123556. updatable?: boolean;
  123557. sideOrientation?: number;
  123558. frontUVs?: Vector4;
  123559. backUVs?: Vector4;
  123560. instance?: Mesh;
  123561. invertUV?: boolean;
  123562. }, scene?: Nullable<Scene>): Mesh;
  123563. /**
  123564. * Creates an custom extruded shape mesh.
  123565. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123566. * * 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.
  123567. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123568. * * 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
  123569. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123570. * * 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
  123571. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123572. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123573. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123574. * * 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
  123575. * * 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
  123576. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123581. * @param name defines the name of the mesh
  123582. * @param options defines the options used to create the mesh
  123583. * @param scene defines the hosting scene
  123584. * @returns the custom extruded shape mesh
  123585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123588. */
  123589. static ExtrudeShapeCustom(name: string, options: {
  123590. shape: Vector3[];
  123591. path: Vector3[];
  123592. scaleFunction?: any;
  123593. rotationFunction?: any;
  123594. ribbonCloseArray?: boolean;
  123595. ribbonClosePath?: boolean;
  123596. cap?: number;
  123597. updatable?: boolean;
  123598. sideOrientation?: number;
  123599. frontUVs?: Vector4;
  123600. backUVs?: Vector4;
  123601. instance?: Mesh;
  123602. invertUV?: boolean;
  123603. }, scene?: Nullable<Scene>): Mesh;
  123604. /**
  123605. * Creates lathe mesh.
  123606. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123607. * * 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
  123608. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123609. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123610. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123611. * * 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
  123612. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123613. * * 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
  123614. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123615. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123616. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123618. * @param name defines the name of the mesh
  123619. * @param options defines the options used to create the mesh
  123620. * @param scene defines the hosting scene
  123621. * @returns the lathe mesh
  123622. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123623. */
  123624. static CreateLathe(name: string, options: {
  123625. shape: Vector3[];
  123626. radius?: number;
  123627. tessellation?: number;
  123628. clip?: number;
  123629. arc?: number;
  123630. closed?: boolean;
  123631. updatable?: boolean;
  123632. sideOrientation?: number;
  123633. frontUVs?: Vector4;
  123634. backUVs?: Vector4;
  123635. cap?: number;
  123636. invertUV?: boolean;
  123637. }, scene?: Nullable<Scene>): Mesh;
  123638. /**
  123639. * Creates a tiled plane mesh
  123640. * * You can set a limited pattern arrangement with the tiles
  123641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123644. * @param name defines the name of the mesh
  123645. * @param options defines the options used to create the mesh
  123646. * @param scene defines the hosting scene
  123647. * @returns the plane mesh
  123648. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123649. */
  123650. static CreateTiledPlane(name: string, options: {
  123651. pattern?: number;
  123652. tileSize?: number;
  123653. tileWidth?: number;
  123654. tileHeight?: number;
  123655. size?: number;
  123656. width?: number;
  123657. height?: number;
  123658. alignHorizontal?: number;
  123659. alignVertical?: number;
  123660. sideOrientation?: number;
  123661. frontUVs?: Vector4;
  123662. backUVs?: Vector4;
  123663. updatable?: boolean;
  123664. }, scene?: Nullable<Scene>): Mesh;
  123665. /**
  123666. * Creates a plane mesh
  123667. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123668. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123669. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123673. * @param name defines the name of the mesh
  123674. * @param options defines the options used to create the mesh
  123675. * @param scene defines the hosting scene
  123676. * @returns the plane mesh
  123677. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123678. */
  123679. static CreatePlane(name: string, options: {
  123680. size?: number;
  123681. width?: number;
  123682. height?: number;
  123683. sideOrientation?: number;
  123684. frontUVs?: Vector4;
  123685. backUVs?: Vector4;
  123686. updatable?: boolean;
  123687. sourcePlane?: Plane;
  123688. }, scene?: Nullable<Scene>): Mesh;
  123689. /**
  123690. * Creates a ground mesh
  123691. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123692. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123694. * @param name defines the name of the mesh
  123695. * @param options defines the options used to create the mesh
  123696. * @param scene defines the hosting scene
  123697. * @returns the ground mesh
  123698. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123699. */
  123700. static CreateGround(name: string, options: {
  123701. width?: number;
  123702. height?: number;
  123703. subdivisions?: number;
  123704. subdivisionsX?: number;
  123705. subdivisionsY?: number;
  123706. updatable?: boolean;
  123707. }, scene?: Nullable<Scene>): Mesh;
  123708. /**
  123709. * Creates a tiled ground mesh
  123710. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123711. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123712. * * 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
  123713. * * 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
  123714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123715. * @param name defines the name of the mesh
  123716. * @param options defines the options used to create the mesh
  123717. * @param scene defines the hosting scene
  123718. * @returns the tiled ground mesh
  123719. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123720. */
  123721. static CreateTiledGround(name: string, options: {
  123722. xmin: number;
  123723. zmin: number;
  123724. xmax: number;
  123725. zmax: number;
  123726. subdivisions?: {
  123727. w: number;
  123728. h: number;
  123729. };
  123730. precision?: {
  123731. w: number;
  123732. h: number;
  123733. };
  123734. updatable?: boolean;
  123735. }, scene?: Nullable<Scene>): Mesh;
  123736. /**
  123737. * Creates a ground mesh from a height map
  123738. * * The parameter `url` sets the URL of the height map image resource.
  123739. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123740. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123741. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123742. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123743. * * 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.
  123744. * * 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).
  123745. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123747. * @param name defines the name of the mesh
  123748. * @param url defines the url to the height map
  123749. * @param options defines the options used to create the mesh
  123750. * @param scene defines the hosting scene
  123751. * @returns the ground mesh
  123752. * @see https://doc.babylonjs.com/babylon101/height_map
  123753. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123754. */
  123755. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123756. width?: number;
  123757. height?: number;
  123758. subdivisions?: number;
  123759. minHeight?: number;
  123760. maxHeight?: number;
  123761. colorFilter?: Color3;
  123762. alphaFilter?: number;
  123763. updatable?: boolean;
  123764. onReady?: (mesh: GroundMesh) => void;
  123765. }, scene?: Nullable<Scene>): GroundMesh;
  123766. /**
  123767. * Creates a polygon mesh
  123768. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123769. * * 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
  123770. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123773. * * Remember you can only change the shape positions, not their number when updating a polygon
  123774. * @param name defines the name of the mesh
  123775. * @param options defines the options used to create the mesh
  123776. * @param scene defines the hosting scene
  123777. * @param earcutInjection can be used to inject your own earcut reference
  123778. * @returns the polygon mesh
  123779. */
  123780. static CreatePolygon(name: string, options: {
  123781. shape: Vector3[];
  123782. holes?: Vector3[][];
  123783. depth?: number;
  123784. faceUV?: Vector4[];
  123785. faceColors?: Color4[];
  123786. updatable?: boolean;
  123787. sideOrientation?: number;
  123788. frontUVs?: Vector4;
  123789. backUVs?: Vector4;
  123790. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123791. /**
  123792. * Creates an extruded polygon mesh, with depth in the Y direction.
  123793. * * 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)
  123794. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123795. * @param name defines the name of the mesh
  123796. * @param options defines the options used to create the mesh
  123797. * @param scene defines the hosting scene
  123798. * @param earcutInjection can be used to inject your own earcut reference
  123799. * @returns the polygon mesh
  123800. */
  123801. static ExtrudePolygon(name: string, options: {
  123802. shape: Vector3[];
  123803. holes?: Vector3[][];
  123804. depth?: number;
  123805. faceUV?: Vector4[];
  123806. faceColors?: Color4[];
  123807. updatable?: boolean;
  123808. sideOrientation?: number;
  123809. frontUVs?: Vector4;
  123810. backUVs?: Vector4;
  123811. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123812. /**
  123813. * Creates a tube mesh.
  123814. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123815. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123816. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123817. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123818. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123819. * * 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)
  123820. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123821. * * 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
  123822. * * 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
  123823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123827. * @param name defines the name of the mesh
  123828. * @param options defines the options used to create the mesh
  123829. * @param scene defines the hosting scene
  123830. * @returns the tube mesh
  123831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123832. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123833. */
  123834. static CreateTube(name: string, options: {
  123835. path: Vector3[];
  123836. radius?: number;
  123837. tessellation?: number;
  123838. radiusFunction?: {
  123839. (i: number, distance: number): number;
  123840. };
  123841. cap?: number;
  123842. arc?: number;
  123843. updatable?: boolean;
  123844. sideOrientation?: number;
  123845. frontUVs?: Vector4;
  123846. backUVs?: Vector4;
  123847. instance?: Mesh;
  123848. invertUV?: boolean;
  123849. }, scene?: Nullable<Scene>): Mesh;
  123850. /**
  123851. * Creates a polyhedron mesh
  123852. * * 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
  123853. * * The parameter `size` (positive float, default 1) sets the polygon size
  123854. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123855. * * 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`
  123856. * * 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
  123857. * * 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)`)
  123858. * * 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
  123859. * * 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
  123860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123863. * @param name defines the name of the mesh
  123864. * @param options defines the options used to create the mesh
  123865. * @param scene defines the hosting scene
  123866. * @returns the polyhedron mesh
  123867. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123868. */
  123869. static CreatePolyhedron(name: string, options: {
  123870. type?: number;
  123871. size?: number;
  123872. sizeX?: number;
  123873. sizeY?: number;
  123874. sizeZ?: number;
  123875. custom?: any;
  123876. faceUV?: Vector4[];
  123877. faceColors?: Color4[];
  123878. flat?: boolean;
  123879. updatable?: boolean;
  123880. sideOrientation?: number;
  123881. frontUVs?: Vector4;
  123882. backUVs?: Vector4;
  123883. }, scene?: Nullable<Scene>): Mesh;
  123884. /**
  123885. * Creates a decal mesh.
  123886. * 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
  123887. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123888. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123889. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123890. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123891. * @param name defines the name of the mesh
  123892. * @param sourceMesh defines the mesh where the decal must be applied
  123893. * @param options defines the options used to create the mesh
  123894. * @param scene defines the hosting scene
  123895. * @returns the decal mesh
  123896. * @see https://doc.babylonjs.com/how_to/decals
  123897. */
  123898. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123899. position?: Vector3;
  123900. normal?: Vector3;
  123901. size?: Vector3;
  123902. angle?: number;
  123903. }): Mesh;
  123904. }
  123905. }
  123906. declare module BABYLON {
  123907. /**
  123908. * A simplifier interface for future simplification implementations
  123909. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123910. */
  123911. export interface ISimplifier {
  123912. /**
  123913. * Simplification of a given mesh according to the given settings.
  123914. * Since this requires computation, it is assumed that the function runs async.
  123915. * @param settings The settings of the simplification, including quality and distance
  123916. * @param successCallback A callback that will be called after the mesh was simplified.
  123917. * @param errorCallback in case of an error, this callback will be called. optional.
  123918. */
  123919. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123920. }
  123921. /**
  123922. * Expected simplification settings.
  123923. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123924. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123925. */
  123926. export interface ISimplificationSettings {
  123927. /**
  123928. * Gets or sets the expected quality
  123929. */
  123930. quality: number;
  123931. /**
  123932. * Gets or sets the distance when this optimized version should be used
  123933. */
  123934. distance: number;
  123935. /**
  123936. * Gets an already optimized mesh
  123937. */
  123938. optimizeMesh?: boolean;
  123939. }
  123940. /**
  123941. * Class used to specify simplification options
  123942. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123943. */
  123944. export class SimplificationSettings implements ISimplificationSettings {
  123945. /** expected quality */
  123946. quality: number;
  123947. /** distance when this optimized version should be used */
  123948. distance: number;
  123949. /** already optimized mesh */
  123950. optimizeMesh?: boolean | undefined;
  123951. /**
  123952. * Creates a SimplificationSettings
  123953. * @param quality expected quality
  123954. * @param distance distance when this optimized version should be used
  123955. * @param optimizeMesh already optimized mesh
  123956. */
  123957. constructor(
  123958. /** expected quality */
  123959. quality: number,
  123960. /** distance when this optimized version should be used */
  123961. distance: number,
  123962. /** already optimized mesh */
  123963. optimizeMesh?: boolean | undefined);
  123964. }
  123965. /**
  123966. * Interface used to define a simplification task
  123967. */
  123968. export interface ISimplificationTask {
  123969. /**
  123970. * Array of settings
  123971. */
  123972. settings: Array<ISimplificationSettings>;
  123973. /**
  123974. * Simplification type
  123975. */
  123976. simplificationType: SimplificationType;
  123977. /**
  123978. * Mesh to simplify
  123979. */
  123980. mesh: Mesh;
  123981. /**
  123982. * Callback called on success
  123983. */
  123984. successCallback?: () => void;
  123985. /**
  123986. * Defines if parallel processing can be used
  123987. */
  123988. parallelProcessing: boolean;
  123989. }
  123990. /**
  123991. * Queue used to order the simplification tasks
  123992. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123993. */
  123994. export class SimplificationQueue {
  123995. private _simplificationArray;
  123996. /**
  123997. * Gets a boolean indicating that the process is still running
  123998. */
  123999. running: boolean;
  124000. /**
  124001. * Creates a new queue
  124002. */
  124003. constructor();
  124004. /**
  124005. * Adds a new simplification task
  124006. * @param task defines a task to add
  124007. */
  124008. addTask(task: ISimplificationTask): void;
  124009. /**
  124010. * Execute next task
  124011. */
  124012. executeNext(): void;
  124013. /**
  124014. * Execute a simplification task
  124015. * @param task defines the task to run
  124016. */
  124017. runSimplification(task: ISimplificationTask): void;
  124018. private getSimplifier;
  124019. }
  124020. /**
  124021. * The implemented types of simplification
  124022. * At the moment only Quadratic Error Decimation is implemented
  124023. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124024. */
  124025. export enum SimplificationType {
  124026. /** Quadratic error decimation */
  124027. QUADRATIC = 0
  124028. }
  124029. }
  124030. declare module BABYLON {
  124031. interface Scene {
  124032. /** @hidden (Backing field) */
  124033. _simplificationQueue: SimplificationQueue;
  124034. /**
  124035. * Gets or sets the simplification queue attached to the scene
  124036. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124037. */
  124038. simplificationQueue: SimplificationQueue;
  124039. }
  124040. interface Mesh {
  124041. /**
  124042. * Simplify the mesh according to the given array of settings.
  124043. * Function will return immediately and will simplify async
  124044. * @param settings a collection of simplification settings
  124045. * @param parallelProcessing should all levels calculate parallel or one after the other
  124046. * @param simplificationType the type of simplification to run
  124047. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124048. * @returns the current mesh
  124049. */
  124050. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124051. }
  124052. /**
  124053. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124054. * created in a scene
  124055. */
  124056. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124057. /**
  124058. * The component name helpfull to identify the component in the list of scene components.
  124059. */
  124060. readonly name: string;
  124061. /**
  124062. * The scene the component belongs to.
  124063. */
  124064. scene: Scene;
  124065. /**
  124066. * Creates a new instance of the component for the given scene
  124067. * @param scene Defines the scene to register the component in
  124068. */
  124069. constructor(scene: Scene);
  124070. /**
  124071. * Registers the component in a given scene
  124072. */
  124073. register(): void;
  124074. /**
  124075. * Rebuilds the elements related to this component in case of
  124076. * context lost for instance.
  124077. */
  124078. rebuild(): void;
  124079. /**
  124080. * Disposes the component and the associated ressources
  124081. */
  124082. dispose(): void;
  124083. private _beforeCameraUpdate;
  124084. }
  124085. }
  124086. declare module BABYLON {
  124087. /**
  124088. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124089. */
  124090. export interface INavigationEnginePlugin {
  124091. /**
  124092. * plugin name
  124093. */
  124094. name: string;
  124095. /**
  124096. * Creates a navigation mesh
  124097. * @param meshes array of all the geometry used to compute the navigatio mesh
  124098. * @param parameters bunch of parameters used to filter geometry
  124099. */
  124100. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124101. /**
  124102. * Create a navigation mesh debug mesh
  124103. * @param scene is where the mesh will be added
  124104. * @returns debug display mesh
  124105. */
  124106. createDebugNavMesh(scene: Scene): Mesh;
  124107. /**
  124108. * Get a navigation mesh constrained position, closest to the parameter position
  124109. * @param position world position
  124110. * @returns the closest point to position constrained by the navigation mesh
  124111. */
  124112. getClosestPoint(position: Vector3): Vector3;
  124113. /**
  124114. * Get a navigation mesh constrained position, within a particular radius
  124115. * @param position world position
  124116. * @param maxRadius the maximum distance to the constrained world position
  124117. * @returns the closest point to position constrained by the navigation mesh
  124118. */
  124119. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124120. /**
  124121. * Compute the final position from a segment made of destination-position
  124122. * @param position world position
  124123. * @param destination world position
  124124. * @returns the resulting point along the navmesh
  124125. */
  124126. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124127. /**
  124128. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124129. * @param start world position
  124130. * @param end world position
  124131. * @returns array containing world position composing the path
  124132. */
  124133. computePath(start: Vector3, end: Vector3): Vector3[];
  124134. /**
  124135. * If this plugin is supported
  124136. * @returns true if plugin is supported
  124137. */
  124138. isSupported(): boolean;
  124139. /**
  124140. * Create a new Crowd so you can add agents
  124141. * @param maxAgents the maximum agent count in the crowd
  124142. * @param maxAgentRadius the maximum radius an agent can have
  124143. * @param scene to attach the crowd to
  124144. * @returns the crowd you can add agents to
  124145. */
  124146. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124147. /**
  124148. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124149. * The queries will try to find a solution within those bounds
  124150. * default is (1,1,1)
  124151. * @param extent x,y,z value that define the extent around the queries point of reference
  124152. */
  124153. setDefaultQueryExtent(extent: Vector3): void;
  124154. /**
  124155. * Get the Bounding box extent specified by setDefaultQueryExtent
  124156. * @returns the box extent values
  124157. */
  124158. getDefaultQueryExtent(): Vector3;
  124159. /**
  124160. * Release all resources
  124161. */
  124162. dispose(): void;
  124163. }
  124164. /**
  124165. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124166. */
  124167. export interface ICrowd {
  124168. /**
  124169. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124170. * You can attach anything to that node. The node position is updated in the scene update tick.
  124171. * @param pos world position that will be constrained by the navigation mesh
  124172. * @param parameters agent parameters
  124173. * @param transform hooked to the agent that will be update by the scene
  124174. * @returns agent index
  124175. */
  124176. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124177. /**
  124178. * Returns the agent position in world space
  124179. * @param index agent index returned by addAgent
  124180. * @returns world space position
  124181. */
  124182. getAgentPosition(index: number): Vector3;
  124183. /**
  124184. * Gets the agent velocity in world space
  124185. * @param index agent index returned by addAgent
  124186. * @returns world space velocity
  124187. */
  124188. getAgentVelocity(index: number): Vector3;
  124189. /**
  124190. * remove a particular agent previously created
  124191. * @param index agent index returned by addAgent
  124192. */
  124193. removeAgent(index: number): void;
  124194. /**
  124195. * get the list of all agents attached to this crowd
  124196. * @returns list of agent indices
  124197. */
  124198. getAgents(): number[];
  124199. /**
  124200. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124201. * @param deltaTime in seconds
  124202. */
  124203. update(deltaTime: number): void;
  124204. /**
  124205. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124206. * @param index agent index returned by addAgent
  124207. * @param destination targeted world position
  124208. */
  124209. agentGoto(index: number, destination: Vector3): void;
  124210. /**
  124211. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124212. * The queries will try to find a solution within those bounds
  124213. * default is (1,1,1)
  124214. * @param extent x,y,z value that define the extent around the queries point of reference
  124215. */
  124216. setDefaultQueryExtent(extent: Vector3): void;
  124217. /**
  124218. * Get the Bounding box extent specified by setDefaultQueryExtent
  124219. * @returns the box extent values
  124220. */
  124221. getDefaultQueryExtent(): Vector3;
  124222. /**
  124223. * Release all resources
  124224. */
  124225. dispose(): void;
  124226. }
  124227. /**
  124228. * Configures an agent
  124229. */
  124230. export interface IAgentParameters {
  124231. /**
  124232. * Agent radius. [Limit: >= 0]
  124233. */
  124234. radius: number;
  124235. /**
  124236. * Agent height. [Limit: > 0]
  124237. */
  124238. height: number;
  124239. /**
  124240. * Maximum allowed acceleration. [Limit: >= 0]
  124241. */
  124242. maxAcceleration: number;
  124243. /**
  124244. * Maximum allowed speed. [Limit: >= 0]
  124245. */
  124246. maxSpeed: number;
  124247. /**
  124248. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124249. */
  124250. collisionQueryRange: number;
  124251. /**
  124252. * The path visibility optimization range. [Limit: > 0]
  124253. */
  124254. pathOptimizationRange: number;
  124255. /**
  124256. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124257. */
  124258. separationWeight: number;
  124259. }
  124260. /**
  124261. * Configures the navigation mesh creation
  124262. */
  124263. export interface INavMeshParameters {
  124264. /**
  124265. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124266. */
  124267. cs: number;
  124268. /**
  124269. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124270. */
  124271. ch: number;
  124272. /**
  124273. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124274. */
  124275. walkableSlopeAngle: number;
  124276. /**
  124277. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124278. * be considered walkable. [Limit: >= 3] [Units: vx]
  124279. */
  124280. walkableHeight: number;
  124281. /**
  124282. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124283. */
  124284. walkableClimb: number;
  124285. /**
  124286. * The distance to erode/shrink the walkable area of the heightfield away from
  124287. * obstructions. [Limit: >=0] [Units: vx]
  124288. */
  124289. walkableRadius: number;
  124290. /**
  124291. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124292. */
  124293. maxEdgeLen: number;
  124294. /**
  124295. * The maximum distance a simplfied contour's border edges should deviate
  124296. * the original raw contour. [Limit: >=0] [Units: vx]
  124297. */
  124298. maxSimplificationError: number;
  124299. /**
  124300. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124301. */
  124302. minRegionArea: number;
  124303. /**
  124304. * Any regions with a span count smaller than this value will, if possible,
  124305. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124306. */
  124307. mergeRegionArea: number;
  124308. /**
  124309. * The maximum number of vertices allowed for polygons generated during the
  124310. * contour to polygon conversion process. [Limit: >= 3]
  124311. */
  124312. maxVertsPerPoly: number;
  124313. /**
  124314. * Sets the sampling distance to use when generating the detail mesh.
  124315. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124316. */
  124317. detailSampleDist: number;
  124318. /**
  124319. * The maximum distance the detail mesh surface should deviate from heightfield
  124320. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124321. */
  124322. detailSampleMaxError: number;
  124323. }
  124324. }
  124325. declare module BABYLON {
  124326. /**
  124327. * RecastJS navigation plugin
  124328. */
  124329. export class RecastJSPlugin implements INavigationEnginePlugin {
  124330. /**
  124331. * Reference to the Recast library
  124332. */
  124333. bjsRECAST: any;
  124334. /**
  124335. * plugin name
  124336. */
  124337. name: string;
  124338. /**
  124339. * the first navmesh created. We might extend this to support multiple navmeshes
  124340. */
  124341. navMesh: any;
  124342. /**
  124343. * Initializes the recastJS plugin
  124344. * @param recastInjection can be used to inject your own recast reference
  124345. */
  124346. constructor(recastInjection?: any);
  124347. /**
  124348. * Creates a navigation mesh
  124349. * @param meshes array of all the geometry used to compute the navigatio mesh
  124350. * @param parameters bunch of parameters used to filter geometry
  124351. */
  124352. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124353. /**
  124354. * Create a navigation mesh debug mesh
  124355. * @param scene is where the mesh will be added
  124356. * @returns debug display mesh
  124357. */
  124358. createDebugNavMesh(scene: Scene): Mesh;
  124359. /**
  124360. * Get a navigation mesh constrained position, closest to the parameter position
  124361. * @param position world position
  124362. * @returns the closest point to position constrained by the navigation mesh
  124363. */
  124364. getClosestPoint(position: Vector3): Vector3;
  124365. /**
  124366. * Get a navigation mesh constrained position, within a particular radius
  124367. * @param position world position
  124368. * @param maxRadius the maximum distance to the constrained world position
  124369. * @returns the closest point to position constrained by the navigation mesh
  124370. */
  124371. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124372. /**
  124373. * Compute the final position from a segment made of destination-position
  124374. * @param position world position
  124375. * @param destination world position
  124376. * @returns the resulting point along the navmesh
  124377. */
  124378. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124379. /**
  124380. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124381. * @param start world position
  124382. * @param end world position
  124383. * @returns array containing world position composing the path
  124384. */
  124385. computePath(start: Vector3, end: Vector3): Vector3[];
  124386. /**
  124387. * Create a new Crowd so you can add agents
  124388. * @param maxAgents the maximum agent count in the crowd
  124389. * @param maxAgentRadius the maximum radius an agent can have
  124390. * @param scene to attach the crowd to
  124391. * @returns the crowd you can add agents to
  124392. */
  124393. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124394. /**
  124395. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124396. * The queries will try to find a solution within those bounds
  124397. * default is (1,1,1)
  124398. * @param extent x,y,z value that define the extent around the queries point of reference
  124399. */
  124400. setDefaultQueryExtent(extent: Vector3): void;
  124401. /**
  124402. * Get the Bounding box extent specified by setDefaultQueryExtent
  124403. * @returns the box extent values
  124404. */
  124405. getDefaultQueryExtent(): Vector3;
  124406. /**
  124407. * Disposes
  124408. */
  124409. dispose(): void;
  124410. /**
  124411. * If this plugin is supported
  124412. * @returns true if plugin is supported
  124413. */
  124414. isSupported(): boolean;
  124415. }
  124416. /**
  124417. * Recast detour crowd implementation
  124418. */
  124419. export class RecastJSCrowd implements ICrowd {
  124420. /**
  124421. * Recast/detour plugin
  124422. */
  124423. bjsRECASTPlugin: RecastJSPlugin;
  124424. /**
  124425. * Link to the detour crowd
  124426. */
  124427. recastCrowd: any;
  124428. /**
  124429. * One transform per agent
  124430. */
  124431. transforms: TransformNode[];
  124432. /**
  124433. * All agents created
  124434. */
  124435. agents: number[];
  124436. /**
  124437. * Link to the scene is kept to unregister the crowd from the scene
  124438. */
  124439. private _scene;
  124440. /**
  124441. * Observer for crowd updates
  124442. */
  124443. private _onBeforeAnimationsObserver;
  124444. /**
  124445. * Constructor
  124446. * @param plugin recastJS plugin
  124447. * @param maxAgents the maximum agent count in the crowd
  124448. * @param maxAgentRadius the maximum radius an agent can have
  124449. * @param scene to attach the crowd to
  124450. * @returns the crowd you can add agents to
  124451. */
  124452. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124453. /**
  124454. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124455. * You can attach anything to that node. The node position is updated in the scene update tick.
  124456. * @param pos world position that will be constrained by the navigation mesh
  124457. * @param parameters agent parameters
  124458. * @param transform hooked to the agent that will be update by the scene
  124459. * @returns agent index
  124460. */
  124461. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124462. /**
  124463. * Returns the agent position in world space
  124464. * @param index agent index returned by addAgent
  124465. * @returns world space position
  124466. */
  124467. getAgentPosition(index: number): Vector3;
  124468. /**
  124469. * Returns the agent velocity in world space
  124470. * @param index agent index returned by addAgent
  124471. * @returns world space velocity
  124472. */
  124473. getAgentVelocity(index: number): Vector3;
  124474. /**
  124475. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124476. * @param index agent index returned by addAgent
  124477. * @param destination targeted world position
  124478. */
  124479. agentGoto(index: number, destination: Vector3): void;
  124480. /**
  124481. * remove a particular agent previously created
  124482. * @param index agent index returned by addAgent
  124483. */
  124484. removeAgent(index: number): void;
  124485. /**
  124486. * get the list of all agents attached to this crowd
  124487. * @returns list of agent indices
  124488. */
  124489. getAgents(): number[];
  124490. /**
  124491. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124492. * @param deltaTime in seconds
  124493. */
  124494. update(deltaTime: number): void;
  124495. /**
  124496. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124497. * The queries will try to find a solution within those bounds
  124498. * default is (1,1,1)
  124499. * @param extent x,y,z value that define the extent around the queries point of reference
  124500. */
  124501. setDefaultQueryExtent(extent: Vector3): void;
  124502. /**
  124503. * Get the Bounding box extent specified by setDefaultQueryExtent
  124504. * @returns the box extent values
  124505. */
  124506. getDefaultQueryExtent(): Vector3;
  124507. /**
  124508. * Release all resources
  124509. */
  124510. dispose(): void;
  124511. }
  124512. }
  124513. declare module BABYLON {
  124514. /**
  124515. * Class used to enable access to IndexedDB
  124516. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124517. */
  124518. export class Database implements IOfflineProvider {
  124519. private _callbackManifestChecked;
  124520. private _currentSceneUrl;
  124521. private _db;
  124522. private _enableSceneOffline;
  124523. private _enableTexturesOffline;
  124524. private _manifestVersionFound;
  124525. private _mustUpdateRessources;
  124526. private _hasReachedQuota;
  124527. private _isSupported;
  124528. private _idbFactory;
  124529. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124530. private static IsUASupportingBlobStorage;
  124531. /**
  124532. * Gets a boolean indicating if Database storate is enabled (off by default)
  124533. */
  124534. static IDBStorageEnabled: boolean;
  124535. /**
  124536. * Gets a boolean indicating if scene must be saved in the database
  124537. */
  124538. readonly enableSceneOffline: boolean;
  124539. /**
  124540. * Gets a boolean indicating if textures must be saved in the database
  124541. */
  124542. readonly enableTexturesOffline: boolean;
  124543. /**
  124544. * Creates a new Database
  124545. * @param urlToScene defines the url to load the scene
  124546. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124547. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124548. */
  124549. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124550. private static _ParseURL;
  124551. private static _ReturnFullUrlLocation;
  124552. private _checkManifestFile;
  124553. /**
  124554. * Open the database and make it available
  124555. * @param successCallback defines the callback to call on success
  124556. * @param errorCallback defines the callback to call on error
  124557. */
  124558. open(successCallback: () => void, errorCallback: () => void): void;
  124559. /**
  124560. * Loads an image from the database
  124561. * @param url defines the url to load from
  124562. * @param image defines the target DOM image
  124563. */
  124564. loadImage(url: string, image: HTMLImageElement): void;
  124565. private _loadImageFromDBAsync;
  124566. private _saveImageIntoDBAsync;
  124567. private _checkVersionFromDB;
  124568. private _loadVersionFromDBAsync;
  124569. private _saveVersionIntoDBAsync;
  124570. /**
  124571. * Loads a file from database
  124572. * @param url defines the URL to load from
  124573. * @param sceneLoaded defines a callback to call on success
  124574. * @param progressCallBack defines a callback to call when progress changed
  124575. * @param errorCallback defines a callback to call on error
  124576. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124577. */
  124578. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124579. private _loadFileAsync;
  124580. private _saveFileAsync;
  124581. /**
  124582. * Validates if xhr data is correct
  124583. * @param xhr defines the request to validate
  124584. * @param dataType defines the expected data type
  124585. * @returns true if data is correct
  124586. */
  124587. private static _ValidateXHRData;
  124588. }
  124589. }
  124590. declare module BABYLON {
  124591. /** @hidden */
  124592. export var gpuUpdateParticlesPixelShader: {
  124593. name: string;
  124594. shader: string;
  124595. };
  124596. }
  124597. declare module BABYLON {
  124598. /** @hidden */
  124599. export var gpuUpdateParticlesVertexShader: {
  124600. name: string;
  124601. shader: string;
  124602. };
  124603. }
  124604. declare module BABYLON {
  124605. /** @hidden */
  124606. export var clipPlaneFragmentDeclaration2: {
  124607. name: string;
  124608. shader: string;
  124609. };
  124610. }
  124611. declare module BABYLON {
  124612. /** @hidden */
  124613. export var gpuRenderParticlesPixelShader: {
  124614. name: string;
  124615. shader: string;
  124616. };
  124617. }
  124618. declare module BABYLON {
  124619. /** @hidden */
  124620. export var clipPlaneVertexDeclaration2: {
  124621. name: string;
  124622. shader: string;
  124623. };
  124624. }
  124625. declare module BABYLON {
  124626. /** @hidden */
  124627. export var gpuRenderParticlesVertexShader: {
  124628. name: string;
  124629. shader: string;
  124630. };
  124631. }
  124632. declare module BABYLON {
  124633. /**
  124634. * This represents a GPU particle system in Babylon
  124635. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124636. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124637. */
  124638. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124639. /**
  124640. * The layer mask we are rendering the particles through.
  124641. */
  124642. layerMask: number;
  124643. private _capacity;
  124644. private _activeCount;
  124645. private _currentActiveCount;
  124646. private _accumulatedCount;
  124647. private _renderEffect;
  124648. private _updateEffect;
  124649. private _buffer0;
  124650. private _buffer1;
  124651. private _spriteBuffer;
  124652. private _updateVAO;
  124653. private _renderVAO;
  124654. private _targetIndex;
  124655. private _sourceBuffer;
  124656. private _targetBuffer;
  124657. private _engine;
  124658. private _currentRenderId;
  124659. private _started;
  124660. private _stopped;
  124661. private _timeDelta;
  124662. private _randomTexture;
  124663. private _randomTexture2;
  124664. private _attributesStrideSize;
  124665. private _updateEffectOptions;
  124666. private _randomTextureSize;
  124667. private _actualFrame;
  124668. private readonly _rawTextureWidth;
  124669. /**
  124670. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124671. */
  124672. static readonly IsSupported: boolean;
  124673. /**
  124674. * An event triggered when the system is disposed.
  124675. */
  124676. onDisposeObservable: Observable<GPUParticleSystem>;
  124677. /**
  124678. * Gets the maximum number of particles active at the same time.
  124679. * @returns The max number of active particles.
  124680. */
  124681. getCapacity(): number;
  124682. /**
  124683. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124684. * to override the particles.
  124685. */
  124686. forceDepthWrite: boolean;
  124687. /**
  124688. * Gets or set the number of active particles
  124689. */
  124690. activeParticleCount: number;
  124691. private _preWarmDone;
  124692. /**
  124693. * Is this system ready to be used/rendered
  124694. * @return true if the system is ready
  124695. */
  124696. isReady(): boolean;
  124697. /**
  124698. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124699. * @returns True if it has been started, otherwise false.
  124700. */
  124701. isStarted(): boolean;
  124702. /**
  124703. * Starts the particle system and begins to emit
  124704. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124705. */
  124706. start(delay?: number): void;
  124707. /**
  124708. * Stops the particle system.
  124709. */
  124710. stop(): void;
  124711. /**
  124712. * Remove all active particles
  124713. */
  124714. reset(): void;
  124715. /**
  124716. * Returns the string "GPUParticleSystem"
  124717. * @returns a string containing the class name
  124718. */
  124719. getClassName(): string;
  124720. private _colorGradientsTexture;
  124721. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124722. /**
  124723. * Adds a new color gradient
  124724. * @param gradient defines the gradient to use (between 0 and 1)
  124725. * @param color1 defines the color to affect to the specified gradient
  124726. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124727. * @returns the current particle system
  124728. */
  124729. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124730. /**
  124731. * Remove a specific color gradient
  124732. * @param gradient defines the gradient to remove
  124733. * @returns the current particle system
  124734. */
  124735. removeColorGradient(gradient: number): GPUParticleSystem;
  124736. private _angularSpeedGradientsTexture;
  124737. private _sizeGradientsTexture;
  124738. private _velocityGradientsTexture;
  124739. private _limitVelocityGradientsTexture;
  124740. private _dragGradientsTexture;
  124741. private _addFactorGradient;
  124742. /**
  124743. * Adds a new size gradient
  124744. * @param gradient defines the gradient to use (between 0 and 1)
  124745. * @param factor defines the size factor to affect to the specified gradient
  124746. * @returns the current particle system
  124747. */
  124748. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124749. /**
  124750. * Remove a specific size gradient
  124751. * @param gradient defines the gradient to remove
  124752. * @returns the current particle system
  124753. */
  124754. removeSizeGradient(gradient: number): GPUParticleSystem;
  124755. /**
  124756. * Adds a new angular speed gradient
  124757. * @param gradient defines the gradient to use (between 0 and 1)
  124758. * @param factor defines the angular speed to affect to the specified gradient
  124759. * @returns the current particle system
  124760. */
  124761. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124762. /**
  124763. * Remove a specific angular speed gradient
  124764. * @param gradient defines the gradient to remove
  124765. * @returns the current particle system
  124766. */
  124767. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124768. /**
  124769. * Adds a new velocity gradient
  124770. * @param gradient defines the gradient to use (between 0 and 1)
  124771. * @param factor defines the velocity to affect to the specified gradient
  124772. * @returns the current particle system
  124773. */
  124774. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124775. /**
  124776. * Remove a specific velocity gradient
  124777. * @param gradient defines the gradient to remove
  124778. * @returns the current particle system
  124779. */
  124780. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124781. /**
  124782. * Adds a new limit velocity gradient
  124783. * @param gradient defines the gradient to use (between 0 and 1)
  124784. * @param factor defines the limit velocity value to affect to the specified gradient
  124785. * @returns the current particle system
  124786. */
  124787. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124788. /**
  124789. * Remove a specific limit velocity gradient
  124790. * @param gradient defines the gradient to remove
  124791. * @returns the current particle system
  124792. */
  124793. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124794. /**
  124795. * Adds a new drag gradient
  124796. * @param gradient defines the gradient to use (between 0 and 1)
  124797. * @param factor defines the drag value to affect to the specified gradient
  124798. * @returns the current particle system
  124799. */
  124800. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124801. /**
  124802. * Remove a specific drag gradient
  124803. * @param gradient defines the gradient to remove
  124804. * @returns the current particle system
  124805. */
  124806. removeDragGradient(gradient: number): GPUParticleSystem;
  124807. /**
  124808. * Not supported by GPUParticleSystem
  124809. * @param gradient defines the gradient to use (between 0 and 1)
  124810. * @param factor defines the emit rate value to affect to the specified gradient
  124811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124812. * @returns the current particle system
  124813. */
  124814. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124815. /**
  124816. * Not supported by GPUParticleSystem
  124817. * @param gradient defines the gradient to remove
  124818. * @returns the current particle system
  124819. */
  124820. removeEmitRateGradient(gradient: number): IParticleSystem;
  124821. /**
  124822. * Not supported by GPUParticleSystem
  124823. * @param gradient defines the gradient to use (between 0 and 1)
  124824. * @param factor defines the start size value to affect to the specified gradient
  124825. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124826. * @returns the current particle system
  124827. */
  124828. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124829. /**
  124830. * Not supported by GPUParticleSystem
  124831. * @param gradient defines the gradient to remove
  124832. * @returns the current particle system
  124833. */
  124834. removeStartSizeGradient(gradient: number): IParticleSystem;
  124835. /**
  124836. * Not supported by GPUParticleSystem
  124837. * @param gradient defines the gradient to use (between 0 and 1)
  124838. * @param min defines the color remap minimal range
  124839. * @param max defines the color remap maximal range
  124840. * @returns the current particle system
  124841. */
  124842. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124843. /**
  124844. * Not supported by GPUParticleSystem
  124845. * @param gradient defines the gradient to remove
  124846. * @returns the current particle system
  124847. */
  124848. removeColorRemapGradient(): IParticleSystem;
  124849. /**
  124850. * Not supported by GPUParticleSystem
  124851. * @param gradient defines the gradient to use (between 0 and 1)
  124852. * @param min defines the alpha remap minimal range
  124853. * @param max defines the alpha remap maximal range
  124854. * @returns the current particle system
  124855. */
  124856. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124857. /**
  124858. * Not supported by GPUParticleSystem
  124859. * @param gradient defines the gradient to remove
  124860. * @returns the current particle system
  124861. */
  124862. removeAlphaRemapGradient(): IParticleSystem;
  124863. /**
  124864. * Not supported by GPUParticleSystem
  124865. * @param gradient defines the gradient to use (between 0 and 1)
  124866. * @param color defines the color to affect to the specified gradient
  124867. * @returns the current particle system
  124868. */
  124869. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124870. /**
  124871. * Not supported by GPUParticleSystem
  124872. * @param gradient defines the gradient to remove
  124873. * @returns the current particle system
  124874. */
  124875. removeRampGradient(): IParticleSystem;
  124876. /**
  124877. * Not supported by GPUParticleSystem
  124878. * @returns the list of ramp gradients
  124879. */
  124880. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124881. /**
  124882. * Not supported by GPUParticleSystem
  124883. * Gets or sets a boolean indicating that ramp gradients must be used
  124884. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124885. */
  124886. useRampGradients: boolean;
  124887. /**
  124888. * Not supported by GPUParticleSystem
  124889. * @param gradient defines the gradient to use (between 0 and 1)
  124890. * @param factor defines the life time factor to affect to the specified gradient
  124891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124892. * @returns the current particle system
  124893. */
  124894. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124895. /**
  124896. * Not supported by GPUParticleSystem
  124897. * @param gradient defines the gradient to remove
  124898. * @returns the current particle system
  124899. */
  124900. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124901. /**
  124902. * Instantiates a GPU particle system.
  124903. * 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.
  124904. * @param name The name of the particle system
  124905. * @param options The options used to create the system
  124906. * @param scene The scene the particle system belongs to
  124907. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124908. */
  124909. constructor(name: string, options: Partial<{
  124910. capacity: number;
  124911. randomTextureSize: number;
  124912. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124913. protected _reset(): void;
  124914. private _createUpdateVAO;
  124915. private _createRenderVAO;
  124916. private _initialize;
  124917. /** @hidden */
  124918. _recreateUpdateEffect(): void;
  124919. /** @hidden */
  124920. _recreateRenderEffect(): void;
  124921. /**
  124922. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124923. * @param preWarm defines if we are in the pre-warmimg phase
  124924. */
  124925. animate(preWarm?: boolean): void;
  124926. private _createFactorGradientTexture;
  124927. private _createSizeGradientTexture;
  124928. private _createAngularSpeedGradientTexture;
  124929. private _createVelocityGradientTexture;
  124930. private _createLimitVelocityGradientTexture;
  124931. private _createDragGradientTexture;
  124932. private _createColorGradientTexture;
  124933. /**
  124934. * Renders the particle system in its current state
  124935. * @param preWarm defines if the system should only update the particles but not render them
  124936. * @returns the current number of particles
  124937. */
  124938. render(preWarm?: boolean): number;
  124939. /**
  124940. * Rebuilds the particle system
  124941. */
  124942. rebuild(): void;
  124943. private _releaseBuffers;
  124944. private _releaseVAOs;
  124945. /**
  124946. * Disposes the particle system and free the associated resources
  124947. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124948. */
  124949. dispose(disposeTexture?: boolean): void;
  124950. /**
  124951. * Clones the particle system.
  124952. * @param name The name of the cloned object
  124953. * @param newEmitter The new emitter to use
  124954. * @returns the cloned particle system
  124955. */
  124956. clone(name: string, newEmitter: any): GPUParticleSystem;
  124957. /**
  124958. * Serializes the particle system to a JSON object.
  124959. * @returns the JSON object
  124960. */
  124961. serialize(): any;
  124962. /**
  124963. * Parses a JSON object to create a GPU particle system.
  124964. * @param parsedParticleSystem The JSON object to parse
  124965. * @param scene The scene to create the particle system in
  124966. * @param rootUrl The root url to use to load external dependencies like texture
  124967. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124968. * @returns the parsed GPU particle system
  124969. */
  124970. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124971. }
  124972. }
  124973. declare module BABYLON {
  124974. /**
  124975. * Represents a set of particle systems working together to create a specific effect
  124976. */
  124977. export class ParticleSystemSet implements IDisposable {
  124978. private _emitterCreationOptions;
  124979. private _emitterNode;
  124980. /**
  124981. * Gets the particle system list
  124982. */
  124983. systems: IParticleSystem[];
  124984. /**
  124985. * Gets the emitter node used with this set
  124986. */
  124987. readonly emitterNode: Nullable<TransformNode>;
  124988. /**
  124989. * Creates a new emitter mesh as a sphere
  124990. * @param options defines the options used to create the sphere
  124991. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124992. * @param scene defines the hosting scene
  124993. */
  124994. setEmitterAsSphere(options: {
  124995. diameter: number;
  124996. segments: number;
  124997. color: Color3;
  124998. }, renderingGroupId: number, scene: Scene): void;
  124999. /**
  125000. * Starts all particle systems of the set
  125001. * @param emitter defines an optional mesh to use as emitter for the particle systems
  125002. */
  125003. start(emitter?: AbstractMesh): void;
  125004. /**
  125005. * Release all associated resources
  125006. */
  125007. dispose(): void;
  125008. /**
  125009. * Serialize the set into a JSON compatible object
  125010. * @returns a JSON compatible representation of the set
  125011. */
  125012. serialize(): any;
  125013. /**
  125014. * Parse a new ParticleSystemSet from a serialized source
  125015. * @param data defines a JSON compatible representation of the set
  125016. * @param scene defines the hosting scene
  125017. * @param gpu defines if we want GPU particles or CPU particles
  125018. * @returns a new ParticleSystemSet
  125019. */
  125020. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125021. }
  125022. }
  125023. declare module BABYLON {
  125024. /**
  125025. * This class is made for on one-liner static method to help creating particle system set.
  125026. */
  125027. export class ParticleHelper {
  125028. /**
  125029. * Gets or sets base Assets URL
  125030. */
  125031. static BaseAssetsUrl: string;
  125032. /**
  125033. * Create a default particle system that you can tweak
  125034. * @param emitter defines the emitter to use
  125035. * @param capacity defines the system capacity (default is 500 particles)
  125036. * @param scene defines the hosting scene
  125037. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125038. * @returns the new Particle system
  125039. */
  125040. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125041. /**
  125042. * This is the main static method (one-liner) of this helper to create different particle systems
  125043. * @param type This string represents the type to the particle system to create
  125044. * @param scene The scene where the particle system should live
  125045. * @param gpu If the system will use gpu
  125046. * @returns the ParticleSystemSet created
  125047. */
  125048. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125049. /**
  125050. * Static function used to export a particle system to a ParticleSystemSet variable.
  125051. * Please note that the emitter shape is not exported
  125052. * @param systems defines the particle systems to export
  125053. * @returns the created particle system set
  125054. */
  125055. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125056. }
  125057. }
  125058. declare module BABYLON {
  125059. interface Engine {
  125060. /**
  125061. * Create an effect to use with particle systems.
  125062. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125063. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125064. * @param uniformsNames defines a list of attribute names
  125065. * @param samplers defines an array of string used to represent textures
  125066. * @param defines defines the string containing the defines to use to compile the shaders
  125067. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125068. * @param onCompiled defines a function to call when the effect creation is successful
  125069. * @param onError defines a function to call when the effect creation has failed
  125070. * @returns the new Effect
  125071. */
  125072. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125073. }
  125074. interface Mesh {
  125075. /**
  125076. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125077. * @returns an array of IParticleSystem
  125078. */
  125079. getEmittedParticleSystems(): IParticleSystem[];
  125080. /**
  125081. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125082. * @returns an array of IParticleSystem
  125083. */
  125084. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125085. }
  125086. /**
  125087. * @hidden
  125088. */
  125089. export var _IDoNeedToBeInTheBuild: number;
  125090. }
  125091. declare module BABYLON {
  125092. interface Scene {
  125093. /** @hidden (Backing field) */
  125094. _physicsEngine: Nullable<IPhysicsEngine>;
  125095. /**
  125096. * Gets the current physics engine
  125097. * @returns a IPhysicsEngine or null if none attached
  125098. */
  125099. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125100. /**
  125101. * Enables physics to the current scene
  125102. * @param gravity defines the scene's gravity for the physics engine
  125103. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125104. * @return a boolean indicating if the physics engine was initialized
  125105. */
  125106. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125107. /**
  125108. * Disables and disposes the physics engine associated with the scene
  125109. */
  125110. disablePhysicsEngine(): void;
  125111. /**
  125112. * Gets a boolean indicating if there is an active physics engine
  125113. * @returns a boolean indicating if there is an active physics engine
  125114. */
  125115. isPhysicsEnabled(): boolean;
  125116. /**
  125117. * Deletes a physics compound impostor
  125118. * @param compound defines the compound to delete
  125119. */
  125120. deleteCompoundImpostor(compound: any): void;
  125121. /**
  125122. * An event triggered when physic simulation is about to be run
  125123. */
  125124. onBeforePhysicsObservable: Observable<Scene>;
  125125. /**
  125126. * An event triggered when physic simulation has been done
  125127. */
  125128. onAfterPhysicsObservable: Observable<Scene>;
  125129. }
  125130. interface AbstractMesh {
  125131. /** @hidden */
  125132. _physicsImpostor: Nullable<PhysicsImpostor>;
  125133. /**
  125134. * Gets or sets impostor used for physic simulation
  125135. * @see http://doc.babylonjs.com/features/physics_engine
  125136. */
  125137. physicsImpostor: Nullable<PhysicsImpostor>;
  125138. /**
  125139. * Gets the current physics impostor
  125140. * @see http://doc.babylonjs.com/features/physics_engine
  125141. * @returns a physics impostor or null
  125142. */
  125143. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125144. /** Apply a physic impulse to the mesh
  125145. * @param force defines the force to apply
  125146. * @param contactPoint defines where to apply the force
  125147. * @returns the current mesh
  125148. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125149. */
  125150. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125151. /**
  125152. * Creates a physic joint between two meshes
  125153. * @param otherMesh defines the other mesh to use
  125154. * @param pivot1 defines the pivot to use on this mesh
  125155. * @param pivot2 defines the pivot to use on the other mesh
  125156. * @param options defines additional options (can be plugin dependent)
  125157. * @returns the current mesh
  125158. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125159. */
  125160. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125161. /** @hidden */
  125162. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125163. }
  125164. /**
  125165. * Defines the physics engine scene component responsible to manage a physics engine
  125166. */
  125167. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125168. /**
  125169. * The component name helpful to identify the component in the list of scene components.
  125170. */
  125171. readonly name: string;
  125172. /**
  125173. * The scene the component belongs to.
  125174. */
  125175. scene: Scene;
  125176. /**
  125177. * Creates a new instance of the component for the given scene
  125178. * @param scene Defines the scene to register the component in
  125179. */
  125180. constructor(scene: Scene);
  125181. /**
  125182. * Registers the component in a given scene
  125183. */
  125184. register(): void;
  125185. /**
  125186. * Rebuilds the elements related to this component in case of
  125187. * context lost for instance.
  125188. */
  125189. rebuild(): void;
  125190. /**
  125191. * Disposes the component and the associated ressources
  125192. */
  125193. dispose(): void;
  125194. }
  125195. }
  125196. declare module BABYLON {
  125197. /**
  125198. * A helper for physics simulations
  125199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125200. */
  125201. export class PhysicsHelper {
  125202. private _scene;
  125203. private _physicsEngine;
  125204. /**
  125205. * Initializes the Physics helper
  125206. * @param scene Babylon.js scene
  125207. */
  125208. constructor(scene: Scene);
  125209. /**
  125210. * Applies a radial explosion impulse
  125211. * @param origin the origin of the explosion
  125212. * @param radiusOrEventOptions the radius or the options of radial explosion
  125213. * @param strength the explosion strength
  125214. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125215. * @returns A physics radial explosion event, or null
  125216. */
  125217. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125218. /**
  125219. * Applies a radial explosion force
  125220. * @param origin the origin of the explosion
  125221. * @param radiusOrEventOptions the radius or the options of radial explosion
  125222. * @param strength the explosion strength
  125223. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125224. * @returns A physics radial explosion event, or null
  125225. */
  125226. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125227. /**
  125228. * Creates a gravitational field
  125229. * @param origin the origin of the explosion
  125230. * @param radiusOrEventOptions the radius or the options of radial explosion
  125231. * @param strength the explosion strength
  125232. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125233. * @returns A physics gravitational field event, or null
  125234. */
  125235. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125236. /**
  125237. * Creates a physics updraft event
  125238. * @param origin the origin of the updraft
  125239. * @param radiusOrEventOptions the radius or the options of the updraft
  125240. * @param strength the strength of the updraft
  125241. * @param height the height of the updraft
  125242. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125243. * @returns A physics updraft event, or null
  125244. */
  125245. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125246. /**
  125247. * Creates a physics vortex event
  125248. * @param origin the of the vortex
  125249. * @param radiusOrEventOptions the radius or the options of the vortex
  125250. * @param strength the strength of the vortex
  125251. * @param height the height of the vortex
  125252. * @returns a Physics vortex event, or null
  125253. * A physics vortex event or null
  125254. */
  125255. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125256. }
  125257. /**
  125258. * Represents a physics radial explosion event
  125259. */
  125260. class PhysicsRadialExplosionEvent {
  125261. private _scene;
  125262. private _options;
  125263. private _sphere;
  125264. private _dataFetched;
  125265. /**
  125266. * Initializes a radial explosioin event
  125267. * @param _scene BabylonJS scene
  125268. * @param _options The options for the vortex event
  125269. */
  125270. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125271. /**
  125272. * Returns the data related to the radial explosion event (sphere).
  125273. * @returns The radial explosion event data
  125274. */
  125275. getData(): PhysicsRadialExplosionEventData;
  125276. /**
  125277. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125278. * @param impostor A physics imposter
  125279. * @param origin the origin of the explosion
  125280. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125281. */
  125282. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125283. /**
  125284. * Triggers affecterd impostors callbacks
  125285. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125286. */
  125287. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125288. /**
  125289. * Disposes the sphere.
  125290. * @param force Specifies if the sphere should be disposed by force
  125291. */
  125292. dispose(force?: boolean): void;
  125293. /*** Helpers ***/
  125294. private _prepareSphere;
  125295. private _intersectsWithSphere;
  125296. }
  125297. /**
  125298. * Represents a gravitational field event
  125299. */
  125300. class PhysicsGravitationalFieldEvent {
  125301. private _physicsHelper;
  125302. private _scene;
  125303. private _origin;
  125304. private _options;
  125305. private _tickCallback;
  125306. private _sphere;
  125307. private _dataFetched;
  125308. /**
  125309. * Initializes the physics gravitational field event
  125310. * @param _physicsHelper A physics helper
  125311. * @param _scene BabylonJS scene
  125312. * @param _origin The origin position of the gravitational field event
  125313. * @param _options The options for the vortex event
  125314. */
  125315. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125316. /**
  125317. * Returns the data related to the gravitational field event (sphere).
  125318. * @returns A gravitational field event
  125319. */
  125320. getData(): PhysicsGravitationalFieldEventData;
  125321. /**
  125322. * Enables the gravitational field.
  125323. */
  125324. enable(): void;
  125325. /**
  125326. * Disables the gravitational field.
  125327. */
  125328. disable(): void;
  125329. /**
  125330. * Disposes the sphere.
  125331. * @param force The force to dispose from the gravitational field event
  125332. */
  125333. dispose(force?: boolean): void;
  125334. private _tick;
  125335. }
  125336. /**
  125337. * Represents a physics updraft event
  125338. */
  125339. class PhysicsUpdraftEvent {
  125340. private _scene;
  125341. private _origin;
  125342. private _options;
  125343. private _physicsEngine;
  125344. private _originTop;
  125345. private _originDirection;
  125346. private _tickCallback;
  125347. private _cylinder;
  125348. private _cylinderPosition;
  125349. private _dataFetched;
  125350. /**
  125351. * Initializes the physics updraft event
  125352. * @param _scene BabylonJS scene
  125353. * @param _origin The origin position of the updraft
  125354. * @param _options The options for the updraft event
  125355. */
  125356. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125357. /**
  125358. * Returns the data related to the updraft event (cylinder).
  125359. * @returns A physics updraft event
  125360. */
  125361. getData(): PhysicsUpdraftEventData;
  125362. /**
  125363. * Enables the updraft.
  125364. */
  125365. enable(): void;
  125366. /**
  125367. * Disables the updraft.
  125368. */
  125369. disable(): void;
  125370. /**
  125371. * Disposes the cylinder.
  125372. * @param force Specifies if the updraft should be disposed by force
  125373. */
  125374. dispose(force?: boolean): void;
  125375. private getImpostorHitData;
  125376. private _tick;
  125377. /*** Helpers ***/
  125378. private _prepareCylinder;
  125379. private _intersectsWithCylinder;
  125380. }
  125381. /**
  125382. * Represents a physics vortex event
  125383. */
  125384. class PhysicsVortexEvent {
  125385. private _scene;
  125386. private _origin;
  125387. private _options;
  125388. private _physicsEngine;
  125389. private _originTop;
  125390. private _tickCallback;
  125391. private _cylinder;
  125392. private _cylinderPosition;
  125393. private _dataFetched;
  125394. /**
  125395. * Initializes the physics vortex event
  125396. * @param _scene The BabylonJS scene
  125397. * @param _origin The origin position of the vortex
  125398. * @param _options The options for the vortex event
  125399. */
  125400. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125401. /**
  125402. * Returns the data related to the vortex event (cylinder).
  125403. * @returns The physics vortex event data
  125404. */
  125405. getData(): PhysicsVortexEventData;
  125406. /**
  125407. * Enables the vortex.
  125408. */
  125409. enable(): void;
  125410. /**
  125411. * Disables the cortex.
  125412. */
  125413. disable(): void;
  125414. /**
  125415. * Disposes the sphere.
  125416. * @param force
  125417. */
  125418. dispose(force?: boolean): void;
  125419. private getImpostorHitData;
  125420. private _tick;
  125421. /*** Helpers ***/
  125422. private _prepareCylinder;
  125423. private _intersectsWithCylinder;
  125424. }
  125425. /**
  125426. * Options fot the radial explosion event
  125427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125428. */
  125429. export class PhysicsRadialExplosionEventOptions {
  125430. /**
  125431. * The radius of the sphere for the radial explosion.
  125432. */
  125433. radius: number;
  125434. /**
  125435. * The strenth of the explosion.
  125436. */
  125437. strength: number;
  125438. /**
  125439. * The strenght of the force in correspondence to the distance of the affected object
  125440. */
  125441. falloff: PhysicsRadialImpulseFalloff;
  125442. /**
  125443. * Sphere options for the radial explosion.
  125444. */
  125445. sphere: {
  125446. segments: number;
  125447. diameter: number;
  125448. };
  125449. /**
  125450. * Sphere options for the radial explosion.
  125451. */
  125452. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125453. }
  125454. /**
  125455. * Options fot the updraft event
  125456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125457. */
  125458. export class PhysicsUpdraftEventOptions {
  125459. /**
  125460. * The radius of the cylinder for the vortex
  125461. */
  125462. radius: number;
  125463. /**
  125464. * The strenth of the updraft.
  125465. */
  125466. strength: number;
  125467. /**
  125468. * The height of the cylinder for the updraft.
  125469. */
  125470. height: number;
  125471. /**
  125472. * The mode for the the updraft.
  125473. */
  125474. updraftMode: PhysicsUpdraftMode;
  125475. }
  125476. /**
  125477. * Options fot the vortex event
  125478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125479. */
  125480. export class PhysicsVortexEventOptions {
  125481. /**
  125482. * The radius of the cylinder for the vortex
  125483. */
  125484. radius: number;
  125485. /**
  125486. * The strenth of the vortex.
  125487. */
  125488. strength: number;
  125489. /**
  125490. * The height of the cylinder for the vortex.
  125491. */
  125492. height: number;
  125493. /**
  125494. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125495. */
  125496. centripetalForceThreshold: number;
  125497. /**
  125498. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125499. */
  125500. centripetalForceMultiplier: number;
  125501. /**
  125502. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125503. */
  125504. centrifugalForceMultiplier: number;
  125505. /**
  125506. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125507. */
  125508. updraftForceMultiplier: number;
  125509. }
  125510. /**
  125511. * The strenght of the force in correspondence to the distance of the affected object
  125512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125513. */
  125514. export enum PhysicsRadialImpulseFalloff {
  125515. /** Defines that impulse is constant in strength across it's whole radius */
  125516. Constant = 0,
  125517. /** Defines that impulse gets weaker if it's further from the origin */
  125518. Linear = 1
  125519. }
  125520. /**
  125521. * The strength of the force in correspondence to the distance of the affected object
  125522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125523. */
  125524. export enum PhysicsUpdraftMode {
  125525. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125526. Center = 0,
  125527. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125528. Perpendicular = 1
  125529. }
  125530. /**
  125531. * Interface for a physics hit data
  125532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125533. */
  125534. export interface PhysicsHitData {
  125535. /**
  125536. * The force applied at the contact point
  125537. */
  125538. force: Vector3;
  125539. /**
  125540. * The contact point
  125541. */
  125542. contactPoint: Vector3;
  125543. /**
  125544. * The distance from the origin to the contact point
  125545. */
  125546. distanceFromOrigin: number;
  125547. }
  125548. /**
  125549. * Interface for radial explosion event data
  125550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125551. */
  125552. export interface PhysicsRadialExplosionEventData {
  125553. /**
  125554. * A sphere used for the radial explosion event
  125555. */
  125556. sphere: Mesh;
  125557. }
  125558. /**
  125559. * Interface for gravitational field event data
  125560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125561. */
  125562. export interface PhysicsGravitationalFieldEventData {
  125563. /**
  125564. * A sphere mesh used for the gravitational field event
  125565. */
  125566. sphere: Mesh;
  125567. }
  125568. /**
  125569. * Interface for updraft event data
  125570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125571. */
  125572. export interface PhysicsUpdraftEventData {
  125573. /**
  125574. * A cylinder used for the updraft event
  125575. */
  125576. cylinder: Mesh;
  125577. }
  125578. /**
  125579. * Interface for vortex event data
  125580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125581. */
  125582. export interface PhysicsVortexEventData {
  125583. /**
  125584. * A cylinder used for the vortex event
  125585. */
  125586. cylinder: Mesh;
  125587. }
  125588. /**
  125589. * Interface for an affected physics impostor
  125590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125591. */
  125592. export interface PhysicsAffectedImpostorWithData {
  125593. /**
  125594. * The impostor affected by the effect
  125595. */
  125596. impostor: PhysicsImpostor;
  125597. /**
  125598. * The data about the hit/horce from the explosion
  125599. */
  125600. hitData: PhysicsHitData;
  125601. }
  125602. }
  125603. declare module BABYLON {
  125604. /** @hidden */
  125605. export var blackAndWhitePixelShader: {
  125606. name: string;
  125607. shader: string;
  125608. };
  125609. }
  125610. declare module BABYLON {
  125611. /**
  125612. * Post process used to render in black and white
  125613. */
  125614. export class BlackAndWhitePostProcess extends PostProcess {
  125615. /**
  125616. * Linear about to convert he result to black and white (default: 1)
  125617. */
  125618. degree: number;
  125619. /**
  125620. * Creates a black and white post process
  125621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125622. * @param name The name of the effect.
  125623. * @param options The required width/height ratio to downsize to before computing the render pass.
  125624. * @param camera The camera to apply the render pass to.
  125625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125626. * @param engine The engine which the post process will be applied. (default: current engine)
  125627. * @param reusable If the post process can be reused on the same frame. (default: false)
  125628. */
  125629. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125630. }
  125631. }
  125632. declare module BABYLON {
  125633. /**
  125634. * This represents a set of one or more post processes in Babylon.
  125635. * A post process can be used to apply a shader to a texture after it is rendered.
  125636. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125637. */
  125638. export class PostProcessRenderEffect {
  125639. private _postProcesses;
  125640. private _getPostProcesses;
  125641. private _singleInstance;
  125642. private _cameras;
  125643. private _indicesForCamera;
  125644. /**
  125645. * Name of the effect
  125646. * @hidden
  125647. */
  125648. _name: string;
  125649. /**
  125650. * Instantiates a post process render effect.
  125651. * A post process can be used to apply a shader to a texture after it is rendered.
  125652. * @param engine The engine the effect is tied to
  125653. * @param name The name of the effect
  125654. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125655. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125656. */
  125657. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125658. /**
  125659. * Checks if all the post processes in the effect are supported.
  125660. */
  125661. readonly isSupported: boolean;
  125662. /**
  125663. * Updates the current state of the effect
  125664. * @hidden
  125665. */
  125666. _update(): void;
  125667. /**
  125668. * Attaches the effect on cameras
  125669. * @param cameras The camera to attach to.
  125670. * @hidden
  125671. */
  125672. _attachCameras(cameras: Camera): void;
  125673. /**
  125674. * Attaches the effect on cameras
  125675. * @param cameras The camera to attach to.
  125676. * @hidden
  125677. */
  125678. _attachCameras(cameras: Camera[]): void;
  125679. /**
  125680. * Detaches the effect on cameras
  125681. * @param cameras The camera to detatch from.
  125682. * @hidden
  125683. */
  125684. _detachCameras(cameras: Camera): void;
  125685. /**
  125686. * Detatches the effect on cameras
  125687. * @param cameras The camera to detatch from.
  125688. * @hidden
  125689. */
  125690. _detachCameras(cameras: Camera[]): void;
  125691. /**
  125692. * Enables the effect on given cameras
  125693. * @param cameras The camera to enable.
  125694. * @hidden
  125695. */
  125696. _enable(cameras: Camera): void;
  125697. /**
  125698. * Enables the effect on given cameras
  125699. * @param cameras The camera to enable.
  125700. * @hidden
  125701. */
  125702. _enable(cameras: Nullable<Camera[]>): void;
  125703. /**
  125704. * Disables the effect on the given cameras
  125705. * @param cameras The camera to disable.
  125706. * @hidden
  125707. */
  125708. _disable(cameras: Camera): void;
  125709. /**
  125710. * Disables the effect on the given cameras
  125711. * @param cameras The camera to disable.
  125712. * @hidden
  125713. */
  125714. _disable(cameras: Nullable<Camera[]>): void;
  125715. /**
  125716. * Gets a list of the post processes contained in the effect.
  125717. * @param camera The camera to get the post processes on.
  125718. * @returns The list of the post processes in the effect.
  125719. */
  125720. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125721. }
  125722. }
  125723. declare module BABYLON {
  125724. /** @hidden */
  125725. export var extractHighlightsPixelShader: {
  125726. name: string;
  125727. shader: string;
  125728. };
  125729. }
  125730. declare module BABYLON {
  125731. /**
  125732. * 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.
  125733. */
  125734. export class ExtractHighlightsPostProcess extends PostProcess {
  125735. /**
  125736. * The luminance threshold, pixels below this value will be set to black.
  125737. */
  125738. threshold: number;
  125739. /** @hidden */
  125740. _exposure: number;
  125741. /**
  125742. * Post process which has the input texture to be used when performing highlight extraction
  125743. * @hidden
  125744. */
  125745. _inputPostProcess: Nullable<PostProcess>;
  125746. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125747. }
  125748. }
  125749. declare module BABYLON {
  125750. /** @hidden */
  125751. export var bloomMergePixelShader: {
  125752. name: string;
  125753. shader: string;
  125754. };
  125755. }
  125756. declare module BABYLON {
  125757. /**
  125758. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125759. */
  125760. export class BloomMergePostProcess extends PostProcess {
  125761. /** Weight of the bloom to be added to the original input. */
  125762. weight: number;
  125763. /**
  125764. * Creates a new instance of @see BloomMergePostProcess
  125765. * @param name The name of the effect.
  125766. * @param originalFromInput Post process which's input will be used for the merge.
  125767. * @param blurred Blurred highlights post process which's output will be used.
  125768. * @param weight Weight of the bloom to be added to the original input.
  125769. * @param options The required width/height ratio to downsize to before computing the render pass.
  125770. * @param camera The camera to apply the render pass to.
  125771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125772. * @param engine The engine which the post process will be applied. (default: current engine)
  125773. * @param reusable If the post process can be reused on the same frame. (default: false)
  125774. * @param textureType Type of textures used when performing the post process. (default: 0)
  125775. * @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)
  125776. */
  125777. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125778. /** Weight of the bloom to be added to the original input. */
  125779. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125780. }
  125781. }
  125782. declare module BABYLON {
  125783. /**
  125784. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125785. */
  125786. export class BloomEffect extends PostProcessRenderEffect {
  125787. private bloomScale;
  125788. /**
  125789. * @hidden Internal
  125790. */
  125791. _effects: Array<PostProcess>;
  125792. /**
  125793. * @hidden Internal
  125794. */
  125795. _downscale: ExtractHighlightsPostProcess;
  125796. private _blurX;
  125797. private _blurY;
  125798. private _merge;
  125799. /**
  125800. * The luminance threshold to find bright areas of the image to bloom.
  125801. */
  125802. threshold: number;
  125803. /**
  125804. * The strength of the bloom.
  125805. */
  125806. weight: number;
  125807. /**
  125808. * Specifies the size of the bloom blur kernel, relative to the final output size
  125809. */
  125810. kernel: number;
  125811. /**
  125812. * Creates a new instance of @see BloomEffect
  125813. * @param scene The scene the effect belongs to.
  125814. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125815. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125816. * @param bloomWeight The the strength of bloom.
  125817. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125818. * @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)
  125819. */
  125820. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125821. /**
  125822. * Disposes each of the internal effects for a given camera.
  125823. * @param camera The camera to dispose the effect on.
  125824. */
  125825. disposeEffects(camera: Camera): void;
  125826. /**
  125827. * @hidden Internal
  125828. */
  125829. _updateEffects(): void;
  125830. /**
  125831. * Internal
  125832. * @returns if all the contained post processes are ready.
  125833. * @hidden
  125834. */
  125835. _isReady(): boolean;
  125836. }
  125837. }
  125838. declare module BABYLON {
  125839. /** @hidden */
  125840. export var chromaticAberrationPixelShader: {
  125841. name: string;
  125842. shader: string;
  125843. };
  125844. }
  125845. declare module BABYLON {
  125846. /**
  125847. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125848. */
  125849. export class ChromaticAberrationPostProcess extends PostProcess {
  125850. /**
  125851. * The amount of seperation of rgb channels (default: 30)
  125852. */
  125853. aberrationAmount: number;
  125854. /**
  125855. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125856. */
  125857. radialIntensity: number;
  125858. /**
  125859. * 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))
  125860. */
  125861. direction: Vector2;
  125862. /**
  125863. * 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))
  125864. */
  125865. centerPosition: Vector2;
  125866. /**
  125867. * Creates a new instance ChromaticAberrationPostProcess
  125868. * @param name The name of the effect.
  125869. * @param screenWidth The width of the screen to apply the effect on.
  125870. * @param screenHeight The height of the screen to apply the effect on.
  125871. * @param options The required width/height ratio to downsize to before computing the render pass.
  125872. * @param camera The camera to apply the render pass to.
  125873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125874. * @param engine The engine which the post process will be applied. (default: current engine)
  125875. * @param reusable If the post process can be reused on the same frame. (default: false)
  125876. * @param textureType Type of textures used when performing the post process. (default: 0)
  125877. * @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)
  125878. */
  125879. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125880. }
  125881. }
  125882. declare module BABYLON {
  125883. /** @hidden */
  125884. export var circleOfConfusionPixelShader: {
  125885. name: string;
  125886. shader: string;
  125887. };
  125888. }
  125889. declare module BABYLON {
  125890. /**
  125891. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125892. */
  125893. export class CircleOfConfusionPostProcess extends PostProcess {
  125894. /**
  125895. * 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.
  125896. */
  125897. lensSize: number;
  125898. /**
  125899. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125900. */
  125901. fStop: number;
  125902. /**
  125903. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125904. */
  125905. focusDistance: number;
  125906. /**
  125907. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125908. */
  125909. focalLength: number;
  125910. private _depthTexture;
  125911. /**
  125912. * Creates a new instance CircleOfConfusionPostProcess
  125913. * @param name The name of the effect.
  125914. * @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.
  125915. * @param options The required width/height ratio to downsize to before computing the render pass.
  125916. * @param camera The camera to apply the render pass to.
  125917. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125918. * @param engine The engine which the post process will be applied. (default: current engine)
  125919. * @param reusable If the post process can be reused on the same frame. (default: false)
  125920. * @param textureType Type of textures used when performing the post process. (default: 0)
  125921. * @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)
  125922. */
  125923. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125924. /**
  125925. * 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.
  125926. */
  125927. depthTexture: RenderTargetTexture;
  125928. }
  125929. }
  125930. declare module BABYLON {
  125931. /** @hidden */
  125932. export var colorCorrectionPixelShader: {
  125933. name: string;
  125934. shader: string;
  125935. };
  125936. }
  125937. declare module BABYLON {
  125938. /**
  125939. *
  125940. * This post-process allows the modification of rendered colors by using
  125941. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125942. *
  125943. * The object needs to be provided an url to a texture containing the color
  125944. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125945. * Use an image editing software to tweak the LUT to match your needs.
  125946. *
  125947. * For an example of a color LUT, see here:
  125948. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125949. * For explanations on color grading, see here:
  125950. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125951. *
  125952. */
  125953. export class ColorCorrectionPostProcess extends PostProcess {
  125954. private _colorTableTexture;
  125955. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125956. }
  125957. }
  125958. declare module BABYLON {
  125959. /** @hidden */
  125960. export var convolutionPixelShader: {
  125961. name: string;
  125962. shader: string;
  125963. };
  125964. }
  125965. declare module BABYLON {
  125966. /**
  125967. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125968. * input texture to perform effects such as edge detection or sharpening
  125969. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125970. */
  125971. export class ConvolutionPostProcess extends PostProcess {
  125972. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125973. kernel: number[];
  125974. /**
  125975. * Creates a new instance ConvolutionPostProcess
  125976. * @param name The name of the effect.
  125977. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125978. * @param options The required width/height ratio to downsize to before computing the render pass.
  125979. * @param camera The camera to apply the render pass to.
  125980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125981. * @param engine The engine which the post process will be applied. (default: current engine)
  125982. * @param reusable If the post process can be reused on the same frame. (default: false)
  125983. * @param textureType Type of textures used when performing the post process. (default: 0)
  125984. */
  125985. constructor(name: string,
  125986. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125987. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125988. /**
  125989. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125990. */
  125991. static EdgeDetect0Kernel: number[];
  125992. /**
  125993. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125994. */
  125995. static EdgeDetect1Kernel: number[];
  125996. /**
  125997. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125998. */
  125999. static EdgeDetect2Kernel: number[];
  126000. /**
  126001. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126002. */
  126003. static SharpenKernel: number[];
  126004. /**
  126005. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126006. */
  126007. static EmbossKernel: number[];
  126008. /**
  126009. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126010. */
  126011. static GaussianKernel: number[];
  126012. }
  126013. }
  126014. declare module BABYLON {
  126015. /**
  126016. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  126017. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  126018. * based on samples that have a large difference in distance than the center pixel.
  126019. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  126020. */
  126021. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  126022. direction: Vector2;
  126023. /**
  126024. * Creates a new instance CircleOfConfusionPostProcess
  126025. * @param name The name of the effect.
  126026. * @param scene The scene the effect belongs to.
  126027. * @param direction The direction the blur should be applied.
  126028. * @param kernel The size of the kernel used to blur.
  126029. * @param options The required width/height ratio to downsize to before computing the render pass.
  126030. * @param camera The camera to apply the render pass to.
  126031. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  126032. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  126033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126034. * @param engine The engine which the post process will be applied. (default: current engine)
  126035. * @param reusable If the post process can be reused on the same frame. (default: false)
  126036. * @param textureType Type of textures used when performing the post process. (default: 0)
  126037. * @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)
  126038. */
  126039. 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);
  126040. }
  126041. }
  126042. declare module BABYLON {
  126043. /** @hidden */
  126044. export var depthOfFieldMergePixelShader: {
  126045. name: string;
  126046. shader: string;
  126047. };
  126048. }
  126049. declare module BABYLON {
  126050. /**
  126051. * Options to be set when merging outputs from the default pipeline.
  126052. */
  126053. export class DepthOfFieldMergePostProcessOptions {
  126054. /**
  126055. * The original image to merge on top of
  126056. */
  126057. originalFromInput: PostProcess;
  126058. /**
  126059. * Parameters to perform the merge of the depth of field effect
  126060. */
  126061. depthOfField?: {
  126062. circleOfConfusion: PostProcess;
  126063. blurSteps: Array<PostProcess>;
  126064. };
  126065. /**
  126066. * Parameters to perform the merge of bloom effect
  126067. */
  126068. bloom?: {
  126069. blurred: PostProcess;
  126070. weight: number;
  126071. };
  126072. }
  126073. /**
  126074. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126075. */
  126076. export class DepthOfFieldMergePostProcess extends PostProcess {
  126077. private blurSteps;
  126078. /**
  126079. * Creates a new instance of DepthOfFieldMergePostProcess
  126080. * @param name The name of the effect.
  126081. * @param originalFromInput Post process which's input will be used for the merge.
  126082. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  126083. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  126084. * @param options The required width/height ratio to downsize to before computing the render pass.
  126085. * @param camera The camera to apply the render pass to.
  126086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126087. * @param engine The engine which the post process will be applied. (default: current engine)
  126088. * @param reusable If the post process can be reused on the same frame. (default: false)
  126089. * @param textureType Type of textures used when performing the post process. (default: 0)
  126090. * @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)
  126091. */
  126092. 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);
  126093. /**
  126094. * Updates the effect with the current post process compile time values and recompiles the shader.
  126095. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126096. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126097. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126098. * @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
  126099. * @param onCompiled Called when the shader has been compiled.
  126100. * @param onError Called if there is an error when compiling a shader.
  126101. */
  126102. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126103. }
  126104. }
  126105. declare module BABYLON {
  126106. /**
  126107. * Specifies the level of max blur that should be applied when using the depth of field effect
  126108. */
  126109. export enum DepthOfFieldEffectBlurLevel {
  126110. /**
  126111. * Subtle blur
  126112. */
  126113. Low = 0,
  126114. /**
  126115. * Medium blur
  126116. */
  126117. Medium = 1,
  126118. /**
  126119. * Large blur
  126120. */
  126121. High = 2
  126122. }
  126123. /**
  126124. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  126125. */
  126126. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  126127. private _circleOfConfusion;
  126128. /**
  126129. * @hidden Internal, blurs from high to low
  126130. */
  126131. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126132. private _depthOfFieldBlurY;
  126133. private _dofMerge;
  126134. /**
  126135. * @hidden Internal post processes in depth of field effect
  126136. */
  126137. _effects: Array<PostProcess>;
  126138. /**
  126139. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126140. */
  126141. focalLength: number;
  126142. /**
  126143. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126144. */
  126145. fStop: number;
  126146. /**
  126147. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126148. */
  126149. focusDistance: number;
  126150. /**
  126151. * 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.
  126152. */
  126153. lensSize: number;
  126154. /**
  126155. * Creates a new instance DepthOfFieldEffect
  126156. * @param scene The scene the effect belongs to.
  126157. * @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.
  126158. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126159. * @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)
  126160. */
  126161. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126162. /**
  126163. * Get the current class name of the current effet
  126164. * @returns "DepthOfFieldEffect"
  126165. */
  126166. getClassName(): string;
  126167. /**
  126168. * 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.
  126169. */
  126170. depthTexture: RenderTargetTexture;
  126171. /**
  126172. * Disposes each of the internal effects for a given camera.
  126173. * @param camera The camera to dispose the effect on.
  126174. */
  126175. disposeEffects(camera: Camera): void;
  126176. /**
  126177. * @hidden Internal
  126178. */
  126179. _updateEffects(): void;
  126180. /**
  126181. * Internal
  126182. * @returns if all the contained post processes are ready.
  126183. * @hidden
  126184. */
  126185. _isReady(): boolean;
  126186. }
  126187. }
  126188. declare module BABYLON {
  126189. /** @hidden */
  126190. export var displayPassPixelShader: {
  126191. name: string;
  126192. shader: string;
  126193. };
  126194. }
  126195. declare module BABYLON {
  126196. /**
  126197. * DisplayPassPostProcess which produces an output the same as it's input
  126198. */
  126199. export class DisplayPassPostProcess extends PostProcess {
  126200. /**
  126201. * Creates the DisplayPassPostProcess
  126202. * @param name The name of the effect.
  126203. * @param options The required width/height ratio to downsize to before computing the render pass.
  126204. * @param camera The camera to apply the render pass to.
  126205. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126206. * @param engine The engine which the post process will be applied. (default: current engine)
  126207. * @param reusable If the post process can be reused on the same frame. (default: false)
  126208. */
  126209. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126210. }
  126211. }
  126212. declare module BABYLON {
  126213. /** @hidden */
  126214. export var filterPixelShader: {
  126215. name: string;
  126216. shader: string;
  126217. };
  126218. }
  126219. declare module BABYLON {
  126220. /**
  126221. * Applies a kernel filter to the image
  126222. */
  126223. export class FilterPostProcess extends PostProcess {
  126224. /** The matrix to be applied to the image */
  126225. kernelMatrix: Matrix;
  126226. /**
  126227. *
  126228. * @param name The name of the effect.
  126229. * @param kernelMatrix The matrix to be applied to the image
  126230. * @param options The required width/height ratio to downsize to before computing the render pass.
  126231. * @param camera The camera to apply the render pass to.
  126232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126233. * @param engine The engine which the post process will be applied. (default: current engine)
  126234. * @param reusable If the post process can be reused on the same frame. (default: false)
  126235. */
  126236. constructor(name: string,
  126237. /** The matrix to be applied to the image */
  126238. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126239. }
  126240. }
  126241. declare module BABYLON {
  126242. /** @hidden */
  126243. export var fxaaPixelShader: {
  126244. name: string;
  126245. shader: string;
  126246. };
  126247. }
  126248. declare module BABYLON {
  126249. /** @hidden */
  126250. export var fxaaVertexShader: {
  126251. name: string;
  126252. shader: string;
  126253. };
  126254. }
  126255. declare module BABYLON {
  126256. /**
  126257. * Fxaa post process
  126258. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126259. */
  126260. export class FxaaPostProcess extends PostProcess {
  126261. /** @hidden */
  126262. texelWidth: number;
  126263. /** @hidden */
  126264. texelHeight: number;
  126265. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126266. private _getDefines;
  126267. }
  126268. }
  126269. declare module BABYLON {
  126270. /** @hidden */
  126271. export var grainPixelShader: {
  126272. name: string;
  126273. shader: string;
  126274. };
  126275. }
  126276. declare module BABYLON {
  126277. /**
  126278. * The GrainPostProcess adds noise to the image at mid luminance levels
  126279. */
  126280. export class GrainPostProcess extends PostProcess {
  126281. /**
  126282. * The intensity of the grain added (default: 30)
  126283. */
  126284. intensity: number;
  126285. /**
  126286. * If the grain should be randomized on every frame
  126287. */
  126288. animated: boolean;
  126289. /**
  126290. * Creates a new instance of @see GrainPostProcess
  126291. * @param name The name of the effect.
  126292. * @param options The required width/height ratio to downsize to before computing the render pass.
  126293. * @param camera The camera to apply the render pass to.
  126294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126295. * @param engine The engine which the post process will be applied. (default: current engine)
  126296. * @param reusable If the post process can be reused on the same frame. (default: false)
  126297. * @param textureType Type of textures used when performing the post process. (default: 0)
  126298. * @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)
  126299. */
  126300. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126301. }
  126302. }
  126303. declare module BABYLON {
  126304. /** @hidden */
  126305. export var highlightsPixelShader: {
  126306. name: string;
  126307. shader: string;
  126308. };
  126309. }
  126310. declare module BABYLON {
  126311. /**
  126312. * Extracts highlights from the image
  126313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126314. */
  126315. export class HighlightsPostProcess extends PostProcess {
  126316. /**
  126317. * Extracts highlights from the image
  126318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126319. * @param name The name of the effect.
  126320. * @param options The required width/height ratio to downsize to before computing the render pass.
  126321. * @param camera The camera to apply the render pass to.
  126322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126323. * @param engine The engine which the post process will be applied. (default: current engine)
  126324. * @param reusable If the post process can be reused on the same frame. (default: false)
  126325. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126326. */
  126327. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126328. }
  126329. }
  126330. declare module BABYLON {
  126331. /** @hidden */
  126332. export var mrtFragmentDeclaration: {
  126333. name: string;
  126334. shader: string;
  126335. };
  126336. }
  126337. declare module BABYLON {
  126338. /** @hidden */
  126339. export var geometryPixelShader: {
  126340. name: string;
  126341. shader: string;
  126342. };
  126343. }
  126344. declare module BABYLON {
  126345. /** @hidden */
  126346. export var geometryVertexShader: {
  126347. name: string;
  126348. shader: string;
  126349. };
  126350. }
  126351. declare module BABYLON {
  126352. /** @hidden */
  126353. interface ISavedTransformationMatrix {
  126354. world: Matrix;
  126355. viewProjection: Matrix;
  126356. }
  126357. /**
  126358. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126359. */
  126360. export class GeometryBufferRenderer {
  126361. /**
  126362. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126363. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126364. */
  126365. static readonly POSITION_TEXTURE_TYPE: number;
  126366. /**
  126367. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126368. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126369. */
  126370. static readonly VELOCITY_TEXTURE_TYPE: number;
  126371. /**
  126372. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126373. * in order to compute objects velocities when enableVelocity is set to "true"
  126374. * @hidden
  126375. */
  126376. _previousTransformationMatrices: {
  126377. [index: number]: ISavedTransformationMatrix;
  126378. };
  126379. /**
  126380. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126381. * in order to compute objects velocities when enableVelocity is set to "true"
  126382. * @hidden
  126383. */
  126384. _previousBonesTransformationMatrices: {
  126385. [index: number]: Float32Array;
  126386. };
  126387. /**
  126388. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126389. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126390. */
  126391. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126392. private _scene;
  126393. private _multiRenderTarget;
  126394. private _ratio;
  126395. private _enablePosition;
  126396. private _enableVelocity;
  126397. private _positionIndex;
  126398. private _velocityIndex;
  126399. protected _effect: Effect;
  126400. protected _cachedDefines: string;
  126401. /**
  126402. * Set the render list (meshes to be rendered) used in the G buffer.
  126403. */
  126404. renderList: Mesh[];
  126405. /**
  126406. * Gets wether or not G buffer are supported by the running hardware.
  126407. * This requires draw buffer supports
  126408. */
  126409. readonly isSupported: boolean;
  126410. /**
  126411. * Returns the index of the given texture type in the G-Buffer textures array
  126412. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126413. * @returns the index of the given texture type in the G-Buffer textures array
  126414. */
  126415. getTextureIndex(textureType: number): number;
  126416. /**
  126417. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126418. */
  126419. /**
  126420. * Sets whether or not objects positions are enabled for the G buffer.
  126421. */
  126422. enablePosition: boolean;
  126423. /**
  126424. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126425. */
  126426. /**
  126427. * Sets wether or not objects velocities are enabled for the G buffer.
  126428. */
  126429. enableVelocity: boolean;
  126430. /**
  126431. * Gets the scene associated with the buffer.
  126432. */
  126433. readonly scene: Scene;
  126434. /**
  126435. * Gets the ratio used by the buffer during its creation.
  126436. * How big is the buffer related to the main canvas.
  126437. */
  126438. readonly ratio: number;
  126439. /** @hidden */
  126440. static _SceneComponentInitialization: (scene: Scene) => void;
  126441. /**
  126442. * Creates a new G Buffer for the scene
  126443. * @param scene The scene the buffer belongs to
  126444. * @param ratio How big is the buffer related to the main canvas.
  126445. */
  126446. constructor(scene: Scene, ratio?: number);
  126447. /**
  126448. * Checks wether everything is ready to render a submesh to the G buffer.
  126449. * @param subMesh the submesh to check readiness for
  126450. * @param useInstances is the mesh drawn using instance or not
  126451. * @returns true if ready otherwise false
  126452. */
  126453. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126454. /**
  126455. * Gets the current underlying G Buffer.
  126456. * @returns the buffer
  126457. */
  126458. getGBuffer(): MultiRenderTarget;
  126459. /**
  126460. * Gets the number of samples used to render the buffer (anti aliasing).
  126461. */
  126462. /**
  126463. * Sets the number of samples used to render the buffer (anti aliasing).
  126464. */
  126465. samples: number;
  126466. /**
  126467. * Disposes the renderer and frees up associated resources.
  126468. */
  126469. dispose(): void;
  126470. protected _createRenderTargets(): void;
  126471. private _copyBonesTransformationMatrices;
  126472. }
  126473. }
  126474. declare module BABYLON {
  126475. interface Scene {
  126476. /** @hidden (Backing field) */
  126477. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126478. /**
  126479. * Gets or Sets the current geometry buffer associated to the scene.
  126480. */
  126481. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126482. /**
  126483. * Enables a GeometryBufferRender and associates it with the scene
  126484. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126485. * @returns the GeometryBufferRenderer
  126486. */
  126487. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126488. /**
  126489. * Disables the GeometryBufferRender associated with the scene
  126490. */
  126491. disableGeometryBufferRenderer(): void;
  126492. }
  126493. /**
  126494. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126495. * in several rendering techniques.
  126496. */
  126497. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126498. /**
  126499. * The component name helpful to identify the component in the list of scene components.
  126500. */
  126501. readonly name: string;
  126502. /**
  126503. * The scene the component belongs to.
  126504. */
  126505. scene: Scene;
  126506. /**
  126507. * Creates a new instance of the component for the given scene
  126508. * @param scene Defines the scene to register the component in
  126509. */
  126510. constructor(scene: Scene);
  126511. /**
  126512. * Registers the component in a given scene
  126513. */
  126514. register(): void;
  126515. /**
  126516. * Rebuilds the elements related to this component in case of
  126517. * context lost for instance.
  126518. */
  126519. rebuild(): void;
  126520. /**
  126521. * Disposes the component and the associated ressources
  126522. */
  126523. dispose(): void;
  126524. private _gatherRenderTargets;
  126525. }
  126526. }
  126527. declare module BABYLON {
  126528. /** @hidden */
  126529. export var motionBlurPixelShader: {
  126530. name: string;
  126531. shader: string;
  126532. };
  126533. }
  126534. declare module BABYLON {
  126535. /**
  126536. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126537. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126538. * As an example, all you have to do is to create the post-process:
  126539. * var mb = new BABYLON.MotionBlurPostProcess(
  126540. * 'mb', // The name of the effect.
  126541. * scene, // The scene containing the objects to blur according to their velocity.
  126542. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126543. * camera // The camera to apply the render pass to.
  126544. * );
  126545. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126546. */
  126547. export class MotionBlurPostProcess extends PostProcess {
  126548. /**
  126549. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126550. */
  126551. motionStrength: number;
  126552. /**
  126553. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126554. */
  126555. /**
  126556. * Sets the number of iterations to be used for motion blur quality
  126557. */
  126558. motionBlurSamples: number;
  126559. private _motionBlurSamples;
  126560. private _geometryBufferRenderer;
  126561. /**
  126562. * Creates a new instance MotionBlurPostProcess
  126563. * @param name The name of the effect.
  126564. * @param scene The scene containing the objects to blur according to their velocity.
  126565. * @param options The required width/height ratio to downsize to before computing the render pass.
  126566. * @param camera The camera to apply the render pass to.
  126567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126568. * @param engine The engine which the post process will be applied. (default: current engine)
  126569. * @param reusable If the post process can be reused on the same frame. (default: false)
  126570. * @param textureType Type of textures used when performing the post process. (default: 0)
  126571. * @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)
  126572. */
  126573. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126574. /**
  126575. * Excludes the given skinned mesh from computing bones velocities.
  126576. * 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.
  126577. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126578. */
  126579. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126580. /**
  126581. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126582. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126583. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126584. */
  126585. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126586. /**
  126587. * Disposes the post process.
  126588. * @param camera The camera to dispose the post process on.
  126589. */
  126590. dispose(camera?: Camera): void;
  126591. }
  126592. }
  126593. declare module BABYLON {
  126594. /** @hidden */
  126595. export var refractionPixelShader: {
  126596. name: string;
  126597. shader: string;
  126598. };
  126599. }
  126600. declare module BABYLON {
  126601. /**
  126602. * Post process which applies a refractin texture
  126603. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126604. */
  126605. export class RefractionPostProcess extends PostProcess {
  126606. /** the base color of the refraction (used to taint the rendering) */
  126607. color: Color3;
  126608. /** simulated refraction depth */
  126609. depth: number;
  126610. /** the coefficient of the base color (0 to remove base color tainting) */
  126611. colorLevel: number;
  126612. private _refTexture;
  126613. private _ownRefractionTexture;
  126614. /**
  126615. * Gets or sets the refraction texture
  126616. * Please note that you are responsible for disposing the texture if you set it manually
  126617. */
  126618. refractionTexture: Texture;
  126619. /**
  126620. * Initializes the RefractionPostProcess
  126621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126622. * @param name The name of the effect.
  126623. * @param refractionTextureUrl Url of the refraction texture to use
  126624. * @param color the base color of the refraction (used to taint the rendering)
  126625. * @param depth simulated refraction depth
  126626. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126627. * @param camera The camera to apply the render pass to.
  126628. * @param options The required width/height ratio to downsize to before computing the render pass.
  126629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126630. * @param engine The engine which the post process will be applied. (default: current engine)
  126631. * @param reusable If the post process can be reused on the same frame. (default: false)
  126632. */
  126633. constructor(name: string, refractionTextureUrl: string,
  126634. /** the base color of the refraction (used to taint the rendering) */
  126635. color: Color3,
  126636. /** simulated refraction depth */
  126637. depth: number,
  126638. /** the coefficient of the base color (0 to remove base color tainting) */
  126639. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126640. /**
  126641. * Disposes of the post process
  126642. * @param camera Camera to dispose post process on
  126643. */
  126644. dispose(camera: Camera): void;
  126645. }
  126646. }
  126647. declare module BABYLON {
  126648. /** @hidden */
  126649. export var sharpenPixelShader: {
  126650. name: string;
  126651. shader: string;
  126652. };
  126653. }
  126654. declare module BABYLON {
  126655. /**
  126656. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126657. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126658. */
  126659. export class SharpenPostProcess extends PostProcess {
  126660. /**
  126661. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126662. */
  126663. colorAmount: number;
  126664. /**
  126665. * How much sharpness should be applied (default: 0.3)
  126666. */
  126667. edgeAmount: number;
  126668. /**
  126669. * Creates a new instance ConvolutionPostProcess
  126670. * @param name The name of the effect.
  126671. * @param options The required width/height ratio to downsize to before computing the render pass.
  126672. * @param camera The camera to apply the render pass to.
  126673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126674. * @param engine The engine which the post process will be applied. (default: current engine)
  126675. * @param reusable If the post process can be reused on the same frame. (default: false)
  126676. * @param textureType Type of textures used when performing the post process. (default: 0)
  126677. * @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)
  126678. */
  126679. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126680. }
  126681. }
  126682. declare module BABYLON {
  126683. /**
  126684. * PostProcessRenderPipeline
  126685. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126686. */
  126687. export class PostProcessRenderPipeline {
  126688. private engine;
  126689. private _renderEffects;
  126690. private _renderEffectsForIsolatedPass;
  126691. /**
  126692. * List of inspectable custom properties (used by the Inspector)
  126693. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126694. */
  126695. inspectableCustomProperties: IInspectable[];
  126696. /**
  126697. * @hidden
  126698. */
  126699. protected _cameras: Camera[];
  126700. /** @hidden */
  126701. _name: string;
  126702. /**
  126703. * Gets pipeline name
  126704. */
  126705. readonly name: string;
  126706. /**
  126707. * Initializes a PostProcessRenderPipeline
  126708. * @param engine engine to add the pipeline to
  126709. * @param name name of the pipeline
  126710. */
  126711. constructor(engine: Engine, name: string);
  126712. /**
  126713. * Gets the class name
  126714. * @returns "PostProcessRenderPipeline"
  126715. */
  126716. getClassName(): string;
  126717. /**
  126718. * If all the render effects in the pipeline are supported
  126719. */
  126720. readonly isSupported: boolean;
  126721. /**
  126722. * Adds an effect to the pipeline
  126723. * @param renderEffect the effect to add
  126724. */
  126725. addEffect(renderEffect: PostProcessRenderEffect): void;
  126726. /** @hidden */
  126727. _rebuild(): void;
  126728. /** @hidden */
  126729. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126730. /** @hidden */
  126731. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126732. /** @hidden */
  126733. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126734. /** @hidden */
  126735. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126736. /** @hidden */
  126737. _attachCameras(cameras: Camera, unique: boolean): void;
  126738. /** @hidden */
  126739. _attachCameras(cameras: Camera[], unique: boolean): void;
  126740. /** @hidden */
  126741. _detachCameras(cameras: Camera): void;
  126742. /** @hidden */
  126743. _detachCameras(cameras: Nullable<Camera[]>): void;
  126744. /** @hidden */
  126745. _update(): void;
  126746. /** @hidden */
  126747. _reset(): void;
  126748. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126749. /**
  126750. * Disposes of the pipeline
  126751. */
  126752. dispose(): void;
  126753. }
  126754. }
  126755. declare module BABYLON {
  126756. /**
  126757. * PostProcessRenderPipelineManager class
  126758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126759. */
  126760. export class PostProcessRenderPipelineManager {
  126761. private _renderPipelines;
  126762. /**
  126763. * Initializes a PostProcessRenderPipelineManager
  126764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126765. */
  126766. constructor();
  126767. /**
  126768. * Gets the list of supported render pipelines
  126769. */
  126770. readonly supportedPipelines: PostProcessRenderPipeline[];
  126771. /**
  126772. * Adds a pipeline to the manager
  126773. * @param renderPipeline The pipeline to add
  126774. */
  126775. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126776. /**
  126777. * Attaches a camera to the pipeline
  126778. * @param renderPipelineName The name of the pipeline to attach to
  126779. * @param cameras the camera to attach
  126780. * @param unique if the camera can be attached multiple times to the pipeline
  126781. */
  126782. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126783. /**
  126784. * Detaches a camera from the pipeline
  126785. * @param renderPipelineName The name of the pipeline to detach from
  126786. * @param cameras the camera to detach
  126787. */
  126788. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126789. /**
  126790. * Enables an effect by name on a pipeline
  126791. * @param renderPipelineName the name of the pipeline to enable the effect in
  126792. * @param renderEffectName the name of the effect to enable
  126793. * @param cameras the cameras that the effect should be enabled on
  126794. */
  126795. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126796. /**
  126797. * Disables an effect by name on a pipeline
  126798. * @param renderPipelineName the name of the pipeline to disable the effect in
  126799. * @param renderEffectName the name of the effect to disable
  126800. * @param cameras the cameras that the effect should be disabled on
  126801. */
  126802. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126803. /**
  126804. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126805. */
  126806. update(): void;
  126807. /** @hidden */
  126808. _rebuild(): void;
  126809. /**
  126810. * Disposes of the manager and pipelines
  126811. */
  126812. dispose(): void;
  126813. }
  126814. }
  126815. declare module BABYLON {
  126816. interface Scene {
  126817. /** @hidden (Backing field) */
  126818. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126819. /**
  126820. * Gets the postprocess render pipeline manager
  126821. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126822. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126823. */
  126824. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126825. }
  126826. /**
  126827. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126828. */
  126829. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126830. /**
  126831. * The component name helpfull to identify the component in the list of scene components.
  126832. */
  126833. readonly name: string;
  126834. /**
  126835. * The scene the component belongs to.
  126836. */
  126837. scene: Scene;
  126838. /**
  126839. * Creates a new instance of the component for the given scene
  126840. * @param scene Defines the scene to register the component in
  126841. */
  126842. constructor(scene: Scene);
  126843. /**
  126844. * Registers the component in a given scene
  126845. */
  126846. register(): void;
  126847. /**
  126848. * Rebuilds the elements related to this component in case of
  126849. * context lost for instance.
  126850. */
  126851. rebuild(): void;
  126852. /**
  126853. * Disposes the component and the associated ressources
  126854. */
  126855. dispose(): void;
  126856. private _gatherRenderTargets;
  126857. }
  126858. }
  126859. declare module BABYLON {
  126860. /**
  126861. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126862. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126863. */
  126864. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126865. private _scene;
  126866. private _camerasToBeAttached;
  126867. /**
  126868. * ID of the sharpen post process,
  126869. */
  126870. private readonly SharpenPostProcessId;
  126871. /**
  126872. * @ignore
  126873. * ID of the image processing post process;
  126874. */
  126875. readonly ImageProcessingPostProcessId: string;
  126876. /**
  126877. * @ignore
  126878. * ID of the Fast Approximate Anti-Aliasing post process;
  126879. */
  126880. readonly FxaaPostProcessId: string;
  126881. /**
  126882. * ID of the chromatic aberration post process,
  126883. */
  126884. private readonly ChromaticAberrationPostProcessId;
  126885. /**
  126886. * ID of the grain post process
  126887. */
  126888. private readonly GrainPostProcessId;
  126889. /**
  126890. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126891. */
  126892. sharpen: SharpenPostProcess;
  126893. private _sharpenEffect;
  126894. private bloom;
  126895. /**
  126896. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126897. */
  126898. depthOfField: DepthOfFieldEffect;
  126899. /**
  126900. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126901. */
  126902. fxaa: FxaaPostProcess;
  126903. /**
  126904. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126905. */
  126906. imageProcessing: ImageProcessingPostProcess;
  126907. /**
  126908. * Chromatic aberration post process which will shift rgb colors in the image
  126909. */
  126910. chromaticAberration: ChromaticAberrationPostProcess;
  126911. private _chromaticAberrationEffect;
  126912. /**
  126913. * Grain post process which add noise to the image
  126914. */
  126915. grain: GrainPostProcess;
  126916. private _grainEffect;
  126917. /**
  126918. * Glow post process which adds a glow to emissive areas of the image
  126919. */
  126920. private _glowLayer;
  126921. /**
  126922. * Animations which can be used to tweak settings over a period of time
  126923. */
  126924. animations: Animation[];
  126925. private _imageProcessingConfigurationObserver;
  126926. private _sharpenEnabled;
  126927. private _bloomEnabled;
  126928. private _depthOfFieldEnabled;
  126929. private _depthOfFieldBlurLevel;
  126930. private _fxaaEnabled;
  126931. private _imageProcessingEnabled;
  126932. private _defaultPipelineTextureType;
  126933. private _bloomScale;
  126934. private _chromaticAberrationEnabled;
  126935. private _grainEnabled;
  126936. private _buildAllowed;
  126937. /**
  126938. * Gets active scene
  126939. */
  126940. readonly scene: Scene;
  126941. /**
  126942. * Enable or disable the sharpen process from the pipeline
  126943. */
  126944. sharpenEnabled: boolean;
  126945. private _resizeObserver;
  126946. private _hardwareScaleLevel;
  126947. private _bloomKernel;
  126948. /**
  126949. * Specifies the size of the bloom blur kernel, relative to the final output size
  126950. */
  126951. bloomKernel: number;
  126952. /**
  126953. * Specifies the weight of the bloom in the final rendering
  126954. */
  126955. private _bloomWeight;
  126956. /**
  126957. * Specifies the luma threshold for the area that will be blurred by the bloom
  126958. */
  126959. private _bloomThreshold;
  126960. private _hdr;
  126961. /**
  126962. * The strength of the bloom.
  126963. */
  126964. bloomWeight: number;
  126965. /**
  126966. * The strength of the bloom.
  126967. */
  126968. bloomThreshold: number;
  126969. /**
  126970. * The scale of the bloom, lower value will provide better performance.
  126971. */
  126972. bloomScale: number;
  126973. /**
  126974. * Enable or disable the bloom from the pipeline
  126975. */
  126976. bloomEnabled: boolean;
  126977. private _rebuildBloom;
  126978. /**
  126979. * If the depth of field is enabled.
  126980. */
  126981. depthOfFieldEnabled: boolean;
  126982. /**
  126983. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126984. */
  126985. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126986. /**
  126987. * If the anti aliasing is enabled.
  126988. */
  126989. fxaaEnabled: boolean;
  126990. private _samples;
  126991. /**
  126992. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126993. */
  126994. samples: number;
  126995. /**
  126996. * If image processing is enabled.
  126997. */
  126998. imageProcessingEnabled: boolean;
  126999. /**
  127000. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  127001. */
  127002. glowLayerEnabled: boolean;
  127003. /**
  127004. * Gets the glow layer (or null if not defined)
  127005. */
  127006. readonly glowLayer: Nullable<GlowLayer>;
  127007. /**
  127008. * Enable or disable the chromaticAberration process from the pipeline
  127009. */
  127010. chromaticAberrationEnabled: boolean;
  127011. /**
  127012. * Enable or disable the grain process from the pipeline
  127013. */
  127014. grainEnabled: boolean;
  127015. /**
  127016. * @constructor
  127017. * @param name - The rendering pipeline name (default: "")
  127018. * @param hdr - If high dynamic range textures should be used (default: true)
  127019. * @param scene - The scene linked to this pipeline (default: the last created scene)
  127020. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  127021. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  127022. */
  127023. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  127024. /**
  127025. * Get the class name
  127026. * @returns "DefaultRenderingPipeline"
  127027. */
  127028. getClassName(): string;
  127029. /**
  127030. * Force the compilation of the entire pipeline.
  127031. */
  127032. prepare(): void;
  127033. private _hasCleared;
  127034. private _prevPostProcess;
  127035. private _prevPrevPostProcess;
  127036. private _setAutoClearAndTextureSharing;
  127037. private _depthOfFieldSceneObserver;
  127038. private _buildPipeline;
  127039. private _disposePostProcesses;
  127040. /**
  127041. * Adds a camera to the pipeline
  127042. * @param camera the camera to be added
  127043. */
  127044. addCamera(camera: Camera): void;
  127045. /**
  127046. * Removes a camera from the pipeline
  127047. * @param camera the camera to remove
  127048. */
  127049. removeCamera(camera: Camera): void;
  127050. /**
  127051. * Dispose of the pipeline and stop all post processes
  127052. */
  127053. dispose(): void;
  127054. /**
  127055. * Serialize the rendering pipeline (Used when exporting)
  127056. * @returns the serialized object
  127057. */
  127058. serialize(): any;
  127059. /**
  127060. * Parse the serialized pipeline
  127061. * @param source Source pipeline.
  127062. * @param scene The scene to load the pipeline to.
  127063. * @param rootUrl The URL of the serialized pipeline.
  127064. * @returns An instantiated pipeline from the serialized object.
  127065. */
  127066. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  127067. }
  127068. }
  127069. declare module BABYLON {
  127070. /** @hidden */
  127071. export var lensHighlightsPixelShader: {
  127072. name: string;
  127073. shader: string;
  127074. };
  127075. }
  127076. declare module BABYLON {
  127077. /** @hidden */
  127078. export var depthOfFieldPixelShader: {
  127079. name: string;
  127080. shader: string;
  127081. };
  127082. }
  127083. declare module BABYLON {
  127084. /**
  127085. * BABYLON.JS Chromatic Aberration GLSL Shader
  127086. * Author: Olivier Guyot
  127087. * Separates very slightly R, G and B colors on the edges of the screen
  127088. * Inspired by Francois Tarlier & Martins Upitis
  127089. */
  127090. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127091. /**
  127092. * @ignore
  127093. * The chromatic aberration PostProcess id in the pipeline
  127094. */
  127095. LensChromaticAberrationEffect: string;
  127096. /**
  127097. * @ignore
  127098. * The highlights enhancing PostProcess id in the pipeline
  127099. */
  127100. HighlightsEnhancingEffect: string;
  127101. /**
  127102. * @ignore
  127103. * The depth-of-field PostProcess id in the pipeline
  127104. */
  127105. LensDepthOfFieldEffect: string;
  127106. private _scene;
  127107. private _depthTexture;
  127108. private _grainTexture;
  127109. private _chromaticAberrationPostProcess;
  127110. private _highlightsPostProcess;
  127111. private _depthOfFieldPostProcess;
  127112. private _edgeBlur;
  127113. private _grainAmount;
  127114. private _chromaticAberration;
  127115. private _distortion;
  127116. private _highlightsGain;
  127117. private _highlightsThreshold;
  127118. private _dofDistance;
  127119. private _dofAperture;
  127120. private _dofDarken;
  127121. private _dofPentagon;
  127122. private _blurNoise;
  127123. /**
  127124. * @constructor
  127125. *
  127126. * Effect parameters are as follow:
  127127. * {
  127128. * chromatic_aberration: number; // from 0 to x (1 for realism)
  127129. * edge_blur: number; // from 0 to x (1 for realism)
  127130. * distortion: number; // from 0 to x (1 for realism)
  127131. * grain_amount: number; // from 0 to 1
  127132. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127133. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127134. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127135. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127136. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127137. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127138. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127139. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127140. * }
  127141. * Note: if an effect parameter is unset, effect is disabled
  127142. *
  127143. * @param name The rendering pipeline name
  127144. * @param parameters - An object containing all parameters (see above)
  127145. * @param scene The scene linked to this pipeline
  127146. * @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)
  127147. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127148. */
  127149. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127150. /**
  127151. * Get the class name
  127152. * @returns "LensRenderingPipeline"
  127153. */
  127154. getClassName(): string;
  127155. /**
  127156. * Gets associated scene
  127157. */
  127158. readonly scene: Scene;
  127159. /**
  127160. * Gets or sets the edge blur
  127161. */
  127162. edgeBlur: number;
  127163. /**
  127164. * Gets or sets the grain amount
  127165. */
  127166. grainAmount: number;
  127167. /**
  127168. * Gets or sets the chromatic aberration amount
  127169. */
  127170. chromaticAberration: number;
  127171. /**
  127172. * Gets or sets the depth of field aperture
  127173. */
  127174. dofAperture: number;
  127175. /**
  127176. * Gets or sets the edge distortion
  127177. */
  127178. edgeDistortion: number;
  127179. /**
  127180. * Gets or sets the depth of field distortion
  127181. */
  127182. dofDistortion: number;
  127183. /**
  127184. * Gets or sets the darken out of focus amount
  127185. */
  127186. darkenOutOfFocus: number;
  127187. /**
  127188. * Gets or sets a boolean indicating if blur noise is enabled
  127189. */
  127190. blurNoise: boolean;
  127191. /**
  127192. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  127193. */
  127194. pentagonBokeh: boolean;
  127195. /**
  127196. * Gets or sets the highlight grain amount
  127197. */
  127198. highlightsGain: number;
  127199. /**
  127200. * Gets or sets the highlight threshold
  127201. */
  127202. highlightsThreshold: number;
  127203. /**
  127204. * Sets the amount of blur at the edges
  127205. * @param amount blur amount
  127206. */
  127207. setEdgeBlur(amount: number): void;
  127208. /**
  127209. * Sets edge blur to 0
  127210. */
  127211. disableEdgeBlur(): void;
  127212. /**
  127213. * Sets the amout of grain
  127214. * @param amount Amount of grain
  127215. */
  127216. setGrainAmount(amount: number): void;
  127217. /**
  127218. * Set grain amount to 0
  127219. */
  127220. disableGrain(): void;
  127221. /**
  127222. * Sets the chromatic aberration amount
  127223. * @param amount amount of chromatic aberration
  127224. */
  127225. setChromaticAberration(amount: number): void;
  127226. /**
  127227. * Sets chromatic aberration amount to 0
  127228. */
  127229. disableChromaticAberration(): void;
  127230. /**
  127231. * Sets the EdgeDistortion amount
  127232. * @param amount amount of EdgeDistortion
  127233. */
  127234. setEdgeDistortion(amount: number): void;
  127235. /**
  127236. * Sets edge distortion to 0
  127237. */
  127238. disableEdgeDistortion(): void;
  127239. /**
  127240. * Sets the FocusDistance amount
  127241. * @param amount amount of FocusDistance
  127242. */
  127243. setFocusDistance(amount: number): void;
  127244. /**
  127245. * Disables depth of field
  127246. */
  127247. disableDepthOfField(): void;
  127248. /**
  127249. * Sets the Aperture amount
  127250. * @param amount amount of Aperture
  127251. */
  127252. setAperture(amount: number): void;
  127253. /**
  127254. * Sets the DarkenOutOfFocus amount
  127255. * @param amount amount of DarkenOutOfFocus
  127256. */
  127257. setDarkenOutOfFocus(amount: number): void;
  127258. private _pentagonBokehIsEnabled;
  127259. /**
  127260. * Creates a pentagon bokeh effect
  127261. */
  127262. enablePentagonBokeh(): void;
  127263. /**
  127264. * Disables the pentagon bokeh effect
  127265. */
  127266. disablePentagonBokeh(): void;
  127267. /**
  127268. * Enables noise blur
  127269. */
  127270. enableNoiseBlur(): void;
  127271. /**
  127272. * Disables noise blur
  127273. */
  127274. disableNoiseBlur(): void;
  127275. /**
  127276. * Sets the HighlightsGain amount
  127277. * @param amount amount of HighlightsGain
  127278. */
  127279. setHighlightsGain(amount: number): void;
  127280. /**
  127281. * Sets the HighlightsThreshold amount
  127282. * @param amount amount of HighlightsThreshold
  127283. */
  127284. setHighlightsThreshold(amount: number): void;
  127285. /**
  127286. * Disables highlights
  127287. */
  127288. disableHighlights(): void;
  127289. /**
  127290. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127291. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127292. */
  127293. dispose(disableDepthRender?: boolean): void;
  127294. private _createChromaticAberrationPostProcess;
  127295. private _createHighlightsPostProcess;
  127296. private _createDepthOfFieldPostProcess;
  127297. private _createGrainTexture;
  127298. }
  127299. }
  127300. declare module BABYLON {
  127301. /** @hidden */
  127302. export var ssao2PixelShader: {
  127303. name: string;
  127304. shader: string;
  127305. };
  127306. }
  127307. declare module BABYLON {
  127308. /** @hidden */
  127309. export var ssaoCombinePixelShader: {
  127310. name: string;
  127311. shader: string;
  127312. };
  127313. }
  127314. declare module BABYLON {
  127315. /**
  127316. * Render pipeline to produce ssao effect
  127317. */
  127318. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127319. /**
  127320. * @ignore
  127321. * The PassPostProcess id in the pipeline that contains the original scene color
  127322. */
  127323. SSAOOriginalSceneColorEffect: string;
  127324. /**
  127325. * @ignore
  127326. * The SSAO PostProcess id in the pipeline
  127327. */
  127328. SSAORenderEffect: string;
  127329. /**
  127330. * @ignore
  127331. * The horizontal blur PostProcess id in the pipeline
  127332. */
  127333. SSAOBlurHRenderEffect: string;
  127334. /**
  127335. * @ignore
  127336. * The vertical blur PostProcess id in the pipeline
  127337. */
  127338. SSAOBlurVRenderEffect: string;
  127339. /**
  127340. * @ignore
  127341. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127342. */
  127343. SSAOCombineRenderEffect: string;
  127344. /**
  127345. * The output strength of the SSAO post-process. Default value is 1.0.
  127346. */
  127347. totalStrength: number;
  127348. /**
  127349. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127350. */
  127351. maxZ: number;
  127352. /**
  127353. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127354. */
  127355. minZAspect: number;
  127356. private _samples;
  127357. /**
  127358. * Number of samples used for the SSAO calculations. Default value is 8
  127359. */
  127360. samples: number;
  127361. private _textureSamples;
  127362. /**
  127363. * Number of samples to use for antialiasing
  127364. */
  127365. textureSamples: number;
  127366. /**
  127367. * Ratio object used for SSAO ratio and blur ratio
  127368. */
  127369. private _ratio;
  127370. /**
  127371. * Dynamically generated sphere sampler.
  127372. */
  127373. private _sampleSphere;
  127374. /**
  127375. * Blur filter offsets
  127376. */
  127377. private _samplerOffsets;
  127378. private _expensiveBlur;
  127379. /**
  127380. * If bilateral blur should be used
  127381. */
  127382. expensiveBlur: boolean;
  127383. /**
  127384. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127385. */
  127386. radius: number;
  127387. /**
  127388. * The base color of the SSAO post-process
  127389. * The final result is "base + ssao" between [0, 1]
  127390. */
  127391. base: number;
  127392. /**
  127393. * Support test.
  127394. */
  127395. static readonly IsSupported: boolean;
  127396. private _scene;
  127397. private _depthTexture;
  127398. private _normalTexture;
  127399. private _randomTexture;
  127400. private _originalColorPostProcess;
  127401. private _ssaoPostProcess;
  127402. private _blurHPostProcess;
  127403. private _blurVPostProcess;
  127404. private _ssaoCombinePostProcess;
  127405. private _firstUpdate;
  127406. /**
  127407. * Gets active scene
  127408. */
  127409. readonly scene: Scene;
  127410. /**
  127411. * @constructor
  127412. * @param name The rendering pipeline name
  127413. * @param scene The scene linked to this pipeline
  127414. * @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 }
  127415. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127416. */
  127417. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127418. /**
  127419. * Get the class name
  127420. * @returns "SSAO2RenderingPipeline"
  127421. */
  127422. getClassName(): string;
  127423. /**
  127424. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127425. */
  127426. dispose(disableGeometryBufferRenderer?: boolean): void;
  127427. private _createBlurPostProcess;
  127428. /** @hidden */
  127429. _rebuild(): void;
  127430. private _bits;
  127431. private _radicalInverse_VdC;
  127432. private _hammersley;
  127433. private _hemisphereSample_uniform;
  127434. private _generateHemisphere;
  127435. private _createSSAOPostProcess;
  127436. private _createSSAOCombinePostProcess;
  127437. private _createRandomTexture;
  127438. /**
  127439. * Serialize the rendering pipeline (Used when exporting)
  127440. * @returns the serialized object
  127441. */
  127442. serialize(): any;
  127443. /**
  127444. * Parse the serialized pipeline
  127445. * @param source Source pipeline.
  127446. * @param scene The scene to load the pipeline to.
  127447. * @param rootUrl The URL of the serialized pipeline.
  127448. * @returns An instantiated pipeline from the serialized object.
  127449. */
  127450. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127451. }
  127452. }
  127453. declare module BABYLON {
  127454. /** @hidden */
  127455. export var ssaoPixelShader: {
  127456. name: string;
  127457. shader: string;
  127458. };
  127459. }
  127460. declare module BABYLON {
  127461. /**
  127462. * Render pipeline to produce ssao effect
  127463. */
  127464. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127465. /**
  127466. * @ignore
  127467. * The PassPostProcess id in the pipeline that contains the original scene color
  127468. */
  127469. SSAOOriginalSceneColorEffect: string;
  127470. /**
  127471. * @ignore
  127472. * The SSAO PostProcess id in the pipeline
  127473. */
  127474. SSAORenderEffect: string;
  127475. /**
  127476. * @ignore
  127477. * The horizontal blur PostProcess id in the pipeline
  127478. */
  127479. SSAOBlurHRenderEffect: string;
  127480. /**
  127481. * @ignore
  127482. * The vertical blur PostProcess id in the pipeline
  127483. */
  127484. SSAOBlurVRenderEffect: string;
  127485. /**
  127486. * @ignore
  127487. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127488. */
  127489. SSAOCombineRenderEffect: string;
  127490. /**
  127491. * The output strength of the SSAO post-process. Default value is 1.0.
  127492. */
  127493. totalStrength: number;
  127494. /**
  127495. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127496. */
  127497. radius: number;
  127498. /**
  127499. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127500. * Must not be equal to fallOff and superior to fallOff.
  127501. * Default value is 0.0075
  127502. */
  127503. area: number;
  127504. /**
  127505. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127506. * Must not be equal to area and inferior to area.
  127507. * Default value is 0.000001
  127508. */
  127509. fallOff: number;
  127510. /**
  127511. * The base color of the SSAO post-process
  127512. * The final result is "base + ssao" between [0, 1]
  127513. */
  127514. base: number;
  127515. private _scene;
  127516. private _depthTexture;
  127517. private _randomTexture;
  127518. private _originalColorPostProcess;
  127519. private _ssaoPostProcess;
  127520. private _blurHPostProcess;
  127521. private _blurVPostProcess;
  127522. private _ssaoCombinePostProcess;
  127523. private _firstUpdate;
  127524. /**
  127525. * Gets active scene
  127526. */
  127527. readonly scene: Scene;
  127528. /**
  127529. * @constructor
  127530. * @param name - The rendering pipeline name
  127531. * @param scene - The scene linked to this pipeline
  127532. * @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 }
  127533. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127534. */
  127535. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127536. /**
  127537. * Get the class name
  127538. * @returns "SSAORenderingPipeline"
  127539. */
  127540. getClassName(): string;
  127541. /**
  127542. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127543. */
  127544. dispose(disableDepthRender?: boolean): void;
  127545. private _createBlurPostProcess;
  127546. /** @hidden */
  127547. _rebuild(): void;
  127548. private _createSSAOPostProcess;
  127549. private _createSSAOCombinePostProcess;
  127550. private _createRandomTexture;
  127551. }
  127552. }
  127553. declare module BABYLON {
  127554. /** @hidden */
  127555. export var standardPixelShader: {
  127556. name: string;
  127557. shader: string;
  127558. };
  127559. }
  127560. declare module BABYLON {
  127561. /**
  127562. * Standard rendering pipeline
  127563. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127564. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127565. */
  127566. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127567. /**
  127568. * Public members
  127569. */
  127570. /**
  127571. * Post-process which contains the original scene color before the pipeline applies all the effects
  127572. */
  127573. originalPostProcess: Nullable<PostProcess>;
  127574. /**
  127575. * Post-process used to down scale an image x4
  127576. */
  127577. downSampleX4PostProcess: Nullable<PostProcess>;
  127578. /**
  127579. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127580. */
  127581. brightPassPostProcess: Nullable<PostProcess>;
  127582. /**
  127583. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127584. */
  127585. blurHPostProcesses: PostProcess[];
  127586. /**
  127587. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127588. */
  127589. blurVPostProcesses: PostProcess[];
  127590. /**
  127591. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127592. */
  127593. textureAdderPostProcess: Nullable<PostProcess>;
  127594. /**
  127595. * Post-process used to create volumetric lighting effect
  127596. */
  127597. volumetricLightPostProcess: Nullable<PostProcess>;
  127598. /**
  127599. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127600. */
  127601. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127602. /**
  127603. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127604. */
  127605. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127606. /**
  127607. * Post-process used to merge the volumetric light effect and the real scene color
  127608. */
  127609. volumetricLightMergePostProces: Nullable<PostProcess>;
  127610. /**
  127611. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127612. */
  127613. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127614. /**
  127615. * Base post-process used to calculate the average luminance of the final image for HDR
  127616. */
  127617. luminancePostProcess: Nullable<PostProcess>;
  127618. /**
  127619. * Post-processes used to create down sample post-processes in order to get
  127620. * the average luminance of the final image for HDR
  127621. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127622. */
  127623. luminanceDownSamplePostProcesses: PostProcess[];
  127624. /**
  127625. * Post-process used to create a HDR effect (light adaptation)
  127626. */
  127627. hdrPostProcess: Nullable<PostProcess>;
  127628. /**
  127629. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127630. */
  127631. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127632. /**
  127633. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127634. */
  127635. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127636. /**
  127637. * Post-process used to merge the final HDR post-process and the real scene color
  127638. */
  127639. hdrFinalPostProcess: Nullable<PostProcess>;
  127640. /**
  127641. * Post-process used to create a lens flare effect
  127642. */
  127643. lensFlarePostProcess: Nullable<PostProcess>;
  127644. /**
  127645. * Post-process that merges the result of the lens flare post-process and the real scene color
  127646. */
  127647. lensFlareComposePostProcess: Nullable<PostProcess>;
  127648. /**
  127649. * Post-process used to create a motion blur effect
  127650. */
  127651. motionBlurPostProcess: Nullable<PostProcess>;
  127652. /**
  127653. * Post-process used to create a depth of field effect
  127654. */
  127655. depthOfFieldPostProcess: Nullable<PostProcess>;
  127656. /**
  127657. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127658. */
  127659. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127660. /**
  127661. * Represents the brightness threshold in order to configure the illuminated surfaces
  127662. */
  127663. brightThreshold: number;
  127664. /**
  127665. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127666. */
  127667. blurWidth: number;
  127668. /**
  127669. * Sets if the blur for highlighted surfaces must be only horizontal
  127670. */
  127671. horizontalBlur: boolean;
  127672. /**
  127673. * Gets the overall exposure used by the pipeline
  127674. */
  127675. /**
  127676. * Sets the overall exposure used by the pipeline
  127677. */
  127678. exposure: number;
  127679. /**
  127680. * Texture used typically to simulate "dirty" on camera lens
  127681. */
  127682. lensTexture: Nullable<Texture>;
  127683. /**
  127684. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127685. */
  127686. volumetricLightCoefficient: number;
  127687. /**
  127688. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127689. */
  127690. volumetricLightPower: number;
  127691. /**
  127692. * Used the set the blur intensity to smooth the volumetric lights
  127693. */
  127694. volumetricLightBlurScale: number;
  127695. /**
  127696. * Light (spot or directional) used to generate the volumetric lights rays
  127697. * The source light must have a shadow generate so the pipeline can get its
  127698. * depth map
  127699. */
  127700. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127701. /**
  127702. * For eye adaptation, represents the minimum luminance the eye can see
  127703. */
  127704. hdrMinimumLuminance: number;
  127705. /**
  127706. * For eye adaptation, represents the decrease luminance speed
  127707. */
  127708. hdrDecreaseRate: number;
  127709. /**
  127710. * For eye adaptation, represents the increase luminance speed
  127711. */
  127712. hdrIncreaseRate: number;
  127713. /**
  127714. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127715. */
  127716. /**
  127717. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127718. */
  127719. hdrAutoExposure: boolean;
  127720. /**
  127721. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127722. */
  127723. lensColorTexture: Nullable<Texture>;
  127724. /**
  127725. * The overall strengh for the lens flare effect
  127726. */
  127727. lensFlareStrength: number;
  127728. /**
  127729. * Dispersion coefficient for lens flare ghosts
  127730. */
  127731. lensFlareGhostDispersal: number;
  127732. /**
  127733. * Main lens flare halo width
  127734. */
  127735. lensFlareHaloWidth: number;
  127736. /**
  127737. * Based on the lens distortion effect, defines how much the lens flare result
  127738. * is distorted
  127739. */
  127740. lensFlareDistortionStrength: number;
  127741. /**
  127742. * Configures the blur intensity used for for lens flare (halo)
  127743. */
  127744. lensFlareBlurWidth: number;
  127745. /**
  127746. * Lens star texture must be used to simulate rays on the flares and is available
  127747. * in the documentation
  127748. */
  127749. lensStarTexture: Nullable<Texture>;
  127750. /**
  127751. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127752. * flare effect by taking account of the dirt texture
  127753. */
  127754. lensFlareDirtTexture: Nullable<Texture>;
  127755. /**
  127756. * Represents the focal length for the depth of field effect
  127757. */
  127758. depthOfFieldDistance: number;
  127759. /**
  127760. * Represents the blur intensity for the blurred part of the depth of field effect
  127761. */
  127762. depthOfFieldBlurWidth: number;
  127763. /**
  127764. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127765. */
  127766. /**
  127767. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127768. */
  127769. motionStrength: number;
  127770. /**
  127771. * Gets wether or not the motion blur post-process is object based or screen based.
  127772. */
  127773. /**
  127774. * Sets wether or not the motion blur post-process should be object based or screen based
  127775. */
  127776. objectBasedMotionBlur: boolean;
  127777. /**
  127778. * List of animations for the pipeline (IAnimatable implementation)
  127779. */
  127780. animations: Animation[];
  127781. /**
  127782. * Private members
  127783. */
  127784. private _scene;
  127785. private _currentDepthOfFieldSource;
  127786. private _basePostProcess;
  127787. private _fixedExposure;
  127788. private _currentExposure;
  127789. private _hdrAutoExposure;
  127790. private _hdrCurrentLuminance;
  127791. private _motionStrength;
  127792. private _isObjectBasedMotionBlur;
  127793. private _floatTextureType;
  127794. private _camerasToBeAttached;
  127795. private _ratio;
  127796. private _bloomEnabled;
  127797. private _depthOfFieldEnabled;
  127798. private _vlsEnabled;
  127799. private _lensFlareEnabled;
  127800. private _hdrEnabled;
  127801. private _motionBlurEnabled;
  127802. private _fxaaEnabled;
  127803. private _motionBlurSamples;
  127804. private _volumetricLightStepsCount;
  127805. private _samples;
  127806. /**
  127807. * @ignore
  127808. * Specifies if the bloom pipeline is enabled
  127809. */
  127810. BloomEnabled: boolean;
  127811. /**
  127812. * @ignore
  127813. * Specifies if the depth of field pipeline is enabed
  127814. */
  127815. DepthOfFieldEnabled: boolean;
  127816. /**
  127817. * @ignore
  127818. * Specifies if the lens flare pipeline is enabed
  127819. */
  127820. LensFlareEnabled: boolean;
  127821. /**
  127822. * @ignore
  127823. * Specifies if the HDR pipeline is enabled
  127824. */
  127825. HDREnabled: boolean;
  127826. /**
  127827. * @ignore
  127828. * Specifies if the volumetric lights scattering effect is enabled
  127829. */
  127830. VLSEnabled: boolean;
  127831. /**
  127832. * @ignore
  127833. * Specifies if the motion blur effect is enabled
  127834. */
  127835. MotionBlurEnabled: boolean;
  127836. /**
  127837. * Specifies if anti-aliasing is enabled
  127838. */
  127839. fxaaEnabled: boolean;
  127840. /**
  127841. * Specifies the number of steps used to calculate the volumetric lights
  127842. * Typically in interval [50, 200]
  127843. */
  127844. volumetricLightStepsCount: number;
  127845. /**
  127846. * Specifies the number of samples used for the motion blur effect
  127847. * Typically in interval [16, 64]
  127848. */
  127849. motionBlurSamples: number;
  127850. /**
  127851. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127852. */
  127853. samples: number;
  127854. /**
  127855. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127856. * @constructor
  127857. * @param name The rendering pipeline name
  127858. * @param scene The scene linked to this pipeline
  127859. * @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)
  127860. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127861. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127862. */
  127863. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127864. private _buildPipeline;
  127865. private _createDownSampleX4PostProcess;
  127866. private _createBrightPassPostProcess;
  127867. private _createBlurPostProcesses;
  127868. private _createTextureAdderPostProcess;
  127869. private _createVolumetricLightPostProcess;
  127870. private _createLuminancePostProcesses;
  127871. private _createHdrPostProcess;
  127872. private _createLensFlarePostProcess;
  127873. private _createDepthOfFieldPostProcess;
  127874. private _createMotionBlurPostProcess;
  127875. private _getDepthTexture;
  127876. private _disposePostProcesses;
  127877. /**
  127878. * Dispose of the pipeline and stop all post processes
  127879. */
  127880. dispose(): void;
  127881. /**
  127882. * Serialize the rendering pipeline (Used when exporting)
  127883. * @returns the serialized object
  127884. */
  127885. serialize(): any;
  127886. /**
  127887. * Parse the serialized pipeline
  127888. * @param source Source pipeline.
  127889. * @param scene The scene to load the pipeline to.
  127890. * @param rootUrl The URL of the serialized pipeline.
  127891. * @returns An instantiated pipeline from the serialized object.
  127892. */
  127893. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127894. /**
  127895. * Luminance steps
  127896. */
  127897. static LuminanceSteps: number;
  127898. }
  127899. }
  127900. declare module BABYLON {
  127901. /** @hidden */
  127902. export var tonemapPixelShader: {
  127903. name: string;
  127904. shader: string;
  127905. };
  127906. }
  127907. declare module BABYLON {
  127908. /** Defines operator used for tonemapping */
  127909. export enum TonemappingOperator {
  127910. /** Hable */
  127911. Hable = 0,
  127912. /** Reinhard */
  127913. Reinhard = 1,
  127914. /** HejiDawson */
  127915. HejiDawson = 2,
  127916. /** Photographic */
  127917. Photographic = 3
  127918. }
  127919. /**
  127920. * Defines a post process to apply tone mapping
  127921. */
  127922. export class TonemapPostProcess extends PostProcess {
  127923. private _operator;
  127924. /** Defines the required exposure adjustement */
  127925. exposureAdjustment: number;
  127926. /**
  127927. * Creates a new TonemapPostProcess
  127928. * @param name defines the name of the postprocess
  127929. * @param _operator defines the operator to use
  127930. * @param exposureAdjustment defines the required exposure adjustement
  127931. * @param camera defines the camera to use (can be null)
  127932. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127933. * @param engine defines the hosting engine (can be ignore if camera is set)
  127934. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127935. */
  127936. constructor(name: string, _operator: TonemappingOperator,
  127937. /** Defines the required exposure adjustement */
  127938. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127939. }
  127940. }
  127941. declare module BABYLON {
  127942. /** @hidden */
  127943. export var depthVertexShader: {
  127944. name: string;
  127945. shader: string;
  127946. };
  127947. }
  127948. declare module BABYLON {
  127949. /** @hidden */
  127950. export var volumetricLightScatteringPixelShader: {
  127951. name: string;
  127952. shader: string;
  127953. };
  127954. }
  127955. declare module BABYLON {
  127956. /** @hidden */
  127957. export var volumetricLightScatteringPassVertexShader: {
  127958. name: string;
  127959. shader: string;
  127960. };
  127961. }
  127962. declare module BABYLON {
  127963. /** @hidden */
  127964. export var volumetricLightScatteringPassPixelShader: {
  127965. name: string;
  127966. shader: string;
  127967. };
  127968. }
  127969. declare module BABYLON {
  127970. /**
  127971. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127972. */
  127973. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127974. private _volumetricLightScatteringPass;
  127975. private _volumetricLightScatteringRTT;
  127976. private _viewPort;
  127977. private _screenCoordinates;
  127978. private _cachedDefines;
  127979. /**
  127980. * If not undefined, the mesh position is computed from the attached node position
  127981. */
  127982. attachedNode: {
  127983. position: Vector3;
  127984. };
  127985. /**
  127986. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127987. */
  127988. customMeshPosition: Vector3;
  127989. /**
  127990. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127991. */
  127992. useCustomMeshPosition: boolean;
  127993. /**
  127994. * If the post-process should inverse the light scattering direction
  127995. */
  127996. invert: boolean;
  127997. /**
  127998. * The internal mesh used by the post-process
  127999. */
  128000. mesh: Mesh;
  128001. /**
  128002. * @hidden
  128003. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  128004. */
  128005. useDiffuseColor: boolean;
  128006. /**
  128007. * Array containing the excluded meshes not rendered in the internal pass
  128008. */
  128009. excludedMeshes: AbstractMesh[];
  128010. /**
  128011. * Controls the overall intensity of the post-process
  128012. */
  128013. exposure: number;
  128014. /**
  128015. * Dissipates each sample's contribution in range [0, 1]
  128016. */
  128017. decay: number;
  128018. /**
  128019. * Controls the overall intensity of each sample
  128020. */
  128021. weight: number;
  128022. /**
  128023. * Controls the density of each sample
  128024. */
  128025. density: number;
  128026. /**
  128027. * @constructor
  128028. * @param name The post-process name
  128029. * @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)
  128030. * @param camera The camera that the post-process will be attached to
  128031. * @param mesh The mesh used to create the light scattering
  128032. * @param samples The post-process quality, default 100
  128033. * @param samplingModeThe post-process filtering mode
  128034. * @param engine The babylon engine
  128035. * @param reusable If the post-process is reusable
  128036. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  128037. */
  128038. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  128039. /**
  128040. * Returns the string "VolumetricLightScatteringPostProcess"
  128041. * @returns "VolumetricLightScatteringPostProcess"
  128042. */
  128043. getClassName(): string;
  128044. private _isReady;
  128045. /**
  128046. * Sets the new light position for light scattering effect
  128047. * @param position The new custom light position
  128048. */
  128049. setCustomMeshPosition(position: Vector3): void;
  128050. /**
  128051. * Returns the light position for light scattering effect
  128052. * @return Vector3 The custom light position
  128053. */
  128054. getCustomMeshPosition(): Vector3;
  128055. /**
  128056. * Disposes the internal assets and detaches the post-process from the camera
  128057. */
  128058. dispose(camera: Camera): void;
  128059. /**
  128060. * Returns the render target texture used by the post-process
  128061. * @return the render target texture used by the post-process
  128062. */
  128063. getPass(): RenderTargetTexture;
  128064. private _meshExcluded;
  128065. private _createPass;
  128066. private _updateMeshScreenCoordinates;
  128067. /**
  128068. * Creates a default mesh for the Volumeric Light Scattering post-process
  128069. * @param name The mesh name
  128070. * @param scene The scene where to create the mesh
  128071. * @return the default mesh
  128072. */
  128073. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  128074. }
  128075. }
  128076. declare module BABYLON {
  128077. interface Scene {
  128078. /** @hidden (Backing field) */
  128079. _boundingBoxRenderer: BoundingBoxRenderer;
  128080. /** @hidden (Backing field) */
  128081. _forceShowBoundingBoxes: boolean;
  128082. /**
  128083. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  128084. */
  128085. forceShowBoundingBoxes: boolean;
  128086. /**
  128087. * Gets the bounding box renderer associated with the scene
  128088. * @returns a BoundingBoxRenderer
  128089. */
  128090. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128091. }
  128092. interface AbstractMesh {
  128093. /** @hidden (Backing field) */
  128094. _showBoundingBox: boolean;
  128095. /**
  128096. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128097. */
  128098. showBoundingBox: boolean;
  128099. }
  128100. /**
  128101. * Component responsible of rendering the bounding box of the meshes in a scene.
  128102. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128103. */
  128104. export class BoundingBoxRenderer implements ISceneComponent {
  128105. /**
  128106. * The component name helpfull to identify the component in the list of scene components.
  128107. */
  128108. readonly name: string;
  128109. /**
  128110. * The scene the component belongs to.
  128111. */
  128112. scene: Scene;
  128113. /**
  128114. * Color of the bounding box lines placed in front of an object
  128115. */
  128116. frontColor: Color3;
  128117. /**
  128118. * Color of the bounding box lines placed behind an object
  128119. */
  128120. backColor: Color3;
  128121. /**
  128122. * Defines if the renderer should show the back lines or not
  128123. */
  128124. showBackLines: boolean;
  128125. /**
  128126. * @hidden
  128127. */
  128128. renderList: SmartArray<BoundingBox>;
  128129. private _colorShader;
  128130. private _vertexBuffers;
  128131. private _indexBuffer;
  128132. private _fillIndexBuffer;
  128133. private _fillIndexData;
  128134. /**
  128135. * Instantiates a new bounding box renderer in a scene.
  128136. * @param scene the scene the renderer renders in
  128137. */
  128138. constructor(scene: Scene);
  128139. /**
  128140. * Registers the component in a given scene
  128141. */
  128142. register(): void;
  128143. private _evaluateSubMesh;
  128144. private _activeMesh;
  128145. private _prepareRessources;
  128146. private _createIndexBuffer;
  128147. /**
  128148. * Rebuilds the elements related to this component in case of
  128149. * context lost for instance.
  128150. */
  128151. rebuild(): void;
  128152. /**
  128153. * @hidden
  128154. */
  128155. reset(): void;
  128156. /**
  128157. * Render the bounding boxes of a specific rendering group
  128158. * @param renderingGroupId defines the rendering group to render
  128159. */
  128160. render(renderingGroupId: number): void;
  128161. /**
  128162. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128163. * @param mesh Define the mesh to render the occlusion bounding box for
  128164. */
  128165. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128166. /**
  128167. * Dispose and release the resources attached to this renderer.
  128168. */
  128169. dispose(): void;
  128170. }
  128171. }
  128172. declare module BABYLON {
  128173. /** @hidden */
  128174. export var depthPixelShader: {
  128175. name: string;
  128176. shader: string;
  128177. };
  128178. }
  128179. declare module BABYLON {
  128180. /**
  128181. * This represents a depth renderer in Babylon.
  128182. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128183. */
  128184. export class DepthRenderer {
  128185. private _scene;
  128186. private _depthMap;
  128187. private _effect;
  128188. private readonly _storeNonLinearDepth;
  128189. private readonly _clearColor;
  128190. /** Get if the depth renderer is using packed depth or not */
  128191. readonly isPacked: boolean;
  128192. private _cachedDefines;
  128193. private _camera;
  128194. /**
  128195. * Specifiess that the depth renderer will only be used within
  128196. * the camera it is created for.
  128197. * This can help forcing its rendering during the camera processing.
  128198. */
  128199. useOnlyInActiveCamera: boolean;
  128200. /** @hidden */
  128201. static _SceneComponentInitialization: (scene: Scene) => void;
  128202. /**
  128203. * Instantiates a depth renderer
  128204. * @param scene The scene the renderer belongs to
  128205. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128206. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128207. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128208. */
  128209. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128210. /**
  128211. * Creates the depth rendering effect and checks if the effect is ready.
  128212. * @param subMesh The submesh to be used to render the depth map of
  128213. * @param useInstances If multiple world instances should be used
  128214. * @returns if the depth renderer is ready to render the depth map
  128215. */
  128216. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128217. /**
  128218. * Gets the texture which the depth map will be written to.
  128219. * @returns The depth map texture
  128220. */
  128221. getDepthMap(): RenderTargetTexture;
  128222. /**
  128223. * Disposes of the depth renderer.
  128224. */
  128225. dispose(): void;
  128226. }
  128227. }
  128228. declare module BABYLON {
  128229. interface Scene {
  128230. /** @hidden (Backing field) */
  128231. _depthRenderer: {
  128232. [id: string]: DepthRenderer;
  128233. };
  128234. /**
  128235. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128236. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128237. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128238. * @returns the created depth renderer
  128239. */
  128240. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128241. /**
  128242. * Disables a depth renderer for a given camera
  128243. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128244. */
  128245. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128246. }
  128247. /**
  128248. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128249. * in several rendering techniques.
  128250. */
  128251. export class DepthRendererSceneComponent implements ISceneComponent {
  128252. /**
  128253. * The component name helpfull to identify the component in the list of scene components.
  128254. */
  128255. readonly name: string;
  128256. /**
  128257. * The scene the component belongs to.
  128258. */
  128259. scene: Scene;
  128260. /**
  128261. * Creates a new instance of the component for the given scene
  128262. * @param scene Defines the scene to register the component in
  128263. */
  128264. constructor(scene: Scene);
  128265. /**
  128266. * Registers the component in a given scene
  128267. */
  128268. register(): void;
  128269. /**
  128270. * Rebuilds the elements related to this component in case of
  128271. * context lost for instance.
  128272. */
  128273. rebuild(): void;
  128274. /**
  128275. * Disposes the component and the associated ressources
  128276. */
  128277. dispose(): void;
  128278. private _gatherRenderTargets;
  128279. private _gatherActiveCameraRenderTargets;
  128280. }
  128281. }
  128282. declare module BABYLON {
  128283. /** @hidden */
  128284. export var outlinePixelShader: {
  128285. name: string;
  128286. shader: string;
  128287. };
  128288. }
  128289. declare module BABYLON {
  128290. /** @hidden */
  128291. export var outlineVertexShader: {
  128292. name: string;
  128293. shader: string;
  128294. };
  128295. }
  128296. declare module BABYLON {
  128297. interface Scene {
  128298. /** @hidden */
  128299. _outlineRenderer: OutlineRenderer;
  128300. /**
  128301. * Gets the outline renderer associated with the scene
  128302. * @returns a OutlineRenderer
  128303. */
  128304. getOutlineRenderer(): OutlineRenderer;
  128305. }
  128306. interface AbstractMesh {
  128307. /** @hidden (Backing field) */
  128308. _renderOutline: boolean;
  128309. /**
  128310. * Gets or sets a boolean indicating if the outline must be rendered as well
  128311. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128312. */
  128313. renderOutline: boolean;
  128314. /** @hidden (Backing field) */
  128315. _renderOverlay: boolean;
  128316. /**
  128317. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128318. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128319. */
  128320. renderOverlay: boolean;
  128321. }
  128322. /**
  128323. * This class is responsible to draw bothe outline/overlay of meshes.
  128324. * It should not be used directly but through the available method on mesh.
  128325. */
  128326. export class OutlineRenderer implements ISceneComponent {
  128327. /**
  128328. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128329. */
  128330. private static _StencilReference;
  128331. /**
  128332. * The name of the component. Each component must have a unique name.
  128333. */
  128334. name: string;
  128335. /**
  128336. * The scene the component belongs to.
  128337. */
  128338. scene: Scene;
  128339. /**
  128340. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128341. */
  128342. zOffset: number;
  128343. private _engine;
  128344. private _effect;
  128345. private _cachedDefines;
  128346. private _savedDepthWrite;
  128347. /**
  128348. * Instantiates a new outline renderer. (There could be only one per scene).
  128349. * @param scene Defines the scene it belongs to
  128350. */
  128351. constructor(scene: Scene);
  128352. /**
  128353. * Register the component to one instance of a scene.
  128354. */
  128355. register(): void;
  128356. /**
  128357. * Rebuilds the elements related to this component in case of
  128358. * context lost for instance.
  128359. */
  128360. rebuild(): void;
  128361. /**
  128362. * Disposes the component and the associated ressources.
  128363. */
  128364. dispose(): void;
  128365. /**
  128366. * Renders the outline in the canvas.
  128367. * @param subMesh Defines the sumesh to render
  128368. * @param batch Defines the batch of meshes in case of instances
  128369. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128370. */
  128371. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128372. /**
  128373. * Returns whether or not the outline renderer is ready for a given submesh.
  128374. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128375. * @param subMesh Defines the submesh to check readyness for
  128376. * @param useInstances Defines wheter wee are trying to render instances or not
  128377. * @returns true if ready otherwise false
  128378. */
  128379. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128380. private _beforeRenderingMesh;
  128381. private _afterRenderingMesh;
  128382. }
  128383. }
  128384. declare module BABYLON {
  128385. /**
  128386. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128387. * @see http://doc.babylonjs.com/babylon101/sprites
  128388. */
  128389. export class SpritePackedManager extends SpriteManager {
  128390. /** defines the packed manager's name */
  128391. name: string;
  128392. /**
  128393. * Creates a new sprite manager from a packed sprite sheet
  128394. * @param name defines the manager's name
  128395. * @param imgUrl defines the sprite sheet url
  128396. * @param capacity defines the maximum allowed number of sprites
  128397. * @param scene defines the hosting scene
  128398. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128399. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128400. * @param samplingMode defines the smapling mode to use with spritesheet
  128401. * @param fromPacked set to true; do not alter
  128402. */
  128403. constructor(
  128404. /** defines the packed manager's name */
  128405. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128406. }
  128407. }
  128408. declare module BABYLON {
  128409. /**
  128410. * Defines the list of states available for a task inside a AssetsManager
  128411. */
  128412. export enum AssetTaskState {
  128413. /**
  128414. * Initialization
  128415. */
  128416. INIT = 0,
  128417. /**
  128418. * Running
  128419. */
  128420. RUNNING = 1,
  128421. /**
  128422. * Done
  128423. */
  128424. DONE = 2,
  128425. /**
  128426. * Error
  128427. */
  128428. ERROR = 3
  128429. }
  128430. /**
  128431. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128432. */
  128433. export abstract class AbstractAssetTask {
  128434. /**
  128435. * Task name
  128436. */ name: string;
  128437. /**
  128438. * Callback called when the task is successful
  128439. */
  128440. onSuccess: (task: any) => void;
  128441. /**
  128442. * Callback called when the task is not successful
  128443. */
  128444. onError: (task: any, message?: string, exception?: any) => void;
  128445. /**
  128446. * Creates a new AssetsManager
  128447. * @param name defines the name of the task
  128448. */
  128449. constructor(
  128450. /**
  128451. * Task name
  128452. */ name: string);
  128453. private _isCompleted;
  128454. private _taskState;
  128455. private _errorObject;
  128456. /**
  128457. * Get if the task is completed
  128458. */
  128459. readonly isCompleted: boolean;
  128460. /**
  128461. * Gets the current state of the task
  128462. */
  128463. readonly taskState: AssetTaskState;
  128464. /**
  128465. * Gets the current error object (if task is in error)
  128466. */
  128467. readonly errorObject: {
  128468. message?: string;
  128469. exception?: any;
  128470. };
  128471. /**
  128472. * Internal only
  128473. * @hidden
  128474. */
  128475. _setErrorObject(message?: string, exception?: any): void;
  128476. /**
  128477. * Execute the current task
  128478. * @param scene defines the scene where you want your assets to be loaded
  128479. * @param onSuccess is a callback called when the task is successfully executed
  128480. * @param onError is a callback called if an error occurs
  128481. */
  128482. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128483. /**
  128484. * Execute the current task
  128485. * @param scene defines the scene where you want your assets to be loaded
  128486. * @param onSuccess is a callback called when the task is successfully executed
  128487. * @param onError is a callback called if an error occurs
  128488. */
  128489. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128490. /**
  128491. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128492. * This can be used with failed tasks that have the reason for failure fixed.
  128493. */
  128494. reset(): void;
  128495. private onErrorCallback;
  128496. private onDoneCallback;
  128497. }
  128498. /**
  128499. * Define the interface used by progress events raised during assets loading
  128500. */
  128501. export interface IAssetsProgressEvent {
  128502. /**
  128503. * Defines the number of remaining tasks to process
  128504. */
  128505. remainingCount: number;
  128506. /**
  128507. * Defines the total number of tasks
  128508. */
  128509. totalCount: number;
  128510. /**
  128511. * Defines the task that was just processed
  128512. */
  128513. task: AbstractAssetTask;
  128514. }
  128515. /**
  128516. * Class used to share progress information about assets loading
  128517. */
  128518. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128519. /**
  128520. * Defines the number of remaining tasks to process
  128521. */
  128522. remainingCount: number;
  128523. /**
  128524. * Defines the total number of tasks
  128525. */
  128526. totalCount: number;
  128527. /**
  128528. * Defines the task that was just processed
  128529. */
  128530. task: AbstractAssetTask;
  128531. /**
  128532. * Creates a AssetsProgressEvent
  128533. * @param remainingCount defines the number of remaining tasks to process
  128534. * @param totalCount defines the total number of tasks
  128535. * @param task defines the task that was just processed
  128536. */
  128537. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128538. }
  128539. /**
  128540. * Define a task used by AssetsManager to load meshes
  128541. */
  128542. export class MeshAssetTask extends AbstractAssetTask {
  128543. /**
  128544. * Defines the name of the task
  128545. */
  128546. name: string;
  128547. /**
  128548. * Defines the list of mesh's names you want to load
  128549. */
  128550. meshesNames: any;
  128551. /**
  128552. * Defines the root url to use as a base to load your meshes and associated resources
  128553. */
  128554. rootUrl: string;
  128555. /**
  128556. * Defines the filename of the scene to load from
  128557. */
  128558. sceneFilename: string;
  128559. /**
  128560. * Gets the list of loaded meshes
  128561. */
  128562. loadedMeshes: Array<AbstractMesh>;
  128563. /**
  128564. * Gets the list of loaded particle systems
  128565. */
  128566. loadedParticleSystems: Array<IParticleSystem>;
  128567. /**
  128568. * Gets the list of loaded skeletons
  128569. */
  128570. loadedSkeletons: Array<Skeleton>;
  128571. /**
  128572. * Gets the list of loaded animation groups
  128573. */
  128574. loadedAnimationGroups: Array<AnimationGroup>;
  128575. /**
  128576. * Callback called when the task is successful
  128577. */
  128578. onSuccess: (task: MeshAssetTask) => void;
  128579. /**
  128580. * Callback called when the task is successful
  128581. */
  128582. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128583. /**
  128584. * Creates a new MeshAssetTask
  128585. * @param name defines the name of the task
  128586. * @param meshesNames defines the list of mesh's names you want to load
  128587. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128588. * @param sceneFilename defines the filename of the scene to load from
  128589. */
  128590. constructor(
  128591. /**
  128592. * Defines the name of the task
  128593. */
  128594. name: string,
  128595. /**
  128596. * Defines the list of mesh's names you want to load
  128597. */
  128598. meshesNames: any,
  128599. /**
  128600. * Defines the root url to use as a base to load your meshes and associated resources
  128601. */
  128602. rootUrl: string,
  128603. /**
  128604. * Defines the filename of the scene to load from
  128605. */
  128606. sceneFilename: string);
  128607. /**
  128608. * Execute the current task
  128609. * @param scene defines the scene where you want your assets to be loaded
  128610. * @param onSuccess is a callback called when the task is successfully executed
  128611. * @param onError is a callback called if an error occurs
  128612. */
  128613. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128614. }
  128615. /**
  128616. * Define a task used by AssetsManager to load text content
  128617. */
  128618. export class TextFileAssetTask extends AbstractAssetTask {
  128619. /**
  128620. * Defines the name of the task
  128621. */
  128622. name: string;
  128623. /**
  128624. * Defines the location of the file to load
  128625. */
  128626. url: string;
  128627. /**
  128628. * Gets the loaded text string
  128629. */
  128630. text: string;
  128631. /**
  128632. * Callback called when the task is successful
  128633. */
  128634. onSuccess: (task: TextFileAssetTask) => void;
  128635. /**
  128636. * Callback called when the task is successful
  128637. */
  128638. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128639. /**
  128640. * Creates a new TextFileAssetTask object
  128641. * @param name defines the name of the task
  128642. * @param url defines the location of the file to load
  128643. */
  128644. constructor(
  128645. /**
  128646. * Defines the name of the task
  128647. */
  128648. name: string,
  128649. /**
  128650. * Defines the location of the file to load
  128651. */
  128652. url: string);
  128653. /**
  128654. * Execute the current task
  128655. * @param scene defines the scene where you want your assets to be loaded
  128656. * @param onSuccess is a callback called when the task is successfully executed
  128657. * @param onError is a callback called if an error occurs
  128658. */
  128659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128660. }
  128661. /**
  128662. * Define a task used by AssetsManager to load binary data
  128663. */
  128664. export class BinaryFileAssetTask extends AbstractAssetTask {
  128665. /**
  128666. * Defines the name of the task
  128667. */
  128668. name: string;
  128669. /**
  128670. * Defines the location of the file to load
  128671. */
  128672. url: string;
  128673. /**
  128674. * Gets the lodaded data (as an array buffer)
  128675. */
  128676. data: ArrayBuffer;
  128677. /**
  128678. * Callback called when the task is successful
  128679. */
  128680. onSuccess: (task: BinaryFileAssetTask) => void;
  128681. /**
  128682. * Callback called when the task is successful
  128683. */
  128684. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128685. /**
  128686. * Creates a new BinaryFileAssetTask object
  128687. * @param name defines the name of the new task
  128688. * @param url defines the location of the file to load
  128689. */
  128690. constructor(
  128691. /**
  128692. * Defines the name of the task
  128693. */
  128694. name: string,
  128695. /**
  128696. * Defines the location of the file to load
  128697. */
  128698. url: string);
  128699. /**
  128700. * Execute the current task
  128701. * @param scene defines the scene where you want your assets to be loaded
  128702. * @param onSuccess is a callback called when the task is successfully executed
  128703. * @param onError is a callback called if an error occurs
  128704. */
  128705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128706. }
  128707. /**
  128708. * Define a task used by AssetsManager to load images
  128709. */
  128710. export class ImageAssetTask extends AbstractAssetTask {
  128711. /**
  128712. * Defines the name of the task
  128713. */
  128714. name: string;
  128715. /**
  128716. * Defines the location of the image to load
  128717. */
  128718. url: string;
  128719. /**
  128720. * Gets the loaded images
  128721. */
  128722. image: HTMLImageElement;
  128723. /**
  128724. * Callback called when the task is successful
  128725. */
  128726. onSuccess: (task: ImageAssetTask) => void;
  128727. /**
  128728. * Callback called when the task is successful
  128729. */
  128730. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128731. /**
  128732. * Creates a new ImageAssetTask
  128733. * @param name defines the name of the task
  128734. * @param url defines the location of the image to load
  128735. */
  128736. constructor(
  128737. /**
  128738. * Defines the name of the task
  128739. */
  128740. name: string,
  128741. /**
  128742. * Defines the location of the image to load
  128743. */
  128744. url: string);
  128745. /**
  128746. * Execute the current task
  128747. * @param scene defines the scene where you want your assets to be loaded
  128748. * @param onSuccess is a callback called when the task is successfully executed
  128749. * @param onError is a callback called if an error occurs
  128750. */
  128751. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128752. }
  128753. /**
  128754. * Defines the interface used by texture loading tasks
  128755. */
  128756. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128757. /**
  128758. * Gets the loaded texture
  128759. */
  128760. texture: TEX;
  128761. }
  128762. /**
  128763. * Define a task used by AssetsManager to load 2D textures
  128764. */
  128765. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128766. /**
  128767. * Defines the name of the task
  128768. */
  128769. name: string;
  128770. /**
  128771. * Defines the location of the file to load
  128772. */
  128773. url: string;
  128774. /**
  128775. * Defines if mipmap should not be generated (default is false)
  128776. */
  128777. noMipmap?: boolean | undefined;
  128778. /**
  128779. * Defines if texture must be inverted on Y axis (default is false)
  128780. */
  128781. invertY?: boolean | undefined;
  128782. /**
  128783. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128784. */
  128785. samplingMode: number;
  128786. /**
  128787. * Gets the loaded texture
  128788. */
  128789. texture: Texture;
  128790. /**
  128791. * Callback called when the task is successful
  128792. */
  128793. onSuccess: (task: TextureAssetTask) => void;
  128794. /**
  128795. * Callback called when the task is successful
  128796. */
  128797. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128798. /**
  128799. * Creates a new TextureAssetTask object
  128800. * @param name defines the name of the task
  128801. * @param url defines the location of the file to load
  128802. * @param noMipmap defines if mipmap should not be generated (default is false)
  128803. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128804. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128805. */
  128806. constructor(
  128807. /**
  128808. * Defines the name of the task
  128809. */
  128810. name: string,
  128811. /**
  128812. * Defines the location of the file to load
  128813. */
  128814. url: string,
  128815. /**
  128816. * Defines if mipmap should not be generated (default is false)
  128817. */
  128818. noMipmap?: boolean | undefined,
  128819. /**
  128820. * Defines if texture must be inverted on Y axis (default is false)
  128821. */
  128822. invertY?: boolean | undefined,
  128823. /**
  128824. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128825. */
  128826. samplingMode?: number);
  128827. /**
  128828. * Execute the current task
  128829. * @param scene defines the scene where you want your assets to be loaded
  128830. * @param onSuccess is a callback called when the task is successfully executed
  128831. * @param onError is a callback called if an error occurs
  128832. */
  128833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128834. }
  128835. /**
  128836. * Define a task used by AssetsManager to load cube textures
  128837. */
  128838. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128839. /**
  128840. * Defines the name of the task
  128841. */
  128842. name: string;
  128843. /**
  128844. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128845. */
  128846. url: string;
  128847. /**
  128848. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128849. */
  128850. extensions?: string[] | undefined;
  128851. /**
  128852. * Defines if mipmaps should not be generated (default is false)
  128853. */
  128854. noMipmap?: boolean | undefined;
  128855. /**
  128856. * Defines the explicit list of files (undefined by default)
  128857. */
  128858. files?: string[] | undefined;
  128859. /**
  128860. * Gets the loaded texture
  128861. */
  128862. texture: CubeTexture;
  128863. /**
  128864. * Callback called when the task is successful
  128865. */
  128866. onSuccess: (task: CubeTextureAssetTask) => void;
  128867. /**
  128868. * Callback called when the task is successful
  128869. */
  128870. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128871. /**
  128872. * Creates a new CubeTextureAssetTask
  128873. * @param name defines the name of the task
  128874. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128875. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128876. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128877. * @param files defines the explicit list of files (undefined by default)
  128878. */
  128879. constructor(
  128880. /**
  128881. * Defines the name of the task
  128882. */
  128883. name: string,
  128884. /**
  128885. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128886. */
  128887. url: string,
  128888. /**
  128889. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128890. */
  128891. extensions?: string[] | undefined,
  128892. /**
  128893. * Defines if mipmaps should not be generated (default is false)
  128894. */
  128895. noMipmap?: boolean | undefined,
  128896. /**
  128897. * Defines the explicit list of files (undefined by default)
  128898. */
  128899. files?: string[] | undefined);
  128900. /**
  128901. * Execute the current task
  128902. * @param scene defines the scene where you want your assets to be loaded
  128903. * @param onSuccess is a callback called when the task is successfully executed
  128904. * @param onError is a callback called if an error occurs
  128905. */
  128906. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128907. }
  128908. /**
  128909. * Define a task used by AssetsManager to load HDR cube textures
  128910. */
  128911. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128912. /**
  128913. * Defines the name of the task
  128914. */
  128915. name: string;
  128916. /**
  128917. * Defines the location of the file to load
  128918. */
  128919. url: string;
  128920. /**
  128921. * Defines the desired size (the more it increases the longer the generation will be)
  128922. */
  128923. size: number;
  128924. /**
  128925. * Defines if mipmaps should not be generated (default is false)
  128926. */
  128927. noMipmap: boolean;
  128928. /**
  128929. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128930. */
  128931. generateHarmonics: boolean;
  128932. /**
  128933. * 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)
  128934. */
  128935. gammaSpace: boolean;
  128936. /**
  128937. * Internal Use Only
  128938. */
  128939. reserved: boolean;
  128940. /**
  128941. * Gets the loaded texture
  128942. */
  128943. texture: HDRCubeTexture;
  128944. /**
  128945. * Callback called when the task is successful
  128946. */
  128947. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128948. /**
  128949. * Callback called when the task is successful
  128950. */
  128951. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128952. /**
  128953. * Creates a new HDRCubeTextureAssetTask object
  128954. * @param name defines the name of the task
  128955. * @param url defines the location of the file to load
  128956. * @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.
  128957. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128958. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128959. * @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)
  128960. * @param reserved Internal use only
  128961. */
  128962. constructor(
  128963. /**
  128964. * Defines the name of the task
  128965. */
  128966. name: string,
  128967. /**
  128968. * Defines the location of the file to load
  128969. */
  128970. url: string,
  128971. /**
  128972. * Defines the desired size (the more it increases the longer the generation will be)
  128973. */
  128974. size: number,
  128975. /**
  128976. * Defines if mipmaps should not be generated (default is false)
  128977. */
  128978. noMipmap?: boolean,
  128979. /**
  128980. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128981. */
  128982. generateHarmonics?: boolean,
  128983. /**
  128984. * 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)
  128985. */
  128986. gammaSpace?: boolean,
  128987. /**
  128988. * Internal Use Only
  128989. */
  128990. reserved?: boolean);
  128991. /**
  128992. * Execute the current task
  128993. * @param scene defines the scene where you want your assets to be loaded
  128994. * @param onSuccess is a callback called when the task is successfully executed
  128995. * @param onError is a callback called if an error occurs
  128996. */
  128997. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128998. }
  128999. /**
  129000. * Define a task used by AssetsManager to load Equirectangular cube textures
  129001. */
  129002. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  129003. /**
  129004. * Defines the name of the task
  129005. */
  129006. name: string;
  129007. /**
  129008. * Defines the location of the file to load
  129009. */
  129010. url: string;
  129011. /**
  129012. * Defines the desired size (the more it increases the longer the generation will be)
  129013. */
  129014. size: number;
  129015. /**
  129016. * Defines if mipmaps should not be generated (default is false)
  129017. */
  129018. noMipmap: boolean;
  129019. /**
  129020. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129021. * but the standard material would require them in Gamma space) (default is true)
  129022. */
  129023. gammaSpace: boolean;
  129024. /**
  129025. * Gets the loaded texture
  129026. */
  129027. texture: EquiRectangularCubeTexture;
  129028. /**
  129029. * Callback called when the task is successful
  129030. */
  129031. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  129032. /**
  129033. * Callback called when the task is successful
  129034. */
  129035. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  129036. /**
  129037. * Creates a new EquiRectangularCubeTextureAssetTask object
  129038. * @param name defines the name of the task
  129039. * @param url defines the location of the file to load
  129040. * @param size defines the desired size (the more it increases the longer the generation will be)
  129041. * If the size is omitted this implies you are using a preprocessed cubemap.
  129042. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129043. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  129044. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  129045. * (default is true)
  129046. */
  129047. constructor(
  129048. /**
  129049. * Defines the name of the task
  129050. */
  129051. name: string,
  129052. /**
  129053. * Defines the location of the file to load
  129054. */
  129055. url: string,
  129056. /**
  129057. * Defines the desired size (the more it increases the longer the generation will be)
  129058. */
  129059. size: number,
  129060. /**
  129061. * Defines if mipmaps should not be generated (default is false)
  129062. */
  129063. noMipmap?: boolean,
  129064. /**
  129065. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129066. * but the standard material would require them in Gamma space) (default is true)
  129067. */
  129068. gammaSpace?: boolean);
  129069. /**
  129070. * Execute the current task
  129071. * @param scene defines the scene where you want your assets to be loaded
  129072. * @param onSuccess is a callback called when the task is successfully executed
  129073. * @param onError is a callback called if an error occurs
  129074. */
  129075. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129076. }
  129077. /**
  129078. * This class can be used to easily import assets into a scene
  129079. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  129080. */
  129081. export class AssetsManager {
  129082. private _scene;
  129083. private _isLoading;
  129084. protected _tasks: AbstractAssetTask[];
  129085. protected _waitingTasksCount: number;
  129086. protected _totalTasksCount: number;
  129087. /**
  129088. * Callback called when all tasks are processed
  129089. */
  129090. onFinish: (tasks: AbstractAssetTask[]) => void;
  129091. /**
  129092. * Callback called when a task is successful
  129093. */
  129094. onTaskSuccess: (task: AbstractAssetTask) => void;
  129095. /**
  129096. * Callback called when a task had an error
  129097. */
  129098. onTaskError: (task: AbstractAssetTask) => void;
  129099. /**
  129100. * Callback called when a task is done (whatever the result is)
  129101. */
  129102. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129103. /**
  129104. * Observable called when all tasks are processed
  129105. */
  129106. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129107. /**
  129108. * Observable called when a task had an error
  129109. */
  129110. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129111. /**
  129112. * Observable called when all tasks were executed
  129113. */
  129114. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129115. /**
  129116. * Observable called when a task is done (whatever the result is)
  129117. */
  129118. onProgressObservable: Observable<IAssetsProgressEvent>;
  129119. /**
  129120. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129121. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  129122. */
  129123. useDefaultLoadingScreen: boolean;
  129124. /**
  129125. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  129126. * when all assets have been downloaded.
  129127. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  129128. */
  129129. autoHideLoadingUI: boolean;
  129130. /**
  129131. * Creates a new AssetsManager
  129132. * @param scene defines the scene to work on
  129133. */
  129134. constructor(scene: Scene);
  129135. /**
  129136. * Add a MeshAssetTask to the list of active tasks
  129137. * @param taskName defines the name of the new task
  129138. * @param meshesNames defines the name of meshes to load
  129139. * @param rootUrl defines the root url to use to locate files
  129140. * @param sceneFilename defines the filename of the scene file
  129141. * @returns a new MeshAssetTask object
  129142. */
  129143. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129144. /**
  129145. * Add a TextFileAssetTask to the list of active tasks
  129146. * @param taskName defines the name of the new task
  129147. * @param url defines the url of the file to load
  129148. * @returns a new TextFileAssetTask object
  129149. */
  129150. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129151. /**
  129152. * Add a BinaryFileAssetTask to the list of active tasks
  129153. * @param taskName defines the name of the new task
  129154. * @param url defines the url of the file to load
  129155. * @returns a new BinaryFileAssetTask object
  129156. */
  129157. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129158. /**
  129159. * Add a ImageAssetTask to the list of active tasks
  129160. * @param taskName defines the name of the new task
  129161. * @param url defines the url of the file to load
  129162. * @returns a new ImageAssetTask object
  129163. */
  129164. addImageTask(taskName: string, url: string): ImageAssetTask;
  129165. /**
  129166. * Add a TextureAssetTask to the list of active tasks
  129167. * @param taskName defines the name of the new task
  129168. * @param url defines the url of the file to load
  129169. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129170. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  129171. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129172. * @returns a new TextureAssetTask object
  129173. */
  129174. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  129175. /**
  129176. * Add a CubeTextureAssetTask to the list of active tasks
  129177. * @param taskName defines the name of the new task
  129178. * @param url defines the url of the file to load
  129179. * @param extensions defines the extension to use to load the cube map (can be null)
  129180. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129181. * @param files defines the list of files to load (can be null)
  129182. * @returns a new CubeTextureAssetTask object
  129183. */
  129184. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  129185. /**
  129186. *
  129187. * Add a HDRCubeTextureAssetTask to the list of active tasks
  129188. * @param taskName defines the name of the new task
  129189. * @param url defines the url of the file to load
  129190. * @param size defines the size you want for the cubemap (can be null)
  129191. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129192. * @param generateHarmonics defines if you want to automatically generate (true by default)
  129193. * @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)
  129194. * @param reserved Internal use only
  129195. * @returns a new HDRCubeTextureAssetTask object
  129196. */
  129197. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  129198. /**
  129199. *
  129200. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  129201. * @param taskName defines the name of the new task
  129202. * @param url defines the url of the file to load
  129203. * @param size defines the size you want for the cubemap (can be null)
  129204. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129205. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129206. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129207. * @returns a new EquiRectangularCubeTextureAssetTask object
  129208. */
  129209. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  129210. /**
  129211. * Remove a task from the assets manager.
  129212. * @param task the task to remove
  129213. */
  129214. removeTask(task: AbstractAssetTask): void;
  129215. private _decreaseWaitingTasksCount;
  129216. private _runTask;
  129217. /**
  129218. * Reset the AssetsManager and remove all tasks
  129219. * @return the current instance of the AssetsManager
  129220. */
  129221. reset(): AssetsManager;
  129222. /**
  129223. * Start the loading process
  129224. * @return the current instance of the AssetsManager
  129225. */
  129226. load(): AssetsManager;
  129227. /**
  129228. * Start the loading process as an async operation
  129229. * @return a promise returning the list of failed tasks
  129230. */
  129231. loadAsync(): Promise<void>;
  129232. }
  129233. }
  129234. declare module BABYLON {
  129235. /**
  129236. * Wrapper class for promise with external resolve and reject.
  129237. */
  129238. export class Deferred<T> {
  129239. /**
  129240. * The promise associated with this deferred object.
  129241. */
  129242. readonly promise: Promise<T>;
  129243. private _resolve;
  129244. private _reject;
  129245. /**
  129246. * The resolve method of the promise associated with this deferred object.
  129247. */
  129248. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129249. /**
  129250. * The reject method of the promise associated with this deferred object.
  129251. */
  129252. readonly reject: (reason?: any) => void;
  129253. /**
  129254. * Constructor for this deferred object.
  129255. */
  129256. constructor();
  129257. }
  129258. }
  129259. declare module BABYLON {
  129260. /**
  129261. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129262. */
  129263. export class MeshExploder {
  129264. private _centerMesh;
  129265. private _meshes;
  129266. private _meshesOrigins;
  129267. private _toCenterVectors;
  129268. private _scaledDirection;
  129269. private _newPosition;
  129270. private _centerPosition;
  129271. /**
  129272. * Explodes meshes from a center mesh.
  129273. * @param meshes The meshes to explode.
  129274. * @param centerMesh The mesh to be center of explosion.
  129275. */
  129276. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129277. private _setCenterMesh;
  129278. /**
  129279. * Get class name
  129280. * @returns "MeshExploder"
  129281. */
  129282. getClassName(): string;
  129283. /**
  129284. * "Exploded meshes"
  129285. * @returns Array of meshes with the centerMesh at index 0.
  129286. */
  129287. getMeshes(): Array<Mesh>;
  129288. /**
  129289. * Explodes meshes giving a specific direction
  129290. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129291. */
  129292. explode(direction?: number): void;
  129293. }
  129294. }
  129295. declare module BABYLON {
  129296. /**
  129297. * Class used to help managing file picking and drag'n'drop
  129298. */
  129299. export class FilesInput {
  129300. /**
  129301. * List of files ready to be loaded
  129302. */
  129303. static readonly FilesToLoad: {
  129304. [key: string]: File;
  129305. };
  129306. /**
  129307. * Callback called when a file is processed
  129308. */
  129309. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129310. private _engine;
  129311. private _currentScene;
  129312. private _sceneLoadedCallback;
  129313. private _progressCallback;
  129314. private _additionalRenderLoopLogicCallback;
  129315. private _textureLoadingCallback;
  129316. private _startingProcessingFilesCallback;
  129317. private _onReloadCallback;
  129318. private _errorCallback;
  129319. private _elementToMonitor;
  129320. private _sceneFileToLoad;
  129321. private _filesToLoad;
  129322. /**
  129323. * Creates a new FilesInput
  129324. * @param engine defines the rendering engine
  129325. * @param scene defines the hosting scene
  129326. * @param sceneLoadedCallback callback called when scene is loaded
  129327. * @param progressCallback callback called to track progress
  129328. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129329. * @param textureLoadingCallback callback called when a texture is loading
  129330. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129331. * @param onReloadCallback callback called when a reload is requested
  129332. * @param errorCallback callback call if an error occurs
  129333. */
  129334. 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);
  129335. private _dragEnterHandler;
  129336. private _dragOverHandler;
  129337. private _dropHandler;
  129338. /**
  129339. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129340. * @param elementToMonitor defines the DOM element to track
  129341. */
  129342. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129343. /**
  129344. * Release all associated resources
  129345. */
  129346. dispose(): void;
  129347. private renderFunction;
  129348. private drag;
  129349. private drop;
  129350. private _traverseFolder;
  129351. private _processFiles;
  129352. /**
  129353. * Load files from a drop event
  129354. * @param event defines the drop event to use as source
  129355. */
  129356. loadFiles(event: any): void;
  129357. private _processReload;
  129358. /**
  129359. * Reload the current scene from the loaded files
  129360. */
  129361. reload(): void;
  129362. }
  129363. }
  129364. declare module BABYLON {
  129365. /**
  129366. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129368. */
  129369. export class SceneOptimization {
  129370. /**
  129371. * Defines the priority of this optimization (0 by default which means first in the list)
  129372. */
  129373. priority: number;
  129374. /**
  129375. * Gets a string describing the action executed by the current optimization
  129376. * @returns description string
  129377. */
  129378. getDescription(): string;
  129379. /**
  129380. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129381. * @param scene defines the current scene where to apply this optimization
  129382. * @param optimizer defines the current optimizer
  129383. * @returns true if everything that can be done was applied
  129384. */
  129385. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129386. /**
  129387. * Creates the SceneOptimization object
  129388. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129389. * @param desc defines the description associated with the optimization
  129390. */
  129391. constructor(
  129392. /**
  129393. * Defines the priority of this optimization (0 by default which means first in the list)
  129394. */
  129395. priority?: number);
  129396. }
  129397. /**
  129398. * Defines an optimization used to reduce the size of render target textures
  129399. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129400. */
  129401. export class TextureOptimization extends SceneOptimization {
  129402. /**
  129403. * Defines the priority of this optimization (0 by default which means first in the list)
  129404. */
  129405. priority: number;
  129406. /**
  129407. * 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
  129408. */
  129409. maximumSize: number;
  129410. /**
  129411. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129412. */
  129413. step: number;
  129414. /**
  129415. * Gets a string describing the action executed by the current optimization
  129416. * @returns description string
  129417. */
  129418. getDescription(): string;
  129419. /**
  129420. * Creates the TextureOptimization object
  129421. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129422. * @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
  129423. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129424. */
  129425. constructor(
  129426. /**
  129427. * Defines the priority of this optimization (0 by default which means first in the list)
  129428. */
  129429. priority?: number,
  129430. /**
  129431. * 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
  129432. */
  129433. maximumSize?: number,
  129434. /**
  129435. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129436. */
  129437. step?: number);
  129438. /**
  129439. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129440. * @param scene defines the current scene where to apply this optimization
  129441. * @param optimizer defines the current optimizer
  129442. * @returns true if everything that can be done was applied
  129443. */
  129444. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129445. }
  129446. /**
  129447. * Defines an optimization used to increase or decrease the rendering resolution
  129448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129449. */
  129450. export class HardwareScalingOptimization extends SceneOptimization {
  129451. /**
  129452. * Defines the priority of this optimization (0 by default which means first in the list)
  129453. */
  129454. priority: number;
  129455. /**
  129456. * Defines the maximum scale to use (2 by default)
  129457. */
  129458. maximumScale: number;
  129459. /**
  129460. * Defines the step to use between two passes (0.5 by default)
  129461. */
  129462. step: number;
  129463. private _currentScale;
  129464. private _directionOffset;
  129465. /**
  129466. * Gets a string describing the action executed by the current optimization
  129467. * @return description string
  129468. */
  129469. getDescription(): string;
  129470. /**
  129471. * Creates the HardwareScalingOptimization object
  129472. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129473. * @param maximumScale defines the maximum scale to use (2 by default)
  129474. * @param step defines the step to use between two passes (0.5 by default)
  129475. */
  129476. constructor(
  129477. /**
  129478. * Defines the priority of this optimization (0 by default which means first in the list)
  129479. */
  129480. priority?: number,
  129481. /**
  129482. * Defines the maximum scale to use (2 by default)
  129483. */
  129484. maximumScale?: number,
  129485. /**
  129486. * Defines the step to use between two passes (0.5 by default)
  129487. */
  129488. step?: number);
  129489. /**
  129490. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129491. * @param scene defines the current scene where to apply this optimization
  129492. * @param optimizer defines the current optimizer
  129493. * @returns true if everything that can be done was applied
  129494. */
  129495. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129496. }
  129497. /**
  129498. * Defines an optimization used to remove shadows
  129499. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129500. */
  129501. export class ShadowsOptimization extends SceneOptimization {
  129502. /**
  129503. * Gets a string describing the action executed by the current optimization
  129504. * @return description string
  129505. */
  129506. getDescription(): string;
  129507. /**
  129508. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129509. * @param scene defines the current scene where to apply this optimization
  129510. * @param optimizer defines the current optimizer
  129511. * @returns true if everything that can be done was applied
  129512. */
  129513. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129514. }
  129515. /**
  129516. * Defines an optimization used to turn post-processes off
  129517. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129518. */
  129519. export class PostProcessesOptimization extends SceneOptimization {
  129520. /**
  129521. * Gets a string describing the action executed by the current optimization
  129522. * @return description string
  129523. */
  129524. getDescription(): string;
  129525. /**
  129526. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129527. * @param scene defines the current scene where to apply this optimization
  129528. * @param optimizer defines the current optimizer
  129529. * @returns true if everything that can be done was applied
  129530. */
  129531. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129532. }
  129533. /**
  129534. * Defines an optimization used to turn lens flares off
  129535. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129536. */
  129537. export class LensFlaresOptimization extends SceneOptimization {
  129538. /**
  129539. * Gets a string describing the action executed by the current optimization
  129540. * @return description string
  129541. */
  129542. getDescription(): string;
  129543. /**
  129544. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129545. * @param scene defines the current scene where to apply this optimization
  129546. * @param optimizer defines the current optimizer
  129547. * @returns true if everything that can be done was applied
  129548. */
  129549. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129550. }
  129551. /**
  129552. * Defines an optimization based on user defined callback.
  129553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129554. */
  129555. export class CustomOptimization extends SceneOptimization {
  129556. /**
  129557. * Callback called to apply the custom optimization.
  129558. */
  129559. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129560. /**
  129561. * Callback called to get custom description
  129562. */
  129563. onGetDescription: () => string;
  129564. /**
  129565. * Gets a string describing the action executed by the current optimization
  129566. * @returns description string
  129567. */
  129568. getDescription(): string;
  129569. /**
  129570. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129571. * @param scene defines the current scene where to apply this optimization
  129572. * @param optimizer defines the current optimizer
  129573. * @returns true if everything that can be done was applied
  129574. */
  129575. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129576. }
  129577. /**
  129578. * Defines an optimization used to turn particles off
  129579. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129580. */
  129581. export class ParticlesOptimization extends SceneOptimization {
  129582. /**
  129583. * Gets a string describing the action executed by the current optimization
  129584. * @return description string
  129585. */
  129586. getDescription(): string;
  129587. /**
  129588. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129589. * @param scene defines the current scene where to apply this optimization
  129590. * @param optimizer defines the current optimizer
  129591. * @returns true if everything that can be done was applied
  129592. */
  129593. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129594. }
  129595. /**
  129596. * Defines an optimization used to turn render targets off
  129597. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129598. */
  129599. export class RenderTargetsOptimization extends SceneOptimization {
  129600. /**
  129601. * Gets a string describing the action executed by the current optimization
  129602. * @return description string
  129603. */
  129604. getDescription(): string;
  129605. /**
  129606. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129607. * @param scene defines the current scene where to apply this optimization
  129608. * @param optimizer defines the current optimizer
  129609. * @returns true if everything that can be done was applied
  129610. */
  129611. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129612. }
  129613. /**
  129614. * Defines an optimization used to merge meshes with compatible materials
  129615. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129616. */
  129617. export class MergeMeshesOptimization extends SceneOptimization {
  129618. private static _UpdateSelectionTree;
  129619. /**
  129620. * Gets or sets a boolean which defines if optimization octree has to be updated
  129621. */
  129622. /**
  129623. * Gets or sets a boolean which defines if optimization octree has to be updated
  129624. */
  129625. static UpdateSelectionTree: boolean;
  129626. /**
  129627. * Gets a string describing the action executed by the current optimization
  129628. * @return description string
  129629. */
  129630. getDescription(): string;
  129631. private _canBeMerged;
  129632. /**
  129633. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129634. * @param scene defines the current scene where to apply this optimization
  129635. * @param optimizer defines the current optimizer
  129636. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129637. * @returns true if everything that can be done was applied
  129638. */
  129639. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129640. }
  129641. /**
  129642. * Defines a list of options used by SceneOptimizer
  129643. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129644. */
  129645. export class SceneOptimizerOptions {
  129646. /**
  129647. * Defines the target frame rate to reach (60 by default)
  129648. */
  129649. targetFrameRate: number;
  129650. /**
  129651. * Defines the interval between two checkes (2000ms by default)
  129652. */
  129653. trackerDuration: number;
  129654. /**
  129655. * Gets the list of optimizations to apply
  129656. */
  129657. optimizations: SceneOptimization[];
  129658. /**
  129659. * Creates a new list of options used by SceneOptimizer
  129660. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129661. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129662. */
  129663. constructor(
  129664. /**
  129665. * Defines the target frame rate to reach (60 by default)
  129666. */
  129667. targetFrameRate?: number,
  129668. /**
  129669. * Defines the interval between two checkes (2000ms by default)
  129670. */
  129671. trackerDuration?: number);
  129672. /**
  129673. * Add a new optimization
  129674. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129675. * @returns the current SceneOptimizerOptions
  129676. */
  129677. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129678. /**
  129679. * Add a new custom optimization
  129680. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129681. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129682. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129683. * @returns the current SceneOptimizerOptions
  129684. */
  129685. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129686. /**
  129687. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129688. * @param targetFrameRate defines the target frame rate (60 by default)
  129689. * @returns a SceneOptimizerOptions object
  129690. */
  129691. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129692. /**
  129693. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129694. * @param targetFrameRate defines the target frame rate (60 by default)
  129695. * @returns a SceneOptimizerOptions object
  129696. */
  129697. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129698. /**
  129699. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129700. * @param targetFrameRate defines the target frame rate (60 by default)
  129701. * @returns a SceneOptimizerOptions object
  129702. */
  129703. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129704. }
  129705. /**
  129706. * Class used to run optimizations in order to reach a target frame rate
  129707. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129708. */
  129709. export class SceneOptimizer implements IDisposable {
  129710. private _isRunning;
  129711. private _options;
  129712. private _scene;
  129713. private _currentPriorityLevel;
  129714. private _targetFrameRate;
  129715. private _trackerDuration;
  129716. private _currentFrameRate;
  129717. private _sceneDisposeObserver;
  129718. private _improvementMode;
  129719. /**
  129720. * Defines an observable called when the optimizer reaches the target frame rate
  129721. */
  129722. onSuccessObservable: Observable<SceneOptimizer>;
  129723. /**
  129724. * Defines an observable called when the optimizer enables an optimization
  129725. */
  129726. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129727. /**
  129728. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129729. */
  129730. onFailureObservable: Observable<SceneOptimizer>;
  129731. /**
  129732. * Gets a boolean indicating if the optimizer is in improvement mode
  129733. */
  129734. readonly isInImprovementMode: boolean;
  129735. /**
  129736. * Gets the current priority level (0 at start)
  129737. */
  129738. readonly currentPriorityLevel: number;
  129739. /**
  129740. * Gets the current frame rate checked by the SceneOptimizer
  129741. */
  129742. readonly currentFrameRate: number;
  129743. /**
  129744. * Gets or sets the current target frame rate (60 by default)
  129745. */
  129746. /**
  129747. * Gets or sets the current target frame rate (60 by default)
  129748. */
  129749. targetFrameRate: number;
  129750. /**
  129751. * Gets or sets the current interval between two checks (every 2000ms by default)
  129752. */
  129753. /**
  129754. * Gets or sets the current interval between two checks (every 2000ms by default)
  129755. */
  129756. trackerDuration: number;
  129757. /**
  129758. * Gets the list of active optimizations
  129759. */
  129760. readonly optimizations: SceneOptimization[];
  129761. /**
  129762. * Creates a new SceneOptimizer
  129763. * @param scene defines the scene to work on
  129764. * @param options defines the options to use with the SceneOptimizer
  129765. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129766. * @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)
  129767. */
  129768. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129769. /**
  129770. * Stops the current optimizer
  129771. */
  129772. stop(): void;
  129773. /**
  129774. * Reset the optimizer to initial step (current priority level = 0)
  129775. */
  129776. reset(): void;
  129777. /**
  129778. * Start the optimizer. By default it will try to reach a specific framerate
  129779. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129780. */
  129781. start(): void;
  129782. private _checkCurrentState;
  129783. /**
  129784. * Release all resources
  129785. */
  129786. dispose(): void;
  129787. /**
  129788. * Helper function to create a SceneOptimizer with one single line of code
  129789. * @param scene defines the scene to work on
  129790. * @param options defines the options to use with the SceneOptimizer
  129791. * @param onSuccess defines a callback to call on success
  129792. * @param onFailure defines a callback to call on failure
  129793. * @returns the new SceneOptimizer object
  129794. */
  129795. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129796. }
  129797. }
  129798. declare module BABYLON {
  129799. /**
  129800. * Class used to serialize a scene into a string
  129801. */
  129802. export class SceneSerializer {
  129803. /**
  129804. * Clear cache used by a previous serialization
  129805. */
  129806. static ClearCache(): void;
  129807. /**
  129808. * Serialize a scene into a JSON compatible object
  129809. * @param scene defines the scene to serialize
  129810. * @returns a JSON compatible object
  129811. */
  129812. static Serialize(scene: Scene): any;
  129813. /**
  129814. * Serialize a mesh into a JSON compatible object
  129815. * @param toSerialize defines the mesh to serialize
  129816. * @param withParents defines if parents must be serialized as well
  129817. * @param withChildren defines if children must be serialized as well
  129818. * @returns a JSON compatible object
  129819. */
  129820. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129821. }
  129822. }
  129823. declare module BABYLON {
  129824. /**
  129825. * Class used to host texture specific utilities
  129826. */
  129827. export class TextureTools {
  129828. /**
  129829. * Uses the GPU to create a copy texture rescaled at a given size
  129830. * @param texture Texture to copy from
  129831. * @param width defines the desired width
  129832. * @param height defines the desired height
  129833. * @param useBilinearMode defines if bilinear mode has to be used
  129834. * @return the generated texture
  129835. */
  129836. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129837. }
  129838. }
  129839. declare module BABYLON {
  129840. /**
  129841. * This represents the different options available for the video capture.
  129842. */
  129843. export interface VideoRecorderOptions {
  129844. /** Defines the mime type of the video. */
  129845. mimeType: string;
  129846. /** Defines the FPS the video should be recorded at. */
  129847. fps: number;
  129848. /** Defines the chunk size for the recording data. */
  129849. recordChunckSize: number;
  129850. /** The audio tracks to attach to the recording. */
  129851. audioTracks?: MediaStreamTrack[];
  129852. }
  129853. /**
  129854. * This can help with recording videos from BabylonJS.
  129855. * This is based on the available WebRTC functionalities of the browser.
  129856. *
  129857. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129858. */
  129859. export class VideoRecorder {
  129860. private static readonly _defaultOptions;
  129861. /**
  129862. * Returns whether or not the VideoRecorder is available in your browser.
  129863. * @param engine Defines the Babylon Engine.
  129864. * @returns true if supported otherwise false.
  129865. */
  129866. static IsSupported(engine: Engine): boolean;
  129867. private readonly _options;
  129868. private _canvas;
  129869. private _mediaRecorder;
  129870. private _recordedChunks;
  129871. private _fileName;
  129872. private _resolve;
  129873. private _reject;
  129874. /**
  129875. * True when a recording is already in progress.
  129876. */
  129877. readonly isRecording: boolean;
  129878. /**
  129879. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129880. * @param engine Defines the BabylonJS Engine you wish to record.
  129881. * @param options Defines options that can be used to customize the capture.
  129882. */
  129883. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129884. /**
  129885. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129886. */
  129887. stopRecording(): void;
  129888. /**
  129889. * Starts recording the canvas for a max duration specified in parameters.
  129890. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129891. * If null no automatic download will start and you can rely on the promise to get the data back.
  129892. * @param maxDuration Defines the maximum recording time in seconds.
  129893. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129894. * @return A promise callback at the end of the recording with the video data in Blob.
  129895. */
  129896. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129897. /**
  129898. * Releases internal resources used during the recording.
  129899. */
  129900. dispose(): void;
  129901. private _handleDataAvailable;
  129902. private _handleError;
  129903. private _handleStop;
  129904. }
  129905. }
  129906. declare module BABYLON {
  129907. /**
  129908. * Class containing a set of static utilities functions for screenshots
  129909. */
  129910. export class ScreenshotTools {
  129911. /**
  129912. * Captures a screenshot of the current rendering
  129913. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129914. * @param engine defines the rendering engine
  129915. * @param camera defines the source camera
  129916. * @param size This parameter can be set to a single number or to an object with the
  129917. * following (optional) properties: precision, width, height. If a single number is passed,
  129918. * it will be used for both width and height. If an object is passed, the screenshot size
  129919. * will be derived from the parameters. The precision property is a multiplier allowing
  129920. * rendering at a higher or lower resolution
  129921. * @param successCallback defines the callback receives a single parameter which contains the
  129922. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129923. * src parameter of an <img> to display it
  129924. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129925. * Check your browser for supported MIME types
  129926. */
  129927. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129928. /**
  129929. * Captures a screenshot of the current rendering
  129930. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129931. * @param engine defines the rendering engine
  129932. * @param camera defines the source camera
  129933. * @param size This parameter can be set to a single number or to an object with the
  129934. * following (optional) properties: precision, width, height. If a single number is passed,
  129935. * it will be used for both width and height. If an object is passed, the screenshot size
  129936. * will be derived from the parameters. The precision property is a multiplier allowing
  129937. * rendering at a higher or lower resolution
  129938. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129939. * Check your browser for supported MIME types
  129940. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129941. * to the src parameter of an <img> to display it
  129942. */
  129943. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129944. /**
  129945. * Generates an image screenshot from the specified camera.
  129946. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129947. * @param engine The engine to use for rendering
  129948. * @param camera The camera to use for rendering
  129949. * @param size This parameter can be set to a single number or to an object with the
  129950. * following (optional) properties: precision, width, height. If a single number is passed,
  129951. * it will be used for both width and height. If an object is passed, the screenshot size
  129952. * will be derived from the parameters. The precision property is a multiplier allowing
  129953. * rendering at a higher or lower resolution
  129954. * @param successCallback The callback receives a single parameter which contains the
  129955. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129956. * src parameter of an <img> to display it
  129957. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129958. * Check your browser for supported MIME types
  129959. * @param samples Texture samples (default: 1)
  129960. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129961. * @param fileName A name for for the downloaded file.
  129962. */
  129963. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129964. /**
  129965. * Generates an image screenshot from the specified camera.
  129966. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129967. * @param engine The engine to use for rendering
  129968. * @param camera The camera to use for rendering
  129969. * @param size This parameter can be set to a single number or to an object with the
  129970. * following (optional) properties: precision, width, height. If a single number is passed,
  129971. * it will be used for both width and height. If an object is passed, the screenshot size
  129972. * will be derived from the parameters. The precision property is a multiplier allowing
  129973. * rendering at a higher or lower resolution
  129974. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129975. * Check your browser for supported MIME types
  129976. * @param samples Texture samples (default: 1)
  129977. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129978. * @param fileName A name for for the downloaded file.
  129979. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129980. * to the src parameter of an <img> to display it
  129981. */
  129982. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129983. /**
  129984. * Gets height and width for screenshot size
  129985. * @private
  129986. */
  129987. private static _getScreenshotSize;
  129988. }
  129989. }
  129990. declare module BABYLON {
  129991. /**
  129992. * A cursor which tracks a point on a path
  129993. */
  129994. export class PathCursor {
  129995. private path;
  129996. /**
  129997. * Stores path cursor callbacks for when an onchange event is triggered
  129998. */
  129999. private _onchange;
  130000. /**
  130001. * The value of the path cursor
  130002. */
  130003. value: number;
  130004. /**
  130005. * The animation array of the path cursor
  130006. */
  130007. animations: Animation[];
  130008. /**
  130009. * Initializes the path cursor
  130010. * @param path The path to track
  130011. */
  130012. constructor(path: Path2);
  130013. /**
  130014. * Gets the cursor point on the path
  130015. * @returns A point on the path cursor at the cursor location
  130016. */
  130017. getPoint(): Vector3;
  130018. /**
  130019. * Moves the cursor ahead by the step amount
  130020. * @param step The amount to move the cursor forward
  130021. * @returns This path cursor
  130022. */
  130023. moveAhead(step?: number): PathCursor;
  130024. /**
  130025. * Moves the cursor behind by the step amount
  130026. * @param step The amount to move the cursor back
  130027. * @returns This path cursor
  130028. */
  130029. moveBack(step?: number): PathCursor;
  130030. /**
  130031. * Moves the cursor by the step amount
  130032. * If the step amount is greater than one, an exception is thrown
  130033. * @param step The amount to move the cursor
  130034. * @returns This path cursor
  130035. */
  130036. move(step: number): PathCursor;
  130037. /**
  130038. * Ensures that the value is limited between zero and one
  130039. * @returns This path cursor
  130040. */
  130041. private ensureLimits;
  130042. /**
  130043. * Runs onchange callbacks on change (used by the animation engine)
  130044. * @returns This path cursor
  130045. */
  130046. private raiseOnChange;
  130047. /**
  130048. * Executes a function on change
  130049. * @param f A path cursor onchange callback
  130050. * @returns This path cursor
  130051. */
  130052. onchange(f: (cursor: PathCursor) => void): PathCursor;
  130053. }
  130054. }
  130055. declare module BABYLON {
  130056. /** @hidden */
  130057. export var blurPixelShader: {
  130058. name: string;
  130059. shader: string;
  130060. };
  130061. }
  130062. declare module BABYLON {
  130063. /** @hidden */
  130064. export var pointCloudVertexDeclaration: {
  130065. name: string;
  130066. shader: string;
  130067. };
  130068. }
  130069. // Mixins
  130070. interface Window {
  130071. mozIndexedDB: IDBFactory;
  130072. webkitIndexedDB: IDBFactory;
  130073. msIndexedDB: IDBFactory;
  130074. webkitURL: typeof URL;
  130075. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  130076. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  130077. WebGLRenderingContext: WebGLRenderingContext;
  130078. MSGesture: MSGesture;
  130079. CANNON: any;
  130080. AudioContext: AudioContext;
  130081. webkitAudioContext: AudioContext;
  130082. PointerEvent: any;
  130083. Math: Math;
  130084. Uint8Array: Uint8ArrayConstructor;
  130085. Float32Array: Float32ArrayConstructor;
  130086. mozURL: typeof URL;
  130087. msURL: typeof URL;
  130088. VRFrameData: any; // WebVR, from specs 1.1
  130089. DracoDecoderModule: any;
  130090. setImmediate(handler: (...args: any[]) => void): number;
  130091. }
  130092. interface HTMLCanvasElement {
  130093. requestPointerLock(): void;
  130094. msRequestPointerLock?(): void;
  130095. mozRequestPointerLock?(): void;
  130096. webkitRequestPointerLock?(): void;
  130097. /** Track wether a record is in progress */
  130098. isRecording: boolean;
  130099. /** Capture Stream method defined by some browsers */
  130100. captureStream(fps?: number): MediaStream;
  130101. }
  130102. interface CanvasRenderingContext2D {
  130103. msImageSmoothingEnabled: boolean;
  130104. }
  130105. interface MouseEvent {
  130106. mozMovementX: number;
  130107. mozMovementY: number;
  130108. webkitMovementX: number;
  130109. webkitMovementY: number;
  130110. msMovementX: number;
  130111. msMovementY: number;
  130112. }
  130113. interface Navigator {
  130114. mozGetVRDevices: (any: any) => any;
  130115. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130116. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130117. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130118. webkitGetGamepads(): Gamepad[];
  130119. msGetGamepads(): Gamepad[];
  130120. webkitGamepads(): Gamepad[];
  130121. }
  130122. interface HTMLVideoElement {
  130123. mozSrcObject: any;
  130124. }
  130125. interface Math {
  130126. fround(x: number): number;
  130127. imul(a: number, b: number): number;
  130128. }
  130129. interface WebGLRenderingContext {
  130130. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130131. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130132. vertexAttribDivisor(index: number, divisor: number): void;
  130133. createVertexArray(): any;
  130134. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130135. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130136. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130137. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130138. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130139. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130140. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130141. // Queries
  130142. createQuery(): WebGLQuery;
  130143. deleteQuery(query: WebGLQuery): void;
  130144. beginQuery(target: number, query: WebGLQuery): void;
  130145. endQuery(target: number): void;
  130146. getQueryParameter(query: WebGLQuery, pname: number): any;
  130147. getQuery(target: number, pname: number): any;
  130148. MAX_SAMPLES: number;
  130149. RGBA8: number;
  130150. READ_FRAMEBUFFER: number;
  130151. DRAW_FRAMEBUFFER: number;
  130152. UNIFORM_BUFFER: number;
  130153. HALF_FLOAT_OES: number;
  130154. RGBA16F: number;
  130155. RGBA32F: number;
  130156. R32F: number;
  130157. RG32F: number;
  130158. RGB32F: number;
  130159. R16F: number;
  130160. RG16F: number;
  130161. RGB16F: number;
  130162. RED: number;
  130163. RG: number;
  130164. R8: number;
  130165. RG8: number;
  130166. UNSIGNED_INT_24_8: number;
  130167. DEPTH24_STENCIL8: number;
  130168. MIN: number;
  130169. MAX: number;
  130170. /* Multiple Render Targets */
  130171. drawBuffers(buffers: number[]): void;
  130172. readBuffer(src: number): void;
  130173. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  130174. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  130175. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  130176. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  130177. // Occlusion Query
  130178. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  130179. ANY_SAMPLES_PASSED: number;
  130180. QUERY_RESULT_AVAILABLE: number;
  130181. QUERY_RESULT: number;
  130182. }
  130183. interface WebGLProgram {
  130184. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  130185. }
  130186. interface EXT_disjoint_timer_query {
  130187. QUERY_COUNTER_BITS_EXT: number;
  130188. TIME_ELAPSED_EXT: number;
  130189. TIMESTAMP_EXT: number;
  130190. GPU_DISJOINT_EXT: number;
  130191. QUERY_RESULT_EXT: number;
  130192. QUERY_RESULT_AVAILABLE_EXT: number;
  130193. queryCounterEXT(query: WebGLQuery, target: number): void;
  130194. createQueryEXT(): WebGLQuery;
  130195. beginQueryEXT(target: number, query: WebGLQuery): void;
  130196. endQueryEXT(target: number): void;
  130197. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  130198. deleteQueryEXT(query: WebGLQuery): void;
  130199. }
  130200. interface WebGLUniformLocation {
  130201. _currentState: any;
  130202. }
  130203. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  130204. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  130205. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  130206. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130207. interface WebGLRenderingContext {
  130208. readonly RASTERIZER_DISCARD: number;
  130209. readonly DEPTH_COMPONENT24: number;
  130210. readonly TEXTURE_3D: number;
  130211. readonly TEXTURE_2D_ARRAY: number;
  130212. readonly TEXTURE_COMPARE_FUNC: number;
  130213. readonly TEXTURE_COMPARE_MODE: number;
  130214. readonly COMPARE_REF_TO_TEXTURE: number;
  130215. readonly TEXTURE_WRAP_R: number;
  130216. readonly HALF_FLOAT: number;
  130217. readonly RGB8: number;
  130218. readonly RED_INTEGER: number;
  130219. readonly RG_INTEGER: number;
  130220. readonly RGB_INTEGER: number;
  130221. readonly RGBA_INTEGER: number;
  130222. readonly R8_SNORM: number;
  130223. readonly RG8_SNORM: number;
  130224. readonly RGB8_SNORM: number;
  130225. readonly RGBA8_SNORM: number;
  130226. readonly R8I: number;
  130227. readonly RG8I: number;
  130228. readonly RGB8I: number;
  130229. readonly RGBA8I: number;
  130230. readonly R8UI: number;
  130231. readonly RG8UI: number;
  130232. readonly RGB8UI: number;
  130233. readonly RGBA8UI: number;
  130234. readonly R16I: number;
  130235. readonly RG16I: number;
  130236. readonly RGB16I: number;
  130237. readonly RGBA16I: number;
  130238. readonly R16UI: number;
  130239. readonly RG16UI: number;
  130240. readonly RGB16UI: number;
  130241. readonly RGBA16UI: number;
  130242. readonly R32I: number;
  130243. readonly RG32I: number;
  130244. readonly RGB32I: number;
  130245. readonly RGBA32I: number;
  130246. readonly R32UI: number;
  130247. readonly RG32UI: number;
  130248. readonly RGB32UI: number;
  130249. readonly RGBA32UI: number;
  130250. readonly RGB10_A2UI: number;
  130251. readonly R11F_G11F_B10F: number;
  130252. readonly RGB9_E5: number;
  130253. readonly RGB10_A2: number;
  130254. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130255. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130256. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130257. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130258. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130259. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130260. 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;
  130261. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130262. readonly TRANSFORM_FEEDBACK: number;
  130263. readonly INTERLEAVED_ATTRIBS: number;
  130264. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130265. createTransformFeedback(): WebGLTransformFeedback;
  130266. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130267. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130268. beginTransformFeedback(primitiveMode: number): void;
  130269. endTransformFeedback(): void;
  130270. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130271. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130272. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130273. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130274. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130275. }
  130276. interface ImageBitmap {
  130277. readonly width: number;
  130278. readonly height: number;
  130279. close(): void;
  130280. }
  130281. interface WebGLQuery extends WebGLObject {
  130282. }
  130283. declare var WebGLQuery: {
  130284. prototype: WebGLQuery;
  130285. new(): WebGLQuery;
  130286. };
  130287. interface WebGLSampler extends WebGLObject {
  130288. }
  130289. declare var WebGLSampler: {
  130290. prototype: WebGLSampler;
  130291. new(): WebGLSampler;
  130292. };
  130293. interface WebGLSync extends WebGLObject {
  130294. }
  130295. declare var WebGLSync: {
  130296. prototype: WebGLSync;
  130297. new(): WebGLSync;
  130298. };
  130299. interface WebGLTransformFeedback extends WebGLObject {
  130300. }
  130301. declare var WebGLTransformFeedback: {
  130302. prototype: WebGLTransformFeedback;
  130303. new(): WebGLTransformFeedback;
  130304. };
  130305. interface WebGLVertexArrayObject extends WebGLObject {
  130306. }
  130307. declare var WebGLVertexArrayObject: {
  130308. prototype: WebGLVertexArrayObject;
  130309. new(): WebGLVertexArrayObject;
  130310. };
  130311. // Type definitions for WebVR API
  130312. // Project: https://w3c.github.io/webvr/
  130313. // Definitions by: six a <https://github.com/lostfictions>
  130314. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130315. interface VRDisplay extends EventTarget {
  130316. /**
  130317. * Dictionary of capabilities describing the VRDisplay.
  130318. */
  130319. readonly capabilities: VRDisplayCapabilities;
  130320. /**
  130321. * z-depth defining the far plane of the eye view frustum
  130322. * enables mapping of values in the render target depth
  130323. * attachment to scene coordinates. Initially set to 10000.0.
  130324. */
  130325. depthFar: number;
  130326. /**
  130327. * z-depth defining the near plane of the eye view frustum
  130328. * enables mapping of values in the render target depth
  130329. * attachment to scene coordinates. Initially set to 0.01.
  130330. */
  130331. depthNear: number;
  130332. /**
  130333. * An identifier for this distinct VRDisplay. Used as an
  130334. * association point in the Gamepad API.
  130335. */
  130336. readonly displayId: number;
  130337. /**
  130338. * A display name, a user-readable name identifying it.
  130339. */
  130340. readonly displayName: string;
  130341. readonly isConnected: boolean;
  130342. readonly isPresenting: boolean;
  130343. /**
  130344. * If this VRDisplay supports room-scale experiences, the optional
  130345. * stage attribute contains details on the room-scale parameters.
  130346. */
  130347. readonly stageParameters: VRStageParameters | null;
  130348. /**
  130349. * Passing the value returned by `requestAnimationFrame` to
  130350. * `cancelAnimationFrame` will unregister the callback.
  130351. * @param handle Define the hanle of the request to cancel
  130352. */
  130353. cancelAnimationFrame(handle: number): void;
  130354. /**
  130355. * Stops presenting to the VRDisplay.
  130356. * @returns a promise to know when it stopped
  130357. */
  130358. exitPresent(): Promise<void>;
  130359. /**
  130360. * Return the current VREyeParameters for the given eye.
  130361. * @param whichEye Define the eye we want the parameter for
  130362. * @returns the eye parameters
  130363. */
  130364. getEyeParameters(whichEye: string): VREyeParameters;
  130365. /**
  130366. * Populates the passed VRFrameData with the information required to render
  130367. * the current frame.
  130368. * @param frameData Define the data structure to populate
  130369. * @returns true if ok otherwise false
  130370. */
  130371. getFrameData(frameData: VRFrameData): boolean;
  130372. /**
  130373. * Get the layers currently being presented.
  130374. * @returns the list of VR layers
  130375. */
  130376. getLayers(): VRLayer[];
  130377. /**
  130378. * Return a VRPose containing the future predicted pose of the VRDisplay
  130379. * when the current frame will be presented. The value returned will not
  130380. * change until JavaScript has returned control to the browser.
  130381. *
  130382. * The VRPose will contain the position, orientation, velocity,
  130383. * and acceleration of each of these properties.
  130384. * @returns the pose object
  130385. */
  130386. getPose(): VRPose;
  130387. /**
  130388. * Return the current instantaneous pose of the VRDisplay, with no
  130389. * prediction applied.
  130390. * @returns the current instantaneous pose
  130391. */
  130392. getImmediatePose(): VRPose;
  130393. /**
  130394. * The callback passed to `requestAnimationFrame` will be called
  130395. * any time a new frame should be rendered. When the VRDisplay is
  130396. * presenting the callback will be called at the native refresh
  130397. * rate of the HMD. When not presenting this function acts
  130398. * identically to how window.requestAnimationFrame acts. Content should
  130399. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130400. * asynchronously from other displays and at differing refresh rates.
  130401. * @param callback Define the eaction to run next frame
  130402. * @returns the request handle it
  130403. */
  130404. requestAnimationFrame(callback: FrameRequestCallback): number;
  130405. /**
  130406. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130407. * Repeat calls while already presenting will update the VRLayers being displayed.
  130408. * @param layers Define the list of layer to present
  130409. * @returns a promise to know when the request has been fulfilled
  130410. */
  130411. requestPresent(layers: VRLayer[]): Promise<void>;
  130412. /**
  130413. * Reset the pose for this display, treating its current position and
  130414. * orientation as the "origin/zero" values. VRPose.position,
  130415. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130416. * updated when calling resetPose(). This should be called in only
  130417. * sitting-space experiences.
  130418. */
  130419. resetPose(): void;
  130420. /**
  130421. * The VRLayer provided to the VRDisplay will be captured and presented
  130422. * in the HMD. Calling this function has the same effect on the source
  130423. * canvas as any other operation that uses its source image, and canvases
  130424. * created without preserveDrawingBuffer set to true will be cleared.
  130425. * @param pose Define the pose to submit
  130426. */
  130427. submitFrame(pose?: VRPose): void;
  130428. }
  130429. declare var VRDisplay: {
  130430. prototype: VRDisplay;
  130431. new(): VRDisplay;
  130432. };
  130433. interface VRLayer {
  130434. leftBounds?: number[] | Float32Array | null;
  130435. rightBounds?: number[] | Float32Array | null;
  130436. source?: HTMLCanvasElement | null;
  130437. }
  130438. interface VRDisplayCapabilities {
  130439. readonly canPresent: boolean;
  130440. readonly hasExternalDisplay: boolean;
  130441. readonly hasOrientation: boolean;
  130442. readonly hasPosition: boolean;
  130443. readonly maxLayers: number;
  130444. }
  130445. interface VREyeParameters {
  130446. /** @deprecated */
  130447. readonly fieldOfView: VRFieldOfView;
  130448. readonly offset: Float32Array;
  130449. readonly renderHeight: number;
  130450. readonly renderWidth: number;
  130451. }
  130452. interface VRFieldOfView {
  130453. readonly downDegrees: number;
  130454. readonly leftDegrees: number;
  130455. readonly rightDegrees: number;
  130456. readonly upDegrees: number;
  130457. }
  130458. interface VRFrameData {
  130459. readonly leftProjectionMatrix: Float32Array;
  130460. readonly leftViewMatrix: Float32Array;
  130461. readonly pose: VRPose;
  130462. readonly rightProjectionMatrix: Float32Array;
  130463. readonly rightViewMatrix: Float32Array;
  130464. readonly timestamp: number;
  130465. }
  130466. interface VRPose {
  130467. readonly angularAcceleration: Float32Array | null;
  130468. readonly angularVelocity: Float32Array | null;
  130469. readonly linearAcceleration: Float32Array | null;
  130470. readonly linearVelocity: Float32Array | null;
  130471. readonly orientation: Float32Array | null;
  130472. readonly position: Float32Array | null;
  130473. readonly timestamp: number;
  130474. }
  130475. interface VRStageParameters {
  130476. sittingToStandingTransform?: Float32Array;
  130477. sizeX?: number;
  130478. sizeY?: number;
  130479. }
  130480. interface Navigator {
  130481. getVRDisplays(): Promise<VRDisplay[]>;
  130482. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130483. }
  130484. interface Window {
  130485. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130486. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130487. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130488. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130489. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130490. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130491. }
  130492. interface Gamepad {
  130493. readonly displayId: number;
  130494. }
  130495. type XRSessionMode =
  130496. | "inline"
  130497. | "immersive-vr"
  130498. | "immersive-ar";
  130499. type XRReferenceSpaceType =
  130500. | "viewer"
  130501. | "local"
  130502. | "local-floor"
  130503. | "bounded-floor"
  130504. | "unbounded";
  130505. type XREnvironmentBlendMode =
  130506. | "opaque"
  130507. | "additive"
  130508. | "alpha-blend";
  130509. type XRVisibilityState =
  130510. | "visible"
  130511. | "visible-blurred"
  130512. | "hidden";
  130513. type XRHandedness =
  130514. | "none"
  130515. | "left"
  130516. | "right";
  130517. type XRTargetRayMode =
  130518. | "gaze"
  130519. | "tracked-pointer"
  130520. | "screen";
  130521. type XREye =
  130522. | "none"
  130523. | "left"
  130524. | "right";
  130525. interface XRSpace extends EventTarget {
  130526. }
  130527. interface XRRenderState {
  130528. depthNear?: number;
  130529. depthFar?: number;
  130530. inlineVerticalFieldOfView?: number;
  130531. baseLayer?: XRWebGLLayer;
  130532. }
  130533. interface XRInputSource {
  130534. handedness: XRHandedness;
  130535. targetRayMode: XRTargetRayMode;
  130536. targetRaySpace: XRSpace;
  130537. gripSpace: XRSpace | undefined;
  130538. gamepad: Gamepad | undefined;
  130539. profiles: Array<string>;
  130540. }
  130541. interface XRSession {
  130542. addEventListener: Function;
  130543. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130544. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130545. requestAnimationFrame: Function;
  130546. end(): Promise<void>;
  130547. renderState: XRRenderState;
  130548. inputSources: Array<XRInputSource>;
  130549. }
  130550. interface XRReferenceSpace extends XRSpace {
  130551. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130552. onreset: any;
  130553. }
  130554. interface XRFrame {
  130555. session: XRSession;
  130556. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130557. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130558. }
  130559. interface XRViewerPose extends XRPose {
  130560. views: Array<XRView>;
  130561. }
  130562. interface XRPose {
  130563. transform: XRRigidTransform;
  130564. emulatedPosition: boolean;
  130565. }
  130566. declare var XRWebGLLayer: {
  130567. prototype: XRWebGLLayer;
  130568. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130569. };
  130570. interface XRWebGLLayer {
  130571. framebuffer: WebGLFramebuffer;
  130572. framebufferWidth: number;
  130573. framebufferHeight: number;
  130574. getViewport: Function;
  130575. }
  130576. interface XRRigidTransform {
  130577. position: DOMPointReadOnly;
  130578. orientation: DOMPointReadOnly;
  130579. matrix: Float32Array;
  130580. inverse: XRRigidTransform;
  130581. }
  130582. interface XRView {
  130583. eye: XREye;
  130584. projectionMatrix: Float32Array;
  130585. transform: XRRigidTransform;
  130586. }
  130587. interface XRInputSourceChangeEvent {
  130588. session: XRSession;
  130589. removed: Array<XRInputSource>;
  130590. added: Array<XRInputSource>;
  130591. }